query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
sequencelengths
0
101
negative_scores
sequencelengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Appends existing TIFF image to another existing TIFF image (i.e. merges TIFF images)
def append_tiff_from_storage puts('Appends existing TIFF image to another existing TIFF image') append_file_name = 'Append.tiff' # Image file name to be appended to original one upload_sample_image_to_cloud upload_image_to_cloud(append_file_name, File.join(ImagingBase::EXAMPLE_IMAGES_FOLDER, append_file_name)) # Update TIFF Image parameters according to fax parameters folder = ImagingBase::CLOUD_PATH # Input file is saved at the Examples folder in the storage storage = nil # We are using default Cloud Storage update_request = AsposeImagingCloud::AppendTiffRequest.new( get_sample_image_file_name, append_file_name, storage, folder) puts('Call AppendTiff') imaging_api.append_tiff(update_request) # Download updated file to local storage download_request = AsposeImagingCloud::DownloadFileRequest.new( File.join(ImagingBase::CLOUD_PATH, get_sample_image_file_name), storage) updated_image = imaging_api.download_file(download_request) save_updated_image_to_output('AppendToTiff.tiff', updated_image) puts end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge(other_image)\n raise 'an image class must be supplied' unless other_image.is_a? Image\n raise 'cannot merge if the user is different' unless other_image.user == user\n raise 'cannot merge if the account_id is different' unless other_image.account_id == account_id\n raise 'cannot merge if the state is different' unless other_image.state == state\n\n new_image = Image.new\n new_image.user = @user\n new_image.entries = entries + other_image.entries\n new_image\n end", "def merge_from(other, dst_x, dst_y, src_x, src_y, w, h, pct, gray = false)\n return super(other, dst_x, dst_y, src_x, src_y, w, h, pct) unless gray\n\n ::GD2::GD2FFI.send(:gdImageCopyMergeGray, image_ptr, other.image_ptr, dst_x.to_i, dst_y.to_i, src_x.to_i, src_y.to_i, w.to_i, h.to_i, pct.to_percent.round.to_i)\n self\n end", "def merge_from(other, dst_x, dst_y, src_x, src_y, w, h, pct)\n ::GD2::GD2FFI.send(:gdImageCopyMerge, image_ptr, other.image_ptr, dst_x.to_i, dst_y.to_i, src_x.to_i, src_y.to_i, w.to_i, h.to_i, pct.to_percent.round.to_i)\n self\n end", "def image_copy(another_image)\n\n java_import Java::edu.stanford.cfuller.imageanalysistools.image.ImageFactory\n\n ImageFactory.create(another_image)\n\n end", "def merge(qrcode)\n merge_record = self.merges.build( :qrcode => qrcode )\n \n templ = Magick::Image.read(self.filepath).first\n\n # TODO work out a problem with Magick::Image.read( qrcode.contents ) - it prefers to only read from a file ??\n qr = Magick::Image.from_blob( qrcode.contents ).first\n \n draw = Magick::Draw.new()\n\n composite_image = Magick::Image.new( templ.columns, templ.rows)\n\n # Composite design, then qr, into this draw object, then draw the draw into a new composite image\n draw.composite( 0, 0, templ.columns, templ.rows, templ) #Magick::OverCompositeOp )\n \n draw.composite( self.offset_left, self.offset_top, qr.columns, qr.rows, qr )\n draw.draw(composite_image)\n\n merge_filepath = \"#{RAILS_ROOT}/public/images/merges/#{merge_record.file_path}.png\" \n composite_image.write(merge_filepath)\n\n merge_filepath\n end", "def writable_image_copy(another_image)\n\n java_import Java::edu.stanford.cfuller.imageanalysistools.image.ImageFactory\n\n ImageFactory.createWritable(another_image)\n\n end", "def merge_layer(other_layer)\n if self.type == Layer::LAYER_NORMAL and\n other_layer.type == Layer::LAYER_NORMAL\n\n # Calculate all the new dimensions for the new canvas\n top = [self.bounds.top, other_layer.bounds.top].min\n left = [self.bounds.left, other_layer.bounds.left].min\n bottom = [self.bounds.bottom, other_layer.bounds.bottom].max\n right = [self.bounds.right, other_layer.bounds.right].max\n width = right - left\n height = bottom - top\n new_bounds = BoundingBox.new top, left, bottom, right\n\n # Create a transparent slate, prepare the composite images to be applied\n slate = Image.new(width, height) { self.background_color = \"none\" }\n self_image = Image.read(self.extracted_image_path).first\n other_image = Image.read(other_layer.extracted_image_path).first\n\n # Calculate all the offsets to be composited.\n self_top_offset = self.bounds.top - top\n self_left_offset = self.bounds.left - left\n other_top_offset = other_layer.bounds.top - top\n other_left_offset = other_layer.bounds.left - left\n\n # Apply composites\n slate.composite!(self_image, self_left_offset, self_top_offset, Magick::OverCompositeOp)\n slate.composite!(other_image, other_left_offset, other_top_offset, Magick::OverCompositeOp)\n \n # Sync it to store\n slate.write(self.extracted_image_path)\n self.sync_image_to_store\n\n # Set new bounds\n self.bounds = new_bounds\n self.initial_bounds = new_bounds\n\n # Delete the merged layer\n self.design.sif.layers.delete other_layer.uid\n \n # Recalculate everything\n self.design.sif.reset_calculated_data\n self.design.sif.save!\n self.design.regroup\n Log.info \"Merge complete\"\n\n end\n end", "def image_shallow_copy(another_image)\n\n java_import Java::edu.stanford.cfuller.imageanalysistools.image.ImageFactory\n\n ImageFactory.createShallow(another_image)\n\n end", "def target\n img = Magick::ImageList.new(TARGET_FILE_NAME + FILE_SUFFIX)\n img = img.resize(NEW_TARGET_SIDE_LENGTH, NEW_TARGET_SIDE_LENGTH)\n img = img.quantize(COLOR_VARIATION, Magick::GRAYColorspace)\n img.write(TARGET_FILE_NAME + NEW_TARGET_NAME_SUFFIX + FILE_SUFFIX)\n img.destroy!\n end", "def modify_tiff_and_upload_to_storage\n puts('Update parameters of a TIFF image and upload to cloud storage')\n\n upload_sample_image_to_cloud\n\n compression = 'adobedeflate'\n resolution_unit = 'inch'\n bit_depth = 1\n horizontal_resolution = 150.0\n vertical_resolution = 150.0\n from_scratch = nil\n folder = ImagingBase::CLOUD_PATH # Input file is saved at the Examples folder in the storage\n storage = nil # We are using default Cloud Storage\n\n request = AsposeImagingCloud::ModifyTiffRequest.new(\n get_sample_image_file_name, bit_depth, compression, resolution_unit, horizontal_resolution,\n vertical_resolution, from_scratch, folder, storage)\n\n puts(\"Call ModifyTiff with params: compression: #{compression}, resolution unit: #{resolution_unit}, \" +\n \"bit depth: #{bit_depth}, horizontal resolution: #{horizontal_resolution}, vertical resolution: \" +\n \"#{vertical_resolution}\")\n\n updated_image = @imaging_api.modify_tiff(request)\n upload_image_to_cloud(get_modified_sample_image_file_name, updated_image)\n puts\n end", "def extend_image_with_file(base_image, new_image, file_path, file_contents)\n container_id = run_stdin [], base_image, file_contents, \"/bin/sh\", \"-c\", \"cat > #{file_path}; cat #{file_path}\"\n wait container_id\n commit container_id, new_image, \"Added #{file_path}\"\n end", "def copy_subimage inimage_id, x, y, width, height, outimage_id\n m_begin \"copy_subimage\"\n img = get_image(inimage_id)\n outimg = img.excerpt(x, y, width, height)\n outimage_id = inimage_id if outimage_id.nil?\n put_image(outimage_id, outimg)\n m_end \"copy_subimage\"\n end", "def operation(*args)\n src_file, out_file = args\n image = Vips::Image.new_from_file src_file\n image.tiffsave(out_file, **options)\n # Return lof if any\n end", "def append_tiff(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, nil)\n nil\n end", "def concatinate(f1, f2)\n\t\tDir.foreach(\"#{f1}\") do |x0|\n\t\t\tnext if x0 == '.' or x0 == '..' or x0.start_with?('.')\n\t\t\tDir.foreach(\"#{f2}\") do |x1|\n\t\t\t\tnext if x1 == '.' or x1 == '..' or x1.start_with?('.')\n\t\t\t\t\n\t\t\t\t# concatenate x and y \t\t\n \t\t\t\tsystem(\"cat #{f1}/#{x0} #{f2}/#{x1} > t1/#{x0}#{x1}\")\n\t\t\t\t# compress concatenated files\n \t\t\t\tsystem(\"7za a -t7z t2/#{x0}#{x1}.7z t1/#{x0}#{x1}\")\n \t \t\t#system(\"7za a -t7z -mx9 -mmt2 -ms4g -m0=lzma:d128m:fb256 t2/#{x0}#{x1}.7z t1/#{x0}#{x1}kd\")\n \t \t\t\n \t \tend \n \t end\t\t\n\tend", "def new_images(repo, dest, image_files)\n dest ||= ''\n image_files.each do |f|\n tmp = f.tempfile\n file = File.join satellitedir, dest, f.original_filename\n FileUtils.cp tmp.path, file\n if dest.empty?\n repo.index.add f.original_filename\n else\n repo.index.add File.join(dest, f.original_filename)\n end\n end\n end", "def new_images(repo, dest, image_files)\n dest ||= ''\n image_files.each do |f|\n tmp = f.tempfile\n file = File.join satellitedir, dest, f.original_filename\n FileUtils.cp tmp.path, file\n if dest.empty?\n repo.index.add f.original_filename\n else\n repo.index.add File.join(dest, f.original_filename)\n end\n end\n end", "def merge\n @mergeit.merge_data(@input_files)\n end", "def add_mk(new_image, iso_path, image_path)\n new_image.add(iso_path, image_path)\n end", "def append_image(image)\n image_ele = @image_ele.clone\n image_ele.at(\".//v:shape\").attributes[\"style\"].value = \"width:#{image.width}pt;height:#{image.height}pt\"\n image_ele.at(\".//v:imagedata\").attributes[\"id\"].value = \"rId#{@rid_index}\"\n image_rel = @image_rel.clone\n image_rel.attributes[\"Id\"].value = \"rId#{@rid_index}\"\n image_rel.attributes[\"Target\"].value = \"media/image#{@rid_index}.#{image.file_type}\"\n FileUtils.cp(image.file_name, \"public/downloads/#{@filename}/blank_doc/word/media/image#{@rid_index}.#{image.file_type}\")\n @rel_doc.at('.//xmlns:Relationships').add_child(image_rel)\n @rid_index += 1\n\n last_para = @main_doc.xpath('.//w:p')[-1]\n last_para.add_child(image_ele)\n end", "def + other\n other.is_a?(Vips::Image) ?\n add(other) : linear(1, other)\n end", "def merge_extent(old, new)\n old.dig(:extent, 0, :locality) and\n old[:extent] = [{ locality_stack: old[:extent] }]\n new.dig(:extent, 0, :locality) and\n new[:extent] = [{ locality_stack: new[:extent] }]\n ret = merge_by_type(old.dig(:extent, 0),\n new.dig(:extent, 0), :locality_stack,\n %i[locality type])\n (ret && !old.dig(:extent, 0)) or return\n old[:extent] ||= []\n old[:extent][0] ||= {}\n old[:extent][0][:locality_stack] = ret\n end", "def merge; end", "def update_image(branch, old_path, new_file, author, message)\n repo = satelliterepo\n repo.checkout(branch)\n # to test if first image is updated\n file = File.join satellitedir, old_path\n FileUtils.cp new_file.tempfile.path, file\n repo.index.add old_path\n commit_id = satellite_commit(\n repo,\n message,\n author,\n branch\n )\n generate_thumbnail old_path, commit_id\n generate_inspire_image old_path if branch == 'master'\n repo.checkout('master')\n end", "def write_images\n # Enumerate all the files in the zip and write any that are in the media directory to the output buffer (which is used to generate the new zip file)\n @file.read_files do |entry| # entry is a file entry in the zip\n if entry.name.include? IMAGE_DIR_NAME\n # Check if this is an image being replaced\n current_image = @images.select { |image| !@relationship_manager.get_relationship(image.id).nil? and entry.name.include? @relationship_manager.get_relationship(image.id)[:target] }.first\n\n unless current_image.nil?\n replacement_path = current_image.path\n data = ::File.read(replacement_path)\n else\n entry.get_input_stream { |is| data = is.sysread }\n end\n\n @file.output_stream.put_next_entry(entry.name)\n @file.output_stream.write data\n end\n end\n\n # Create any new images\n @unique_image_paths = []\n @images.select { |image| image.is_new }.each do |new_image|\n next if @unique_image_paths.include? new_image.target # we only want to write each image once\n @unique_image_paths << new_image.target\n @file.output_stream.put_next_entry(\"word/#{new_image.target}\")\n @file.output_stream.write ::File.read(new_image.path)\n end\n end", "def update_image(branch, old_path, new_file, author, message)\n repo = satelliterepo\n repo.checkout(branch)\n file = File.join satellitedir, old_path\n FileUtils.cp new_file.tempfile.path, file\n repo.index.add old_path\n commit_id = satellite_commit(\n repo,\n message,\n author,\n branch\n )\n generate_thumbnail old_path, commit_id\n repo.checkout('master')\n end", "def extend!(other)\n # Any image_registries entry in |self| should take precedence\n # over any identical key in |other|. The behavior of merge is that\n # the 'other' hash wins.\n @image_registries = other.image_registries.merge(@image_registries)\n\n # Same behavior as above for #default_flags.\n @default_flags = other.default_flags.merge(@default_flags)\n\n # artifacts should be merged by 'name'. In other words, if |self| and |other|\n # specify the same 'name' of a registry, self's config for that registry\n # should win wholesale (no merging of flags.)\n @artifacts = (@artifacts + other.artifacts).uniq { |h| h.fetch('name') }\n\n # Same behavior as for flags and registries, but the flags within the flavor\n # are in a Hash, so we need a deep merge.\n @flavors = other.flavors.deep_merge(@flavors)\n\n # A break from the preceding merging logic - Dependent hooks have to come\n # first and a given named hook can only be run once. But seriously, you\n # probably don't want to make a library that specifies hooks.\n @hooks = (other.hooks + @hooks).uniq\n\n @expiration = (@expiration + other.expiration).uniq { |h| h.fetch('repository') }\n end", "def do_overlay_image(image, hash)\n #puts \"get image\"\n #puts \"#{hash.inspect}\"\n #puts \"Image: #{hash[:image_path]}\"\n #puts \"File exists? #{File.exists?(hash[:image_path])}\"\n overlay_i = Magick::ImageList.new(hash[:image_path]).first\n #puts \"Do we want to colorize?\"\n if hash.has_key? :colorize\n \n #opc = hash[:opacity]\n overlay_i = do_colorize(overlay_i, hash.merge({:opacity=>0.5})) #overlay_i.colorize(opc, opc, opc, hash[:colorize])\n end\n return image.composite(overlay_i, 0, image.rows-overlay_i.rows, Magick::OverCompositeOp)\n end", "def place_onto(x, y, image, target)\n target.import_pixels(x, y, image.columns, image.rows, 'RGB', image.export_pixels)\n end", "def create_temp_with_image\n image, filename, content_type = create_image\n temp = TempImage.new\n temp.transaction do\n temp.image.attach(io: image, filename: filename, content_type: content_type) if temp.save\n end\n temp\n end", "def dup_src\n BufferedImage.new to_java.color_model, to_java.raster, true, nil\n end", "def modify_tiff_from_storage\n puts('Update parameters of a TIFF image from cloud storage')\n\n upload_sample_image_to_cloud\n\n compression = 'adobedeflate'\n resolution_unit = 'inch'\n bit_depth = 1\n horizontal_resolution = 150.0\n vertical_resolution = 150.0\n from_scratch = nil\n folder = ImagingBase::CLOUD_PATH # Input file is saved at the Examples folder in the storage\n storage = nil # We are using default Cloud Storage\n\n request = AsposeImagingCloud::ModifyTiffRequest.new(\n get_sample_image_file_name, bit_depth, compression, resolution_unit, horizontal_resolution,\n vertical_resolution, from_scratch, folder, storage)\n\n puts(\"Call ModifyTiff with params: compression: #{compression}, resolution unit: #{resolution_unit}, bit depth:\" +\n \" #{bit_depth}, horizontal resolution: #{horizontal_resolution}, vertical resolution: \" +\n \"#{vertical_resolution}\")\n\n updated_image = imaging_api.modify_tiff(request)\n save_updated_sample_image_to_output(updated_image, false)\n puts\n end", "def merge(source); end", "def gdal_merge(input_files, output_file, merge_strategy = :lossless)\n return nil if input_files.length == 0\n return CDBTool.link_output(input_files[0], output_file) if input_files.length == 1\n\n command = case merge_strategy\n when :lossless\n \"gdal_merge.py -o #{output_file} -co BIGTIFF=YES -co COMPRESS=LZW -co NUM_THREADS=ALL_CPUS -co TILED=YES -n 0 -a_nodata 0 #{input_files.join(\" \")}\"\n when :lossy\n \"gdal_merge.py -o #{output_file} -co BIGTIFF=YES -co COMPRESS=JPEG -co TILED=YES #{input_files.join(\" \")}\"\n end\n\n merge = Mixlib::ShellOut.new(command, live_stdout: $stdout, live_stderr: $stderr)\n\n if File.exists?(output_file)\n puts \"Output exists, skipping merge command.\"\n else\n puts command\n merge.run_command\n $mosaic.log(\"#{output_file},#{File.size(output_file)},#{merge.execution_time}s\")\n end\nend", "def merge(xml1, file2)\n xml2 = File.read(file2)\n return xml2 unless xml1\n\n merge_xml(xml1, xml2)\n end", "def blue_shift\n @photo = Photo.find(params[:id])\n img = Magick::Image.read('public' + @photo.attachment_url).first\n img = img.blue_shift(2)\n img.write('public' + @photo.attachment_url)\n end", "def merge!(other)\n assert_archive other\n clear_caches\n\n merge_data @data, other.as_json, other.uri\n nil\n end", "def render\n canvas = Vips::Image.grey(@width, @height)\n\n @tiles.each do |tile|\n canvas = canvas.insert(tile.image, tile.offset.x, tile.offset.y) # rubocop:disable Style/RedundantSelfAssignment\n end\n\n # add attribution image to bottom corner if available & attribution fits into image\n if add_attribution?\n options = { x: canvas.width - attribution.width, y: canvas.height - attribution.height }\n canvas = canvas.composite2(attribution, :over, **options)\n end\n\n canvas\n end", "def add_images(branch, dest, image_files, author)\n repo = satelliterepo\n repo.checkout(branch) unless repo.empty?\n new_images repo, dest, image_files\n commit_id = satellite_commit(\n repo,\n get_message(image_files),\n author,\n branch\n )\n f = File.join(dest.to_s, image_files.last.original_filename)\n generate_thumbnail f, commit_id\n repo.checkout('master')\n end", "def merge(other)\n self.merge_actors(other)\n self.compress_history()\n end", "def merge!; end", "def put_image(_x, _y, _image)\n @reacs[:images] << [_x, _y, _image]\n end", "def merge(other)\n append(*other)\n end", "def add_images(branch, dest, image_files, author)\n repo = satelliterepo\n repo.checkout(branch) unless repo.empty?\n new_images repo, dest, image_files\n commit_id = satellite_commit(\n repo,\n get_message(image_files),\n author,\n branch\n )\n f = File.join(dest.to_s, image_files.last.original_filename)\n generate_thumbnail f, commit_id\n inspire_image if branch == 'master'\n repo.checkout('master')\n end", "def merge(other); end", "def apply(template_image)\n self.scale\n\n image = Magick::ImageList.new(self.artwork.image.path)\n\n image[0].rotate!(rotation) unless rotation.nil?\n image.resize!(self.width, self.height)\n\n center_x = template_image.columns / 2\n crop_image!(image, center_x)\n\n self.image_x += template_image.columns / 2 if self.leg == 'right'\n\n # x_copies = (image[0].columns / template[0].columns).ceil\n # y_copies = (image[0].rows / template[0].rows).ceil\n\n # To be tiling, see http://www.imagemagick.org/RMagick/doc/ilist.html#mosaic\n # tiled = Magick::ImageList.new\n # page = Magick::Rectangle.new(0,0,0,0)\n # x_copies.times do |x|\n # y_copies.times do |y|\n\n # end\n # end\n\n design_image = template_image[0].composite(image, self.image_x, self.image_y, Magick::DstOverCompositeOp)\n\n if mirror\n design_image.flop!\n design_image.composite!(image, self.image_x, self.image_y, Magick::DstOverCompositeOp)\n design_image.flop!\n end\n\n intermediate_location = \"#{Dir.tmpdir}/#{SecureRandom.hex}.png\"\n design_image.write(intermediate_location)\n intermediate_location\n end", "def dup_src\n BufferedImage.new width, height, color_type\n end", "def interlace\n manipulate! do |img|\n img.strip\n img.combine_options do |c|\n c.quality \"80\"\n c.depth \"8\"\n c.interlace \"plane\"\n end\n img\n end\n end", "def create_modified_tiff(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end", "def audit_tirerack_images\n mfg_list = get_manufacturer_list\n Product.in_taxon('Tires').each do |tire|\n if tire.images.empty?\n # does it exist in our public/images/tirerack directory?\n # only way to tell would be to query the product file and try and extract the image name\n mfg_list.each do |mfg|\n key = get_product_key(mfg, tire.name) if tire.taxons.map(&:name).include?(mfg)\n if key.instance_of?(Hash) && key.has_key?(:images)\n key[:images].each do |img|\n # check if this image exists now \n base = File.basename(img).gsub(/_s.jpg/,'_l.jpg')\n if File.exists?(File.join(RAILS_ROOT, \"public\", \"images\", \"tirerack\",base))\n # OK.. so assign it to the product then.. since it already exists\n begin\n # add this variants image to the product as an image for the product\n i = Image.new\n i.attachment= File.new(File.join(RAILS_ROOT, \"public\", \"images\", \"tirerack\",base))\n i.viewable_id = tire.id\n i.viewable_type = 'Product'\n i.save\n rescue\n debuglog \"updating Product Image Failed\\n\"\n end\n end\n end\n end\n end\n end\n end\n end", "def copy\n ditto = self.class.new\n @images.each { |f| ditto << f.copy }\n ditto.scene = @scene\n ditto\n end", "def reformat(tifs, cfg)\n # do vis\n vis = File.basename(tifs['vis'], '.tif')\n command = \" #{cfg['awips_conversion']['vis_stretch']} #{vis}.tif #{vis}.stretched.tif\"\n puts(\"INFO: stretching #{command}\")\n shell_out!(command,clean_environment: true)\n command = \"gdalwarp #{cfg['awips_conversion']['warp_opts']} -te #{cfg['awips_conversion']['extents']} #{cfg['gdal']['co_opts']} -t_srs #{cfg['awips_conversion']['proj']} #{vis}.stretched.tif #{vis}.302.tif\"\n puts(\"INFO: warping to 302.. #{command}\")\n shell_out!(command,clean_environment: true)\n end", "def generate_images width=500, height=350\n # Base image with all territories shaded\n canvas = Magick::Image.new(width, height, Magick::TextureFill.new(@@map_bg))\n canvas.format = 'jpg'\n gc = Magick::Draw.new\n Territory.all.each do |t|\n gc.fill(\"transparent\")\n if t.clan\n gc.fill(\"rgb(#{t.clan.color_rgb.join(',')})\")\n gc.fill_opacity(0.25)\n end\n gc.stroke('rgb(64, 0, 0)')\n gc.stroke_width(1)\n if t.shape # uses svg-like shapes\n s = t.shape.split(',')\n path = \"M #{s[0]} #{s[1]} \"\n s[2..-1].each_slice(2) do |p|\n path << \"L #{p[0]} #{p[1]} \"\n end\n path << \"z\"\n gc.path(path)\n end\n\n if t.clan\n # draw the small icon for the clan if it exists\n if t.clan.image_filename 16\n gc.composite(t.position_x - 8, t.position_y - 8, 16, 16,\n Magick::Image.read(\"#{RAILS_ROOT}/public/images/#{t.clan.image_filename(16)}\").first)\n else # or draw a circle of their color\n gc.fill(\"rgb(#{t.clan.color_rgb.join(',')})\")\n gc.fill_opacity(1);\n gc.circle(t.position_x, t.position_y, t.position_x + 5, t.position_y)\n end\n else\n gc.circle(t.position_x, t.position_y, t.position_x + 5, t.position_y)\n end\n end\n gc.draw(canvas)\n canvas.write(\"#{RAILS_ROOT}/public/images/map/base.jpg\"){ self.quality = 95 } # TODO tweak the quality\n\n true\n end", "def attach_image_to_observation(image)\n @observation.add_image(image)\n image.log_reuse_for(@observation)\n if @observation.gps_hidden\n error = image.strip_gps!\n flash_error(:runtime_failed_to_strip_gps.t(msg: error)) if error\n end\n redirect_with_query(permanent_observation_path(id: @observation.id))\n # render(\"observations/show\",\n # location: permanent_observation_path(id: @observation.id,\n # q: get_query_param))\n end", "def merge(other)\n result = super\n\n result.sources = other.sources + self.sources\n result\n end", "def merge(front, back)\n length = overlay_length(front, back)\n front+back[length..-1]\n end", "def adopt(other_tile)\n other_tile.operations.each do |op|\n @operations << op.clone\n end\n end", "def enhance_frame(frame:, footer_height: 0, content_file: nil, combined_file:)\n base = MiniMagick::Image.open(frame)\n content = base.crop \"#{base.width}x#{base.height - footer_height}+0+0\"\n footer = create_footer(frame, footer_height)\n content = enhance_image(content)\n\n tempfile = Tempfile.new(['', '.png'])\n combined = append_images(content, footer, tempfile)\n content.write(content_file.to_s) unless content_file.nil?\n combined.write(combined_file.to_s)\n end", "def get_timage_from_yd\n if (params['gid'].nil?)\n txt = \"\"\n else\n user = User.find_by_sql(\"select id, dh, yxmc, jm_tag,width,height from timage where id=#{params['gid']};\")\n dh,width,height = user[0]['dh'], user[0]['width'], user[0]['height']\n\n if !File.exists?(\"./dady/img_tmp/#{dh}/\")\n system\"mkdir -p ./dady/img_tmp/#{dh}/\" \n end\n \n convert_filename = \"./dady/img_tmp/#{dh}/\"+user[0][\"yxmc\"].gsub('$', '-').gsub('TIF','JPG').gsub('tif','JPG')\n local_filename = \"./dady/img_tmp/#{dh}/\"+user[0][\"yxmc\"].gsub('$', '-')\n\n if !File.exists?(local_filename)\n user = User.find_by_sql(\"select id, dh, yxmc, jm_tag from timage where id=#{params['gid']};\")\n im_data = get_image_by_gid(params['gid'])\n\n tmpfile = rand(36**10).to_s(36)\n ff = File.open(\"./tmp/#{tmpfile}\",'w')\n ff.write(im_data)\n ff.close\n puts \"./tmp/#{tmpfile} #{local_filename}\"\n if (user[0]['jm_tag'].to_i == 1)\n system(\"decrypt ./tmp/#{tmpfile} #{local_filename}\")\n else\n system(\"scp ./tmp/#{tmpfile} #{local_filename}\")\n end \n system(\"rm ./tmp/#{tmpfile}\")\n end\n \n system(\"convert '#{local_filename}' '#{convert_filename}'\")\n if (convert_filename.upcase.include?'JPG') || (convert_filename.upcase.include?'TIF') || (convert_filename.upcase.include?'TIFF') || (convert_filename.upcase.include?'JPEG') \n imagesize=FastImage.size convert_filename\n \n if imagesize[0].to_i > imagesize[1].to_i\n txt = \"/assets/#{convert_filename}?2\"\n else\n txt = \"/assets/#{convert_filename}?1\"\n end\n else\n txt = \"/assets/#{convert_filename}?2\"\n end\n archive= User.find_by_sql(\"select * from archive where dh='#{dh}';\")\n set_rz(archive[0]['mlh'],'','','','影像查看',params['userid'],user[0][\"yxmc\"],user[0][\"yxmc\"],dh)\n end\n render :text => txt\n end", "def operation(*args)\n src_file, out_file = args\n image = Vips::Image.new_from_file(src_file).add_alpha\n watermark = Vips::Image.new_from_file options[:image]\n image.composite2(watermark,\n :over,\n x: options[:origin_x],\n y: options[:origin_y]).write_to_file out_file\n end", "def setup\n size 200, 200\n @a = load_image 'construct.jpg'\n @b = load_image 'wash.jpg'\n @offset = 0.0\nend", "def add_tags(directory)\n log_file(\"[START] adding tags...\")\n\n Dir.glob(directory + \"**/*.{DNG,JPG,JPEG,CR2,RW2}\", File::FNM_CASEFOLD).each do |image|\n parent_folder = File.basename(File.dirname(image))\n\n unless IGNORE_FOLDERS.include?(parent_folder) then\n make = `exiftool -b -make \"#{image}\"`\n if (make.length > 0) then\n puts `tag -a #{make} \"#{image}\"`\n puts \"adding \" + make + \" to \" + image\n end\n\n gps = `exiftool -b -gpslatitude \"#{image}\"`\n if (gps.length > 0) then\n puts `tag -a Geotagged \"#{image}\"`\n puts \"adding Geotagged to \" + image\n end\n\n if (['.dng', '.rw2', '.cr2'].include? File.extname(image).downcase) then\n puts `tag -a RAW \"#{image}\"`\n end\n end\n end\n\nend", "def copy_from(other, dst_x, dst_y, src_x, src_y,\n dst_w, dst_h, src_w = nil, src_h = nil)\n raise ArgumentError unless src_w.nil? == src_h.nil?\n\n if src_w\n ::GD2::GD2FFI.send(:gdImageCopyResampled, image_ptr, other.image_ptr, dst_x.to_i, dst_y.to_i, src_x.to_i, src_y.to_i, dst_w.to_i, dst_h.to_i, src_w.to_i, src_h.to_i)\n else\n ::GD2::GD2FFI.send(:gdImageCopy, image_ptr, other.image_ptr, dst_x.to_i, dst_y.to_i, src_x.to_i, src_y.to_i, dst_w.to_i, dst_h.to_i)\n end\n self\n end", "def merge\n @filenames.each do |f_name|\n reader = Fileread_with_row_index.new(f_name)\n last_row = reader.count_row - 1\n for i in 0..last_row \n line = reader.read_row(i)\n @writer.puts(line)\n end\n end\n end", "def merge_top_and_bottom_of_mouth\n Commander.run!(\"convert #{@dir}/top.miff #{@dir}/bottom.miff\",\n \"-append #{@dir}/opened_mouth.miff\")\n end", "def write_tactile_images( data, products_src_dir, dest_dir, data_mtime )\n # Attach our product data to global site variable. This allows pages to see this product's data.\n data.each do |image|\n puts \"## Processing image #{image['uuid']}\"\n index = TactileImagePage.new( self, self.config['source'], File.join(dest_dir, image['uuid']), 'index.html', products_src_dir, 'image', data_mtime )\n index.set_data('title', image['Title'])\n index.set_data('description', image['Description'])\n index.set_data('tactile_image', image)\n index.set_data('metadata', image.slice('Tags', 'Creator', 'Source', 'Language', 'Font'))\n index.render(self.layouts, site_payload)\n index.write(self.dest)\n # Record the fact that this page has been added, otherwise Site::cleanup will remove it.\n self.pages << index\n end\n end", "def add_existing_image(name, path)\n @images << Image.new(name, path)\n end", "def merge_data!(other, source: T.unsafe(nil)); end", "def enhance_image(image)\n colors = image.get_pixels.flatten\n colors.map! { |color| color**2 / 255 }\n blob = colors.pack('C*') # Recreate the original image, credit to stackoverflow.com/questions/53764046\n image = MiniMagick::Image.import_pixels(blob, image.width, image.height, 8, 'rgb')\n image.statistic('mean', '6x6')\n image.threshold(threshold_percent)\n image.statistic('median', '9x9') # Replace with object discard below set size\n end", "def replace_image(loc, image, source_sub_area = nil)\n raise ArgumentError.new unless format == image.format\n loc -= source_sub_area.loc if source_sub_area\n source_sub_area = (area - loc) | image.area | source_sub_area\n target_sub_area = source_sub_area + loc\n return unless target_sub_area.present?\n\n data = @data\n w = source_sub_area.w\n l = source_sub_area.loc\n each_line(target_sub_area) do |range|\n data[range] = image.sub_horizontal_line(l, w)\n l.y += 1\n end\n end", "def add_image( id, image_name, x_position, speed, width, height )\n OSX::NSLog(\"Received image ##{id} (#{image_name})\")\n# image_name = OSX::NSBundle.mainBundle.pathForImageResource( image_name )\n image_name = \"/Users/alpha/src/cyberart/images/#{image_name}.jpg\"\n image = CAImage.new( id, image_name, x_position, speed, width, height )\n @semaphore.synchronize { temp_images = @images.dup }\n temp_images << image\n @semaphore.synchronize { @images = temp_images }\n end", "def merge!( other )\n my_keys = @ini.keys\n other_keys =\n case other\n when IniFile; other.instance_variable_get(:@ini).keys\n when Hash; other.keys\n else raise \"cannot merge contents from '#{other.class.name}'\" end\n\n (my_keys & other_keys).each do |key|\n @ini[key].merge!(other[key])\n end\n\n (other_keys - my_keys).each do |key|\n @ini[key] = other[key]\n end\n\n self\n end", "def union(b)\n b.each do |bf|\n af = @cfile_by_name[bf.file]\n if af\n af.union bf\n else\n @cfile_by_name[bf.file] = bf\n end\n end\n self\n end", "def create_collage\n # load the template\n \n \n img_path = \"#{::Rails.root.to_s}/tmp/sets/\"\n img_name = \"set_#{self.id}_#{Time.now.to_i}\"\n \n #template \n # template = Magick::Image.read(\"#{RAILS_ROOT}/public/images/set_template.png\").first\n # or blank white image\n template = Magick::Image.new(600, 480){\n self.background_color = '#ffffff'\n }\n \n template.format = 'png'\n # template.filename = img_name\n \n # go through all set items by z_index and add lay it over the template\n for item in self.set_items.order(\"z_index asc\")\n photo = Magick::Image.read(item.product.assets.first.image.url(:thumb).to_s).first\n photo = photo.scale(item.width, item.height)\n photo = photo.rotate(item.rotation)\n # composite item over template offsetting pos_x and pos_y for the template border\n template.composite!(photo, item.pos_x, item.pos_y, Magick::OverCompositeOp)\n end\n\n # create temp file \n \n tmp_image = Tempfile.new([img_name, '.png'])\n \n # write rmagick image in tempfile\n \n template.write(tmp_image.path)\n \n # save & upload with carrierwave\n \n self.blog_image = tmp_image\n \n # self.blog_image.store!(template)\n \n self.write_blog_image_identifier\n \n self.save!\n \n #File.delete(img_path + img_name)\n \n tmp_image.delete\n \n end", "def merge!(other); end", "def gdal_addo(input_file, merge_strategy = :lossless)\n command = case merge_strategy\n when :lossless\n \"gdaladdo --config COMPRESS_OVERVIEW LZW #{input_file} 2 4 8 16\"\n when :lossy\n \"gdaladdo --config COMPRESS_OVERVIEW JPEG #{input_file} 2 4 8 16\"\n end\n\n addo = Mixlib::ShellOut.new(command, live_stdout: $stdout, live_stderr: $stderr)\n\n puts command\n addo.run_command\n $mosaic.log(\"#{input_file},#{File.size(input_file)},#{addo.execution_time}s\")\nend", "def attach_image_to_glossary_term(image = nil)\n if image &&\n @object.add_image(image) &&\n @object.save\n image.log_reuse_for(@object)\n redirect_with_query(glossary_term_path(@object.id))\n else\n flash_error(:runtime_no_save.t(:glossary_term)) if image\n render(:reuse,\n location: reuse_images_for_glossary_term_path(params[:img_id]))\n end\n end", "def create_txt(file, new_file)\n stdout = `exiftool \"#{file}\" > \"#{new_file}.tif.txt\"`\n puts stdout\nend", "def concat other_frames\n raise TypeError unless other_frames.kind_of?(Frames)\n @avi.process_movi do |this_indices, this_movi|\n this_size = this_movi.size\n this_movi.pos = this_size\n other_frames.avi.process_movi do |other_indices, other_movi|\n while d = other_movi.read(BUFFER_SIZE) do\n this_movi.print d\n end\n other_meta = other_indices.collect do |m|\n x = m.dup\n x[:offset] += this_size\n x\n end\n this_indices.concat other_meta\n [other_indices, other_movi]\n end\n [this_indices, this_movi]\n end\n\n self\n end", "def prepend_file_to_file(file_name_1, data1, file_name_2)\n File.open(append_root_path(file_name_1), 'w') do |f1|\n f1.puts data1\n File.foreach(append_root_path(file_name_2)) do |f2|\n f1.puts f2\n end\n end\n end", "def convert_img_tags!(log)\n log[:files_open] += 1\n file_marked = false\n @doc.xpath(\"//img\").each do |img|\n file_marked = true\n log[:tags] += 1\n\n original = img.to_html.gsub(\"\\\">\", \"\\\" />\").gsub(\"\\\" >\", \"\\\" />\").delete(\"\\\\\")\n original2 = img.to_html.gsub(\"\\\">\", \"\\\"/>\").gsub(\"\\\" >\", \"\\\" />\").delete(\"\\\\\")\n original3 = img.to_html.gsub(\"\\\">\", \"\\\">\").gsub(\"\\\" >\", \"\\\" />\").delete(\"\\\\\")\n image_tag = RailsImageTag.new(img).to_erb\n\n @content.gsub!(original, image_tag)\n @content.gsub!(original2, image_tag)\n @content.gsub!(original3, image_tag)\n puts image_tag\n end\n\n write_file(log) if file_marked\n end", "def add_image(img)\n unless images.include?(img)\n images << img\n self.thumb_image = img unless thumb_image\n self.updated_at = Time.zone.now\n save\n notify_users(:added_image)\n reload\n end\n img\n end", "def merge_layers(l1, l2)\r\n\t# [[1,2,3],[1,2,3],[1,2,3]]\r\n\tl1.each_with_index do |row, rindex|\r\n\t\trow.each_with_index do |item, cindex|\r\n\t\t\tif item == 2\r\n\t\t\t\t l1[rindex][cindex] = l2[rindex][cindex].dup\r\n\t\t\tend\r\n\t\tend\r\n\tend\r\n\tl1\r\nend", "def add_image(path, point, width, height = 0.0)\n end", "def attach_good_images(observation, images)\n return unless images\n images.each do |image|\n unless observation.image_ids.include?(image.id)\n observation.add_image(image)\n observation.log_create_image(image)\n end\n end\n end", "def attach\n return unless (@observation = find_observation!)\n\n return unless check_observation_permission!\n\n image = Image.safe_find(params[:img_id])\n unless image\n flash_error(:runtime_image_reuse_invalid_id.t(id: params[:img_id]))\n # redirect_to(:reuse) and return\n render(:reuse,\n location: reuse_images_for_observation_path(@observation.id))\n return\n end\n\n attach_image_to_observation(image)\n end", "def attach_good_images(observation, images)\n return unless images\n\n images.each do |image|\n unless observation.image_ids.include?(image.id)\n observation.add_image(image)\n image.log_create_for(observation)\n end\n end\n end", "def whole_images\n ( self.images + self.variant_images ).uniq\n end", "def attach\n @object = GlossaryTerm.safe_find(params[:id])\n\n image = Image.safe_find(params[:img_id])\n unless image\n flash_error(:runtime_image_reuse_invalid_id.t(id: params[:img_id]))\n render(:reuse,\n location: reuse_images_for_glossary_term_path(params[:img_id]))\n return\n end\n\n attach_image_to_glossary_term(image)\n end", "def make\n Paperclip.log(\"*********** Label Thumbnail Processor...\")\n dst = Tempfile.new([@basename, @format].compact.join(\".\"))\n dst.binmode\n\n # first create the name text image\n nameImg = createText(name, \"72\", \"\")\n\n # next create the description text image\n descImg = createText(description, \"36\", \"800x\")\n\n # next create the blend text image\n blendImg = createText(blend, \"72\", \"\")\n\n # now composite name text onto comp\n comp = compositeFiles(nameImg, @file, \"820x100!+40+40\")\n\n # now composite blend text onto comp\n comp2 = compositeFiles(blendImg, comp, \"810x50!+50+1050\")\n\n #now composite the description onto the dst\n dst = compositeFiles(descImg, comp2, \"820x300+50+865\")\n\n if generate_tin_image\n dst = compositeFiles(dst, tin_path, \"332x436!+234+139\")\n dst = compositeFiles(tin_fade_path, dst, \"800x800!+0+0\")\n end\n \n dst\n end", "def update_tiff_to_fax_from_storage\n puts('Update parameters of TIFF image according to fax parameters')\n\n upload_sample_image_to_cloud\n\n # Update TIFF Image parameters according to fax parameters\n folder = ImagingBase::CLOUD_PATH # Input file is saved at the Examples folder in the storage\n storage = nil # We are using default Cloud Storage\n\n request = AsposeImagingCloud::ConvertTiffToFaxRequest.new(get_sample_image_file_name, storage, folder)\n\n puts('Call ConvertTiffToFax')\n\n updated_image = imaging_api.convert_tiff_to_fax(request)\n save_updated_image_to_output('ConvertTiffToFax.tiff', updated_image)\n puts\n end", "def fetch_image(host,old_file,new_file)\n\t`rm #{old_file}` \n\t`mv #{new_file} #{old_file}`\t\n\topen('assets/images/radar/new.png', 'wb') do |file|\n\t\tfile << open('host').read\n\tend\n\tnew_file\nend", "def create_xmp(file, new_file)\n if File.exists?(\"#{new_file}.tif.xmp\")\n # exiftool outputs a large amount of unhappiness if the file exists\n puts \"#{new_file}.tif.xmp already exists, skipping\"\n else\n stdout = `exiftool \"#{file}\" -o \"#{new_file}.tif.xmp\"`\n puts stdout\n end\nend", "def merge srcdir, dstfile\n FileUtil.copy_merge(@hdfs, Path.new(srcdir), @hdfs, Path.new(dstfile), false, @conf, \"\")\n end", "def merge srcdir, dstfile\n FileUtil.copy_merge(@hdfs, Path.new(srcdir), @hdfs, Path.new(dstfile), false, @conf, \"\")\n end", "def merge(other)\n assert_archive other\n\n data = deep_clone(@data)\n merge_data data, other.as_json, other.uri\n\n self.class.new data\n end", "def process_small_image\n small_image.encode!(:png).convert!('-resize 50x50 -gravity center -background none -extent 50x50')\n end", "def merge(other)\n dup << other\n end", "def persist_tiles\n reference_image_hash.each_pair do |char, image|\n puts \"saving to: #{filename_for_training_image(char, 'gif')}\"\n\n image.write(filename_for_training_image(char, 'gif'))\n end\n\n noise_image_hash.each_pair do |char, image|\n image.write(filename_for_noise_image(char, 'gif'))\n end\n end", "def main()\n img = ImageList.new($input)\n convert = ImageList.new\n page = Magick::Rectangle.new(0,0,0,0)\n $total_ops = (img.rows * img.columns).to_f\n\n for i in 0..img.rows\n for j in 0..img.columns\n pixel = generate_hex_pixel(rgb_to_hex(img.pixel_color(j,i)))\n convert << pixel\n page.x = j * pixel.columns\n page.y = i * pixel.rows\n pixel.page = page\n progress()\n end\n end\n\n puts 'Writing image, this could take a while...'\n convert.mosaic.write($output)\nend" ]
[ "0.61741656", "0.6001265", "0.5858601", "0.577929", "0.55328095", "0.55000424", "0.5443584", "0.54142827", "0.53489655", "0.53430873", "0.5236349", "0.5224159", "0.52176", "0.5184148", "0.5158657", "0.5064444", "0.5064444", "0.5038985", "0.50312716", "0.502292", "0.5006569", "0.49875435", "0.49762768", "0.49696362", "0.49691582", "0.4931094", "0.49081418", "0.48941442", "0.48855597", "0.488493", "0.48835823", "0.48804358", "0.48800918", "0.4843845", "0.48304197", "0.48281917", "0.48234978", "0.48185873", "0.48132628", "0.48082554", "0.4801641", "0.47907633", "0.478792", "0.47860324", "0.4758515", "0.473171", "0.4721261", "0.47174898", "0.47054854", "0.46980497", "0.468307", "0.46750703", "0.46653464", "0.46603316", "0.46564522", "0.46551526", "0.46541396", "0.46514016", "0.46414897", "0.4633109", "0.46173656", "0.46166292", "0.46166167", "0.46148577", "0.46142957", "0.4609913", "0.46089703", "0.4604784", "0.4585747", "0.45842952", "0.45838898", "0.45774707", "0.45746094", "0.4574292", "0.4571843", "0.4571102", "0.45432577", "0.45413065", "0.45405793", "0.4533132", "0.4530989", "0.45222157", "0.45179182", "0.45171884", "0.4512646", "0.45109746", "0.4508317", "0.45077148", "0.4506919", "0.4500902", "0.44998786", "0.44839627", "0.44775534", "0.44769275", "0.44769275", "0.4473762", "0.44674268", "0.44642085", "0.44636396", "0.44555742" ]
0.7009079
0
GET /events GET /events.json
def index @events = Event.order(sort_column + ' ' + sort_direction) respond_to do |format| format.html # index.html.erb format.json { render json: @events } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def events\n response = self.class.get('/v1/events.json')\n response.code == 200 ? JSON.parse(response.body) : nil\n end", "def get_events\n Resources::Event.parse(request(:get, \"Events\"))\n end", "def get_events()\n @client.make_request(:get, @client.concat_user_path(\"#{CALL_PATH}/#{id}/events\"))[0]\n end", "def index\n #returns all events from eventbrite API, need to change to pull from her endpoint\n @eventList = Event.retrieve_all_events params\n render json: @eventList, status: 200\n end", "def get_events\n response = request(:get, \"/devmgr/v2/events\")\n #status(response, 200, 'Failed to get current events from server')\n #JSON.parse(response.body)\n response\n end", "def index\n @events = Event.all\n render json: @events, status: 200\n end", "def index\n @events = Event.all\n render json: @events\n end", "def index\n @events = current_user.events\n\n render json: @events\n end", "def index\n @events = Event.find(:all)\n respond_to do |format|\n format.html\n format.json\n end\n end", "def index\n @events = Event.all\n\n render json: @events\n end", "def index\n @event = Event.all\n render json: @event\n end", "def index\n @events = Event.live\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.live\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n respond_to do |format|\n format.html\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n respond_to do |format|\n format.html \n format.json do\n render :json => {events: @events}\n end\n end\n end", "def index\n response = { events: Event.all }\n respond_to do |format|\n format.json { render json: response.to_json }\n format.html { render :index }\n end\n end", "def get_events\n if @user.uuid.present?\n @events = @user.events.active_events.page(params[:page])\n paginate json: @events, per_page: params[:per_page]\n elsif @user.uuid == \"guest\"\n @events = Com::Nbos::Events::Event.active_events.where(tenant_id: @user.tenant_id)\n render json: @events\n else\n render :json => {messageCode: \"bad.request\", message: \"Bad Request\"}, status: 400\n end\n end", "def index\n\t\t@events = Event.all.order('created_at desc')\n\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render :json => @events }\n\t\tend\n\tend", "def index\n @events = Event.all\n respond_to do |format|\n format.html \n format.json \n end\n end", "def get_events(args)\n\tapi_url = \"#{@base_url}/#{args[:collection]}/#{args[:key]}/events/#{args[:event_type]}\"\n\tdo_the_get_call( url: api_url, user: @user )\nend", "def events(project_id, options = {})\n get \"projects/#{project_id}/events\", options\n end", "def index\n @events = current_user.events\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def show\n @event = Event.find(params[:id])\n render json: @event\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n \n @events = current_user.events\n \n \n respond_to do |format|\n format.html {}\n format.json { render json: Event.events_to_json(@events) }\n end\n end", "def events\n data[\"events\"]\n end", "def events\n url = 'https://api.artic.edu/api/v1/exhibitions?limit=35'\n\n res = RestClient.get(url)\n JSON.parse(res)\nend", "def index\n @events = @calendar.events.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @events }\n end\n end", "def index\n @events = @category.events\n render json: @events \n end", "def index\n\t\t@events = current_user.events\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render json: @events }\n\t\tend\n\tend", "def show\n render json: @event\n end", "def show\n render json: @event\n end", "def show\n render json: @event\n end", "def show\n render json: @event\n end", "def show\n render json: @event\n end", "def index\n event = Event.find(params[:event_id])\n render json: event.route, status: :ok\n end", "def index\n render json: Event.all, status: :ok\n end", "def show\n render json: @event, status: :ok\n end", "def index\n @upcoming_events = Event.upcoming\n @past_events = Event.past\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n respond_with(@events)\n end", "def get_event(session, options={})\n json_request \"get\", {:session => session}, options\n end", "def index\n @events = getUpcomingEvents()\n \n @page_title = \"Events\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def get(event_id)\n @client.request \"events/#{event_id}\"\n end", "def index\n\t\t@events = Event.page(params[:page]).per(10)\n\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json {\n\t\t\t\trender :json => @events.to_json\n\t\t\t}\n\t\tend\n\n\tend", "def show\n event_id = params[:id]\n if event_id.present?\n @event = Com::Nbos::Events::Event.active_events.where(id: event_id, tenant_id: @user.tenant_id)\n if @event.present?\n render :json => @event\n else\n render :json => {messageCode: \"event.notfound\", message: \"Event Not Found\"}, status: 404\n end\n else\n render :json => {messageCode: \"bad.request\", message: \"Bad Request\"}, status: 400\n end\n end", "def events\n collection(\"events\")\n end", "def event(event, options = {})\n get \"events/#{event}\", options\n end", "def past_events\n @events = Event.past\n render json: @events, include: :talks\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def get_event_list ( year )\n get_api_resource \"#{@@api_base_url}events/#{year}\"\n end", "def index\n begin\n events = Event.all\n render :json => {events: ActiveModel::ArraySerializer.new(events, each_serializer: EventsSerializer), :code => 200}, status: :ok\n rescue Exception => e\n logger.error {\"Error while populating list of events. ErrorMessage: #{e.message}, Params: #{params.inspect}\"}\n render json: {error: e.message, code: 500}\n end\n end", "def show\n \trender json: @event\n end", "def show\n @events = fetch_events\n end", "def show\n render json: EventSerializer.new(@event).as_json, status: 200\n end", "def list\n @events = Event.coming_events\n respond_to do |format|\n format.html do\n render layout: 'events'\n end\n format.json do \n events = @events.map {|event| {event: event, users: event.users, applied: event.users.include?(current_user) }}\n render json: events \n end\n end\n end", "def index\n if params[:query].present?\n @events = GroupEvent.send(params[:query])\n else\n @events = GroupEvent.published\n end\n\n render json: @events\n end", "def fullcalendar_events_json\n events.map do |event|\n {\n id: event.id.to_s,\n title: event.name,\n start: event.starts_at.strftime('%Y-%m-%d %H:%M:%S'),\n end: event.ends_at.strftime('%Y-%m-%d %H:%M:%S'),\n allDay: event.all_day,\n url: event_path(event)\n }\n end\n end", "def show\n @event = Event.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event_event = Event::Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event_event }\n end\n end", "def index\n if params[:user]\n @events = Event.where(user: params[:user]).first\n else\n @events = Event.all.order('created_at asc')\n end\n\n render json: @events, :only => [:id, :date, :user, :event_type, :message, :otheruser]\n end", "def show\n @event = Event.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def details\n get(\"v1/event/#{@id}\")\n end", "def show\n @event = Event.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event } \n end\n end", "def show\n render json: format_event(@event)\n end", "def index\n @events = Event.all\n @event = Event.new\n\n respond_to do |format|\n format.html\n format.json { render 'events/index', events: @events }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end" ]
[ "0.8337294", "0.82393", "0.7943906", "0.7928331", "0.77682066", "0.77408546", "0.76701826", "0.7665501", "0.76581633", "0.7642472", "0.76212007", "0.7615658", "0.7615658", "0.7612881", "0.75687", "0.7522498", "0.7488667", "0.74813455", "0.74698067", "0.7441679", "0.74408287", "0.7439104", "0.7438", "0.7410777", "0.74091715", "0.74091715", "0.74091715", "0.74091715", "0.74091715", "0.74091715", "0.74091715", "0.74091715", "0.74091715", "0.74091715", "0.74001324", "0.73986024", "0.73760885", "0.7367902", "0.7366312", "0.7364237", "0.7363436", "0.73616976", "0.73616976", "0.73616976", "0.73616976", "0.73616976", "0.73592705", "0.7352217", "0.7334486", "0.73247266", "0.7320335", "0.72969604", "0.72951084", "0.7288287", "0.7282072", "0.72735256", "0.72733235", "0.72477293", "0.7245006", "0.7228475", "0.7228475", "0.72234964", "0.72129667", "0.72124153", "0.7182632", "0.71820146", "0.71711934", "0.71332264", "0.712864", "0.7123786", "0.7122708", "0.7114666", "0.7110134", "0.7110134", "0.7104194", "0.71022034", "0.7101582", "0.7101437", "0.7099895", "0.70996326", "0.70996326", "0.70996326", "0.70996326", "0.70996326", "0.70996326", "0.70996326", "0.70996326", "0.70996326", "0.70996326", "0.70996326", "0.70996326", "0.70996326", "0.70996326", "0.70996326", "0.70996326", "0.70996326", "0.70996326", "0.70996326", "0.70996326", "0.70996326", "0.70996326" ]
0.0
-1
GET /events/1 GET /events/1.json
def show @event = Event.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @event } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @event = Event.find(params[:id])\n render json: @event\n end", "def get(event_id)\n @client.request \"events/#{event_id}\"\n end", "def show\n event_id = params[:id]\n if event_id.present?\n @event = Com::Nbos::Events::Event.active_events.where(id: event_id, tenant_id: @user.tenant_id)\n if @event.present?\n render :json => @event\n else\n render :json => {messageCode: \"event.notfound\", message: \"Event Not Found\"}, status: 404\n end\n else\n render :json => {messageCode: \"bad.request\", message: \"Bad Request\"}, status: 400\n end\n end", "def get_events()\n @client.make_request(:get, @client.concat_user_path(\"#{CALL_PATH}/#{id}/events\"))[0]\n end", "def events\n response = self.class.get('/v1/events.json')\n response.code == 200 ? JSON.parse(response.body) : nil\n end", "def index\n #returns all events from eventbrite API, need to change to pull from her endpoint\n @eventList = Event.retrieve_all_events params\n render json: @eventList, status: 200\n end", "def index\n @events = Event.all\n render json: @events, status: 200\n end", "def index\n @event = Event.all\n render json: @event\n end", "def index\n @events = Event.find(:all)\n respond_to do |format|\n format.html\n format.json\n end\n end", "def index\n respond_to do |format|\n format.html\n format.json { render json: @events }\n end\n end", "def get_events\n Resources::Event.parse(request(:get, \"Events\"))\n end", "def show\n @event = Event.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def index\n @events = Event.live\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.live\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def details\n get(\"v1/event/#{@id}\")\n end", "def index\n @events = Event.all\n render json: @events\n end", "def show\n\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @myevent = Myevent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @myevent }\n end\n end", "def show\n @event = Event.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n @event_event = Event::Event.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event_event }\n end\n end", "def index\n event = Event.find(params[:event_id])\n render json: event.route, status: :ok\n end", "def index\n @events = Event.all\n\n render json: @events\n end", "def show\n render json: @event, status: :ok\n end", "def index\n @events = Event.all\n respond_to do |format|\n format.html \n format.json do\n render :json => {events: @events}\n end\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.json { render json: @events }\n end\n end", "def show\n @event = Event.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event } \n end\n end", "def show\n @event = Event.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @event }\n end\n end", "def show\n @event = Event.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @event }\n end\n end", "def show\n render json: @event\n end", "def show\n render json: @event\n end", "def show\n render json: @event\n end", "def show\n render json: @event\n end", "def show\n render json: @event\n end", "def index\n @events = Event.all\n respond_to do |format|\n format.html \n format.json \n end\n end", "def show\n render json: EventSerializer.new(@event).as_json, status: 200\n end", "def event(event, options = {})\n get \"events/#{event}\", options\n end", "def index\n response = { events: Event.all }\n respond_to do |format|\n format.json { render json: response.to_json }\n format.html { render :index }\n end\n end", "def index\n render json: Event.all, status: :ok\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def index\n @events = current_user.events\n\n render json: @events\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def event(id, options = {})\n get \"events/#{id}\", options\n end", "def index\n @events = Event.all\n @event = Event.new\n\n respond_to do |format|\n format.html\n format.json { render 'events/index', events: @events }\n end\n end", "def show\n @event = Event.find(params[:id])\n @client = Client.find(@event.client_id)\n @event_type = EventType.find(@event.event_type_id)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def index\n @events = Event.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @events }\n end\n end", "def get_event ( event_key )\n get_api_resource \"#{@@api_base_url}event/#{event_key}\"\n end", "def get_events(args)\n\tapi_url = \"#{@base_url}/#{args[:collection]}/#{args[:key]}/events/#{args[:event_type]}\"\n\tdo_the_get_call( url: api_url, user: @user )\nend", "def index\n @event = Event.find(params[:event_id])\n\n end", "def index\n @upcoming_events = Event.upcoming\n @past_events = Event.past\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def show\n \trender json: @event\n end", "def index\n @events = current_user.events\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def index\n @events = getUpcomingEvents()\n \n @page_title = \"Events\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @events }\n end\n end", "def show\n render json: format_event(@event)\n end", "def index\n respond_with(@events)\n end", "def show\n @current_event = CurrentEvent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @current_event }\n end\n end", "def get_events\n if @user.uuid.present?\n @events = @user.events.active_events.page(params[:page])\n paginate json: @events, per_page: params[:per_page]\n elsif @user.uuid == \"guest\"\n @events = Com::Nbos::Events::Event.active_events.where(tenant_id: @user.tenant_id)\n render json: @events\n else\n render :json => {messageCode: \"bad.request\", message: \"Bad Request\"}, status: 400\n end\n end", "def show\n begin\n @event = Event.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n logger.error \"Attempt to show invalid event #{params[:id]}\"\n redirect_to events_path, notice: 'Invalid event ID'\n else\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end\n end", "def index\n @events = @category.events\n render json: @events \n end", "def index\n\t\t@events = Event.all.order('created_at desc')\n\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render :json => @events }\n\t\tend\n\tend", "def show\n @event = Event.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @event, methods: [:talks] }\n end\n end", "def get_events\n response = request(:get, \"/devmgr/v2/events\")\n #status(response, 200, 'Failed to get current events from server')\n #JSON.parse(response.body)\n response\n end", "def index\n if params[:user]\n @events = Event.where(user: params[:user]).first\n else\n @events = Event.all.order('created_at asc')\n end\n\n render json: @events, :only => [:id, :date, :user, :event_type, :message, :otheruser]\n end", "def get_event(session, options={})\n json_request \"get\", {:session => session}, options\n end", "def index\n \n @events = current_user.events\n \n \n respond_to do |format|\n format.html {}\n format.json { render json: Event.events_to_json(@events) }\n end\n end", "def show\n @calendar = Calendar.find(params[:id])\n @events = Event.find(@calendar.event_ids)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @calendar }\n end\n end" ]
[ "0.75022924", "0.74003553", "0.7360236", "0.73483384", "0.734628", "0.7336635", "0.73162717", "0.7286345", "0.7280093", "0.72448486", "0.722994", "0.7218412", "0.7218412", "0.721763", "0.721763", "0.72140783", "0.7203632", "0.7198198", "0.71961105", "0.7189425", "0.7189013", "0.7184017", "0.7183158", "0.718145", "0.71768117", "0.7164014", "0.71630543", "0.71582675", "0.7157298", "0.71194905", "0.71194905", "0.71194905", "0.71194905", "0.71194905", "0.7103394", "0.7097978", "0.7085923", "0.7073736", "0.707076", "0.7068357", "0.7068357", "0.70653474", "0.70593154", "0.70593154", "0.70593154", "0.70593154", "0.70593154", "0.70593154", "0.70593154", "0.70593154", "0.70593154", "0.70593154", "0.70495737", "0.70417565", "0.70380235", "0.70317364", "0.7026767", "0.7025042", "0.7018307", "0.6992369", "0.6983668", "0.69716734", "0.6966988", "0.69488955", "0.6948659", "0.69430053", "0.69286466", "0.69253206", "0.69211066", "0.6917694", "0.69121385", "0.689186", "0.6889872", "0.6876414", "0.6852297", "0.6850897" ]
0.7191539
43
GET /events/new GET /events/new.json
def new @event = Event.new 3.times { @event.attachments.build } respond_to do |format| format.html # new.html.erb format.json { render json: @event } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @event = Event.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @create_event = CreateEvent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @create_event }\n end\n end", "def new\n # @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n\n # render :action => 'new'\n end", "def new\n @event = current_user.events.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event_event = Event::Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event_event }\n end\n end", "def new\n @event = Event.new\n @event.time = Time.now\n \n @page_title = \"New Event\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n\t\t@event = Event.new\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.json { render json: @event }\n\t\tend\n\tend", "def new\n @current_event = CurrentEvent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @current_event }\n end\n end", "def new\n @event_request = EventRequest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event_request }\n end\n end", "def new\n @myevent = Myevent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @myevent }\n end\n end", "def new\n assign_new_event\n\n respond_to do |format|\n format.html { render :edit }\n format.js { render(:update) { |page| page.redirect_to(action: :new, event: event_params) } }\n end\n end", "def new\n setup_variables\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @event }\n end\n end", "def new\n @event = Event.new(event_type: params[:event_type])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = @current_account.events.new(Event.defaults) # TODO, set this account-wid\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @evento = Evento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @evento }\n end\n end", "def new\n @event=Event.new \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project.events }\n end\n end", "def new\n @event = Event.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @event }\n end\n end", "def new\n @event = Event.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @event }\n end\n end", "def new\n @event = Event.new_default\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @event }\n end\n end", "def new\n @main_event = MainEvent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @main_event }\n end\n end", "def new\n @event = current_user.events.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @event }\n format.js # return the HTML block for use by the AJAX new.js.erb\n end\n end", "def new\n @users_event = UsersEvent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @users_event }\n end\n end", "def new\n @event = Event.new\n @needs = Need.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @calevent = Calevent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @calevent }\n end\n end", "def new\n @event = Event.new\n @userId = session[:user_id]\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n @name = params[:name]\n @description = params[:description]\n @location = params[:location]\n @start_time = params[:start_time]\n @end_time = params[:end_time]\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n @event.user_id = current_user.id\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n @title = 'New Event'\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @event }\n end\n end", "def new\n @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @event }\n end\n end", "def new\n @events_tag = EventsTag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @events_tag }\n end\n end", "def new\n @activity_event = ActivityEvent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @activity_event }\n end\n end", "def new\n @entry = Entry.new(dob: Date.new(Date.today.year - 18, 1, 1))\n get_events\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end", "def new\n @calendar_event = CalendarEvent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @calendar_event }\n end\n end", "def new\n @event = Event.new\n @page_title = \"Add an Event\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @event }\n end\n end", "def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @event }\n end\n end", "def new\n @event = Event.new\n #@venues = Venue.all\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @new_event = Event.new\n end", "def new\n @event = Event.new\n @categories = Category.all or []\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def create\n puts params[:event]\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to events_path, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @simple_event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @simple_event }\n end\n end", "def new\n @event_source = EventSource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @event_source }\n end\n end", "def new\n @idea_event = IdeaEvent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @idea_event }\n end\n end", "def create\n \n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, :notice => 'Event was successfully created.' }\n format.json { render :json => @event, :status => :created, :location => @event }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @event.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @section_event = SectionEvent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @section_event }\n end\n end", "def new\n @weather_event = WeatherEvent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @weather_event }\n end\n end", "def new\n @event_log_entry = EventLogEntry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event_log_entry }\n end\n end", "def new\n @event = Event.find(params[:event_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @eventtime }\n end\n end", "def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to \"/#{@event.url}\" }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @event_schedule = EventSchedule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event_schedule }\n end\n end", "def new\n @event = Event.new\n setup_accounts\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @event }\n end\n end", "def new\n @event = Event.new\n\n @idea = Idea.find(params[:idea_id])\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end", "def new\n @event = Event.new\n if !(can? :manage, :all)\n flash[:error] = \"Access Denied.\"\n redirect_to root_url\n else\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end\n end" ]
[ "0.81609446", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.81505513", "0.8110529", "0.8107766", "0.8092567", "0.80846554", "0.80684704", "0.7999689", "0.7991803", "0.7951315", "0.781366", "0.78075147", "0.779362", "0.77705824", "0.7751462", "0.77457386", "0.7706269", "0.76265216", "0.7624129", "0.7616397", "0.7613026", "0.76081914", "0.75342673", "0.7531945", "0.75180125", "0.75154895", "0.7511866", "0.74955404", "0.7487049", "0.7476453", "0.7468936", "0.7466888", "0.7466888", "0.7466888", "0.7466888", "0.7466888", "0.7466888", "0.7466888", "0.7466888", "0.7466888", "0.7466888", "0.7466888", "0.7466888", "0.7466888", "0.7465296", "0.746489", "0.74380267", "0.7390529", "0.7381613", "0.73814714", "0.7377225", "0.73596585", "0.7351789", "0.7347289", "0.7345126", "0.7326438", "0.7323555", "0.73063886", "0.7301011", "0.729608", "0.72767663", "0.72661", "0.7258782", "0.72508454", "0.72444355", "0.72438437", "0.72267365", "0.72258604" ]
0.0
-1
POST /events POST /events.json
def create @event = Event.new(params[:event]) respond_to do |format| if @event.save format.html { redirect_to @event, notice: 'Event was successfully created.' } format.json { render json: @event, status: :created, location: @event } else format.html { render action: "new" } format.json { render json: @event.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_event event, data={}\n data[:event] = event\n post '/event', data\n end", "def create\n event = Event.new(event_params)\n event.save!\n render json: event\n end", "def create\n Rails.logger.debug(\"Received event #{params[:event]}\")\n head :ok\n end", "def create\n @event = Event.new(params[:event])\n\n if @event.save\n render json: @event, status: :created, location: @event\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def create\n megam_rest.post_event(to_hash)\n end", "def create\n @event = Event.new(event_params)\n\n if @event.save\n \tdata = { data: @event, status: :created, message: \"Event was successfully created.\" }\n render :json => data\n else\n \tdata = { data: @event.errors, status: :unprocessable_entity }\n render :json => data\n end\n end", "def create\n @event = Event.new(event_params)\n if @event.save\n head :created\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def create\n puts params[:event]\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to events_path, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, :notice => 'Event was successfully created.' }\n format.json { render :json => @event, :status => :created, :location => @event }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @event.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.json { render :show, status: :created, location: @event }\n else\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.json { render :show, status: :created, location: @event }\n else\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.find_by_authentication_token(params[:auth_token])\n @event = Event.new.from_json(params[:event])\n @event.user_id = @user.id\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n @event.organizer = current_user\n\n if @event.save\n render json: @event, status: :created, location: @event\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def save\n event = params\n # This assumes that all keys exists. Yay no error handling...\n toSave = Event.new(update_type: event[:event],\n start_time: event[:payload][:event][:start_time_pretty],\n end_time: event[:payload][:event][:end_time_pretty],\n location: event[:payload][:event][:location],\n invitee_name: event[:payload][:invitee][:name],\n duration: event[:payload][:event_type][:duration],\n event_kind: event[:payload][:event_type][:kind])\n toSave.save\n render json: {}, status: 200\n end", "def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, :notice => 'Event was successfully created.' }\n format.json { render :json => @event, :status => :created, :location => @event }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @event.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: t(:event_created) }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n params['user_id'] = current_user.id if current_user\n @event = Event.new(event_params)\n\n if @event.save\n render json: { location: format_event(@event) }, status: :created\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to \"/#{@event.url}\" }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def push_events\n saved = []\n jsonHash = request.POST[:_json];\n jsonHash.each do |jsonEvent|\n event = Event.new\n event.race_id = jsonEvent[\"raceId\"]\n event.walker_id = jsonEvent[\"walkerId\"]\n event.eventId = jsonEvent[\"eventId\"]\n event.eventType = jsonEvent[\"type\"]\n event.eventData = jsonEvent[\"data\"]\n event.batteryLevel = jsonEvent[\"batL\"]\n event.batteryState = jsonEvent[\"batS\"]\n event.timestamp = Time.zone.parse(jsonEvent[\"time\"])\n if event.save # if new\n saved << jsonEvent[\"eventId\"]\n if event.race_id != 0 # if not unknown race_id\n after_create(event)\n end\n else # if exists\n saved << jsonEvent[\"eventId\"]\n puts \"Not Saved!\" # debug print\n puts jsonEvent # debug print \n end\n end\n render :json => {:savedEventIds => saved}\n end", "def create\n result = Event::CreateEvent.perform(event_context)\n\n respond_to do |format|\n if result.success?\n @event = result.event\n format.json { render action: 'show', status: :created }\n else\n format.json { render json: { :errors => result.errors.full_messages }, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n if @event.save\n render :show, status: :created, location: @event\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def create\n @event = Events::Event.new(event_params)\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to events_path, notice: \"Event #{@event} was successfully created.\" }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to events_path, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: events_path(@event) }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, event: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n params[:event] = convert_datetimes( params[:event] )\n @event = @current_account.events.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # render json: params[:event]\n temp_event = Event.create(\n name: params[:event][:name],\n location: params[:event][:location],\n date: params[:event][:date],\n time: params[:event][:time],\n budget: params[:event][:budget],\n user: current_user\n )\n redirect_to \"/items?event=#{temp_event.id}\"\n end", "def create\n \n @event = Event.new(event_params)\n \n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: \"Event was successfully created.\" }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event_event = Event::Event.new(params[:event_event])\n\n respond_to do |format|\n if @event_event.save\n format.html { redirect_to @event_event, notice: 'Event was successfully created.' }\n format.json { render json: @event_event, status: :created, location: @event_event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event_event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to events_path, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to dashboard_home_path }\n format.json { render 'event', status: :created, event: @event }\n else\n format.html { render dashboard_home_path }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n logger.debug @event.errors.inspect\n format.html { redirect_to @event, notice: 'データが新規作成されました。' }\n format.json { render :show, status: :created, location: @event }\n else\n logger.debug @event.errors.to_hash(true)\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to new_event_path, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, flash: {success: 'Event was successfully created.'} }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: \"Event was successfully created.\" }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: \"Event was successfully created.\" }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, success: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'El evento fue creado exitosamente.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n flash[:success] = \"Event was successfully created.\"\n format.html { redirect_to @event }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n @event = Event.new(event_params)\r\n convert_timezone @event\r\n event_type_status @event\r\n if @event.save_without_exception\r\n update_theme @event\r\n add_event_categories @event\r\n add_event_location @event\r\n create_group_guest_list @event\r\n add_photos @event\r\n # Create Groups and contacts through CSV\r\n contacts_imports\r\n render json: SuccessResponse.new(\r\n code: 200, message: 'Event Created.', location: '/events/List?id=' + @event.id.to_s, eventID: @event.id\r\n ), adapter: :json, status: :ok\r\n else\r\n render json: ErrorResponse.new, adapter: :json, status: :unprocessable_entity\r\n end\r\n end", "def create\n @event = current_user.events.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: t(:event_success) }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_events\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Aula cadastrada com sucesso.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to action: :index, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to new_user_event_path(current_user), notice: 'event was successfully created.' }\n format.json\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(params[:event])\n @event.url = BASE_URL + @event.name.gsub(' ', '_')\n \n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render action: 'show', status: :created, location: @event }\n else\n format.html { render action: 'new' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_event(url, event, payload_type, payload)\n body = {\n :event => event,\n :payload_type => payload_type }\n body[:payload] = payload if payload\n\n http_post(url) do |req|\n req.headers['Content-Type'] = 'application/json'\n req.body = body.to_json\n req.params['verification'] = 1 if event == 'verification'\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render action: 'show', status: :created, location: @event }\n else\n format.html { render action: 'new' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render action: 'show', status: :created, location: @event }\n else\n format.html { render action: 'new' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = @calendar.events.new(event_params)\n respond_to do |format|\n if @event.save\n format.json { render json: @event }\n else\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n flash[:success] = \"Wydarzenie zostało utworzone.\"\n format.html {redirect_to @event}\n format.json {render :show, status: :created, location: @event}\n else\n format.html {render :new}\n format.json {render json: @event.errors, status: :unprocessable_entity}\n end\n end\n end", "def create\n @event = Event.new(params[:event])\n\n respond_to do |format|\n if @event.save\n format.html { redirect_to event_registration_path(id: @event.id), notice: 'Event was successfully created.' }\n format.json { render json: @event, status: :created, location: @event }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event = Event.new(event_params)\n @event.creator = @current_user\n\n if @event.save\n @event.users.each do |user|\n p \"event user = #{user.name}\"\n user.send_event_push(PushTypes::NEW_EVENT, current_user.to_push, @event.title)\n end\n else\n render json: @event.errors, status: :unprocessable_entity\n return\n end\n end", "def create\n @event = Event.new(event_params)\n if @event.save\n render json: @event, status: 201\n @user_event = UserEvent.create(admin: true, event_id: @event.id, user_id: current_user.id)\n else\n render json: { message: \"Please make sure to fill all required fields.\" }, status: 401\n end\n end", "def create\n @event = Event.new(event_params)\n respond_to do |format|\n if @event.save\n track_activity @event\n format.html { redirect_to :back, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n after_event_created_mail @event\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @myevent = Myevent.new(params[:myevent])\n\n respond_to do |format|\n if @myevent.save\n format.html { redirect_to @myevent, notice: 'Myevent was successfully created.' }\n format.json { render json: @myevent, status: :created, location: @myevent }\n else\n format.html { render action: \"new\" }\n format.json { render json: @myevent.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.7714071", "0.7611226", "0.76028967", "0.7541319", "0.7444731", "0.73206913", "0.73138195", "0.728203", "0.7251226", "0.7235907", "0.7235907", "0.7215051", "0.71682763", "0.7150409", "0.7126664", "0.7118896", "0.7117831", "0.71162695", "0.70964044", "0.70907074", "0.7083036", "0.7081109", "0.7080767", "0.7071589", "0.7057984", "0.70422375", "0.7016941", "0.70167124", "0.70091015", "0.70081246", "0.6989661", "0.6987218", "0.6970633", "0.6970633", "0.6966775", "0.6948742", "0.6948119", "0.6948119", "0.6948119", "0.6948119", "0.6948119", "0.6948119", "0.6948119", "0.6948119", "0.6948119", "0.6948119", "0.6948119", "0.6948119", "0.6948119", "0.6948119", "0.6948119", "0.6948119", "0.6948119", "0.6948119", "0.6948119", "0.6948119", "0.6948119", "0.6948119", "0.6948119", "0.6948119", "0.6948119", "0.6948119", "0.6948119", "0.6942416", "0.6936477", "0.69359535", "0.69359535", "0.69318086", "0.69268054", "0.6907236", "0.6905569", "0.69051725", "0.6904514", "0.6902843", "0.69011873", "0.6899826", "0.68961006", "0.68811166", "0.68746495", "0.68642014", "0.68642014", "0.6843213", "0.68419445", "0.6836244", "0.68352246", "0.6820027", "0.68000513", "0.6791519" ]
0.7018503
37
PUT /events/1 PUT /events/1.json
def update @event = Event.find(params[:id]) if @event.update_attributes(params[:event]) redirect_to @event, :notice => "Termin erfolgreich gespeichert." else render :action => 'edit' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n if @event.update(event_params)\n render json: @event, status: 201\n else\n render json: { message: \"Error. Error. Please try again.\"}, status: 400\n end\n end", "def put_events(args)\n\tapi_url = \"#{@base_url}/#{args[:collection]}/#{args[:key]}/events/#{args[:event_type]}\"\n\tputs do_the_put_call( url: api_url, user: @user, json: args[:json] )\nend", "def update\n if @event.update(event_params(params))\n render json: @event, status: 200\n else\n render :json => @event.errors, :status => 422\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.json { head :no_content }\n else\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @event.update(event_params)\n render json: { location: format_event(@event) }\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.json { render json: @event }\n else\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\tif @event.update(event_params)\n head :no_content\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.json { render :show, status: :ok, location: @event }\n else\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.json { render :show, status: :ok, location: @event }\n else\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n if @event.update(params[:event])\n head :no_content\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def update\n @event = Event.find(params[:id])\n\n if @event.update(event_params)\n head :no_content\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def update\n @event = Event.find(params[:id])\n\n if @event.update(event_params)\n head :no_content\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def update\n @event = Event.using(:shard_one).find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, :notice => 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @event.errors, :status => :unprocessable_entity }\n end\n end\n\n\n\n end", "def update\n # @event = Event.find(params[:id])\n\n if @event.update(event_params)\n head :no_content\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def update\r\n @event.update(event_params)\r\n end", "def update\n if @event.update(event_params)\n render :show, status: :ok, location: @event\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def update\n if @event.update(event_params)\n render :show, status: :ok, location: @event\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def update\n @event.update(event_params)\n end", "def update\n @event.update(event_params) \n end", "def update\n \n \n @event = Event.find(params[:id])\n\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: t(:event_updated) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n \n end\n end", "def update\n if @event.update(event_params)\n \tdata = { data: @event, status: :ok, message: \"Event was successfully updated.\" }\n render :json => data\n else\n \tdata = { data: @event.errors, status: :unprocessable_entity }\n render :json => data\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @event.update(event_params)\n\n format.html { redirect_to @event }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n return forbidden unless user_is_owner\n return bad_request unless @event.update_attributes(event_params)\n render json: @event, status: :ok\n end", "def update\n @event = Event.find(params[:id])\n if @event.update(event_params)\n render :show, status: :ok, location: @event\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end", "def update\n event_id = params[:id]\n if event_id.present? && params[:event].present? && @user.uuid.present? && @user.uuid != \"guest\"\n event_params = params[:event]\n @event = Com::Nbos::Events::Event.where(id: params[:id], user_id: @user.id ).first\n if @event.present?\n @event.update(event_params.permit!)\n if @event.save\n render :json => @event\n else\n data = add_error_messages(@event)\n render :json => data\n end\n else\n render :json => {\"messageCode\": \"module.user.unauthorized\", \"message\": \"Unauthorized to update others Event\"}, status: 404\n end\n else\n render :json => {messageCode: \"bad.request\", message: \"Bad Request\"}, status: 400\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, flash: {success: 'Event was successfully created.'} }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n @event.save!\n end\n end", "def patch_event\n user_id = params[\"user_id\"]\n group_id = params[\"group_id\"]\n event_id = params[\"event_id\"]\n\n #TODO Handle 404 if event not found\n event = Event.find(event_id)\n\n json_body = JSON.parse(request.body.read)\n\n @@event_service.patch_event(json_body, user_id, group_id, event_id)\n\n render status: :ok, text: \"\"\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { redirect_to @event }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event_event = Event::Event.find(params[:id])\n\n respond_to do |format|\n if @event_event.update_attributes(params[:event_event])\n format.html { redirect_to @event_event, notice: 'Event was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event_event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, :notice => 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @event.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, :notice => 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @event.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, :notice => 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @event.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n\n\n\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to '/', notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event = Event.find(params[:id])\n\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.75664943", "0.74722904", "0.7472032", "0.7430477", "0.7370732", "0.7366599", "0.7356629", "0.73164594", "0.73164594", "0.73085743", "0.72540325", "0.72540325", "0.72351176", "0.7175737", "0.71719027", "0.7161037", "0.7161037", "0.7160709", "0.71240234", "0.71132576", "0.709661", "0.7095998", "0.70714176", "0.7070656", "0.7051321", "0.7046919", "0.7038694", "0.7027827", "0.70224917", "0.69991666", "0.69683176", "0.6959444", "0.6959444", "0.6959444", "0.6958065", "0.694111", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.69383377", "0.6936375" ]
0.0
-1
DELETE /events/1 DELETE /events/1.json
def destroy @event = Event.find(params[:id]) @event.destroy respond_to do |format| format.html { redirect_to events_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @event = Event.using(:shard_one).find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def delete_event\n if params[:id]\n @e = Evento.find(params[:id]).destroy\n end\n render :json => msj = { :status => true, :message => 'ok'}\n end", "def destroy\n @event = Event.find(params[:id])\n \n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n #@event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n # @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @events = Event.where(event_id: params[:id])\n @events.each.destroy\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n\n end", "def destroy\n @event_event = Event::Event.find(params[:id])\n @event_event.destroy\n\n respond_to do |format|\n format.html { redirect_to event_events_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url}\n format.json { head :no_content }\n end\n end", "def destroy\n @myevent = Myevent.find(params[:id])\n @myevent.destroy\n\n respond_to do |format|\n format.html { redirect_to myevents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n\n sync_destroy @event\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html {redirect_to events_url}\n format.json {head :no_content}\n end\n end", "def destroy\n @calevent = Calevent.find(params[:id])\n @calevent.destroy\n\n respond_to do |format|\n format.html { redirect_to calevents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n #@event.update_attribute(:deleted, true)\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n render :nothing => true, :status => 200, :content_type => 'text/plain'\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url, notice: t(:event_deleted) }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_events_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n\n head :no_content\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to root_url, notice: 'Event was successfully removed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url, notice: 'データが削除されました。' }\n format.json { head :no_content }\n end\n end", "def delete_event\r\n event = Event.find_by(id: params[:eventid].to_i)\r\n if event.present?\r\n event.update(status: 3)\r\n lt_update_event_status event, 'archived'\r\n render json: SuccessResponse.new(\r\n code: 200,\r\n message: 'Event Deleted.'\r\n ), adapter: :json, status: :ok\r\n else\r\n render json: ErrorResponse.new(\r\n code: 404,\r\n message: 'Event not found!'\r\n ), adapter: :json, status: :not_found\r\n end\r\n\r\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url, notice: 'Event was successfully removed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url, notice: 'Event was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url, notice: 'Event was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @client = Client.find(@event.client_id)\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_to_client_path(@client) }\n format.json { head :no_content }\n end\n end", "def destroy\n @event_request = EventRequest.find(params[:id])\n @event_request.destroy\n\n respond_to do |format|\n format.html { redirect_to event_requests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url, notice: 'Мероприятие успешно удалено.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = current_user.events.find_by_url(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @post_event.destroy\n respond_to do |format|\n format.html { redirect_to post_events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @event = @current_account.events.find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @evento = Evento.find(params[:id])\n @evento.destroy\n\n respond_to do |format|\n format.html { redirect_to eventos_url }\n format.json { head :ok }\n end\n end", "def destroy\n @event = Event.find(params[:id])\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url, notice: 'Event was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @eventtype.events.each do |e|\n e.destroy\n end\n @eventtype.destroy\n respond_to do |format|\n format.html { redirect_to eventtypes_url }\n format.json { head :no_content }\n end\n end", "def destroy \n @event.destroy \n respond_to do |format|\n format.html { redirect_to events_url, success: 'Event was successfully removed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.destroy\n respond_to do |format|\n format.html { redirect_to events_url }\n format.mobile { redirect_to events_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @create_event = CreateEvent.find(params[:id])\n @create_event.destroy\n\n respond_to do |format|\n format.html { redirect_to create_events_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.769268", "0.76872975", "0.76872975", "0.76872975", "0.7680665", "0.7585337", "0.75682765", "0.7560537", "0.75407815", "0.7540473", "0.7540473", "0.7540473", "0.7540473", "0.7540473", "0.7540473", "0.7540473", "0.7540473", "0.7540473", "0.7540473", "0.7540473", "0.7539941", "0.75382024", "0.7537234", "0.7526631", "0.75194746", "0.75194746", "0.75194746", "0.75194746", "0.75194746", "0.75194746", "0.75194746", "0.75194746", "0.75194746", "0.75194746", "0.75194746", "0.75194746", "0.75194746", "0.75194746", "0.75194746", "0.75194746", "0.75194746", "0.74953985", "0.74650526", "0.7459677", "0.7453618", "0.7446788", "0.74399537", "0.7439926", "0.7434689", "0.7432393", "0.7401567", "0.73877174", "0.73772806", "0.7371874", "0.7365335", "0.7337954", "0.733497", "0.733497", "0.7322736", "0.73000205", "0.7296434", "0.72906893", "0.7289899", "0.7289422", "0.728712", "0.7284745", "0.7283742", "0.72820485", "0.72724354", "0.72697437" ]
0.75145763
67
Produce una matrice di rotazione premoltiplicativa attorno all'asse x
def get_x_rotation_matrix(alpha) Matrix[ [1.0, 0.0, 0.0, 0.0], [0.0, Math.cos(alpha), -Math.sin(alpha), 0.0], [0.0, Math.sin(alpha), Math.cos(alpha), 0.0], [0.0, 0.0, 0.0, 1.0]] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def matrix_row\n return [ self.run, self.rise * -1, (p1.y * self.run - self.rise*p1.x)]\n end", "def matricula\n end", "def matrix\n end", "def x(escalar)\n maux=Array.new(@nFil) { Array.new(@mCol) }\n \n (@nFil).times do |i|\n (@mCol).times do |j|\n maux[i][j] = @matriz[i][j]\n end\n end\n \n aux = Matriz.new(maux)\n for i in 0...@nFil do\n for j in 0...@mCol do\n aux.matriz[i][j] = @matriz[i][j] * escalar\n end\n end\n aux\n end", "def x\n @x ||= X.new( c*r, a, (-1*c*(b - c*n)), (r*r*a - (b - c*n)*(b - c*n)) )\n end", "def x\n @x ||= X.new( c*r, a, (-1*c*(b - c*n)), (r*r*a - (b - c*n)*(b - c*n)) )\n end", "def x(escalar)\n aux = MatrizDensa.new(@matriz)\n for i in 0...@nFil do\n for j in 0...@mCol do\n aux.matriz[i][j] = @matriz[i][j] * escalar\n end\n end\n aux\n end", "def matz; end", "def generate_matrix\n [].tap { |a| 25.times { a << 'X' } }.each_slice(5).to_a\n end", "def trasponer\n\t\telemento = Array.new(0)\n\t\tfor i in 0...colum do\n\t\t\tfila = Array.new(0)\n\t\t\tfor j in 0...filas do\n\t\t\t\tfila << pos[j][i]\n\t\t\tend\n\t\t\telemento << fila\n\t\tend\n\t\tMatriz.new(@ncol, @nfil, elemento)\n\tend", "def trasponer\n\t\t\telemento = Array.new(0)\n\t\t\tfor i in 0...colum\n\t\t\t\tfila = Array.new(0)\n\t\t\t\tfor j in 0...filas\n\t\t\t\t\tfila << pos[j][i]\n\t\t\t\tend\n\t\t\t\telemento << fila\n\t\t\tend\n\t\t\tMatriz.new(@ncol, @nfil, elemento)\n\t\tend", "def make_comatrix(arrs)\n init_member(arrs[0].count)\n update_mean_and_r(arrs)\n end", "def *(mat)\n if (@mCol == mat.nFil)\n result = Array.new\n (@nFil).times do |i|\n result[i] = Array.new\n (mat.mCol).times do |j|\n\t if(@matriz[i][j].class==Fraccion)\n result[i][j] = Fraccion.new(0,1)\n\t else\n\t result[i][j] = 0\n\t end\n end\n end\n\n aux = Matriz.new(result)\n\n (@nFil).times do |i|\n (mat.mCol).times do |j|\n (@mCol).times do |z|\n aux.matriz[i][j] += @matriz[i][z] * mat.matriz[z][j]\n end\n end\n end\n else\n aux = 0\n end\n aux\n end", "def porf(other)\n\t\t\tif ((@nfil != other.ncol) || (@ncol != other.nfil))\n\t\t\t\tputs \"No se pueden multiplicarr las matrices\"\n\t\t\telse\n\t\t\t\telemento = Array.new(0)\n\t\t\t\tfor i in 0...nfil\n\t\t\t\t\tfila = Array.new(0)\n\t\t\t\t\tfor j in 0...other.ncol\n\t\t\t\t\t\taux = Fraccion.new(1,1)\n\t\t\t\t\t\taux = aux - aux\n\t\t\t\t\t\tfor k in 0...ncol\n\t\t\t\t\t\t\taux += pos[i][k] * other.pos[k][j]\n\t\t\t\t\t\tend\n\t\t\t\t\t\tfila << aux\n\t\t\t\t\tend\n\t\t\t\t\telemento << fila\n\t\t\t\tend\n\t\t\tend\n\t\t\tMatriz.new(@nfil, other.ncol, elemento)\n\t\tend", "def residuals\n result = []\n @domain.zip(@image) do |x, y|\n result << y - (@a * x + @b)\n end\n result\n end", "def *(mat)\n if (@mCol == mat.nFil)\n result = Array.new\n for i in 0...@nFil do\n result[i] = Array.new\n for j in 0...mat.mCol do\n if (mat.matriz[0][0].class == Fraccion)\n result[i][j] = Fraccion.new(0, 1)\n else\n result[i][j] = 0\n end\n end\n end\n\n aux = MatrizDensa.new(result)\n\n for i in 0...@nFil do\n for j in 0...mat.mCol do\n for z in 0...@mCol do\n aux.matriz[i][j] += @matriz[i][z] * mat.matriz[z][j]\n end\n end\n end\n else\n aux = 0\n end\n aux\n end", "def r2\n @n_predictors.times.inject(0) {|ac,i| ac+@coeffs_stan[i]* @matrix_y[i,0]} \n end", "def features_simple_real_modular(A=matrix)\n \n\nend", "def test_c()\n mx = Itk::Maxima.new() ;\n x = [[1.0,2,3,4],[4,1,2,3],[3,1,4,2],[1,2,1,3]] ;\n pp x ;\n# pp mx.eigenvalues(x) ;\n pp mx.trace(x) ;\n end", "def por(other)\n\t\t\tif ((@nfil != other.ncol) || (@ncol != other.nfil))\n\t\t\t\tputs \"No se pueden multiplicarr las matrices\"\n\t\t\telse\n\t\t\t\telemento = Array.new(0)\n\t\t\t\tfor i in 0...nfil\n\t\t\t\t\tfila = Array.new(0)\n\t\t\t\t\tfor j in 0...other.ncol\n\t\t\t\t\t\taux = 0\n\t\t\t\t\t\tfor k in 0...ncol\n\t\t\t\t\t\t\taux += pos[i][k] * other.pos[k][j]\n\t\t\t\t\t\tend\n\t\t\t\t\t\tfila << aux\n\t\t\t\t\tend\n\t\t\t\t\telemento << fila\n\t\t\t\tend\n\t\t\tend\n\t\t\tMatriz.new(@nfil, other.ncol, elemento)\n\t\tend", "def victoire\n \n [[@a1, @a2, @a3],\n [@a1, @b2, @c3],\n [@a1, @b1, @c1],\n [@b1, @b2, @b3],\n [@c1, @c2, @c3],\n [@c1, @b2, @a3],\n [@a2, @b2, @c2],\n [@a3, @b3, @c3]]\n end", "def exercise_1113 (matrix)\n end", "def adx(x)\n x * MINIMAP_RATIO + P_X\n end", "def redesign\n x = @mat[0].length\n y = @mat.size\n (1..y-2).each do |i|\n (1..x-2).each do |j|\n @mat[i][j] = \"0\"\n end\n end\n\n divide(1,x-2,1,y-2)\n end", "def relative_transform_matrix(bone)\n return channel_data_for(bone).relative_transform_matrix\n end", "def cramers_rule(ax,ay,az,a)\n # ax = array for all coefficients of x\n # ay = array for all coefficients of y\n # az = array for all coefficients of z\n # a = array for all constants\n x = Matrix[a,ay,az].determinant/Matrix[ax,ay,az].determinant.to_f\n y = Matrix[ax,a,az].determinant/Matrix[ax,ay,az].determinant.to_f\n z = Matrix[ax,ay,a].determinant/Matrix[ax,ay,az].determinant.to_f\n p x\n p y \n p z\n end", "def get_transformation(circ)\n p1 = get_triple\n p2 = circ.get_triple.reverse\n\n m1 = Matrix.cross_ratio(p1)\n m2 = Matrix.cross_ratio(p2).proj_inv\n\n m2 * m1\n end", "def createMatrix()\n #matriks = Matrix.new\n @matriks_data = Matrix.zero(@jumlah_node)\n for i in 0..@jumlah_node-1\n for j in 0..@jumlah_node-1\n @matriks_data[i,j] = @file_data[i*@jumlah_node+ j]\n end\n end\n end", "def generate_submatrices\n @hilbert_basis.find.to_a.combination(VERTICES).collect{ \n |x|Matrix.rows(x)}\n end", "def * (other)\n i=0\n m_aux = Array.new(@fila) {Array.new(other.columna,0)}\n while i < @fila\n j = 0\n while j < other.columna\n m_aux[i][j] = 0\n k = 0\n while k < @columna\n m_aux[i][j] += matriz[i][k] * other.matriz[k][j]\n k += 1\n end\n j +=1\n end\n i +=1\n end\n Matriz.new(m_aux)\n end", "def adx(n)\n ; n * MAP_RATIO + M_X;\n end", "def normal_matrices\n MSPhysics::Newton::CurvySlider.get_normal_matrices(@address)\n end", "def to_immut_matrix()\n return Matrix.rows self\n end", "def matrix\n (follow_object ? follow_object.matrix.inverse : Matrix.identity(4)) * rotation.matrix + rotation.translate(0,0,-@zoom)\n end", "def rotate_x(\n theta # float\n) # mat3\n deg = degrees(theta).floor % 360\n if $rotation_memo[\"x#{deg}\"]\n return $rotation_memo[\"x#{deg}\"]\n end\n c = Math.cos(theta) # float\n s = Math.sin(theta) # float\n matrix = Mat3.new(\n Vec3.new(1, 0, 0),\n Vec3.new(0, c, -s),\n Vec3.new(0, s, c)\n );\n $rotation_memo[\"x#{deg}\"] = matrix\n matrix\nend", "def matriz_mensaje\n @m_mensaje=Array.new(4){Array.new(4,'')}\n i,j,contador=0,0,0\n @m.each do |x|\n if(contador==4)\n contador=0\n i=0\n j+=1\n end\n @m_mensaje[i][j] = x\n #p a[i][j]\n i+=1\n contador+=1\n end\n @m_mensaje\n\n end", "def x\n self.rock_x * $GRID_SIZE\n end", "def transform(x)\n x = ::Rumale::Validation.check_convert_sample_array(x)\n\n z = kernel_mat(x, @components)\n z.dot(@normalizer)\n end", "def -(mat)\n if (mat.nFil == @nFil && mat.mCol == @mCol)\n \n maux=Array.new(@nFil) { Array.new(@mCol) }\n \n (@nFil).times do |i|\n (@mCol).times do |j|\n maux[i][j] = @matriz[i][j]\n end\n end\n \n aux = Matriz.new(maux)\n (@nFil).times do |i|\n (@mCol).times do |j|\n aux.matriz[i][j] = @matriz[i][j] - mat.matriz[i][j]\n end\n end\n else\n aux = 0\n end\n aux\n end", "def output\r\n @orthonormalized_matrix.map{|vector| vector.to_a } \r\n end", "def mrg; xparam(8); end", "def make_matrixarray\n\t\tmatrix = []\n\t\[email protected] do |this_speaker|\n\t\t\tmatrix << row(this_speaker)\n\t\tend\n\t\t#return matrix array\n\t\treturn matrix\n\tend", "def lax_friedrichs\n @u[0] = @mx.times.map { |j| self.ic(@x[j]) } # IC: u(x,0)\n alpha = @a*@dt/@dx\n 0.upto(@mt-2) do |n|\n @u[n+1] = (1.upto(@mx-3)).to_a\n @u[n+1].map! { |j| 0.5*(@u[n][j+1]+u[n][j-1])-0.5*alpha*(@u[n][j+1]-@u[n][j-1]) }\n @u[n+1].unshift 0.5*(@u[n][1]+u[n][@mx-2])-0.5*alpha*(@u[n][1]-@u[n][@mx-2]) # u(0,t)\n @u[n+1].push 0.5*(@u[n][0]+u[n][@mx-3])-0.5*alpha*(@u[n][0]-@u[n][@mx-3]) # u(max(x), t)\n @u[n+1].push @u[n+1][0] # periodic BC\n end\n end", "def nrm2 incx=1, n=nil\n self.twoDMat.getFrobeniusNorm()\n end", "def +(mat)\n if (mat.f == @f && mat.c == @c)\n resultado = Array.new\n for i in 0...@f do\n resultado[i] = Array.new\n for j in 0...@c do\n# \t if((!@matriz[i].nil?) && (!@matriz[i][j].nil?) && (!mat.matriz[i].nil?) && (!mat.matriz[i][j].nil?) && ((@matriz[i][j].class = Fraccion) || (mat.matriz[i][j] == Fraccion)))\n# \t resultado[i][j] = Fraccion.new(0,1)\n# \t else\n\t resultado[i][j] = 0 \n# \t end\n end\n end\n aux = Densa.new(resultado)\n nElementos = 0\n for i in 0...@f do\n for j in 0...@c do\n\t if ((!@matriz[i].nil?) && (!@matriz[i][j].nil?) && (!mat.matriz[i].nil?) && (!mat.matriz[i][j].nil?))\n aux.matriz[i][j] = @matriz[i][j] + mat.matriz[i][j]\n nElementos += 1\n\t elsif ((!@matriz[i].nil?) && (!@matriz[i][j].nil?) && ((!mat.matriz[i].nil?) || (!mat.matriz[i].nil? && !mat.matriz[i][j].nil?)))\n\t aux.matriz[i][j] = @matriz[i][j]\n nElementos += 1\n\t elsif ((!mat.matriz[i].nil?) && (!mat.matriz[i][j].nil?) && ((!@matriz[i].nil?) || (!@matriz[i].nil? && !@matriz[i][j].nil?)))\n\t aux.matriz[i][j] = mat.matriz[i][j]\n nElementos += 1\n\t end\n end\n end\n if ((@f * @c) * 0.4 > nElementos)\n aux = to_dispersa(aux)\n end\n else\n aux = \"No se pueden sumar\"\n end\n aux\n end", "def residency_diploma\n\tend", "def transform(x)\n x = ::Rumale::Validation.check_convert_sample_array(x)\n\n x.dot(@components.transpose)\n end", "def to_dispersa(mat)\n resultado = {}\n for i in 0...mat.f do\n for j in 0...mat.c do\n if (mat.matriz[i][j] != 0)\n if (resultado[i].nil?)\n resultado[i] = {}\n end\n resultado[i][j] = mat.matriz[i][j]\n end\n end \n end\n aux = Dispersa.new(mat.f, mat.c, resultado)\n end", "def lax_wendroff\n @u[0] = @mx.times.map { |j| self.ic(@x[j]) } # IC: u(x,0)\n alpha = @a*@dt/@dx\n 0.upto(@mt-2) do |n|\n @u[n+1] = (1.upto(@mx-3)).to_a\n @u[n+1].map! { |j| @u[n][j]-0.5*alpha*(@u[n][j+1]-@u[n][j-1])+0.5*(alpha**2)*(u[n][j+1]-2*u[n][j]+u[n][j-1]) }\n @u[n+1].unshift @u[n][0]-0.5*alpha*(@u[n][1]-@u[n][@mx-2])+0.5*(alpha**2)*(u[n][1]-2*u[n][0]+u[n][@mx-2]) # u(0,t)\n @u[n+1].push @u[n][@mx-2]-0.5*alpha*(@u[n][0]-@u[n][@mx-3])+0.5*(alpha**2)*(u[n][0]-2*u[n][@mx-2]+u[n][@mx-3]) # u(max(x), t)\n @u[n+1].push @u[n+1][0] # periodic BC\n end\n end", "def similarity_matrix\n multiply_self(normalize)\n end", "def residues\n @rs\n end", "def create_matrix\n (0...@height).to_a.map {|element| [0]*@width}\n end", "def -(other)\r\n\t\t\r\n\t\t#if ((other.class.to_s == \"Dispersa\") && (other.fil == @fil) && (other.col == @col))\r\n\t\t\t\r\n\t\t\tmatrizResta = Array.new(@fil) {Array.new(@col) {0}}\r\n\t\t\t\r\n\t\t\ti = 0\r\n\t\t\t\r\n\t\t\t(other.numElementos - 1).times {\r\n\t\t\t\t\r\n\t\t\t\tmatrizResta[other.filM[i]][other.colM[i]] = 0 - other.eleM[i]\r\n\t\t\t\t\r\n\t\t\t\ti += 1\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t\r\n\t\t\ti = 0\r\n\t\t\t\r\n\t\t\t(@numElementos - 1).times {\r\n\t\t\t\t\r\n\t\t\t\tmatrizResta[@filM[i]][@colM[i]] += @eleM[i] \r\n\t\t\t\t\r\n\t\t\t\ti += 1\r\n\t\t\t}\r\n\t\t\t\t\r\n\t\t\t#puts \"resta = #{matrizResta}\"\r\n\t\t\treturn matrizResta\r\n\t\t\t\r\n\t\t#else\r\n\t\t\t#raise ArgumentError, \"Matrices de distinto tamanio\"\r\n\t\t#end\r\n\tend", "def *(other)\r\n\r\n\t\t#if ((other.class.to_s == \"Dispersa\") && (other.fil == @fil) && (other.col == @col))\r\n\t\t\t\r\n\t\t\tmatrizProd = Array.new(@fil) {Array.new(@col) {0}}\t\t\t\r\n\r\n\t\t\t0.upto(other.numElementos - 1) do |i|\r\n\r\n\t\t\t\tif (other.filM[i] = @colM[i])\r\n\t\t\t\t\tmatrizProd[@filM[i]][@colM[i]] += @eleM[i] * other.eleM[i]\r\n\t\t\t\tend\r\n\r\n\t\t\tend\t\t\t\r\n\t\t\t\r\n\t\t\t#puts \"prod = #{matrizProd}\"\r\n\t\t\treturn matrizProd\r\n\t\t\t\r\n\t\t#else\r\n\t\t\t#raise ArgumentError, \"Matrices de distinto tamanio\"\r\n\t\t#end\r\n\t\t\r\n\tend", "def *(mat)\n if (@c == mat.f)\n result = Array.new\n for i in 0...@f do\n result[i] = Array.new\n for j in 0...@c do\n result[i][j] = 0\n end\n end\n aux = Densa.new(result)\n nElementos = 0\n for i in 0...@f do\n for j in 0...mat.c do\n for z in 0...@c do\n if ((!@matriz[i].nil?) && (!@matriz[i][z].nil?) && (!mat.matriz[z].nil?) && (!mat.matriz[z][j].nil?))\n aux.matriz[i][j] += @matriz[i][z] * mat.matriz[z][j]\n nElementos += 1\n end\n end\n end\n end\n if ((@f * @c) * 0.4 > nElementos)\n aux = to_dispersa(aux)\n end\n else\n aux = \"No se pueden multiplicar\"\n end\n aux\n end", "def fleiss(matrix)\n debug = true\n\n # n Number of rating per subjects (number of human raters)\n n = checkEachLineCount(matrix) # PRE : every line count must be equal to n\n i_N = matrix.size\n k = matrix[0].size\n\n if debug\n puts \"#{n} raters.\"\n puts \"#{i_N} subjects.\"\n puts \"#{k} categories.\"\n end\n\n # Computing p[]\n p = [0.0] * k\n (0...k).each do |j|\n p[j] = 0.0\n (0...i_N).each {|i| p[j] += matrix[i][j] } \n p[j] /= i_N*n \n end\n\n puts \"p = #{p.join(',')}\" if debug\n\n # Computing f_P[] \n f_P = [0.0] * i_N\n\n (0...i_N).each do |i|\n f_P[i] = 0.0\n (0...k).each {|j| f_P[i] += matrix[i][j] * matrix[i][j] } \n f_P[i] = (f_P[i] - n) / (n * (n - 1)) \n end \n\n puts \"f_P = #{f_P.join(',')}\" if debug\n\n # Computing Pbar\n f_Pbar = sum(f_P) / i_N\n puts \"f_Pbar = #{f_Pbar}\" if debug\n\n # Computing f_PbarE\n f_PbarE = p.inject(0.0) { |acc,el| acc + el**2 }\n\n puts \"f_PbarE = #{f_PbarE}\" if debug \n\n kappa = (f_Pbar - f_PbarE) / (1 - f_PbarE)\n puts \"kappa = #{kappa}\" if debug \n\n kappa \nend", "def *(other)\n m = Array.new(@nfil){Array.new(@ncol){0}}\n for i in 0...nfil do\n for j in 0...other.ncol do \n for k in 0...ncol do\n m[i][j] = m[i][j] + self.mat[i][k] * other.mat[k][j]\n end\n end\n end\n return Matriz.new(self.nfil,other.ncol,m) \n end", "def calculate\n max_row_index, max_column_index = setup\n\n bordered_image.noise[0..max_row_index].each_with_index do |row, row_index|\n row[0..max_column_index].each_with_index do |_, index|\n row_range, column_range = calculate_window_range(row_index, index, invader)\n radar_window = bordered_image.noise_range(row_range, column_range)\n similarity = window_similarity(invader, radar_window)\n update_similarity(matrix, similarity, row_range, column_range) if similarity\n end\n end\n\n matrix\n end", "def row(r)\n return matrix[r].map{|e| e.dup}\n end", "def render_matrix\n Matrix.rows render_rows\n end", "def rra\n end", "def *(other)\n\t\telemento = Array.new(0)\n\t\tfor i in 0...filas do\n\t\t\tfila = Array.new(0)\n\t\t\tfor j in 0...colum do\n\t\t\t\tfila << pos[i][j]*other\n\t\t\tend\n\t\t\telemento << fila\n\t\tend\n\t\tMatriz.new(@nfil, @ncol, elemento)\n\tend", "def imc \n\t\t@peso/(@talla*@talla)\n\tend", "def test_b()\n mx = Itk::Maxima.new() ;\n x = [[1.0,2,3,4],[4,1,2,3],[3,1,4,2],[1,2,1,3]] ;\n pp x ;\n pp mx.determinant(x) ;\n pp mx.invert(x) ;\n end", "def initialize_matrix!\n @matrix = config.map do |_hand, minimum_position|\n minimum_position\n end.each_slice(13).to_a\n end", "def PrimeraRonda(matriz,numAleatorios)\t\r\n\t\tfor x1 in 0..numAleatorios\r\n\t\t\t\t@tablero[Random.rand(fila-1)][Random.rand(col-1)]= true\r\n\t\tend\r\n\tend", "def *(other)\n\t\t\telemento = Array.new(0)\n\t\t\tfor i in 0...filas\n\t\t\t\tfila = Array.new(0)\n\t\t\t\tfor j in 0...colum\n\t\t\t\t\tfila << pos[i][j]*other\n\t\t\t\tend\n\t\t\t\telemento << fila\n\t\t\tend\n\t\t\tMatriz.new(@nfil, @ncol, elemento)\n\t\tend", "def createMatrix\n jsonArray = Array.new(@matrixRow)\n #Tenim un array vertical de n files, en cada casella es crea un altre\n #vector horitzontal amb tantes posicions com \"tags\" té aquest tipus de taula\n\t\tfor i in 0..@matrixRow-1\n\t\t\tjsonArrayColumns = Array.new(@matrixColumn)\n\t\t\tfor j in 0..@matrixColumn-1\n if i==0 #Quan es la primera fila s'afegeixen els tags a la matriu\n jsonArrayColumns[j] = @firstRow[j]\n else\n\t\t\t\t jsonArrayColumns[j] = @jsonObject[i-1][@firstRow[j]]\n end\n\t\t\tend\n\t\t\tjsonArray[i] = jsonArrayColumns\n\t\tend\n return jsonArray\n end", "def +(mat)\n if (mat.nFil == @nFil && mat.mCol == @mCol)\n maux=Array.new(@nFil) { Array.new(@mCol) }\n \n (@nFil).times do |i|\n (@mCol).times do |j|\n maux[i][j] = @matriz[i][j]\n end\n end\n \n aux = Matriz.new(maux)\n (@nFil).times do |i|\n (@mCol).times do |j|\n aux.matriz[i][j] = @matriz[i][j] + mat.matriz[i][j]\n end\n end\n else\n aux = 0\n end\n aux\n end", "def mat_frm\n @matr_format[[@calc_type]]\n end", "def source_matrices\n a = []\n experiments.each { |experiment| a.concat(experiment.source_matrices) }\n a.active_record_uniq\n end", "def to_f\n\n flotante = Array.new(matriz.size - 1)\n for i in 0...matriz.size\n flotante[i] = Array.new(matriz[i].size - 1)\n for j in 0...matriz[i].size\n flotante[i][j] = (matriz[i][j]).to_f\n end\n end\n MatrizDensa.new(flotante)\n\n\tend", "def *(other)\r\n\t\t\r\n\t\t#if ((other.class.to_s == \"Densa\") && (@fil == @col) && (other.fil == other.col) && (@fil == other.fil))\r\n\t\t\t\r\n\t\t\tmatrizMult = Array.new(@fil) {Array.new(@col)}\r\n\t\t\t\r\n\t\t\ti = 0\r\n\t\t\t(0..(@fil - 1)).collect {\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t0.upto(@col - 1) do |j|\r\n\t\t\t\t\t\r\n\t\t\t\t\tmatrizMult[i][j] = 0\t\t\r\n\t\t\t\t\t\r\n\t\t\t\t\tk = 0\t\t\t\t\t\r\n\t\t\t\t\t(@col - 1).times {\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tmatrizMult[i][j] = matrizMult[i][j] + (@matrix[i][k] * other.matrix[k][j])\r\n\t\t\t\t\t\tk += 1\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\tend\r\n\t\t\t\ti += 1\t\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t#puts \"#{matrizMult}\"\r\n\t\t\treturn matrizMult\r\n\t\t\t\r\n\t\t#else\r\n\t\t\t#raise ArgumentError, \"Numero distinto de filas y columnas\"\r\n\t\t#end\r\n\t\t\r\n\tend", "def reflection\n i = self.copy\n n = self.normalized\n r = ( 2 * ((i*(-1.0)).dot(n)) * (n) ) + ( n )\n r = Vector.new(r.a)\n end", "def index\n @partos = @matriz.partos\n end", "def to_s\n matString = \"\"\n for i in 0...@nFil do\n for j in 0...@mCol do\n matString = matString + @matriz[i][j].to_s + \" \"\n end\n matString = matString + \"\\n\"\n end\n matString\n end", "def minima\n return Features.minima(@data)\n end", "def generate_experiment_matrix(chromosome_x, chromosome_y)\n experiment_matrix = []\n (0...@taguchi_array.size).each do |i|\n row_chromosome = Chromosome.new\n (0...@taguchi_array[0].size).each do |j|\n row_chromosome <<\n if @taguchi_array[i][j].zero?\n chromosome_x[j]\n else\n chromosome_y[j]\n end\n end\n experiment_matrix << row_chromosome\n end\n experiment_matrix\n end", "def latex_matrix\n if @type == \"controlled\"\n @matrix.map { |value, matrix| [value, latex_matrix_for(matrix)] }\n else\n latex_matrix_for @matrix\n end\n end", "def rectangular\n [re, im]\n end", "def normal_matrix_at_point(point)\n MSPhysics::Newton::CurvySlider.get_normal_martix_at_point(@address, point)\n end", "def gen_data(parameters, x)\n mu = parameters[:mu]\n sig2 = parameters[:sig2]\n gamma = parameters[:gamma]\n size_i = x.shape[0]\n size_n = x.shape[1]\n\n sim_data_out = N.zeros_like(x)\n\n size_i.times do |i|\n size_n.times do |n|\n next if MLRatioSolve.skip_indices.include?([i,n])\n sim_data_out[i,n] = randnorm(mu[i]/gamma[n], sig2[i]/gamma[n]**2)\n end\n end\n\n sim_data_out\n end", "def -(mat)\n if (mat.f == @f && mat.c == @c)\n result = Array.new\n for i in 0...@f do\n result[i] = Array.new\n for j in 0...@c do\n result[i][j] = 0\n end\n end\n aux = Densa.new(result)\n nElementos = 0\n for i in 0...@f do\n for j in 0...@c do\n if ((!@matriz[i].nil?) && (!@matriz[i][j].nil?) && (!mat.matriz[i].nil?) && (!mat.matriz[i][j].nil?))\n aux.matriz[i][j] = @matriz[i][j] - mat.matriz[i][j]\n nElementos += 1\n elsif ((!@matriz[i].nil?) && (!@matriz[i][j].nil?) && ((!mat.matriz[i].nil?) || (!mat.matriz[i].nil? && !mat.matriz[i][j].nil?)))\n aux.matriz[i][j] = @matriz[i][j]\n nElementos += 1\n elsif ((!mat.matriz[i].nil?) && (!mat.matriz[i][j].nil?) && ((!@matriz[i].nil?) || (!@matriz[i].nil? && !@matriz[i][j].nil?)))\n aux.matriz[i][j] = - mat.matriz[i][j]\n nElementos += 1\n end\n end\n end\n if ((@f * @c) * 0.4 > nElementos)\n aux = to_dispersa(aux)\n end\n else\n aux = \"No se pueden sumar\"\n end\n aux\n end", "def to_mat(pos=[0,0,0])\n xx, xy, xz, xw = @x*@x, @x*@y, @x*@z, @x*@w\n yy, yz, yw = @y*@y, @y*@z, @y*@w\n zz, zw = @z*@z, @z*@w\n [\n 1-2*(yy+zz), 2*(xy+zw), 2*(xz-yw), 0,\n 2*(xy-zw), 1-2*(xx+zz), 2*(yz+xw), 0,\n 2*(xz+yw), 2*(yz-xw), 1-2*(xx+yy), 0,\n pos[0], pos[1], pos[2], 1\n ]\n end", "def p11\n\tgrid = Matrix[\n\t\t[8,\t2, 22,97,38,15,0, 40,0, 75,4, 5, 7, 78,52,12,50,77,91,8],\n\t\t[49,49,99,40,17,81,18,57,60,87,17,40,98,43,69,48,4, 56,62,0],\n\t\t[81,49,31,73,55,79,14,29,93,71,40,67,53,88,30,3, 49,13,36,65],\n\t\t[52,70,95,23,4, 60,11,42,69,24,68,56,1, 32,56,71,37,2, 36,91],\n\t\t[22,31,16,71,51,67,63,89,41,92,36,54,22,40,40,28,66,33,13,80],\n\t\t[24,47,32,60,99,3, 45,2, 44,75,33,53,78,36,84,20,35,17,12,50],\n\t\t[32,98,81,28,64,23,67,10,26,38,40,67,59,54,70,66,18,38,64,70],\n\t\t[67,26,20,68,2, 62,12,20,95,63,94,39,63,8, 40,91,66,49,94,21],\n\t\t[24,55,58,5, 66,73,99,26,97,17,78,78,96,83,14,88,34,89,63,72],\n\t\t[21,36,23,9, 75,0, 76,44,20,45,35,14,0, 61,33,97,34,31,33,95],\n\t\t[78,17,53,28,22,75,31,67,15,94,3, 80,4, 62,16,14,9, 53,56,92],\n\t\t[16,39,5, 42,96,35,31,47,55,58,88,24,0, 17,54,24,36,29,85,57],\n\t\t[86,56,0, 48,35,71,89,7, 5, 44,44,37,44,60,21,58,51,54,17,58],\n\t\t[19,80,81,68,5, 94,47,69,28,73,92,13,86,52,17,77,4, 89,55,40],\n\t\t[4,\t52,8, 83,97,35,99,16,7, 97,57,32,16,26,26,79,33,27,98,66],\n\t\t[88,36,68,87,57,62,20,72,3, 46,33,67,46,55,12,32,63,93,53,69],\n\t\t[4,\t42,16,73,38,25,39,11,24,94,72,18,8, 46,29,32,40,62,76,36],\n\t\t[20,69,36,41,72,30,23,88,34,62,99,69,82,67,59,85,74,4, 36,16],\n\t\t[20,73,35,29,78,31,90,1, 74,31,49,71,48,86,81,16,23,57,5, 54],\n\t\t[1,\t70,54,71,83,51,54,69,16,92,33,48,61,43,52,1, 89,19,67,48]\n\t]\n\tproducts = []\n\t(0...grid.row_count).each do |row|\n\t\t(0...grid.column_count).each do |col|\n\t\t\tright = col + 3 < grid.row_count\n\t\t\tdown = row + 3 < grid.column_count\n\t\t\tleft = col - 3 >= 0\n\t\t\tif right\n\t\t\t\tset = grid.minor(row..row,col..col+3)\n\t\t\t\tproducts << set.reduce(:*)\n\t\t\tend\n\t\t\tif down and right\n\t\t\t\tdiagonal = []\n\t\t\t\t(0..3).each do |x|\n\t\t\t\t\tdiagonal << grid.minor(row+x..row+x,col+x..col+x).component(0,0)\n\t\t\t\tend\n\t\t\t\tproducts << diagonal.reduce(:*)\n\t\t\tend\n\t\t\tif down\n\t\t\t\tset = grid.minor(row..row+3,col..col)\n\t\t\t\tproducts << set.reduce(:*)\n\t\t\tend\n\t\t\tif down and left\n\t\t\t\tdiagonal = []\n\t\t\t\t(0..3).each do |x|\n\t\t\t\t\tdiagonal << grid.minor(row+x..row+x,col-x..col-x).component(0,0)\n\t\t\t\tend\n\t\t\t\tproducts << diagonal.reduce(:*)\n\t\t\tend\n\t\tend\n\tend\n\tproducts.max\nend", "def ahorrodinero(año)\n\n i = 0\n final = Array.new \n final1 = Array.new \n final2 = Array.new \n \n\n datos = Valore.where(:año => año)\n \n datos.each do |datos|\n \n \n final[i] = datos.read_attribute(\"es\")\n final1[i] = datos.read_attribute(\"tarifa\")\n final2[i] = final1[i]*final[i]\n \n i = i +1\n \n \n end\n \n return final2\n\n\n\n end", "def multiplicar(matrizc)\n\n \t\tmatRes = Array.new(matriz.size - 1,0)\n\n\t\tfor fil in 0...matriz[0].size\n\n\t\t\tmatRes[fil] = Array.new(matrizc.matriz.size,0)\n\n\t\t\tfor col in 0...matrizc.matriz.size\n\n\t\t\t\tfor pos in 0...matriz.size\n\n\t\t\t\t\tprod = matriz[fil][pos] * matrizc.matriz[pos][col]\n\t\t\t\t\tmatRes[fil][col] = matRes[fil][col] + prod\n\n\t\t\t\tend\n\n\t\t\tend\n\n \t\tend\n\n \t\tMatriz.new(matRes)\n\n \tend", "def mrf; xparam(5); end", "def generate_non_singular!\n @colt_property.generateNonSingular(@colt_matrix)\n end", "def r\n return (x**2.0 + y**2.0 + z**2.0)**0.5\n end", "def to_s\r\n\t\t\r\n\t\tmatrizMuestra = Array.new(@fil) {Array.new(@col) {0}}\r\n\t\t\r\n\t\tnumEle = 0\r\n\t\ti = 0\r\n\t\t\t\r\n\t\twhile i < @numElementos\t\t\t\t\t\t\r\n\t\t\t\r\n\t\t\tmatrizMuestra[@filM[i]][@colM[i]] = @eleM[i]\r\n\t\t\t\r\n\t\t\ti += 1\r\n\t\tend\r\n\t\t\r\n\t\t#puts \"muestra = #{matrizMuestra}\"\r\n\t\treturn matrizMuestra\r\n\t\t\r\n\tend", "def calcularDiagonalPrincipal (indice, valor)\n\t valores = Array.new\n\t indices = Array.new\n\t \t \n\t indicefor = indice\n\t valorfor = valor\n\t\t\n\t\t##Se calculan los valores diagonales hacia adelante\n\t\twhile (indicefor <= (@tamano-1) && valorfor <= (@tamano-1)) do\n\t\t\tindices << indicefor\n\t\t\tvalores << valorfor\n\t\t\tindicefor +=1\n\t\t\tvalorfor +=1\n\t\t\t\n\t\tend\n\t\t\n\t\t##Se calculan los valores diagonales hacia atras\n\t\tindicesnew = Array.new\n\t\tvaloresnew = Array.new\n\t\tindicefor = indice-1\n\t\tvalorfor = valor-1\n\t\twhile (indicefor >= 0 && valorfor >= 0) do\n\t\t\tindicesnew << indicefor\n\t\t\tvaloresnew << valorfor\n\t\t\tindicefor -=1\n\t\t\tvalorfor -=1\n\t\t\t\n\t\tend\n\t\t\n\t\tmatriz = Matrix[indicesnew.reverse + indices, valoresnew.reverse + valores]\n\t\t\t\t\n\t\t# matris [filas (0 para indices- 1 para valores) , columnas son valores(valor inicial...valor final)]\n\t\t# ejemplo : puts matriz[0,5]\n\t\treturn matriz\n \n \n end", "def principal_components(input, m=nil)\n if @use_gsl\n data_matrix=input.to_gsl\n else\n data_matrix=input.to_matrix\n end\n m||=@m\n \n raise \"data matrix variables<>pca variables\" if data_matrix.column_size!=@n_variables\n \n fv=feature_matrix(m)\n pcs=(fv.transpose*data_matrix.transpose).transpose\n \n pcs.extend Statsample::NamedMatrix\n pcs.fields_y = m.times.map { |i| \"PC_#{i+1}\".to_sym }\n pcs.to_dataframe\n end", "def create_all(r, c, s)\n\ttotal_matrices_needed = s ** (r * c)\n\tall_possible_ms(all_possible_rows(c, s), r, total_matrices_needed)\nend", "def fifteen \n size_x = 10 \n size_y = 10\n row = []\n for i in 1..size_x\n row.push(0)\n end\n\n @@mat = []\n\n for i in 1..size_y\n @@mat.push(row.clone)\n end\n \n move(0,0)\n\n return @@mat[size_x-1][size_y-1]\n\nend", "def friend_circles(matrix)\nend", "def carbohidratos\n\t\treturn @carbohidratos*@cantidad\n\tend", "def *(o)\n\t if(self.col == o.row)\n \t\t matres = self.class.new(self.row,self.col)\n# \t\t\t for i in 0...self.row\n# \t\t\t for j in 0...o.col\n# \t\t for k in 0...self.col\n\n\t\t\t i = 0\n \t\t\t (0..(self.row - 1)).collect {\n \t\t\t 0.upto(o.col - 1) do |j|\n\t\t\t k = 0\n \t\t (self.col - 1).times {\n \t\t\tmatres[i,j] += self[i,k] * o[k,j]\n\t\t\t k += 1\n\t\t\t }\n\t\t\t end\n# \t\t end\n# end\n# end\n\n\t\t\ti += 1\n\t\t\t}\n matres\n end\n end", "def get_matrix\n matrix = SnekMath::Matrix.new(area[0].length, area.length, 'empty')\n area.each_with_index do |row, y|\n row.each_with_index do |cell, x|\n matrix.set(x, y, cell)\n end\n end\n matrix\n end", "def transform(x)\n x = ::Rumale::Validation.check_convert_sample_array(x)\n\n cx = @params[:whiten] ? (x - @mean) : x\n cx.dot(@components.transpose)\n end" ]
[ "0.5693579", "0.5467707", "0.54469603", "0.5420482", "0.53573006", "0.53573006", "0.529591", "0.52841896", "0.52515054", "0.52499425", "0.52153283", "0.51736885", "0.51408595", "0.50721747", "0.5055609", "0.5043943", "0.5019113", "0.4993827", "0.4993557", "0.49852735", "0.49815878", "0.4950524", "0.49243742", "0.49195078", "0.4917011", "0.4884295", "0.4867179", "0.48635826", "0.483503", "0.48060584", "0.4787407", "0.4759894", "0.4746794", "0.47184914", "0.47075135", "0.46969527", "0.4692181", "0.46891078", "0.4687959", "0.46790612", "0.4678036", "0.46647105", "0.46597132", "0.46424812", "0.46341863", "0.4633783", "0.4633764", "0.46316662", "0.46315303", "0.4630633", "0.46210963", "0.46198606", "0.4611111", "0.46108475", "0.4607186", "0.45965883", "0.45907217", "0.45903265", "0.45863807", "0.45796394", "0.45735636", "0.4568491", "0.45616138", "0.4560983", "0.45542264", "0.45527336", "0.45458528", "0.4527075", "0.45255303", "0.4522736", "0.45194376", "0.450992", "0.449716", "0.4480798", "0.44727305", "0.4472394", "0.44669977", "0.44641832", "0.4463539", "0.4462563", "0.44617224", "0.44593132", "0.44588053", "0.44557285", "0.44520566", "0.4446336", "0.44410402", "0.44381255", "0.44360164", "0.44336143", "0.44292572", "0.44281277", "0.44268182", "0.44252613", "0.44245905", "0.4420846", "0.44088903", "0.4408223", "0.44058937", "0.44036084" ]
0.48998326
25
Runs the test case.
def test_importNode07 doc = nil aNewDoc = nil element = nil aNode = nil attributes = nil name = nil attr = nil lname = nil namespaceURI = "http://www.nist.gov"; qualifiedName = "emp:employee"; doc = load_document("staffNS", true) aNewDoc = load_document("staff", true) element = aNewDoc.createElementNS(namespaceURI, qualifiedName) aNode = doc.importNode(element, false) attributes = aNode.attributes() assertSize("throw_Size", 1, attributes) name = aNode.nodeName() assert_equal("emp:employee", name, "nodeName") attr = attributes.item(0) lname = attr.localName() assert_equal("defaultAttr", lname, "lname") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run\n print_banner\n @test_plan.each do |plan|\n found_nodes = nodes(plan)\n if found_nodes\n found_nodes.each { |node| execute_plan_tests(node, plan) }\n end\n end\n exit @ret_code\n end", "def run\n\n @startDate = Time.now.to_i * 1000\n @status = 'Started'\n start_test_run(create_test_objects(@tests, @runOptions, @id), @cmd)\n @status = 'Completed'\n @endDate = Time.now.to_i * 1000\n set_status\n @event_emitter.emit_event(test_run_completed: self)\n check_status_and_exit\n #add login for sending an exit code based on whether or not there were any failures.\n end", "def go_run_one(test_case)\n @status = :running\n Thread.new do\n begin\n @test_suite.run_test(test_case) do |result|\n @test_results[result[:source]] = result[:result]\n end\n rescue => e\n puts e\n print e.bracktrace.join(\"\\n\")\n ensure\n @status = :ran\n end\n end\n end", "def run\n test_using_random_sample\n test_using_first_of\n end", "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 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 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_test\n # Add your code here...\n end", "def run_test\n # Add your code here...\n end", "def run_tests\n\n ::RSpec::Core::Runner.run([])\n\n print ::IRB.CurrentContext.io.prompt\n\n end", "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\[email protected] += 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\[email protected] += 1\n\t\t\telsif ctx.skipped?\n\t\t\t\tputs \" = skipped ============\"\n\t\t\t\[email protected] += 1\n\t\t\telse\n\t\t\t\tputs \" - ok.\"\n\t\t\t\[email protected] += 1\n\t\t\tend\n\t\t\tputs\n\t\tend", "def run!\n test_result = Tester::Runner.run(file)\n if test_result.stdout.to_s.strip.empty?\n new_reason = reason\n else\n new_reason = test_result.stdout \n end\n # Capture the exit status, and map to a result object\n result = case test_result.exitstatus\n when 0; Result::Pass\n when 1; Result::Fail\n when 2; Result::Skip\n when nil; Result::NoResult\n else\n new_reason = (test_result.stderr.strip + \"\\n\" + test_result.stdout.strip).strip\n Result::Error\n end\n Tester::Test.new(file, base, result, new_reason, stack)\n end", "def running_test_case; end", "def testloop\n \n end", "def test!\n in_test_dir do\n notify.start(\"Running tests on: #{proj_branch}\")\n test.run!\n notify.done(\"Test finished: #{test.status}\", test.passed?)\n end\n end", "def run\n exe_file, result = compile\n\n if result.failed?\n puts result.error\n return\n end\n\n if cases.empty?\n puts 'No test case found!'\n return\n end\n\n cmd = TTY::Command.new(printer: :progress)\n exe_output = File.join(@temp_dir, 'output')\n\n cases.each do |input, output|\n cmd.run!(exe_file, in: input, out: exe_output)\n identical = FileUtils.compare_file(output, exe_output)\n identical ? puts('Passed') : puts('Failed')\n end\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 run\n if enabled?\n reset\n puts \"Running test: #{path}\"\n puts \"Follow Here: #{File.join(job_folder, 'all.log')}\"\n runner.run(command, job_folder)\n puts Formatter.status_line(self)\n status\n else\n puts \"Test disabled, skipping.\"\n end\n end", "def exec_test\n $stderr.puts 'Running tests...' if verbose?\n\n runner = config.testrunner\n\n case runner\n when 'auto'\n unless File.directory?('test')\n $stderr.puts 'no test in this package' if verbose?\n return\n end\n begin\n require 'test/unit'\n rescue LoadError\n setup_rb_error 'test/unit cannot loaded. You need Ruby 1.8 or later to invoke this task.'\n end\n autorunner = Test::Unit::AutoRunner.new(true)\n autorunner.to_run << 'test'\n autorunner.run\n else # use testrb\n opt = []\n opt << \" -v\" if verbose?\n opt << \" --runner #{runner}\"\n if File.file?('test/suite.rb')\n notests = false\n opt << \"test/suite.rb\"\n else\n notests = Dir[\"test/**/*.rb\"].empty?\n lib = [\"lib\"] + config.extensions.collect{ |d| File.dirname(d) }\n opt << \"-I\" + lib.join(':')\n opt << Dir[\"test/**/{test,tc}*.rb\"]\n end\n opt = opt.flatten.join(' ').strip\n # run tests\n if notests\n $stderr.puts 'no test in this package' if verbose?\n else\n cmd = \"testrb #{opt}\"\n $stderr.puts cmd if verbose?\n system cmd #config.ruby \"-S tesrb\", opt\n end\n end\n end", "def runner; end", "def sub_test\n shell(test_script, source_dir)\n end", "def run_test\n if validate(@test)\n generate(@test)\n else\n $stderr.puts \"There were some errors, fix them and rerun the program.\"\n end\nend", "def run_fe_tests\n end", "def run_app_tests\n end", "def call\n scenario.run(self)\n end", "def run\n testable = Parser.new(@argv).parse\n Executor.new(testable).execute\n end", "def test\n if phase.has_key?('test')\n execute(\"test\", phase['test'])\n end\n end", "def test() \n @runner.prepareForFile(@filename)\n testIfAvailable(codeFilename())\n end", "def run(*test_cases)\n @report.on_start if @report.respond_to?(:on_start)\n test_cases.each do |test_case|\n @report.on_enter(test_case) if @report.respond_to?(:on_enter)\n test_case.run(self)\n @report.on_exit(test_case) if @report.respond_to?(:on_exit)\n end\n @report.on_end if @report.respond_to?(:on_end)\n end", "def test_running\n assert_equal(\"Huff puff huff puff\", Human.new(\"Zelda\").run)\n assert_equal(\"Huff puff huff puff\", Human.new(\"Mary\").run)\n end", "def 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_cases; end", "def test_case; end", "def run( result )\n\t\tprint_test_header self.name\n\t\tsuper\n\tend", "def run_command\n # run the test suite and check the result\n res, time = time_command @config.command\n if res then\n puts statusbar \"✓ All tests passed\", time, &:white_on_green\n else\n puts statusbar \"✗ Tests failed\", time, &:white_on_red\n end\n res\n end", "def run(reporter=nil)\n run_tests(tests, true, reporter)\n end", "def run_all\n run_suite(@suite)\n end", "def test_run\n assert_respond_to(@ts, :run)\n end", "def call(*params)\n self.send :test, *params\n end", "def tests; end", "def tests; end", "def run_suite(tests)\n @app.run_suite(tests)\n end", "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", "def run\n begin\n self.class.roby_should_run(self, Roby.app)\n super\n rescue MiniTest::Skip => e\n puke self.class, self.name, e\n end\n end", "def run(files)\n file = files.first\n puts \"** Running #{file}\"\n \n class_filename = file.sub(self.class::CLASS_MAP, '')\n \n # get the class\n test_class = resolve_classname(class_filename)\n \n # create dummy wrapper modules if test is in subfolder\n test_class.split('::').each do |part|\n eval \"module ::#{part}; end\" if !part.match('Test')\n end\n \n begin \n clear_class(test_class.constantize) \n rescue NameError \n \n end\n \n # TODO: make this reload use load_file\n $\".delete(file)\n \n begin\n require file\n rescue LoadError\n notifier.error(\"Error in #{file}\", $!)\n puts $!\n return\n rescue ArgumentError\n notifier.error(\"Error in #{file}\", $!)\n puts $!\n return\n rescue SyntaxError\n notifier.error(\"Error in #{file}\", $!)\n puts $!\n return\n end\n \n # TODO: change that to run multiple suites\n #klass = Kernel.const_get(test_class) - this threw errors\n klass = eval(test_class)\n \n Test::Unit::UI::Console::TestRunner.run(klass)\n Test::Unit.run = false\n \n # Invoke method to test that writes to stdout.\n result = test_io.string.to_s.dup\n\n # clear the buffer \n test_io.truncate(0)\n \n # sent result to notifier\n notifier.result(file, result.split(\"\\n\").compact.last)\n\n # sent result to stdio\n puts result\n \n end", "def run_test \n \n test_table = make_test_table(\"ml-100k/u1.test\")\n @testdata = MovieTest.new(test_table)\n end", "def testing\n # ...\n end", "def run_tests(argv, input, output)\n raise NotImplemented\n end", "def run\n run_accuracy_scenario if accuracy_scenario? && validating_accuracy?\n run_connection_scenario if connection_scenario? && validating_connections?\n end", "def run_all\n deploy_code\n run_test\n end", "def run_test(test)\n @app.run_test(test)\n end", "def run\n runner = self\n @test_cases.each do |path|\n next if ENV['TEST_CASE'] && !File.basename(path).match(ENV['TEST_CASE'])\n\n Aws::ModelValidators.load_json(path).tap do |test_case|\n\n models = test_case.inject({}) { |h,(k,v)| h[k.to_sym] = v; h }\n errors = models.delete(:errors)\n\n @group.it(File.basename(path[0..-6])) do\n pending unless errors\n results = described_class.new.validate(models, apply_schema: false)\n unless runner.results_match?(results, errors)\n expect(results).to eq(errors)\n end\n end\n\n end\n end\n end", "def run\n if Process.respond_to?(:fork)\n fork {\n runner = Test::Runner.new(config)\n success = runner.run\n exit -1 unless success\n }\n Process.wait\n else\n runner = Test::Runner.new(config)\n success = runner.run\n exit -1 unless success\n end\n end", "def run_tests(sideload_config:)\n telnet_config ={\n 'Host' => @roku_ip_address,\n 'Port' => 8085\n }\n\n @device_config[:init_params] = {\n root_dir: @root_dir\n }\n loader = Loader.new(**@device_config)\n connection = Net::Telnet.new(telnet_config)\n code, _build_version = loader.sideload(**sideload_config)\n if code == SUCCESS\n @device_config[:init_params] = nil\n linker = Linker.new(**@device_config)\n linker.launch(options: \"RunTests:true\")\n\n connection.waitfor(@end_reg) do |txt|\n handle_text(txt: txt)\n end\n print_logs\n connection.puts(\"cont\\n\")\n end\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 run\n end", "def run\n end", "def test\n end", "def test\n end", "def test\n end", "def run(result)\n begin\n @_result = result\n @internal_data.test_started\n yield(STARTED, name)\n yield(STARTED_OBJECT, self)\n begin\n run_setup\n run_test\n run_cleanup\n add_pass\n rescue Exception\n @internal_data.interrupted\n raise unless handle_exception($!)\n ensure\n begin\n run_teardown\n rescue Exception\n raise unless handle_exception($!)\n end\n end\n @internal_data.test_finished\n result.add_run\n yield(FINISHED, name)\n yield(FINISHED_OBJECT, self)\n ensure\n # @_result = nil # For test-spec's after_all :<\n end\n end", "def run\n end", "def run\n end", "def run\n end", "def run\n end", "def run\n end", "def run\n end", "def run\n end", "def test\n\n end", "def run_tests(state, target)\n if (target.nil?)\n # This only works if you have busser installed and the appropriate\n # plugins, otherwise this won't do anything. For the record, I\n # still haven't gotten busser working locally\n path = \"#{config[:test_base_path]}/#{instance.suite.name}\"\n Dir.chdir(path) do\n system(\"busser test\")\n end\n else\n # We do have a node (i.e., a target) so we run on that host, so let's go\n # get our machine/transport to our machine\n machines = state[:machines]\n raise ClientError, \"No machine with name #{target} exists, cannot run test \" +\n \"suite as specified by .kitchen.yml\" if !machines.include?(target)\n node = get_node(state, target)\n provisioner = ChefMetal.provisioner_for_node(node)\n machine = provisioner.connect_to_machine(node)\n transport = machine.transport\n\n # Get the instance busser/setup and run our tests on our machine\n busser = instance.busser\n old_path = busser[:test_base_path]\n busser[:test_base_path] = \"#{busser[:test_base_path]}/#{target}\"\n execute(transport, busser.sync_cmd)\n execute(transport, busser.run_cmd)\n # We have to reset this after we modify it for the node; otherwise this is\n # a persistent change\n busser[:test_base_path] = old_path\n end\n end", "def run_all\n UI.info \"Running all tests...\"\n _really_run(Util.xcodebuild_command(options))\n end", "def run\n log.info(\"Running...\")\n result = run_internal()\n log.info(\"Success! #{result.message}\")\n return result\n end", "def run\n return run_work_unit unless @options['benchmark']\n status = CloudCrowd.display_status(@status)\n log(\"ran #{@action_name}/#{status} in \" + Benchmark.measure { run_work_unit }.to_s)\n end", "def call(tests)\n Result::Test.new(\n output: '',\n passed: true,\n runtime: 0.0,\n tests: tests\n )\n end", "def define_run_task\n desc @run_description\n task 'run' do\n target_sha = ENV['TARGET_SHA']\n ts = TTNT::TestSelector.new(repo, target_sha, expanded_file_list)\n tests = ts.select_tests!\n\n if tests.empty?\n STDERR.puts 'No test selected.'\n else\n if ENV['ISOLATED']\n tests.each do |test|\n args = \"#{ruby_opts_string} #{test} #{option_list}\"\n run_ruby args\n break if @failed && ENV['FAIL_FAST']\n end\n else\n args =\n \"#{ruby_opts_string} #{run_code} \" +\n \"#{tests.to_a.join(' ')} #{option_list}\"\n run_ruby args\n end\n end\n end\n end", "def running_test_step; end", "def run(*args)\n files = args.select { |arg| arg !~ /^-/ }\n\n files = parse_files(files)\n examples = parse_examples(files)\n\n add_pwd_to_path\n\n generate_tests(examples)\n run_tests\n end", "def run_tests\n `make > dev/null`\n @test_harness.run_test(\"./triangle 0 0 0 0 0 0\", :nat_simple)\n @test_harness.run_test(\"./triangle 1 1 2 2 3 3\", :nat_hard)\n @test_harness.run_test(\"./triangle 1 1 3 2 1 3\", :iso_acute)\n @test_harness.run_test(\"./triangle 1 1 3 2 5 1\", :iso_obtuse)\n @test_harness.run_test(\"./triangle 1 1 0 2 0 1\", :iso_right)\n @test_harness.run_test(\"./triangle 1 1 5 1 5 4\", :sca_right)\n @test_harness.run_test(\"./triangle 1 1 4 2 6 1\", :sca_obtuse)\n @test_harness.run_test(\"./triangle 1 1 2 2 4 1\", :sca_obtuse)\n @test_harness.run_test(\"./triangle 0 0 1 3 4 0\", :sca_acute)\n `make clean`\n end", "def run\n @rspec_test_name = PATH_TO_RSPEC_SPEC_FOLDER + @rspec_test_name\n unless File.exists?(\"#{@rspec_test_name}\")\n @@failed_tests.push(\"Test not exists: #{@rspec_test_name}\")\n @@failed_tests_counter +=1\n return 1\n end\n @cmd = `rspec #{@rspec_test_name}`\n describe_test(@rspec_test_name, @cmd, $?.exitstatus)\n generate_and_expand_output\n end", "def call\n rv = @runner.call\n exit(rv ? 0 : 1)\n end", "def test \n end", "def run\n if server_is_available?\n run_tests\n @csv_writer.write(@configuration.csv_mode, @results) unless @results.empty? if defined?(Rails) and Rails.version.match(/^3.+$/)\n @results.each_with_index do |result, index|\n result.honk_in(@configuration.verbosity, index)\n end unless @results.empty?\n else\n puts(\"Server #{@configuration.host} seems to be unavailable!\")\n end\n error_count = @results.select{ |r| !r.succeeded }.count\n puts \"\\n\\nResults: I greatfully ran #{ @spec.size } test(s), \\033[32m#{ @spec.size - error_count }\\033[0m succeeded, \\033[31m#{ error_count }\\033[0m failed.\"\n exit(error_count)\n end", "def test\n puts \"this is a test\"\n end", "def run\n each_test do |liquid, layout, assigns, page_template, template_name|\n compile_and_render(liquid, layout, assigns, page_template, template_name)\n end\n end", "def run\n end", "def run\n setup\n fuzzing_loop\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 run\n puts self.name + \" runs\"\n end", "def done\n puts 'Done running tests'\n end", "def run_tests\n test_suite = self.task.tests.order(:order)\n testsStrings = test_suite.map do |test|\n test_string = task.fxn_name + \"(\"\n test_string + \"...\"+test.parsed_inputs.to_s + \")\"\n end\n formated_user_code = self.solution.gsub(\"\\n\", \" \")\n data = JSON.dump({user_code: formated_user_code, tests: testsStrings})\n uri = URI.parse(\"https://wci7v1nq8j.execute-api.us-west-2.amazonaws.com/v1\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(uri.request_uri)\n request.body = data\n response = http.request(request)\n response = JSON.parse(response.body)\n if response[\"errorMessage\"]\n message = response[\"errorMessage\"]\n if message.include?(\"timed out\")\n message = \"Task timed out after 4.00 seconds\"\n end\n return {error: true, error_message: message }\n end\n user_results = response[\"results\"]\n test_results = {log: response[\"log\"].gsub(\"\\n\", \"<br/>\"), results: {} }\n test_suite.each_with_index do |test, idx|\n result = user_results[idx]\n passed = result == test.output\n test_result = {\n passed: passed,\n expected: test.output.to_s,\n received: result.to_s\n }\n test_results[:results][test.order] = test_result\n end\n handle_completion(test_results[:results])\n test_results\n 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\n raise \"Not implemented for this check.\"\n end", "def run_test(assertion, setup)\n rv = assertion.execute(setup, assertion.suite.ancestry_teardown)\n @count[:test] += 1\n @count[rv.status] += 1\n\n rv\n end", "def runsuite\n # get the name of the suite file chosen by the user\n @suite = params['suite']\n start_time = Time.now.strftime('%Y-%m-%d_-_%H-%M-%S')\n # Create filename for console output log\n session[:console_filename] = \"log/runner/console-#{start_time}.log\"\n # Create batch file that will be used to execute the test\n batch_filename = \"run-#{start_time}.bat\"\n wd = session[:working_dir]\n batch_path = File.join(wd + '/../runner_batch_files/' + batch_filename)\n batch_handle = File.new(batch_path, 'w+')\n # Build the command line string to execute the requested script.\n #\n # \"-Cdirectory\" is used to make the cmd shell cd into suite_dir before\n # executing the script, in case the suite script tries to 'require' any\n # other files. Without this, ruby might have trouble resolving the path\n # to files the suite tries to load.\n cmd = \"ruby -C#{session[:suite_dir] } #{@suite} --\" +\n\t \" -v verbose > #{session[:console_filename]}\"\n batch_handle.puts cmd # write cmd to batch file\n batch_handle.close\n # Run the batch file (which launches the test suite).\n system(batch_path)\n end", "def testcase3(prog)\n rc = prog.run(\"blah\")\n assert_equal(0, rc, \"program should exit normally\")\n end", "def run\n end", "def run\n # Here we're using Phantom to load the page and run the specs\n command = \"#{Phantomjs.path} 'phantom_jasmine_run.js' #{@jasmine_server_url} #{@result_batch_size}\"\n IO.popen(command) do |output|\n # The `phantom_jasmine_run.js` script writes out batches of results as JSON\n output.each do |line|\n raw_results = JSON.parse(line, :max_nesting => false)\n # Formatters expect to get `Jasmine::Result` objects.\n # It is the runner's job to convert the result objects from the page, and pass them to the `format` method of their formatter.\n results = raw_results.map { |r| Result.new(r) }\n @formatter.format(results)\n end\n end\n # When the tests have finished, call `done` on the formatter to run any necessary completion logic.\n @formatter.done\n end", "def run_test\n # Make sure that params have been set\n raise_error('You need to pass some params to run the test. At least, an url or script') unless block_given?\n params = Hashie::Mash.new\n yield params\n raise_error('No params were passed to run_test method') if params.empty?\n\n response = connection.post do |req|\n req.url \"#{TEST_BASE}\"\n req.params['k'] = key\n req.params['f'] = @params.f\n params.each do |k, v|\n req.params[k] = v\n end\n end\n return not_available (response) unless response.status == 200\n @response = Response.new(self, Hashie::Mash.new(JSON.parse(response.body)))\n end", "def run; end", "def run; end", "def run; end" ]
[ "0.7799092", "0.7670545", "0.75712216", "0.75627315", "0.75226235", "0.75201446", "0.74722594", "0.7330742", "0.7330742", "0.72492516", "0.72388816", "0.72313887", "0.72023034", "0.7136023", "0.70817155", "0.7047509", "0.7020568", "0.6938718", "0.6918842", "0.6867642", "0.685644", "0.6845935", "0.6817201", "0.6810139", "0.680572", "0.6803889", "0.67997265", "0.6793733", "0.6784917", "0.67702806", "0.67316455", "0.67290086", "0.6725608", "0.6722428", "0.67195565", "0.671884", "0.6708754", "0.670722", "0.66878986", "0.66848284", "0.66848284", "0.6673693", "0.6657514", "0.6642", "0.6639669", "0.6639478", "0.6634425", "0.6630447", "0.66186225", "0.6617495", "0.66160864", "0.6608177", "0.66003597", "0.6593121", "0.6588042", "0.658473", "0.658473", "0.65748334", "0.65748334", "0.65748334", "0.65747154", "0.6560065", "0.6560065", "0.6560065", "0.6560065", "0.6560065", "0.6560065", "0.6560065", "0.6558287", "0.65582854", "0.6553281", "0.6551349", "0.65511096", "0.65477747", "0.6546237", "0.6538623", "0.6535636", "0.6534499", "0.65266925", "0.6521796", "0.6506653", "0.6499989", "0.6466085", "0.6461466", "0.64613205", "0.6441548", "0.6439917", "0.64376867", "0.6434754", "0.64299625", "0.64272463", "0.6415641", "0.640835", "0.6407985", "0.6397046", "0.63966566", "0.63951164", "0.6388161", "0.63875526", "0.63875526", "0.63875526" ]
0.0
-1
Gets URI that identifies the test.
def targetURI "http://www.w3.org/2001/DOM-Test-Suite/tests/Level-1/importNode07" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getURI()\n return @uri.to_s\n end", "def uri\n @uri.to_s\n end", "def uri\n uri_for({}, nil)\n end", "def uri\n return @uri\n end", "def uri\n return @uri\n end", "def uri\n @uri\n end", "def uri\n @uri\n end", "def url\n if @resource.element\n @resource.uri.sub /\\{.*\\}/, @testcase.id.to_s\n else\n @resource.uri\n end\n end", "def url\n uri.to_s\n end", "def url\n uri.to_s\n end", "def url\n uri\n end", "def url\n uri\n end", "def uri\n @uri\n end", "def uri\n @uri\n end", "def uri\n @uri ||= URI(url)\n end", "def base_uri\n suite_configuration.core_uri\n end", "def uri_path\n __getobj__.uri.path\n end", "def uri\n \"#{@@config[:base_uri]}#{id}\"\n end", "def uri\n @_uri ||= URI(@url)\n end", "def uri\n @_uri ||= URI(@url)\n end", "def to_s\n uri\n end", "def uri\n uri_prefix + Digest::MD5.hexdigest(self.address)\n end", "def uri\n @uri ||= URI.parse @url if @url\n @uri\n end", "def uri\n drb = Thread.current['DRb']\n client = (drb && drb['client'])\n if client\n uri = client.uri\n return uri if uri\n end\n current_server.uri\n end", "def request_uri\n calculate_uri(@http_request.url)\n end", "def path\n @uri.request_uri\n end", "def request_uri\n @request.uri\n end", "def uri\n Util.join_uri(self.class.uri, self.id)\n end", "def uri\n \"http://example.com#{base_path}#{anchor}\"\n end", "def get_uri\n request_object.uri\n end", "def uri\n self + \"\"\n end", "def uri\n self + \"\"\n end", "def uri\n read_attr :uri\n end", "def uri_endpoint\n URI( self.endpoint )\n end", "def get_uri\n unless self.uri == nil\n return self.uri\n else \n return repository.generate_uri(title)\n end\n end", "def resolved_uri; end", "def uri\n @uri ||= resource_template.uri_for(params, application.base)\n end", "def uri\n @uri ||= URI.parse(url)\n end", "def to_s\n @uri\n end", "def uri\n raise NotImplementedError\n end", "def path\n @uri.path\n end", "def to_uri\n build_uri\n end", "def uri(path)\n return File.join(@base_url, path)\n end", "def uri\n database.uri + '/' + ensure_id\n end", "def uri\n \"#{base_uri}#{path}\"\n end", "def uri; end", "def uri; end", "def uri; end", "def uri; end", "def uri; end", "def uri; end", "def uri; end", "def uri; end", "def uri; end", "def uri; end", "def uri; end", "def uri; end", "def uri_host; end", "def get_URI()\n \t return @outputs[\"URI\"]\n \tend", "def get_URI()\n \t return @outputs[\"URI\"]\n \tend", "def get_URI()\n \t return @outputs[\"URI\"]\n \tend", "def get_URI()\n \t return @outputs[\"URI\"]\n \tend", "def uri\n @uri ||= select { |type,value| type == :uri }.map do |(type,value)|\n URI.parse(value)\n end\n end", "def uri\n attributes.fetch(:uri)\n end", "def uri\n attributes.fetch(:uri)\n end", "def to_s\n uri_string\n end", "def base_uri\t\t\t\n\t\tURI.parse( \"http://\" + @factory.site_name + \".\" + @factory.api_host_base + @path )\n\tend", "def get_test_url(version, suite, num, suffix = nil)\n suffix ||= case suite\n when /xhtml/ then \"xhtml\"\n when /html/ then \"html\"\n when /svg/ then \"svg\"\n else \"xml\"\n end\n\n url(\"/test-suite/test-cases/#{version}/#{suite}/#{num}.#{suffix}\").\n sub(/localhost:\\d+/, HOSTNAME) # For local testing\n end", "def full_path\n uri.request_uri\n end", "def full_uri\n \"#{host_uri}#{uri}\"\n end", "def uri\n URI::Generic.build(host: addr, port: port)\n end", "def uri\n URI::Generic.build(host: addr, port: port)\n end", "def uri\n N::URI.new(self[:uri])\n end", "def uri\n N::URI.new(self[:uri])\n end", "def server_url\n @uri\n end", "def uri\n nil\n end", "def uri( new_uri=nil )\n\t\tif new_uri\n\t\t\t@uri = URI( new_uri )\n\t\t\[email protected] ||= self.addresses.first.to_s\n\n\t\t\tself.app_protocol( @uri.scheme )\n\t\t\tself.port( @uri.port )\n\t\tend\n\n\t\treturn @uri.to_s\n\tend", "def uri\n # special parsing is done to remove the protocol, host, and port that\n # some Handlers leave in there. (Fixes inconsistencies.)\n URI.parse(self.env['REQUEST_URI'] || self.env['PATH_INFO']).path\n end", "def uri\n ::Spyke::Path.new(@uri_template, fmrest_uri_attributes) if @uri_template\n end", "def getPath()\n return @uri.path\n end", "def uri\n \n end", "def to_addressable_uri\n @uri\n end", "def uri\n URI.new :scheme => scheme,\n :host => host,\n :path => path,\n :query => query\n end", "def to_s\n uri.to_s\n end", "def request_uri; end", "def actual_uri\n redirects_to or uri\n end", "def resource_uri\n \"#{resource_name}/#{uid}\"\n end", "def uri\n \"http://#{hostname}:#{port}#{path}\"\n end", "def actual_url\n @browser.current_url\n end", "def uri\n \"#{database.uri}/#{ensure_id}\"\n end", "def uri\n File.join(self.scope, self.to_param)\n end", "def current_resource_uri\n \"/#{components[0..1].join('/')}\" rescue nil\n end", "def uri\n raise @fetch_error if fetch_error\n raise @invalid_uri_error if invalid_uri_error?\n return @redirect_log.last.uri unless @redirect_log.empty?\n return @source_uri\n end", "def uri\n opts[:uri]\n end", "def getHost()\n return @uri.host\n end", "def base_uri\n @base_uri ||= guess_base_uri\n end", "def base_uri\n \"#{self.class.base_uri}/#{name}\"\n end", "def to_s\n @uri\n end", "def targetURI\n \"http://www.w3.org/2001/DOM-Test-Suite/tests/Level-1/entitygetpublicid\"\n end", "def uri\n @uri ||= URI.parse(\"http://\" + domain)\n end", "def base_uri\n @base_uri\n end" ]
[ "0.7387945", "0.7351851", "0.71513367", "0.7137951", "0.7137951", "0.7114108", "0.7114108", "0.7086164", "0.70651335", "0.6988005", "0.6925742", "0.6925742", "0.69119173", "0.69119173", "0.6861145", "0.68302125", "0.68073744", "0.67857945", "0.6764499", "0.6764499", "0.6752177", "0.671709", "0.67031777", "0.6693263", "0.6691108", "0.6654199", "0.6648638", "0.66362673", "0.6635746", "0.66351104", "0.66329724", "0.66329724", "0.66212434", "0.65969145", "0.65837026", "0.65483797", "0.6536056", "0.65343106", "0.65297514", "0.6522225", "0.6516369", "0.6503132", "0.6429535", "0.64265907", "0.6425845", "0.63942146", "0.63942146", "0.63942146", "0.63942146", "0.63942146", "0.63942146", "0.63942146", "0.63942146", "0.63942146", "0.63942146", "0.63942146", "0.63942146", "0.6383816", "0.6372118", "0.6372118", "0.6372118", "0.6372118", "0.63714486", "0.63626665", "0.63626665", "0.63623977", "0.63592285", "0.6350157", "0.6344753", "0.63319325", "0.6327873", "0.6327873", "0.632342", "0.632342", "0.6314074", "0.63053113", "0.63050616", "0.62959135", "0.62898624", "0.6275253", "0.62670434", "0.6258649", "0.6256758", "0.6248515", "0.62463045", "0.62451184", "0.6234412", "0.62303627", "0.62244624", "0.6219039", "0.62164104", "0.62086225", "0.62044376", "0.6190659", "0.6188886", "0.6186325", "0.61797494", "0.6179413", "0.61768866", "0.6173964", "0.61689866" ]
0.0
-1
Image manipulate Resizing can be wrong when .EXT of file is wrong
def strict_resize image, w, h image.resize "#{ w }x#{ h }!" image end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resize_picture picture_owner, path, filename_extension\n\n # if filename_extension == 'jpg'\n resize_factor = \"PICTURE_#{picture_owner.upcase}_PREVIEW_SIZE\".constantize.first # e.g. *PICTURE_COACH_PREVIEW_SIZE*\n system \"convert #{path}/original.#{filename_extension} -resize '#{resize_factor}' #{path}/preview.#{filename_extension}\"\n\n resize_factor = \"PICTURE_#{picture_owner.upcase}_VIEW_SIZE\".constantize.first # e.g. *PICTURE_COACH_VIEW_SIZE*\n system \"convert #{path}/original.#{filename_extension} -resize '#{resize_factor}' #{path}/view.#{filename_extension}\"\n # else\n # # for logo file: just symbol links to original one (nothing to resize)\n # system \"ln -s #{path}/original.#{filename_extension} #{path}/preview.#{filename_extension}\"\n # system \"ln -s #{path}/original.#{filename_extension} #{path}/view.#{filename_extension}\"\n # end\n # Thumb is and in Africa thumb\n resize_factor = \"PICTURE_#{picture_owner.upcase}_THUMB_SIZE\".constantize.first # e.g. *PICTURE_COACH_THUMB_SIZE*\n system \"convert #{path}/original.#{filename_extension} -resize '#{resize_factor}' #{path}/thumb.#{filename_extension}\"\n\n end", "def resize_image(file_name,resize_file_name=\"test\",resized_width=0,resized_height=0,render_file_as=\"png\")\n image = Image.import(file_name)\n resize_image = image.resize(resized_width, resized_height,true)\n\n file=File.new(resize_file_name,\"wb\")\n if render_file_as == \"png\"\n file.write resize_image.png\n elsif\t render_file_as == \"jpeg\"\n file.write resize_image.jpeg\n elsif\t render_file_as == \"gd\"\n file.write resize_image.gd\n elsif\t render_file_as == \"gd2\"\n file.write resize_image.gd2\n else\n puts \"Provide proper image\"\n end\n file.close\n end", "def resize_image(img_path)\n img = MiniMagick::Image.open(img_path)\n print_status(\"Original #{img_path} dimension = #{img.height}x#{img.width}\")\n new_width = img.width - (img.width * REIZEPERT).to_i\n new_height = img.height - (img.height * REIZEPERT).to_i\n img = img.resize(\"#{new_width}x#{new_height}\")\n print_status(\"Resized #{img_path} dimension = #{img.height}x#{img.width}\")\n img.write(img_path)\nend", "def old_resize_image(img, size)\n size = size.first if size.is_a?(Array) && size.length == 1 && !size.first.is_a?(Fixnum)\n if size.is_a?(Fixnum) || (size.is_a?(Array) && size.first.is_a?(Fixnum))\n size = [size, size] if size.is_a?(Fixnum)\n img.thumbnail!(*size)\n elsif size.is_a?(String) && size =~ /^c.*$/ # Image cropping - example geometry string: c75x75\n dimensions = size[1..size.size].split(\"x\")\n img.crop_resized!(dimensions[0].to_i, dimensions[1].to_i)\n else\n img.change_geometry(size.to_s) { |cols, rows, image| image.resize!(cols<1 ? 1 : cols, rows<1 ? 1 : rows) }\n end\n self.width = img.columns if respond_to?(:width)\n self.height = img.rows if respond_to?(:height)\n img.strip! unless attachment_options[:keep_profile]\n quality = img.format.to_s[/JPEG/] && get_jpeg_quality\n out_file = write_to_temp_file(img.to_blob { self.quality = quality if quality })\n temp_paths.unshift out_file\n self.size = File.size(self.temp_path)\n end", "def resize_image(img, size) \n # resize_image take size in a number of formats, we just want \n # Strings in the form of \"crop: WxH\" \n if (size.is_a?(String) && size =~ /^crop: (\\d*)x(\\d*)/i) || \n (size.is_a?(Array) && size.first.is_a?(String) && \n size.first =~ /^crop: (\\d*)x(\\d*)/i) \n img.crop_resized!($1.to_i, $2.to_i) \n # We need to save the resized image in the same way the \n # orignal does. \n self.temp_path = write_to_temp_file(img.to_blob) \n else \n super # Otherwise let attachment_fu handle it \n end \n end", "def resize_image(img, size)\n size = size.first if size.is_a?(Array) && size.length == 1 && !size.first.is_a?(Fixnum)\n if size.is_a?(Fixnum) || (size.is_a?(Array) && size.first.is_a?(Fixnum))\n size = [size, size] if size.is_a?(Fixnum)\n img.thumbnail!(*size)\n elsif size.is_a?(String) && size =~ /^c.*$/ # Image cropping - example geometry string: c75x75\n dimensions = size[1..size.size].split(\"x\")\n img.crop_resized!(dimensions[0].to_i, dimensions[1].to_i)\n elsif size.is_a?(String) && size =~ /^b.*$/ # Resize w/border - example geometry string: b75x75\n dimensions = size[1..size.size].split(\"x\")\n img.change_geometry(dimensions.join(\"x\")) do |cols, rows, image| \n image.resize!(cols<1 ? 1 : cols, rows<1 ? 1 : rows ) \n end\n img.background_color = \"black\"\n x_offset = (img.columns - dimensions[0].to_i) / 2\n y_offset = (img.rows - dimensions[1].to_i) / 2\n img = img.extent(dimensions[0].to_i, dimensions[1].to_i, x_offset, y_offset)\n else\n img.change_geometry(size.to_s) { |cols, rows, image| image.resize!(cols<1 ? 1 : cols, rows<1 ? 1 : rows) }\n end\n img.strip! unless attachment_options[:keep_profile]\n temp_paths.unshift write_to_temp_file(img.to_blob)\n end", "def resize\n if size.max > 1024\n res = %x( #{magick_bin_name(\"convert\")} -auto-orient -resize 1024x768 #{Shellwords.shellescape path} #{Shellwords.shellescape path})\n Rails.logger.info res\n end\n unless has_thumbnail?\n unless File.exists? path.gsub(/(.+)\\/.+/, '\\1/thumbs')\n Dir.mkdir path.gsub(/(.+)\\/.+/, '\\1/thumbs')\n end\n ## that's a bit broken on windows - why?\n res = %x( #{magick_bin_name(\"convert\")} -verbose -auto-orient -strip -thumbnail 300x160 #{Shellwords.shellescape path} #{Shellwords.shellescape path.gsub(/(.+)\\/(.+)/, '\\1/thumbs/\\2')})\n Rails.logger.info res\n end\n end", "def resize_pic(filename,resizewidth,out_path)\n nw = resizewidth\n n = File.basename(filename)\n i = QuickMagick::Image.read(filename).first\n w = i.width.to_f # Retrieves width in pixels\n h = i.height.to_f # Retrieves height in pixels\n pr = w/h\n nh = nw/pr \n i.resize \"#{nw}x#{nh}!\"\n i.save \"#{out_path}/#{n}\"\nend", "def create_resized_image\n create_image do |xfrm|\n if size\n MiniMagick::Tool::Convert.new do |cmd|\n cmd << xfrm.path # input\n cmd.flatten\n cmd.resize(size)\n cmd << xfrm.path # output\n end\n end\n end\n end", "def resize_image(img, size)\n size = size.first if size.is_a?(Array) && size.length == 1 && !size.first.is_a?(Fixnum)\n if size.is_a?(Fixnum) || (size.is_a?(Array) && size.first.is_a?(Fixnum))\n size = [size, size] if size.is_a?(Fixnum)\n img.thumbnail!(*size)\n elsif size.is_a?(String) && size =~ /^c.*$/ # Image cropping - example geometry string: c75x75\n dimensions = size[1..size.size].split(\"x\")\n img.crop_resized!(dimensions[0].to_i, dimensions[1].to_i)\n elsif size.is_a?(String) && size =~ /^b.*$/ # Resize w/border - example geometry string: b75x75\n dimensions = size[1..size.size].split(\"x\")\n img.change_geometry(dimensions.join(\"x\")) do |cols, rows, image|\n image.resize!(cols<1 ? 1 : cols, rows<1 ? 1 : rows )\n end\n img.background_color = \"black\"\n x_offset = (img.columns - dimensions[0].to_i) / 2\n y_offset = (img.rows - dimensions[1].to_i) / 2\n img = img.extent(dimensions[0].to_i, dimensions[1].to_i, x_offset, y_offset)\n else\n img.change_geometry(size.to_s) { |cols, rows, image| image.resize!(cols<1 ? 1 : cols, rows<1 ? 1 : rows) }\n end\n img.strip! unless attachment_options[:keep_profile]\n temp_paths.unshift write_to_temp_file(img.to_blob)\n end", "def check_and_resize_images(path)\n # We don't want to modify the path so create\n # a temporary glob path and retain the original\n #\n # Just a simple hack to allow us to pass `path` to\n # the resize! method at the end of this method.\n glob_path = path\n glob_path += '/**/*'\n\n # Check the images before including the extensions\n # into the extensions attribute\n Dir.glob(glob_path) do |img|\n if image?(img)\n # get the extension of the file and making sure it is\n # included in the formats we have required to be valid\n ext = File.extname(img).gsub('.', '').downcase\n\n # This could be improved\n if VALID_FORMATS.map { |format| format.downcase }.include?(ext)\n extension = { name: ext }\n self.extensions << extension unless self.extensions.include?(extension)\n end\n end\n end\n\n # only resize if there are any files\n resize!(path) unless extensions.empty?\n end", "def resize_retina_image(image_filename)\n \n image_name = File.basename(image_filename)\n \n image = Magick::Image.read(image_filename).first # Read the image\n new_image = image.scale(SCALE_BY)\n \n if new_image.write(image_filename) # Overwrite image file\n puts \"Resizing Image (#{SCALE_BY}): #{image_name}\"\n else\n puts \"Error: Couldn't resize image #{image_name}\"\n end\n \nend", "def img_resize( dat, w, h, options = {} )\n quality = options[:quality]\n format = options[:format]\n\n begin\n img = GD2::Image.load(dat)\n if h == 0\n h = ( w / img.aspect ).to_i\n end\n\n puts \"resizing image… width: #{w}, height: #{h}, quality: #{quality}\" if $debug\n\n # make sure it doesn't upscale image\n res = img.size\n\n if res[0] < w and res[1] < h\n w = res[0]\n h = res[1]\n elsif res[0] < w\n w = res[0]\n h = (w / img.aspect).to_i\n elsif res[1] < h\n h = res[1]\n w = (h / img.aspect).to_i\n end\n\n nimg = img.resize( w, h )\n\n if img_type(dat) == :jpeg and quality\n nimg.jpeg( quality.to_i )\n else\n case img_type(dat)\n when :png\n nimg.png\n when :jpeg\n nimg.jpeg\n when :gif\n nimg.gif\n else\n raise 'img_resize(), unknown output format'\n end\n end\n rescue => errmsg\n puts \"error: resize failed. #{w} #{h} #{quality}\"\n p errmsg\n return nil\n end\nend", "def resize(path, image, size)\n Rails.logger.warn \"resize method\"\n return false if size.split('x').count!=2\n Rails.logger.warn \"before File.exists? check: #{size.split('x').count}\"\n return false if !File.exists?(File.join(path))\n\n Rails.logger.warn \"before mkdir: #{path}/#{id}\"\n FileUtils.mkdir_p \"#{path}/thumbnails/#{id}\" if !File.exists?(File.join(path, 'thumbnails', id.to_s))\n\n image_original_path = \"#{path}/#{image}\"\n image_resized_path = \"#{path}/thumbnails/#{id}/#{size}_#{image}\"\n\n width = size.split('x')[0]\n height = size.split('x')[1]\n\n Rails.logger.warn \"Magick::Image.read(#{image_original_path})\"\n begin\n i = Magick::Image.read(image_original_path).first\n Rails.logger.warn \"before i.resize_to_fit\"\n i.resize_to_fit(width.to_i,height.to_i).write(image_resized_path)\n rescue Exception => e\n Rails.logger.error e\n end\n\n true\n end", "def resize_image(params)\n # The path of the image\n path = \"public/images/#{params[1]}/#{@tempo.id}_#{params[1]}.#{params[0]}\"\n # Read the image\n img = Magick::Image.read(\"public/images/original/#{@original_image_name}\").first\n # Resize and Crop the image\n target = Magick::Image.new(params[2], params[3])\n thumb = img.resize_to_fill!(params[2], params[3])\n target.composite(thumb, Magick::CenterGravity, Magick::CopyCompositeOp).write(path)\n # Insert the width and height into an object\n @tempo.width, @tempo.height = \"#{params[2]}\", \"#{params[3]}\"\n # Add the link and tags to its DB\n add_linkID_tagsID(path,params[1])\n # Delete the image after uploading it to the storage\n File.delete(path)\n end", "def resize\n @image.resize \"#{@placement[:a]}x#{OUTER}\\!\"\n end", "def resize_and_optimize(width, height)\n manipulate! do |img|\n img.format(\"jpg\") do |c|\n c.quality \"70\"\n c.resize \"#{width}x#{height}\"\n end\n\n img\n end\n end", "def large_process\n case [model.attachable_type, model.image_type]\n when ['User', 'avatar'] then\n resize_to_fill 1024, 683 # 3x2\n when ['User', 'inspiration'] then\n resize_to_fit 1024, 9999 # fixed width\n when ['Message', 'avatar'] then\n resize_to_fit 1024, 9999 # fixed width\n when ['Message', 'alternate'] then\n resize_to_fit 1024, 9999 # fixed width\n when ['Alternative', 'avatar'] then\n resize_to_fill 1024, 683 # 3x2\n else\n resize_to_fit 1024, 9999 # fixed width\n end\n # TODO: Test and implement this.\n # fix_exif_rotation\n quality 70\n end", "def calcImgSizes(res, file, maxheight, maxwidth, grid)\n myres = res.to_f\n myheight = `identify -format \"%h\" \"#{file}\"`\n myheight = myheight.to_f\n myheightininches = (myheight / myres)\n mywidth = `identify -format \"%w\" \"#{file}\"`\n mywidth = mywidth.to_f\n mywidthininches = (mywidth / myres)\n # if current height or width exceeds max, resize to max, proportionately\n if mywidthininches > maxwidth or myheightininches > maxheight then\n targetheight = maxheight * myres\n targetwidth = maxwidth * myres\n `convert \"#{file}\" -density #{myres} -resize \"#{targetwidth}x#{targetheight}>\" -quality 100 \"#{file}\"`\n end\n myheight = `identify -format \"%h\" \"#{file}\"`\n myheight = myheight.to_f\n myheightininches = (myheight / myres)\n mymultiple = ((myheight / myres) * 72.0) / grid\n if mymultiple <= 1\n resizecmd = \"\"\n else\n newheight = ((mymultiple.floor * grid) / 72.0) * myres\n resizecmd = \"-resize \\\"x#{newheight}\\\" \"\n end\n return resizecmd\nrescue => e\n return \"error method calcImgSize: #{e}\"\nend", "def set_original\n if keep_original\n if size_o.blank?\n image = MiniMagick::Image.open(name)\n self.size_o = \"#{image.width}x#{image.height}\"\n end\n else\n self.size_o = ''\n end\nend", "def rename_image_files(old_name)\n [ :original , :medium , :thumb ].each do |size|\n old_path = ImagesModule.image_path_for_basename(old_name, size, true)\n if old_path\n extension = File.extname(old_path)\n new_path = image_path(size, true, extension)\n FileUtils.mv(old_path, new_path) if old_path != new_path\n end\n end\n end", "def img_name_size(file, size)\n return file.sub(\"_300\", \"_#{size}\")\n end", "def resize_all(size_constraint)\n require 'rmagick'\n\n Dir.new('.').each do |f|\n if f.match(/jpg/)\n if (i = Magick::Image.read(f).first)\n i.resize_to_fit!(size_constraint)\n i.write(f)\n end\n end\n end\nend", "def resize_image uri, options = { }\n\n\t# parse id, mime type from image uri\n\tformat = uri.split('/').last.match(/\\.(.+)$/)[1]\n\tid = uri.split('/').last.sub(/\\..+$/, '').slugify\n\n\t# resize image and save to /tmp\n\timage = Image.read(uri)[0]\n\t\n\t# calculate width/height based on percentage of \n\t# difference of width from absolute value of 150\n\tif options[:width]\n\t\twidth = options[:width]\n\t\tscale = (image.page.width - width) / image.page.width.to_f\n\t\theight = image.page.height - (image.page.height * scale)\n\n\t\timage = image.thumbnail(width, height)\n\t\timage.write(\n\t\t\tpath = \"/tmp/#{id}-constrainedw.#{format}\"\n\t\t)\t\t\n\n\telsif options[:height]\n\t\theight = options[:height]\n\t\tscale = (image.page.height - height) / image.page.height.to_f\n\t\twidth = image.page.width - (image.page.width * scale)\n\n\t\timage = image.thumbnail(width, height)\n\t\timage.write(\n\t\t\tpath = \"/tmp/#{id}-thumbh.#{format}\"\n\t\t)\n\n\telse\n\t\twidth = 150\n\t\tscale = (image.page.width - width) / image.page.width.to_f\n\t\theight = image.page.height - (image.page.height * scale)\n\n\t\timage = image.thumbnail(width, height)\n\t\timage.write(\n\t\t\tpath = \"/tmp/#{id}-thumb.#{format}\"\n\t\t)\n\n\tend\n\n path\nend", "def fix_exif_rotation\n return unless self.file.content_type.start_with? 'image'\n \n manipulate! do |img|\n img.tap(&:auto_orient)\n img = yield(img) if block_given?\n img\n end\n end", "def resizeImage(file, size)\n img_orig = Magick::Image.read(\"public/#{file}\").first\n \n width = img_orig.columns\n height = img_orig.rows\n \n if(width > size || height > size)\n if(width > height)\n height = size * height / width\n width = size\n else\n width = size * height / width\n height = size\n end\n \n img = img_orig.resize_to_fit(width, height)\n \n img.write(\"public/#{file}\")\n end\n end", "def resize_image(img, size)\n img.delete_profile('*')\n\n # resize_image take size in a number of formats, we just want\n # Strings in the form of \"crop: WxH\"\n if (size.is_a?(String) && size =~ /^crop: (\\d*)x(\\d*)/i) ||\n (size.is_a?(Array) && size.first.is_a?(String) &&\n size.first =~ /^crop: (\\d*)x(\\d*)/i)\n img.crop_resized!($1.to_i, $2.to_i)\n # We need to save the resized image in the same way the\n # orignal does.\n quality = img.format.to_s[/JPEG/] && get_jpeg_quality\n out_file = write_to_temp_file(img.to_blob { self.quality = quality if quality })\n self.temp_paths.unshift out_file\n else\n old_resize_image(img, size) # Otherwise let attachment_fu handle it\n end\n end", "def process_image(src, dest, maxw, maxh)\n i = QuickMagick::Image.read(src).first\n # AMF - added quality setting to limit size of images (some sites had high quality jpeg, so files sizes were still big)\n i.quality = 75\n w, h = i.width, i.height\n extra = (w - h/(maxh.to_f/maxw.to_f)).to_i\n if extra > 0\n i.shave(\"#{extra>>1}x0\") if i.width > i.height\n w -= extra\n end\n if w > maxw or h > maxh\n i.resize(\"#{maxw}x#{maxh}\")\n end\n i.save(dest)\n end", "def resize_image(img, size)\n size = size.first if size.is_a?(Array) && size.length == 1\n if size.is_a?(Fixnum) || (size.is_a?(Array) && size.first.is_a?(Fixnum))\n if size.is_a?(Fixnum)\n # Borrowed from image science's #thumbnail method and adapted \n # for this.\n scale = size.to_f / (img.width > img.height ? img.width.to_f : img.height.to_f)\n img.resize!((img.width * scale).round(1), (img.height * scale).round(1), false)\n else\n img.resize!(size.first, size.last, false) \n end\n else\n w, h = [img.width, img.height] / size.to_s\n img.resize!(w, h, false)\n end\n temp_paths.unshift random_tempfile_filename\n self.size = img.export(self.temp_path)\n end", "def resizeImage(imageName)\n image = MiniMagick::Image.open(imageName)\n height = image.height\n width = image.width\n\n if height > width\n ratio = 128.0 / height\n reHeight = (height * ratio).floor\n reWidth = (width * ratio).floor\n else\n ratio = 128.0 / width\n reHeight = (height * ratio).floor\n reWidth = (width * ratio).floor\n end\n\n image.resize(\"#{reHeight} x #{reWidth}\")\n image.write(\"resize.jpg\")\n end", "def process_image(path)\n picture_name = File.basename(path)\n thumbnail_dir = File.join(File.dirname(path), \"thumbnails\")\n thumbnail_path = File.join(thumbnail_dir, \"#{File.basename(picture_name, File.extname(picture_name))}.jpg\")\n Dir.mkdir(thumbnail_dir) unless File.exist?(thumbnail_dir)\n\n image_optim = ImageOptim.new\n\n image = MiniMagick::Image.open(path)\n image_prop = {\n \"name\" => picture_name,\n \"thumb\" => \"thumbnails/#{picture_name}\",\n \"height\" => image.height,\n \"width\" => image.width\n }\n\n return image_prop if File.exist?(thumbnail_path)\n\n# -sampling-factor 4:2:0 -strip -quality 85 -interlace JPEG -colorspace RGB\n\n image.format \"jpeg\" unless File.extname(picture_name) == \"jpg\"\n image.combine_options do |b|\n b.resize \"#{MAX_DIMENSION}>\"\n b.sampling_factor \"4:2:0\"\n b.strip\n b.interlace \"JPEG\"\n b.colorspace \"RGB\"\n b.quality 85\n end\n image.write thumbnail_path\n\n image_optim.optimize_image!(path)\n image_optim.optimize_image!(thumbnail_path)\n\n image_prop\nend", "def find_and_resize!(path)\n check_and_resize_images(path)\n end", "def resize(path)\n img = MiniMagick::Image.open(@file)\n img.combine_options do |c|\n c.quality @options[:quality] if @options[:quality]\n c.resize \"#{@width}x#{@height}>\"\n end\n\n img.write(path)\n end", "def capture_size_before_cache(new_file) \n if model.image_width.nil? || model.image_height.nil?\n model.image_width, model.image_height = `identify -format \"%wx %h\" #{new_file.path}`.split(/x/).map { |dim| dim.to_i }\n end\n end", "def process_images(dir)\n pattern = File.join(\"**\", dir, \"*.png\")\n files = Dir.glob(pattern)\n files.each do |f|\n unless f.include?(IMG_THUMB) || f.include?(IMG_FINAL)\n puts \"Converting image #{f}\"\n f2 = f.gsub /.png/, ''\n # thumbs\n system \"convert #{f} -resize #{IMG_THUMB_SIZE}^ -extent #{IMG_THUMB_SIZE} #{f2}#{IMG_THUMB}.png\" unless File.exists?(\"#{f2}#{IMG_THUMB}.png\")\n # final\n system \"convert #{f} -resize #{IMG_SIZE} #{f2}#{IMG_FINAL}.png\" unless File.exists?(\"#{f2}#{IMG_FINAL}.png\") \n end\n end\nend", "def resize(path)\n gravity = @options.key?(:gravity) ? @options[:gravity] : 'Center'\n\n img = MiniMagick::Image.open(@file)\n cols, rows = img[:dimensions]\n\n img.combine_options do |cmd|\n if @width != cols || @height != rows\n scale_x = @width/cols.to_f\n scale_y = @height/rows.to_f\n\n if scale_x >= scale_y\n cols = (scale_x * (cols + 0.5)).round\n rows = (scale_x * (rows + 0.5)).round\n cmd.resize \"#{cols}\"\n else\n cols = (scale_y * (cols + 0.5)).round\n rows = (scale_y * (rows + 0.5)).round\n cmd.resize \"x#{rows}\"\n end\n end\n\n cmd.quality @options[:quality] if @options.key?(:quality)\n cmd.gravity gravity\n cmd.background 'rgba(255,255,255,0.0)'\n cmd.extent \"#{@width}x#{@height}\" if cols != @width || rows != @height\n end\n\n img.write(path)\n end", "def process_small_image\n small_image.encode!(:png).convert!('-resize 50x50 -gravity center -background none -extent 50x50')\n end", "def save_image_dimensions\n if data.content_type == \"image/jpeg\" || \"image/png\" || \"image/jpg\" || \"image/gif\"\n geo = Paperclip::Geometry.from_file(data.queued_for_write[:original])\n self.width = geo.width\n self.height = geo.height\n end\n end", "def autosize(img_pub_path, opts)\n if opts[:maxwidth]\n if opts[:exact]\n width_opts = \"w#{opts[:maxwidth]}\"\n else\n width_opts = \"mxw#{opts[:maxwidth]}\"\n end\n else\n width_opts = \"wa\"\n end\n\n if opts[:maxheight]\n if opts[:exact]\n height_opts = \"h#{opts[:maxheight]}\"\n else\n height_opts = \"mxh#{opts[:maxheight]}\"\n end\n else\n height_opts = \"ha\"\n end\n\n ext = rescue_me(\".jpg\"){ img_pub_path[img_pub_path.rindex(\".\")..-1] }\n img_fixed_pub_path = \"#{img_pub_path}.#{width_opts}.#{height_opts}#{ext}\"\n\n img_priv_path = \"public#{img_pub_path}\"\n img_fixed_priv_path = \"public#{img_fixed_pub_path}\"\n\n unless File.exists?(img_fixed_priv_path)\n if(File.exists?(img_priv_path))\n begin\n img = MiniMagick::Image.from_file(img_priv_path)\n img.resize \"#{opts[:maxwidth]}x#{opts[:maxheight]}\"\n img.write img_fixed_priv_path\n rescue\n logger.error(\"Error writing image auto-resize: #{img_fixed_priv_path}: #{$!}\")\n end\n else\n logger.error(\"File does not exist: #{img_priv_path}\")\n end\n end\n\n return img_fixed_pub_path\n end", "def change_size(size)\n return false if size == current_image_size\n\n if size == 'auto'\n new_column, new_row, new_extra_lines = working_article.calculate_fitting_image_size(column, row, extra_height_in_lines)\n if column == new_column && row == new_row && extra_height_in_lines == new_extra_lines\n return false\n end\n\n self.column = new_column\n self.row = new_row\n self.extra_height_in_lines = new_extra_lines\n save\n true\n elsif size.include?('x')\n size_array = size.split('x')\n self.column = size_array[0].to_i\n self.row = size_array[1].to_i\n save\n true\n else\n puts 'wrong size format!!!'\n return false\n end\n end", "def store_image_dimensions_for_cropping\n save_attached_files # make sure Paperclip stores the files before this callback is executed\n if file.exists?\n img = ThumbMagick::Image.new(file.path('tocrop'))\n w,h = img.dimensions\n self.resize = 1\n self.crop_w = w\n self.crop_h = h\n self.crop_x = self.crop_y = 0\n save_without_versioning\n latest_version.update_attributes(:resize => resize, :crop_w => crop_w, :crop_h => crop_h, :crop_x => 0, :crop_y => 0)\n end\n end", "def small(input) # Method that returns the image\n self.images[input].variant(resize: \"300x300\").processed # Resizing the image and return it\n end", "def uploadoriginal(file,path)\n\text = File.extname(file)\n \tif ext.upcase == \".JPG\"\n \t\textfinal = \".jpg\"\n \telsif ext.upcase == \".JPEG\"\n \t\textfinal = \".jpg\"\n \telsif ext.upcase == \".GIF\"\n \t\textfinal = \".gif\"\n \telsif ext.upcase == \".PNG\"\n \t\textfinal = \".png\"\n \tend\t\n\t\t\n\t\t\n \t#nombre original de la imagen\n \tfilename_orig = File.basename(file, '.*')\n\n \t#remove white space in image name\n \tfilename_orig = filename_orig.gsub(\" \",\"-\")\n\n \twidth = 800\n\n \timage = Magick::Image.read(file).first\n\n \twidthimage = image.columns\n \theightimage = image.rows\n \theight = (width * heightimage) / widthimage\n \tthumbnail = image.thumbnail(width, height)\n\n\n \tfinalname = path + \"800-\" + filename_orig + extfinal\n \tq=99\n \tthumbnail.write(finalname){ self.quality = q }\n return filename_orig + extfinal\n \nend", "def check_for_resize; end", "def dynamic_resize_to_fit(size)\n resize_to_fit *(model.class::IMAGE_CONFIG[size])\n end", "def resize_and_save!(height = MAX_HEIGHT, width = MAX_WIDTH, validate = true)\n #KS- Only do thumbnailing if the Image Magick library can be loaded.\n # This is to make setup easier for other developers- they are not\n # required to have Image Magick.\n # More information on Image Magick is available at \n # http://studio.imagemagick.org/RMagick/doc/usage.html\n if RMAGICK_SUPPORTED\n #MES- Turn the blob into an ImageMagick object\n img = Magick::Image.from_blob(data).first\n if img.nil?\n logger.info \"Failed to resize image #{self.name}- unable to create RMagick wrapper for image\"\n return nil\n end\n \n #MES- Shrink the image\n self.data = img.change_geometry(\"#{MAX_WIDTH}x#{MAX_HEIGHT}\"){ |cols, rows, img| \n if img.rows > rows || img.columns > cols\n img.resize!(cols, rows)\n else\n img\n end\n }.to_blob\n end\n \n successful = save_with_validation(validate)\n raise \"Error: picture #{self.id} not saved properly\" if !successful\n end", "def resize_image(content, content_type, size)\n filename = \"/tmp/\" + (1 + rand(10000000)).to_s + \".\" + content_type\n filename_resized = \"/tmp/\" + (1 + rand(10000000)).to_s + \"_resized.\" + content_type\n File.open(filename, 'w') do |f|\n f.write( content)\n end\n result = %x[sips --resampleWidth #{size} #{filename} --out #{filename_resized}]\n content_resized = IO.readlines(filename_resized,'r').to_s\n return content_resized\nend", "def resize_to_fit width, height\n manipulate! do |image|\n cols = image.width\n rows = image.height\n\n if width != cols or height != rows\n scale = [width/cols.to_f, height/rows.to_f].min\n cols = (scale * (cols + 0.5)).round\n rows = (scale * (rows + 0.5)).round\n image.resize cols, rows do |img|\n yield(img) if block_given?\n img.save current_path\n end\n end\n end\n end", "def convert(filename)\n\n uuid = UUID.timestamp_create().to_s22\n\n source_file = Rails.root.join(DIRECTORY, \"#{uuid}_#{filename}\")\n full_size_image_file = Rails.root.join(DIRECTORY, \"#{uuid}_full_image.jpg\")\n large_thumbnail_file = Rails.root.join(DIRECTORY, \"#{uuid}_large_thumb_image.jpg\")\n small_thumbnail_file = Rails.root.join(DIRECTORY, \"#{uuid}_small_thumb_image.jpg\")\n\n # Write the source file to directory.\n f = File.new(source_file, \"wb\")\n f.write(self.raw_data)\n f.close\n\n # Use RMagick to resize the source file to the size defined by FULL_IMAGE_SIZE\n # and write the result to full_size_image_file\n full_size = Magick::Image.read(source_file).first\n full_size.change_geometry(FULL_IMAGE_SIZE) { |cols, rows, img|\n img.resize!(cols, rows)\n }\n full_size.write(full_size_image_file)\n\n # Use RMagick to resize the source file to the size defined by LARGE_THUMB_SIZE\n # and write the result to large_thumbnail_file\n large_thumb = Magick::Image.read(source_file).first\n large_thumb.change_geometry(LARGE_THUMB_SIZE) { |cols, rows, img|\n img.resize!(cols, rows)\n }\n large_thumb.write(large_thumbnail_file)\n\n # Make a thumbnail using RMagick. Thumbnail is created by cutting as big as possible\n # square-shaped piece from the center of the image and then resizing it to 50x50px.\n small_thumb = Magick::Image.read(source_file).first\n small_thumb.crop_resized!(SMALL_THUMB_WIDTH, SMALL_THUMB_HEIGHT, Magick::NorthGravity)\n small_thumb.write(small_thumbnail_file)\n\n # All conversions must succeed, else it's an error, probably because image file\n # is somehow corrupted.\n unless File.exists?(full_size_image_file) and File.exists?(large_thumbnail_file) and File.exists?(small_thumbnail_file)\n errors.add(:base, \"File upload failed. Image file is probably corrupted.\")\n return false\n end\n\n # Write new images to database and then delete image files.\n self.data = File.open(full_size_image_file,'rb').read\n File.delete(full_size_image_file)\n self.large_thumb = File.open(large_thumbnail_file,'rb').read\n File.delete(large_thumbnail_file)\n self.small_thumb = File.open(small_thumbnail_file,'rb').read\n File.delete(small_thumbnail_file)\n\n # Delete source file if it exists.\n File.delete(source_file)\n\n return true\n end", "def update_image_attributes\n if imageable.present?\n self.width, self.height = `identify -format \"%wx%h\" #{url.file.path}`.split(/x/)\n end\n end", "def processed_image\n if params[:upsample] == 'true'\n resize_string = @size.to_s\n else\n resize_string = \"#{@size}>\"\n end\n image_file = @picture.image_file\n if image_file.nil?\n raise MissingImageFileError, \"Missing image file for #{@picture.inspect}\"\n end\n if params[:crop_size].present? && params[:crop_from].present?\n crop_from = params[:crop_from].split('x')\n image_file = image_file.process(:thumb, \"#{params[:crop_size]}+#{crop_from[0]}+#{crop_from[1]}\")\n image_file.process(:resize, resize_string)\n elsif params[:crop] == 'crop' && @size.present?\n width, height = @size.split('x').collect(&:to_i)\n # prevent upscaling unless :upsample param is true\n # unfurtunally dragonfly does not handle this correctly while cropping\n unless params[:upsample] == 'true'\n if width > image_file.width\n width = image_file.width\n end\n if height > image_file.height\n height = image_file.height\n end\n end\n image_file.process(:resize_and_crop, :width => width, :height => height, :gravity => 'c')\n elsif @size.present?\n image_file.process(:resize, resize_string)\n else\n image_file\n end\n end", "def resize_to_fit(new_width, new_height)\n width, height = FastImage.size(self.current_path)\n width_ratio = new_width.to_f / width.to_f\n height_when_width_used = height * width_ratio\n if height_when_width_used <= new_height\n new_height = height_when_width_used\n else\n height_ratio = new_height.to_f / height.to_f\n new_width = width * height_ratio\n end\n FastImage.resize(self.current_path, self.current_path, new_width, new_height)\n end", "def setup_available_sizes(file)\n# ::Rails.logger.debug \"setup_available_sizes: #{file.path}\"\n# if model.original_image_width.nil? || model.original_image_height.nil?\n# \n# img = ::Magick::Image::read(@file.file).first\n# model.original_image_width = img.columns\n# model.original_image_height = img.rows\n# ::Rails.logger.debug \"setup w/h for validtaion #{img.columns}x#{img.rows}\"\n# end\n\n model.class::IMAGE_CONFIG.keys.each do |key|\n self.class_eval do\n define_method(\"has_#{key}_config?\".to_sym) { |file| true }\n end\n end\n end", "def resize_image(image, options = {})\n processor = ::RedArtisan::CoreImage::Processor.new(image)\n size = options[:size]\n size = size.first if size.is_a?(Array) && size.length == 1\n if size.is_a?(Fixnum) || (size.is_a?(Array) && size.first.is_a?(Fixnum))\n if size.is_a?(Fixnum)\n processor.fit(size)\n else\n processor.resize(size[0], size[1])\n end\n else\n new_size = get_image_size(image) / size.to_s\n processor.resize(new_size[0], new_size[1])\n end\n \n destination = options[:to] || @file\n AttachmentFu::Pixels::Image.new destination do |img|\n processor.render do |result|\n img.width, img.height = get_image_size(result)\n result.save destination, OSX::NSJPEGFileType\n end\n end\n end", "def check_and_correct_file_extension\n extension = File.extname(avatar_file_name).downcase\n self.avatar.instance_write(:file_name, \"#{avatar_file_name}.jpg\") if extension.blank?\n end", "def portrait(size)\n unless File.exists? \"#{RAILS_ROOT}/public/system/characters/#{self.id}_#{size.to_i}.jpg\"\n begin\n File.open(\"#{RAILS_ROOT}/public/system/characters/#{self.id}_256.jpg\",\"wb\") do |f|\n Net::HTTP.start(\"image.eveonline.com\") do |http|\n resp = http.get(\"/Character/#{self.id}_256.jpg\")\n f << resp.body\n end\n end\n # Now use MiniMagick to bake some 16/32 images from the larger source\n \n image = MiniMagick::Image.from_file(\"#{RAILS_ROOT}/public/system/characters/#{self.id}_256.jpg\")\n image.resize \"16x16\"\n image.write(\"#{RAILS_ROOT}/public/system/characters/#{self.id}_16.jpg\")\n \n image = MiniMagick::Image.from_file(\"#{RAILS_ROOT}/public/system/characters/#{self.id}_256.jpg\")\n image.resize \"32x32\"\n image.write(\"#{RAILS_ROOT}/public/system/characters/#{self.id}_32.jpg\")\n \n image = MiniMagick::Image.from_file(\"#{RAILS_ROOT}/public/system/characters/#{self.id}_256.jpg\")\n image.resize \"64x64\"\n image.write(\"#{RAILS_ROOT}/public/system/characters/#{self.id}_64.jpg\")\n rescue\n return \"/images/logo_not_found_#{size}.jpg\"\n end\n end\n return \"/system/characters/#{self.id}_#{size.to_i}.jpg\"\n end", "def set_image_size(file = local_file_name(:full_size))\n w, h = FastImage.size(file)\n return unless /^\\d+$/.match?(w.to_s)\n\n self.width = w.to_i\n self.height = h.to_i\n save_without_our_callbacks\n end", "def my_resize(width, height)\n manipulate! do |img|\n img.resize \"#{width}x#{height}!\"\n img\n end\n end", "def resize_and_crop(size) \n manipulate! do |image| \n if image[:width] < image[:height]\n remove = (image[:height] - 135).round \n image.shave(\"0x#{remove}\") \n elsif image[:width] > image[:height] \n remove = ((image[:width] - image[:height])/2).round\n image.shave(\"#{remove}x0\")\n end\n image.resize(\"#{size}\")\n image\n end\n end", "def upRes(file_path)\t\n\t\toriginal_image = Magick::Image.read(file_path) { self.density = \"300.0x300.0\" }\n\t\toriginal_image.each do |image|\n\t\t\t image = image.resample(300.0, 300.0)\n\t\t\t image.write(file_path) { self.quality = 100 }\n\t\tend\n\tend", "def fix_exif_rotation\n manipulate! do |img|\n img.auto_orient\n img = yield(img) if block_given?\n img\n end\n end", "def resize_and_crop(size)\n manipulate! do |image|\n Rails.logger.error '----------- image:'\n Rails.logger.error image.inspect\n\n if image[:width] < image[:height]\n remove = ((image[:height] - image[:width]) / 2).round\n image.shave(\"0x#{remove}\")\n elsif image[:width] > image[:height]\n remove = ((image[:width] - image[:height]) / 2).round\n image.shave(\"#{remove}x0\")\n end\n image.resize(\"#{size}x#{size}\")\n image\n end\n end", "def fix_exif_rotation\n manipulate! do |img|\n img.auto_orient\n img = yield(img) if block_given?\n img\n end\n end", "def fix_exif_rotation\n manipulate! do |img|\n img.auto_orient\n img = yield(img) if block_given?\n img\n end\n end", "def resize_image(download_path, resize_path, height, width, crop)\n `convert #{download_path.inspect} -resize \"#{height}x#{width}\" #{resize_path.inspect}`\n end", "def fix_exif_rotation\n manipulate! do |img|\n img.tap(&:auto_orient)\n end\n end", "def rename old,new,params=nil\n a = self.image(old)\n return nil if a.nil?\n b = self.image(new)\n if !b.nil?\n raise 'Error #3 ' + @@errors[3] if !params || !params[:force]\n delete b[:original]\n end\n self.store absolute(a[:original]),:name => new\n a[:widths].each do |w|\n self.fetch new , :width => w\n end\n a[:heights].each do |w|\n self.fetch new , :height => w\n end\n delete a[:original]\n end", "def proper_image_sequence_format\n if not image_sequence =~ /\\.mha\\z/\n errors.add(:image_sequence, \"must be in .mha format currently\")\n end\n end", "def process_image#:doc:\n \n if !self.file || (self.file.respond_to?(:length) && self.file.length == 0)\n if new_record?\n raise 'No file.'\n else\n return true\n end\n end\n \n self.original_filename = self.file.original_filename if self.file.respond_to?(:original_filename)\n \n unless self.file.is_a?(Array)\n #Read image data from form\n begin\n original = ::Magick::ImageList.new.concat(\n ::Magick::Image.from_blob(\n self.file.read\n ).map{|im|\n im.strip!\n }\n )\n rescue\n raise 'Could not read image. Are you sure this is an image file?'\n end\n else#Image is already a Magick::ImageList\n original = self.file.is_a?(::Magick::ImageList) ? self.file : ::Magick::ImageList.new.concat(self.file)\n end\n \n #Scale/crop images\n begin\n #Will be a hash of [size, image] pairs, eg ['small', <Magick::ImageList>]\n scaled_images = sizes.map{|name,size|\n \n if size.is_a? Array\n if size.size > 1\n method = size[1].to_sym\n size = size[0]\n else\n method = :scale\n size = size[0]\n end\n end\n \n [\n name,\n original.collect{|im|\n im.change_geometry(size){|cols,rows,img|\n if method == :crop\n img.crop_resized(cols, rows, ::Magick::NorthWestGravity)\n else# method == :scale\n img.resize(cols, rows)\n end\n }\n }\n ]\n }\n rescue Exception\n raise 'Could not scale image.'\n end\n \n #Write scaled images to files\n #Should possibly combine with scaling to consume less memory\n begin\n FileUtils.mkdir_p(save_path_with_own_path)\n delete_files#Delete old files\n scaled_images.each{|pair|\n if pair.last.size > 1#Assume image is animated\n self.content_type = 'image/gif'\n pair.last.write(save_path_with_filename(pair.first))\n else\n self.content_type = 'image/jpeg'\n pair.last.first.write(save_path_with_filename(pair.first))\n end\n }\n rescue Exception\n raise 'Could not write image.'\n end\n rescue Exception => e\n self.errors.add('file', e.message)\n delete_files\n return false\n ensure\n #Throw RMagick stuff out of memory\n #TODO: Not sure this works the way I think it does\n self.file = nil\n scaled_images = nil\n GC.start\n end", "def resize_to_fill_and_save_dimensions(new_width, new_height)\n img = ::MiniMagick::Image.from_file(current_path)\n width, height = img['width'], img['height']\n \n resize_to_fill(new_width, new_height)\n \n w_ratio = width.to_f / new_width.to_f\n h_ratio = height.to_f / new_height.to_f\n \n ratio = [w_ratio, h_ratio].min\n \n model.send(\"#{mounted_as}_w=\", ratio * new_width)\n model.send(\"#{mounted_as}_h=\", ratio * new_height)\n model.send(\"#{mounted_as}_x=\", (width - model.send(\"#{mounted_as}_w\")) / 2)\n model.send(\"#{mounted_as}_y=\", (height - model.send(\"#{mounted_as}_h\")) / 2)\n end", "def convert_image\n i = 0 \n main = [small\t=\t[\"jpg\",\"small\",240,160], \n\t medium\t=\t[\"jpg\",\"medium\",640,427], \n\t large\t=\t[\"jpg\",\"large\",1024,683]]\n while i < main.count\n # Runs the resize function with params to each size\n resize_image(main[i])\n i +=1\n end\n end", "def transform!(metadata, vmcatcher_configuration)\n Itchy::Log.info \"[#{self.class.name}] Transforming image format \" \\\n \"for #{metadata.dc_identifier.inspect}\"\n\n image_file = orig_image_file(metadata, vmcatcher_configuration)\n\n unless File.file?(image_file)\n Itchy::Log.error \"[#{self.class.name}] Event image file - #{image_file}] - does not exist!\"\n fail Itchy::Errors::ImageTransformationError\n end\n\n begin\n if archived?(image_file)\n unpacking_dir = process_archive(metadata, vmcatcher_configuration)\n file_format = format(\"#{unpacking_dir}/#{metadata.dc_identifier}\")\n else\n file_format = format(image_file)\n unpacking_dir = copy_unpacked!(metadata, vmcatcher_configuration)\n end\n if file_format == @options.required_format\n new_file_name = copy_same_format(unpacking_dir, metadata)\n else\n converter = Itchy::FormatConverter.new(unpacking_dir, metadata, vmcatcher_configuration)\n new_file_name = converter.convert!(file_format, @options.required_format, @options.output_dir, @options.qemu_img_binary)\n end\n remove_dir(unpacking_dir)\n rescue Itchy::Errors::FileInspectError, Itchy::Errors::FormatConversionError,\n Itchy::Errors::PrepareEnvError => ex\n fail Itchy::Errors::ImageTransformationError, ex\n end\n new_file_name\n end", "def adjust_image tempfile\n image = MiniMagick::Image.read tempfile\n\n if options[:h] && options[:w]\n image.crop \"#{options[:w]}x#{options[:h]}+#{options[:x]}+#{options[:y]}\"\n image.write tempfile\n end\n\n image\n end", "def rmagik_info(file)\n puts \"- - - - - :rmagik-S\"\n puts file\n puts \">> Checking for oversized file > 430px wide\"\n img = Magick::Image::read(file).first\n puts \"Geometry: #{img.columns}x#{img.rows} - #{img.columns.class}x#{img.rows.class}\"\n\n if img.columns > 430 # resize to 430 wide\n \n scale = (430.0 / img.columns.to_f).round(6) # calculate scaling factor for image\n \n puts \"RESIZING before copying x#{scale}\"\n \n file_large = file.sub(File.extname(file), '_LRG.jpg') # copy to image_name_LRG.jpg\n FileUtils.cp( file, \"scratch/#{file_large}\")\n \n img_430 = img.scale(scale)\n \n img_430.write(file)\n \n end\n \n #img = Magick::Image::read(file).first\n #puts \" Format: #{img.format}\"\n #puts \" Geometry: #{img.columns}x#{img.rows}\"\n #puts \" Class: \" + case img.class_type\n # when Magick::DirectClass\n # \"DirectClass\"\n # when Magick::PseudoClass\n # \"PseudoClass\"\n # end\n #puts \" Depth: #{img.depth} bits-per-pixel\"\n #puts \" Colors: #{img.number_colors}\"\n #puts \" Filesize: #{img.filesize}\"\n #puts \" Resolution: #{img.x_resolution.to_i}x#{img.y_resolution.to_i} \"+\n # \"pixels/#{img.units == Magick::PixelsPerInchResolution ?\n # \"inch\" : \"centimeter\"}\"\n #if img.properties.length > 0\n # puts \" Properties:\"\n # img.properties { |name,value|\n # puts %Q| #{name} = \"#{value}\"|\n # }\n #end\n puts \"- - - - - :rmagik-E\"\nend", "def resize_and_write_file(filename, filename_output, max_width, max_height = nil)\n pic = Magick::Image.read(filename).first\n img_width, img_height = pic.columns, pic.rows\n ratio = img_width.to_f / max_width.to_f\n\n if max_height.nil?\n max_height = img_height / ratio\n end\n\n pic.change_geometry!(\"#{max_width}x#{max_height}>\") { |cols, rows, img|\n img.resize_to_fit!(cols, rows)\n img.write filename_output\n img.destroy!\n }\n\n nbytes, content = File.size(filename_output), nil\n File.open(filename_output, \"rb\") { |f| content = f.read nbytes }\n content\nend", "def picture_format\n extension_white_list = %w[jpg jpeg gif png]\n\n return unless picture.attached?\n return if extension_white_list.any? do |extension|\n picture.blob.content_type.starts_with?(\"image/#{extension}\")\n end\n\n picture.purge\n errors.add(:picture, \"は画像ファイルではありません\")\n end", "def extension\n (options[:convert_to] || 'jpg').to_s.downcase.gsub(\"jpeg\", \"jpg\")\n end", "def determine_whether_to_resize_image\n if label == :access && pdf? && format == \"pdf\"\n output_file = directives.fetch(:url).split('file:')[1]\n begin\n _stdin, _stdout, _stderr = popen3(\"cp #{source_path} #{output_file}\")\n rescue StandardError => e\n Rails.logger.error(\"#{self.class} copy error: #{e}\")\n end\n else\n create_resized_image\n end\n end", "def test_11a\r\n db = build\r\n assert_raise RuntimeError do\r\n db.rename 'image-1.jpg','image-2.jpg'\r\n end\r\n assert File.exists?(db.fetch('image-1.jpg' , :width => 30))\r\n assert File.exists?(db.fetch('image-2.jpg' , :width => 60))\r\n db.rename 'image-1.jpg','image-2.jpg',:force => true\r\n assert_nil db.fetch('image-1.jpg')\r\n assert File.exists?(db.absolute('image-2.jpg',\r\n :width => 30 ))\r\n assert_nil db.fetch('image-2.jpg',\r\n :width => 60,\r\n :resize => false)\r\n end", "def resize_to_limit(new_width, new_height)\n width, height = FastImage.size(self.current_path)\n if width > new_width || height > new_height\n resize_to_fit(new_width, new_height)\n end\n end", "def extname\n File.extname(image_src).delete('.') unless image_src.nil?\n end", "def optimize_for_pagespeed\n # according to https://developers.google.com/speed/docs/insights/OptimizeImages\n if self.file.content_type == 'image/jpeg'\n # convert orig.jpg -sampling-factor 4:2:0 -strip -quality 85 -interlace JPEG orig_converted.jpg\n manipulate! do |img|\n img.sampling_factor '4:2:0'\n img.strip\n img.quality 85\n img.interlace 'JPEG'\n img\n end\n else\n # convert cuppa.png -strip cuppa_converted.png\n manipulate! do |img|\n img.strip\n img\n end\n end\n end", "def update_asset_attributes\n if !self.external_service? and self.present? and self.changed?\n self.content_type = self.filename.file.content_type\n self.file_size = self.filename.file.size\n self.width, self.height = `identify -format \"%wx%h\" #{self.filename.file.path}`.split(/x/) unless self.document? or self.width? or self.height?\n self.ratio = self.width.to_f / self.height.to_f if self.width.present? and self.height.present?\n end\n end", "def resizeImages\n # For each of the 9 images\n for counter in (1..9)\n pngName = \"./images/\" + counter.to_s() + \".png\"\n image = Magick::Image.read(pngName).first\n # Make the new image 25% larger\n thumb = image.scale(1.25)\n thumb.write(pngName)\n end\n end", "def rmagick_resize(max_size=2048)\n OptionalGems.require('RMagick','rmagick') unless defined?(Magick)\n\n image = Magick::Image.read(file_path)[0]\n image.resize_to_fit!(max_size)\n image.format=\"JPG\"\n image.to_blob\n end", "def img_size(image_size, new_size)\n decrease = new_size.fdiv(image_size)\n return decrease\nend", "def update_file_size\n size = File.size(self.file_path)\n if !self.image_size? or self.image_size != size\n self.update_attributes({:image_size => size})\n end\n end", "def display_image\n image.variant resize_to_limit: Settings.validation.post.img_resize\n end", "def do_resize(height = THUMBNAIL_HEIGHT, width = THUMBNAIL_WIDTH)\n #MES- Only do thumbnailing if the Image Magick library can be loaded.\n # This is to make setup easier for other developers- they are not\n # required to have Image Magick.\n # More information on Image Magick is available at \n # http://studio.imagemagick.org/RMagick/doc/usage.html\n if RMAGICK_SUPPORTED\n #MES- Turn the blob into an ImageMagick object\n img = Magick::Image.from_blob(data).first\n if img.nil?\n logger.info \"Failed to resize image #{self.name}- unable to create RMagick wrapper for image\"\n return nil\n end\n \n #MES- Shrink the image\n return img.crop_resized(width, height)\n else\n return nil\n end\n end", "def resize_image\n image = params[:fleet][:image]\n return if image.nil?\n\n begin\n image = MiniMagick::Image.new(image.tempfile.path)\n image.resize '175x260>'\n rescue MiniMagick::Error\n # errors here will be caught in model validation\n end\n end", "def create_resized_image\n create_image do |xfrm|\n if size\n xfrm.flatten\n xfrm.resize(size)\n end\n end\n end", "def normalize(file_type)\n return @img_data if file_type == 'pdf'\n\n label_image = MiniMagick::Image.read(@img_data)\n label_image.combine_options do |img|\n img.rotate(90) if label_image.width > label_image.height\n img.rotate(180) if [:fedex].include?(@carrier)\n img.bordercolor('#ffffff')\n img.border('1x1')\n img.trim\n end\n\n @img_data = label_image.to_blob\n end", "def thumb\n @agency_logo = AgencyLogo.find(params[:id])\n respond_to do |format|\n format.jpg # thumb.jpg.flexi\n end\n end", "def conform( image )\n @logger.info( \"T #{Thread.current[:id]}: Conform image: #{ image }\" )\n return @asset_functions.create_asset( image, @output_format ) {|a| @output_type_obj.convert_resize_extent_color_specs( image, a )}\n end", "def maybe_convert_extension(ext); end", "def substrate_images\n Dir.chdir(\"source\") do\n allnames = Dir.glob(\"images/substrates/**/*\")\n filenames = allnames.select { |f| !File.directory?(f) }\n\n filenames.map do |f|\n basename = File.basename(f, File.extname(f))\n extra = nil\n # if identify_dimensions\n if false\n identify = `identify #{f}`\n dimensions = /\\d+x\\d+/.match(identify)[0]\n extra = dimensions\n else\n extra = \"\"\n end\n\n [ f, \"#{basename} #{extra}\" ]\n end\n end\n end", "def imagemagick?; end", "def convert(filename)\n\n uuid = UUID.timestamp_create().to_s22\n\n source_file = File.join(\"#{RAILS_ROOT}/#{DIRECTORY}\", \"#{uuid}_#{filename}\")\n full_size_image_file = File.join(\"#{RAILS_ROOT}/#{DIRECTORY}\", \"#{uuid}_full_image.jpg\")\n large_thumbnail_file = File.join(\"#{RAILS_ROOT}/#{DIRECTORY}\", \"#{uuid}_large_thumb_image.jpg\")\n small_thumbnail_file = File.join(\"#{RAILS_ROOT}/#{DIRECTORY}\", \"#{uuid}_small_thumb_image.jpg\")\n\n # Write the source file to directory.\n f = File.new(source_file, \"wb\")\n f.write(self.raw_data)\n f.close\n\n # Then resize the source file to the size defined by full_image_size parameter\n # and convert it to .jpg file. Resize uses ImageMagick directly from command line.\n img = system(\"#{'convert'} '#{source_file}' -resize #{FULL_IMAGE_SIZE} '#{full_size_image_file}' > #{RAILS_ROOT}/log/convert.log\")\n large_thumb = system(\"#{'convert'} '#{source_file}' -resize #{LARGE_THUMB_SIZE} '#{large_thumbnail_file}' > #{RAILS_ROOT}/log/convert.log\")\n\n # If new file exists, it means that the original file is a valid image file. If so,\n # make a thumbnail using RMagick. Thumbnail is created by cutting as big as possible\n # square-shaped piece from the center of the image and then resizing it to 50x50px.\n if img\n small_thumb = Magick::Image.read(source_file).first\n small_thumb.crop_resized!(SMALL_THUMB_WIDTH, SMALL_THUMB_HEIGHT, Magick::NorthGravity)\n small_thumb.write(small_thumbnail_file)\n end\n\n # Delete source file if it exists.\n File.delete(source_file) if File.exists?(source_file)\n\n # Both conversions must succeed, else it's an error, probably because image file\n # is somehow corrupted.\n unless img and large_thumb and small_thumb\n errors.add_to_base(\"File upload failed. Image file is probably corrupted.\")\n return false\n end\n\n # Write new images to database and then delete image files.\n self.data = File.open(full_size_image_file,'rb').read\n File.delete(full_size_image_file) if File.exists?(full_size_image_file)\n self.large_thumb = File.open(large_thumbnail_file,'rb').read\n File.delete(large_thumbnail_file) if File.exists?(large_thumbnail_file)\n self.small_thumb = File.open(small_thumbnail_file,'rb').read\n File.delete(small_thumbnail_file) if File.exists?(small_thumbnail_file)\n return true\n end", "def read_dimensions\n if image?\n if file = asset.queued_for_write[:original]\n geometry = Paperclip::Geometry.from_file(file)\n self.original_width = geometry.width\n self.original_height = geometry.height\n self.original_extension = File.extname(file.path)\n end\n end\n true\n end", "def make_responsive(img,type,width)\n [\n [\"-resize 'x#{width}>'\", \".webp\"],\n [\"-resize 'x#{width * 2}>'\", \"@2x.webp\"],\n ].each do |i|\n convert(type, img, i.first, i.last)\n end\nend" ]
[ "0.72622323", "0.70233345", "0.68927896", "0.6849576", "0.6684884", "0.64868003", "0.6485243", "0.6483435", "0.6455015", "0.6436636", "0.6432602", "0.6417946", "0.6406757", "0.6397087", "0.63838613", "0.63602746", "0.6323126", "0.63132304", "0.63073623", "0.62921274", "0.6248478", "0.6192455", "0.61806583", "0.61714137", "0.6160853", "0.6154143", "0.61445147", "0.61149883", "0.61128664", "0.6093441", "0.60758483", "0.6073849", "0.60687584", "0.604681", "0.6017247", "0.5966741", "0.5965205", "0.59625906", "0.5948752", "0.59474933", "0.5930995", "0.59259033", "0.59088445", "0.59057707", "0.58947176", "0.5889261", "0.5888386", "0.5875011", "0.5854539", "0.584409", "0.584294", "0.58271396", "0.5823245", "0.5820522", "0.58195674", "0.58188987", "0.57692957", "0.5764325", "0.57620823", "0.5761577", "0.5757104", "0.57534534", "0.5753044", "0.57528543", "0.5752439", "0.5751016", "0.5745843", "0.5744091", "0.5743895", "0.573631", "0.57215977", "0.5712053", "0.5711866", "0.5710517", "0.57063276", "0.5691185", "0.56886256", "0.56863946", "0.5684504", "0.5671572", "0.5670737", "0.56630045", "0.56591743", "0.5652217", "0.56466085", "0.5643687", "0.56161326", "0.5613654", "0.56039673", "0.5599715", "0.5595135", "0.55750346", "0.55621207", "0.555968", "0.5548474", "0.5538993", "0.55384564", "0.55379987", "0.5532706", "0.5530852" ]
0.6043332
34
scale = original_iamge[:width].to_f / image_on_screen[:width].to_f usually scale should be 1
def crop image, x0 = 0, y0 = 0, w = 100, h = 100, scale = 1 x0 = (x0.to_f * scale).to_i y0 = (y0.to_f * scale).to_i w = (w.to_f * scale).to_i h = (h.to_f * scale).to_i image.crop "#{ w }x#{ h }+#{ x0 }+#{ y0 }" image end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scale_by_pixels(dimensions)\n out_pixels = sqrt(options[:width] * options[:height]).truncate\n src_pixels = sqrt(dimensions[0] * dimensions[1]).truncate\n out_pixels / src_pixels.to_f\n end", "def GetImageScale()\n\t\treturn @img_scale;\n\tend", "def fullwidth\n return self.bitmap.width.to_f * self.zoom_x\n end", "def scale\n scale_factor = 20 # template.png height divided by canvas height\n self.image_x *= scale_factor\n self.image_y *= scale_factor\n self.height *= scale_factor\n self.width *= scale_factor\n self.rotation *= 180 / Math::PI\n end", "def scale\n @photo = Photo.find(params[:id])\n img = Magick::Image.read('public' + @photo.attachment_url).first\n img = img.scale(1.5)\n img.write('public' + @photo.attachment_url)\n end", "def hscale(factor)\n @width *= factor\n @left *= factor\n self\n end", "def scale(value)\r\n value * @height/2 + @height/4\r\n end", "def scale_factor(point, view)\n\n px_to_length(view)/view.pixels_to_model(1, point)\n\n end", "def scaling\n @scaling || 0.0\n end", "def scale\n self['scale']\n end", "def medium_width\n width * medium_height / height\n end", "def resize_ratio_for asset\n base_geo = asset.geometry(:base_to_crop)\n original_geo = asset.geometry\n # Returning the biggest size as the ratio will be more exact.\n field = base_geo.width > base_geo.height ? :width : :height\n #Ratio to original / base\n original_geo.send(field).to_f / base_geo.send(field).to_f\n end", "def scales\n \n end", "def img_size(image_size, new_size)\n decrease = new_size.fdiv(image_size)\n return decrease\nend", "def scale( value )\n ( value - @min ) / ( @max - @min )\n end", "def image_width\n end", "def small(input) # Method that returns the image\n self.images[input].variant(resize: \"300x300\").processed # Resizing the image and return it\n end", "def get_doc_scale w, h\n page_w, page_h = @current_page.size\n\n scale_x = w / page_w \n scale_y = h / page_h\n\n if scale_x > scale_y\n scale_y\n else\n scale_x\n end\n end", "def get_scaled_size(image, width_bound, height_bound)\n width_multiplier = 1.0 * width_bound / image.columns\n height_multiplier = 1.0 * height_bound / image.rows\n\n if image.rows * width_multiplier <= height_bound\n width_multiplier\n else\n height_multiplier\n end\n end", "def aspect_ratio\n return 'none' unless fixed_ratio?\n dims = fullsize_settings[:dimensions]\n dims[0].to_f / dims[1]\n end", "def scaleimage **opts\n Vips::Image.scale self, **opts\n end", "def image_width(image_width)\n end", "def scale(*args)\n r = Rect.new x, y, w, h\n r.resolution = r.resolution * Vector2[args.singularize]\n r\n end", "def scale\n @data['scale']\n end", "def scale_up(scale)\n self.side_length *= scale\n end", "def aspect_ratio(style_name=nil)\n style_name ||= reflection.default_style\n if style_name.equal?(:original)\n original_width = from_examination(:@original_width)\n original_height = from_examination(:@original_height)\n original_width.to_f / original_height\n else\n w, h = *dimensions(style_name)\n w.to_f / h\n end\n end", "def set_aspect_ratio\n @columns = 25\n @rows = 25\n base_image_columns = @base_image[\"%w\"].to_i\n base_image_rows = @base_image[\"%h\"].to_i\n\n if base_image_columns > base_image_rows\n @columns *= (base_image_columns / base_image_rows.to_f)\n @columns = @columns.round\n else\n @rows *= (base_image_rows / base_image_columns.to_f)\n @rows = @rows.round\n end\n end", "def SetImageScale(scale)\n\t\t@img_scale = scale;\n\tend", "def scaleTo2 (target_dims_meters)\n bb = Sketchup.active_model.bounds \n car_height = bb.depth\n min_mirror_z = 0.50 * car_height # mirrors are definitely higher than this\n\n adjusted_car_width = 0 # init with large number\n adjusted_car_min = 0\n for part in Sketchup.active_model.definitions\n max_corner = part.bounds.max\n min_corner = part.bounds.min\n # \"max_corner.z > 0\" -- a hack to remove some exhilary shit\n if max_corner.z > 0 and max_corner.z < bb.depth * min_mirror_z\n adjusted_car_width = [max_corner.y.to_m, adjusted_car_width].max\n #puts part.name, max_corner, adjusted_car_width\n adjusted_car_min = [min_corner.y.to_m, adjusted_car_min].min\n #puts part.name, max_corner, adjusted_car_width\n end\n end\n raise 'adjusted_car_width < 0' if adjusted_car_width == 0\n puts \"adjusted max: #{adjusted_car_width}, min: #{adjusted_car_min}\"\n #puts \"car_width: #{bb.height.to_m}, adjusted: #{adjusted_car_width}\"\n\n # here's what we want to have\n target_car_width = target_dims_meters[1]\n # we only use car width (y) as the most reliable (no extra stuff on sides)\n scale = target_car_width / adjusted_car_width\n origin = Geom::Point3d.new 0,0,0\n transform = Geom::Transformation.scaling origin, scale\n entities = Sketchup.active_model.entities\n #entities.transform_entities(transform, entities.to_a)\n\nend", "def scale(width: @image.width, height: @image.height,\n algorithm: 'bilineal') # bilinear, nearest_neighbor\n if algorithm == 'nearest_neighbor'\n Image.new(@image.resample_nearest_neighbor(width, height), path)\n else\n Image.new(@image.resample_bilinear(width, height), path)\n end\n end", "def scale( scale_x, scale_y = scale_x )\n dup.scale!(scale_x, scale_y)\n end", "def aspect_ratio; (@x/@y).abs; end", "def scale(factor_x, factor_y=factor_x, &rendering_code); end", "def large_image_width\n 850\n end", "def scale_within(new_size)\n target_size = SugarCube::CoreGraphics::Size(new_size)\n image_size = self.size\n\n if CGSizeEqualToSize(target_size, self.size)\n return self\n end\n\n width = image_size.width\n height = image_size.height\n\n target_width = target_size.width\n target_height = target_size.height\n\n width_factor = target_width / width\n height_factor = target_height / height\n\n if width_factor < height_factor\n scale_factor = width_factor\n else\n scale_factor = height_factor\n end\n\n if scale_factor == 1\n return self\n end\n\n scaled_size = CGSize.new(width * scale_factor, height * scale_factor)\n return scale_to(scaled_size)\n end", "def aspect\n width / height\n end", "def normalize\n resize(1.0)\n end", "def new_dimensions_for(orig_width, orig_height)\n new_width = orig_width\n new_height = orig_height\n\n case @flag\n when :percent\n scale_x = @width.zero? ? 100 : @width\n scale_y = @height.zero? ? @width : @height\n new_width = scale_x.to_f * (orig_width.to_f / 100.0)\n new_height = scale_y.to_f * (orig_height.to_f / 100.0)\n when :<, :>, nil\n scale_factor =\n if new_width.zero? || new_height.zero?\n 1.0\n else\n if @width.nonzero? && @height.nonzero?\n [@width.to_f / new_width.to_f, @height.to_f / new_height.to_f].min\n else\n @width.nonzero? ? (@width.to_f / new_width.to_f) : (@height.to_f / new_height.to_f)\n end\n end\n new_width = scale_factor * new_width.to_f\n new_height = scale_factor * new_height.to_f\n new_width = orig_width if @flag && orig_width.send(@flag, new_width)\n new_height = orig_height if @flag && orig_height.send(@flag, new_height)\n when :aspect\n new_width = @width unless @width.nil?\n new_height = @height unless @height.nil?\n end\n\n [new_width, new_height].collect! { |v| v.round }\n end", "def new_dimensions_for(orig_width, orig_height)\n new_width = orig_width\n new_height = orig_height\n\n case @flag\n when :percent\n scale_x = @width.zero? ? 100 : @width\n scale_y = @height.zero? ? @width : @height\n new_width = scale_x.to_f * (orig_width.to_f / 100.0)\n new_height = scale_y.to_f * (orig_height.to_f / 100.0)\n when :<, :>, nil\n scale_factor =\n if new_width.zero? || new_height.zero?\n 1.0\n else\n if @width.nonzero? && @height.nonzero?\n [@width.to_f / new_width.to_f, @height.to_f / new_height.to_f].min\n else\n @width.nonzero? ? (@width.to_f / new_width.to_f) : (@height.to_f / new_height.to_f)\n end\n end\n new_width = scale_factor * new_width.to_f\n new_height = scale_factor * new_height.to_f\n new_width = orig_width if @flag && orig_width.send(@flag, new_width)\n new_height = orig_height if @flag && orig_height.send(@flag, new_height)\n when :aspect\n new_width = @width unless @width.nil?\n new_height = @height unless @height.nil?\n end\n\n [new_width, new_height].collect! { |v| v.round }\n end", "def scale_image(preferred_width, preferred_height)\n # Retrieve the current height and width\n image_data = ActiveStorage::Analyzer::ImageAnalyzer.new(image).metadata\n new_width = image_data[:width]\n new_height = image_data[:height]\n\n # Adjust the width\n if new_width > preferred_width\n new_width = preferred_width\n new_height = (new_height * new_width) / image_data[:width]\n end\n\n # Adjust the height\n if new_height > preferred_height\n old_height = new_height\n new_height = preferred_height\n new_width = (new_width * new_height) / old_height\n end\n\n # Return the resized image\n image.variant(resize_to_limit: [new_width, new_height])\n end", "def scale(factor=0.75, quality: nil)\n \n read() do |img|\n \n img2 = img.scale(factor) \n write img2, quality\n \n end\n \n end", "def normalized_sizes(width, height)\n if width.to_i > @image.width\n width = @image.width\n end\n if height.to_i > @image.height\n height = @image.height\n end\n \"#{width}x#{height}\"\n end", "def normalize_x x\n (x.to_f + ((@width - @height) / @height) / 2) * @width / (@width/@height)\n end", "def scale(name)\n \n end", "def aspect_ratio\n height.to_f / width.to_f\n end", "def pixel_aspect_ratio\n pixel_width / pixel_height\n end", "def normalize\n normalization_factor = norm_2(self)\n return self if normalization_factor.zero?\n\n self.scale (1.0 / normalization_factor.to_f)\n end", "def set_ratio\n @ratio = $program.width.to_f / $program.height\n end", "def scale_to_fit_container( aspect, container_width, container_height )\n width, height = aspect.split( Optparser::ASPECT_CHOICE_CUSTOM_PREFIX ).last.split( 'x' ).collect{|x| x.to_f}\n factor = container_height / container_width > height / width ? container_width / width : container_height / height\n @logger.debug( \"Scaling factor to fit custom aspect ratio #{ width } x #{ height } in #{ @options.size } container: #{ factor }\" )\n width_scaled = width * factor\n height_scaled = height * factor\n return width_scaled.floor, height_scaled.floor\n end", "def update_zoom\n @effectus_old_zoom_x = @picture.zoom_x\n @effectus_old_zoom_y = @picture.zoom_y\n self.zoom_x = @effectus_old_zoom_x / 100.0\n self.zoom_y = @effectus_old_zoom_y / 100.0\n end", "def aspect\n width.to_f / height\n end", "def scale(key, value)\n (value - @smallest_seen_values[key]) / (@largest_seen_values[key] - @smallest_seen_values[key])\n end", "def calc_image_dimensions(desired_w, desired_h, actual_w, actual_h, scale = false)\n if scale\n wp = desired_w / actual_w.to_f\n hp = desired_h / actual_h.to_f\n\n if wp < hp\n width = actual_w * wp\n height = actual_h * wp\n else\n width = actual_w * hp\n height = actual_h * hp\n end\n else\n width = desired_w || actual_w\n height = desired_h || actual_h\n end\n return width.to_f, height.to_f\n end", "def scale= scale\n protected_use_method(MM::Scaling, :@scale, scale)\n end", "def scale(factor_x, factor_y, around_x, around_y, &rendering_code); end", "def scale_to(new_size)\n scale_to(new_size, background:nil)\n end", "def show\n maybe_update_aspect_ratio @image\n end", "def pixel_size; size.x * size.y; end", "def px_to_length(view)\n\n view.pixels_to_model 1, @scale_origin\n\n end", "def get_card_imagescaled_of(scale_lbl,lbl)\r\n unless @cards_scaled_info[scale_lbl]\r\n @log.warn(\"get_card_imagescaled_of no scale inforrmation found\")\r\n return get_card_image_of(lbl)\r\n end\r\n unless @cards_scaled[scale_lbl]\r\n # intialize hash to store all reduced cards. Use the card label to get it.\r\n @cards_scaled[scale_lbl] = {}\r\n end\r\n unless @cards_scaled[scale_lbl][lbl]\r\n # first time that this scaled image is accessed, create it\r\n @cards_scaled[scale_lbl][lbl] = load_create_scaled_img(scale_lbl, lbl)\r\n end\r\n return @cards_scaled[scale_lbl][lbl]\r\n end", "def process_small_image\n small_image.encode!(:png).convert!('-resize 50x50 -gravity center -background none -extent 50x50')\n end", "def setscale(*)\n super\n end", "def aspect_ratio\n if self.width && self.height\n return self.width/self.height.to_f\n else\n return 1.324 # Derived from the default values, above\n end\n end", "def scale(w, h, method = :bilinear)\n @image.send(\"resample_#{method}!\", w, h)\n self\n end", "def scale_aspect_to_minimum_size(aSize)\n if aSize.width/aSize.height > self.size.width/self.size.height\n s = CGSize.new(aSize.width, (aSize.width/size.width * size.height).to_i)\n else\n s = CGSize.new((aSize.height/size.height * size.width).to_i, aSize.height)\n end\n\n scale_to_size(s)\n end", "def scale\n raise NotImplementedError, \"Subclass responsibility\"\n end", "def scale_aspect_to_fill_size(aSize)\n if aSize.width/aSize.height > size.width/size.height\n croppedImg = image_by_cropping_to_center_size(CGSize.new(size.width, (size.width/aSize.width * aSize.height).to_i))\n else\n croppedImg = image_by_cropping_to_center_size(CGSize.new((size.height/aSize.height * aSize.width).to_i, size.height))\n end\n\n croppedImg.scale_to_size(aSize)\n end", "def resize_retina_image(image_filename)\n \n image_name = File.basename(image_filename)\n \n image = Magick::Image.read(image_filename).first # Read the image\n new_image = image.scale(SCALE_BY)\n \n if new_image.write(image_filename) # Overwrite image file\n puts \"Resizing Image (#{SCALE_BY}): #{image_name}\"\n else\n puts \"Error: Couldn't resize image #{image_name}\"\n end\n \nend", "def scale_by(width_factor, height_factor, &block)\n squish(width*width_factor, height*height_factor, &block)\n end", "def vscale(factor)\n @height = @height * factor\n @top *= factor\n self\n end", "def scaled_to(destination)\n Scale.transform(self).to(destination)\n end", "def aspect\n width.to_f / height.to_f if !(width.blank? && height.blank?)\n end", "def post_scale diffs\n diffs.reduce(0, :+).to_f / diffs.size\n end", "def aspect_ratio\n if self.native_width && self.native_height\n return self.native_width/self.native_height.to_f\n else\n return 1.324 # Derived from the default values, above\n end\n end", "def display_image \r\n self.image.variant(resize_to_limit: [1000, 1000]) \r\n end", "def scale(*amount)\n self.dup.scale! *amount\n end", "def modify_image\n if @vertical\n @main_image = @main_image.zooming_v\n else\n @main_image = @main_image.zooming_h\n end\n end", "def scale_by_bounds(dimensions)\n x = options[:width] / dimensions[0].to_f\n y = options[:height] / dimensions[1].to_f\n x * dimensions[1] > options[:height] ? y : x\n end", "def scale(sx,sy)\n set RGhost::Scale.new(sx,sy)\n \n end", "def scale(*args, &block); end", "def large_process\n case [model.attachable_type, model.image_type]\n when ['User', 'avatar'] then\n resize_to_fill 1024, 683 # 3x2\n when ['User', 'inspiration'] then\n resize_to_fit 1024, 9999 # fixed width\n when ['Message', 'avatar'] then\n resize_to_fit 1024, 9999 # fixed width\n when ['Message', 'alternate'] then\n resize_to_fit 1024, 9999 # fixed width\n when ['Alternative', 'avatar'] then\n resize_to_fill 1024, 683 # 3x2\n else\n resize_to_fit 1024, 9999 # fixed width\n end\n # TODO: Test and implement this.\n # fix_exif_rotation\n quality 70\n end", "def zoom\n `#@native.devicePixelRatio`\n end", "def rate_scale; end", "def scale_aspect_to_maximum_size(aSize)\n if aSize.width/aSize.height > self.size.width/self.size.height\n s = CGSize.new((aSize.height/size.height * size.width).to_i, aSize.height)\n else\n s = CGSize.new(aSize.width, (aSize.width/size.width * size.height).to_i)\n end\n\n scale_to_size(s)\n end", "def calc_native_res_zoom(image_source)\n\t\timage = get_image(image_source)\n\t\tside_length = calc_side_length(image)\n\t\tzoom = log2(side_length)-log2(TILE_SIZE)\n\t\tzoom = 0 if zoom < 0\n\t\tzoom\n\tend", "def thumb_width\n width * thumb_height / height\n end", "def scale_to_fit(width, height)\n @image = @image.scale_to_fit(width, height)\n self\n end", "def scale_to(new_size, background:background)\n new_size = SugarCube::CoreGraphics::Size(new_size)\n\n image_size = self.size\n\n if CGSizeEqualToSize(image_size, new_size)\n return self\n end\n\n new_image = nil\n width = image_size.width\n height = image_size.height\n\n target_width = new_size.width\n target_height = new_size.height\n\n scale_factor = 0.0\n scaled_width = target_width\n scaled_height = target_height\n\n thumbnail_point = CGPoint.new(0.0, 0.0)\n width_factor = target_width / width\n height_factor = target_height / height\n\n if width_factor < height_factor\n scale_factor = width_factor\n else\n scale_factor = height_factor\n end\n\n scaled_width = width * scale_factor\n scaled_height = height * scale_factor\n\n # center the image\n\n if width_factor < height_factor\n thumbnail_point.y = (target_height - scaled_height) * 0.5\n elsif width_factor > height_factor\n thumbnail_point.x = (target_width - scaled_width) * 0.5\n end\n\n # this is actually the interesting part:\n\n UIGraphicsBeginImageContextWithOptions(new_size, false, self.scale)\n\n if background\n background = background.uicolor\n context = UIGraphicsGetCurrentContext()\n background.setFill\n CGContextAddRect(context, [[0, 0], new_size])\n CGContextDrawPath(context, KCGPathFill)\n end\n\n thumbnail_rect = CGRectZero\n thumbnail_rect.origin = thumbnail_point\n thumbnail_rect.size.width = scaled_width\n thumbnail_rect.size.height = scaled_height\n\n self.drawInRect(thumbnail_rect)\n\n new_image = UIGraphicsGetImageFromCurrentImageContext()\n UIGraphicsEndImageContext()\n\n raise \"could not scale image\" unless new_image\n\n return new_image\n end", "def GetScaleFactor()\n\t\treturn @k;\n\tend", "def aspect_ratio\n (@x/@y).abs\n end", "def display_image\n image.variant resize_to_limit: Settings.validation.post.img_resize\n end", "def resize_dimensions(original_dimensions, style)\n if style.filled?\n style.dimensions\n else\n original_aspect_ratio = original_dimensions[0].to_f / original_dimensions[1]\n target_aspect_ratio = style.dimensions[0].to_f / style.dimensions[1]\n if original_aspect_ratio > target_aspect_ratio\n width = style.dimensions[0]\n height = (width / original_aspect_ratio).round\n else\n height = style.dimensions[1]\n width = (height * original_aspect_ratio).round\n end\n [width, height]\n end\n end", "def scaled_from(source)\n Scale.transform(self).from(source)\n end", "def update_controller_scaling(view)\n\n @scale_origin =\n if @path.empty?\n @ip.position\n else\n bb = Geom::BoundingBox.new\n bb.add @path\n bb.center\n end\n\n nil\n\n end", "def update_scale\n heightpx = @board.height*@scale\n widthpx = @board.width*@scale\n # Gameboard\n @board_window.height = heightpx\n @board_window.width = widthpx\n # Clue windows\n @clues_windows[:rows].height = heightpx\n @clues_windows[:rows].width = (@scale*@board.clues[:rows].map { |row| row.length }.max)\n @clues_windows[:columns].height = (@scale*@board.clues[:columns].map { |column| column.length }.max)\n @clues_windows[:columns].width = widthpx\n # Clues\n @clues_list.each { |clue| clue[:text_object].delete() }\n @passing.each { |pass| pass.remove() }\n @passing = draw_passing(@board.clues)\n @clues_list = draw_clues(@board.clues)\n # Blocks\n @blocks.each do |block, cell|\n x = block.coords[:x]*@scale\n y = block.coords[:y]*@scale\n cell.coords = [x, y, x+@scale, y+@scale]\n end\n # Guide lines\n @guide_lines.each { |line| line.remove }\n @guide_lines = draw_guide_lines()\n update_highlight()\n end", "def scale=(val)\n self['scale'] = val\n end", "def width_of image; return run(\"sips #{image} -g pixelWidth\").split(' ').last.to_i end", "def apply_preserve_aspect_ratio(change_orientation=false)\n return unless preserve_aspect_ratio?\n\n side = @transcoder_options[:preserve_aspect_ratio]\n size = @raw_options.send(side)\n side = invert_side(side) if change_orientation \n\n if @transcoder_options[:enlarge] == false\n original_size = @movie.send(side)\n size = original_size if original_size < size\n end\n\n case side\n when :width\n new_height = size / @movie.calculated_aspect_ratio\n new_height = evenize(new_height)\n @raw_options[:resolution] = \"#{size}x#{new_height}\"\n when :height\n new_width = size * @movie.calculated_aspect_ratio\n new_width = evenize(new_width)\n @raw_options[:resolution] = \"#{new_width}x#{size}\"\n end\n\n invert_resolution if change_orientation \n end", "def scale_inside(other)\n wratio = other.width / width\n hratio = other.height / height\n if wratio < hratio\n Size.new(other.width, height * wratio)\n else\n Size.new(width * hratio, other.height)\n end\n end", "def aspect_ratio(size)\n size[:width].to_f / size[:height]\n end", "def scale_to_fit(new_width, new_height, &block)\n squish(*scale_dimensions_to_fit(new_width, new_height), &block)\n end" ]
[ "0.71910375", "0.7097154", "0.7045114", "0.6847256", "0.6820939", "0.68075377", "0.66945076", "0.6647444", "0.6521559", "0.65080374", "0.64740944", "0.64687574", "0.6427284", "0.6403538", "0.6379229", "0.6340301", "0.6327297", "0.63096726", "0.6307333", "0.6285941", "0.62858105", "0.6262799", "0.62090147", "0.6198582", "0.6194442", "0.61578214", "0.6144115", "0.6125019", "0.61242044", "0.6107914", "0.60989213", "0.60971105", "0.6096738", "0.60840386", "0.6076425", "0.60719866", "0.6069524", "0.6067977", "0.6067977", "0.60673946", "0.60668975", "0.60551155", "0.60503423", "0.60354334", "0.6009068", "0.60002136", "0.59909856", "0.5989745", "0.5984403", "0.59821516", "0.59597385", "0.5955616", "0.59480643", "0.5947276", "0.59455097", "0.5934684", "0.592936", "0.592936", "0.5924636", "0.5903723", "0.58982784", "0.5895843", "0.589473", "0.5894488", "0.58887696", "0.58853096", "0.588293", "0.5866769", "0.5863984", "0.58634454", "0.58350486", "0.5831161", "0.5829013", "0.58266336", "0.582439", "0.5823775", "0.58112687", "0.58076626", "0.5803301", "0.57994354", "0.5792471", "0.57755846", "0.5773404", "0.5771311", "0.5771261", "0.57663226", "0.57538486", "0.5737834", "0.5722905", "0.5712488", "0.5712189", "0.5708812", "0.5703634", "0.5695775", "0.5690612", "0.5689946", "0.56896687", "0.5677903", "0.5676921", "0.5670947", "0.5647553" ]
0.0
-1
, :message instance methods
def deliver! self.do_deliver end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def message(message) end", "def message( message )\n\tend", "def message; end", "def message; end", "def message; end", "def message; end", "def message; end", "def message; end", "def message() end", "def msg(message)\n end", "def message\n end", "def message; Message.new; end", "def message\n @_message\n end", "def message\n @_message\n end", "def message=(_); end", "def message\n @message\n end", "def initialize message\n @message = message\n end", "def message\n \n end", "def message\n\t\t@message \n\tend", "def message\n raise \"Override #message in the service class\"\n end", "def message\n __getobj__\n end", "def message\n __getobj__\n end", "def message\n __getobj__\n end", "def message(type, *args)\n end", "def message\n @message || super\n end", "def process_message(message)\n end", "def message\n @message\n end", "def message\n process_mess\n end", "def create_message(data); end", "def create_message(data); end", "def messages; end", "def messages; end", "def messages; end", "def message=(_arg0); end", "def message=(_arg0); end", "def message\n data.message\n end", "def new_message\n end", "def message( *msgs )\n\t\tself.class.message( *msgs )\n\tend", "def message\n MESSAGE\n end", "def message\n MESSAGE\n end", "def message\n MESSAGE\n end", "def message\n MESSAGE\n end", "def send_message(msg); end", "def message_buffer; end", "def message\n call_once\n @message\n end", "def send_message(message); end", "def send_message(message); end", "def message(msg)\n\t\[email protected](msg)\n\tend", "def message\n @message ||= Interface::Message.new(self)\n end", "def message_template; end", "def message\n\t\tself.object[:message]\n\tend", "def message\n to_s\n end", "def message\n to_s\n end", "def message(message)\n # message can be also accessed via instance method\n message == self.payload # true\n # store_message(message['text'])\n end", "def message( *msgs )\n\t\t\tself.class.message( *msgs )\n\t\tend", "def update_message(data); end", "def update_message(data); end", "def initialize( message )\n @message = message\n end", "def message( *args )\n raise NotImplementedError, \"You must implement #message in your driver.\"\n end", "def message\n\t\tself.object[\"message\"]\n\tend", "def message(*args)\n method_missing(:message, args)\n end", "def next_message; end", "def next_message; end", "def messages\n end", "def messages\n end", "def personal_message(msg, cl, state)\n respond(msg, cl, \"Hi. Your message was: #{msg.inspect}\")\n respond(msg, cl, \"Body: #{msg.body.to_s}\")\nend", "def initialize\n super(MESSAGE)\n end", "def message=(arg)\n @_message = arg\n end", "def message\n attributes.fetch(:message)\n end", "def msg; end", "def msg; end", "def msg; end", "def messaging\n end", "def initialize(message:)\n @message = message\n end", "def message\n @data['message']\n end", "def lookup_message(name)\n\t\tend", "def message\n attributes[:message]\n end", "def process(message)\n end", "def initialize(message)\n super(message)\n end", "def to_s; message; end", "def send(message)\n message\n end", "def getMessage()\n return @message\n end", "def add_message(name, message)\n\t\tend", "def receive_message(message)\n end", "def message=(message)\n end", "def description\n self[:message]\n end", "def message\n @attributes[:message]\n end", "def on_message(m)\n end", "def message_class\n return Scene_Battle::Message\n end", "def call(message)\n raise NotImplementedError, \"Must implement this method in subclass\"\n end", "def message\n info['Message']\n end", "def messages\n self\n end", "def onmessage(&blk); super; end", "def message\n t(\".message\")\n end", "def msg=(_); end", "def msg=(_); end", "def message\n @name\n end", "def msg\n self['msg']||{}\n end", "def message_for(test); end", "def message_for(test); end", "def get_message\n raise NotImplementedError.new(\"#{self.class.name}#get_message() is not implemented.\")\n end" ]
[ "0.85979795", "0.8378066", "0.8154617", "0.8154617", "0.8154617", "0.8154617", "0.8154617", "0.8154617", "0.8128793", "0.8017373", "0.7996192", "0.79782015", "0.7779669", "0.7779669", "0.77296764", "0.77103895", "0.7691525", "0.7688421", "0.7561985", "0.75408506", "0.7525254", "0.7525254", "0.7525254", "0.7494762", "0.7474334", "0.7469473", "0.7430876", "0.74260336", "0.7424561", "0.7424561", "0.7397812", "0.7397812", "0.7397812", "0.73895085", "0.73895085", "0.73777235", "0.7359538", "0.73474246", "0.73169947", "0.73169947", "0.73169947", "0.73169947", "0.7301193", "0.7299384", "0.72968316", "0.72834724", "0.72834724", "0.7251517", "0.7224949", "0.71975464", "0.7189451", "0.71880627", "0.71880627", "0.7153061", "0.7152169", "0.71505207", "0.71505207", "0.7146027", "0.7145925", "0.7116396", "0.71065164", "0.71022695", "0.71022695", "0.7102025", "0.7102025", "0.7101053", "0.7083934", "0.70792145", "0.7068362", "0.70151055", "0.70151055", "0.70151055", "0.6981254", "0.6966133", "0.6950029", "0.6938112", "0.68913853", "0.6888282", "0.68491364", "0.68354654", "0.681387", "0.68126357", "0.6811742", "0.680765", "0.6805806", "0.6804878", "0.6767386", "0.6753817", "0.6722419", "0.6719811", "0.671328", "0.66955763", "0.66823244", "0.6681414", "0.6681288", "0.6681288", "0.6663405", "0.66595495", "0.6653737", "0.6653737", "0.66479236" ]
0.0
-1
make sure we have the message without default field
def message_text clear_default_fields result = self.message reset_default_fields result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def not_valid_message; nil; end", "def not_valid_message; nil; end", "def default_messages=(_arg0); end", "def test_generate_message_blank_with_default_message\n assert_equal \"can’t be blank\", @person.errors.generate_message(:title, :blank)\n end", "def test_generate_message_empty_with_default_message\n assert_equal \"can’t be empty\", @person.errors.generate_message(:title, :empty)\n end", "def message\n @props.fetch(:message, \"must be valid\")\n end", "def not_spam\n errors.add(:base, \"invalid reply\") if check_field.present?\n end", "def message?\n false\n end", "def msg\n self['msg']||{}\n end", "def message\n @message || super\n end", "def message=(_); end", "def test_generate_message_exclusion_with_default_message\n assert_equal \"is reserved\", @person.errors.generate_message(:title, :exclusion, value: \"title\")\n end", "def insert_fallbacks!(msg)\n msg[:attachments].each do |attachment|\n next unless attachment[:fields]\n\n attachment[:fields].each do |field|\n field[:value] = 'N/A' if field[:value].blank?\n end\n end\n\n msg\n end", "def test_generate_message_accepted_with_default_message\n assert_equal \"must be accepted\", @person.errors.generate_message(:title, :accepted)\n end", "def message\n @options.fetch(:message) { \"\" }\n end", "def clean_message(message); end", "def message mess\n @message = mess\n @keys_to_clear = 2 if mess\nend", "def default_message\n \"Invalid Derelict instance\"\n end", "def message; end", "def message; end", "def message; end", "def message; end", "def message; end", "def message; end", "def attribute_to_check_message_against; end", "def handle_bogus_message(message)\n # This needs a good solution\n end", "def handle_default_options\n # before mergin check if custom :message provided by developer\n message_provided = options[:message]\n\n # do merge\n @options = DEFAULT_OPTIONS.merge(options)\n\n # handle default message template based on condition if\n # custom message was provided by developer\n @options[:message] = options[:message] % options[:validator].upcase unless message_provided\n end", "def leave_blank_text_message\n fill_in('message', :with => '')\nend", "def default_message_for(key)\n if @options[:message]\n :message\n else\n @options[:\"#{key}_message\"] = key\n :\"#{key}_message\"\n end\n end", "def default_message_options\n @default_message_options ||= {type: 'message'}\n end", "def message; Message.new; end", "def message?\n #errors.on(:message) != nil\n errors[:message] != nil\n end", "def has_message_id?\n !fields.select { |f| f.responsible_for?('Message-ID') }.empty?\n end", "def messages\n @messages ||= ''\n end", "def invalid_message\r\n @invalid_message ||= 'Please enter Yes or No.'\r\n end", "def test_generate_message_inclusion_with_default_message\n assert_equal \"is not included in the list\", @person.errors.generate_message(:title, :inclusion, value: \"title\")\n end", "def new_message\n end", "def test_generate_message_invalid_with_default_message\n assert_equal \"is invalid\", @person.errors.generate_message(:title, :invalid, value: \"title\")\n end", "def msg(message)\n end", "def default_fields\n defaults = {}\n defaults = defaults.merge(@message.default_fields_with_name(:deactivation_message)) if @message\n defaults\n end", "def message( message )\n\tend", "def message_template; end", "def messages(value_only: true)\n varfields('m', value_only: value_only)\n end", "def custom_message\n @custom_message ||= params[:custom_message]\n end", "def message(message) end", "def inactive_message; end", "def inactive_message; end", "def notify_about_missing_field(attribute, message)\n if self.send(attribute).blank?\n options = {:to => self.email,\n :subject => \"Your user account needs updating\",\n :message => message,\n :url_label => \"Modify your profile\",\n :url => Rails.application.routes.url_helpers.edit_user_url(self, :host => \"whiteboard.sv.cmu.edu\")\n }\n GenericMailer.email(options).deliver\n end\n end", "def test_generate_message_confirmation_with_default_message\n assert_equal \"doesn’t match Title\", @person.errors.generate_message(:title, :confirmation)\n end", "def msg=(_); end", "def msg=(_); end", "def check_message(params)\n unless params[:message].blank?\n continue(params)\n else\n fail(:no_message_given)\n end\n end", "def must_be_empty(msg=nil)\n EmptyAssay.assert!(self, :message=>msg, :backtrace=>caller)\n end", "def message\n end", "def message() end", "def empty_messages(attribute)\n return unless self[attribute].present?\n # There were errors\n self[attribute].clear\n add(attribute, false)\n end", "def msg; end", "def msg; end", "def msg; end", "def messages; end", "def messages; end", "def messages; end", "def error_check\n raise \"Subject is blank!\" if @message_config[:subject].strip.length == 0\n raise \"Subject is long!\" if @message_config[:subject].length > 120\n raise \"Body is blank!\" if @message_config[:body].strip.length == 0\n end", "def copy_fields(to_msg)\n\t\tend", "def new_msg?\n msg && !event[:subtype]\n end", "def clear_message\n errors.clear\n end", "def message\n render_message unless message_rendered?\n @_message\n end", "def clear_message\n @m.synchronize do\n @message=\"\"\n end\n end", "def valid?(message)\n true\n end", "def empty?\n @messages.empty?\n end", "def not(msg=nil)\n @negated = !@negated\n @message = msg if msg\n self\n end", "def is_text_message?(message)\n !message.text.nil?\nend", "def message=(_arg0); end", "def message=(_arg0); end", "def actual_message=(msg)\n write_attribute(:actual_message, msg) unless substituted_draft_message == draft_message\n end", "def allow_message_expectations_on_nil\n Proxy.allow_message_expectations_on_nil\n end", "def allow_message_expectations_on_nil\n Proxy.allow_message_expectations_on_nil\n end", "def set_message_price\n @message = if @price_data.blank? \n NO_RESULT_MESSAGE\n else\n SUCCESS_MESSAGE\n end\n end", "def force_message m; send_message format_message(nil, Time.now, m) end", "def test_generate_message_not_a_number_with_default_message\n assert_equal \"is not a number\", @person.errors.generate_message(:title, :not_a_number, value: \"title\")\n end", "def msg(m=\"\")\n @m ||= m\n end", "def test_necessary_existence_of_communication_subject\n test_necessary_existence_of_model_field(\"cannot be empty\", @communication, :communication_subject)\n end", "def set_message(msg)\n @message = msg\n false\n end", "def __messages__\n defined?(messages) ? Array[*messages] : nil\n end", "def msg_exists(msg) \n not msg.nil? and not msg.empty?\n end", "def message\n @options[:message] || \"failed validation\"\n end", "def inactive_message\n if !approved?\n :not_approved\n else\n super # mensaje\n end\n end", "def yield_or_default(message, default_message = \"\")\n message.nil? ? default_message : message\n end", "def yield_or_default(message, default_message = \"\")\n message.nil? ? default_message : message\n end", "def yield_or_default(message, default_message = \"\")\n message.nil? ? default_message : message\n end", "def yield_or_default(message, default_message = \"\")\n message.nil? ? default_message : message\n end", "def yield_or_default(message, default_message = \"\")\n message.nil? ? default_message : message\n end", "def message\n\t\t@message \n\tend", "def blank_comments_message\r\n return \"Be the first to say something about this place.\"\r\n end", "def add_null_message_to_errors(field)\n @errors << {message: \"#{field} must not be blank.\", variable: \"#{field}\"}\n end", "def set_message_org\n @message = if @organizations.blank? \n NO_RESULT_MESSAGE\n else\n SUCCESS_MESSAGE\n end\n end", "def message\n MESSAGE\n end", "def message\n MESSAGE\n end", "def message\n MESSAGE\n end", "def message\n MESSAGE\n end" ]
[ "0.7641877", "0.7641877", "0.68796325", "0.67119354", "0.6693178", "0.6635683", "0.6629244", "0.6625963", "0.66057205", "0.66011995", "0.6588887", "0.65215915", "0.64992106", "0.6418044", "0.6415026", "0.64002913", "0.63732433", "0.63675946", "0.63432", "0.63432", "0.63432", "0.63432", "0.63432", "0.63432", "0.6342344", "0.62907946", "0.628173", "0.6268647", "0.62680197", "0.62616044", "0.62587696", "0.6244167", "0.62146795", "0.62106967", "0.6197105", "0.6194824", "0.61940765", "0.6157868", "0.6149573", "0.61479145", "0.61295974", "0.61129725", "0.6105401", "0.6103488", "0.60932076", "0.6091781", "0.6091781", "0.60887337", "0.60819715", "0.60818297", "0.60818297", "0.6069588", "0.60640055", "0.60574293", "0.60537153", "0.6050036", "0.6047413", "0.6047413", "0.6047413", "0.60402286", "0.60402286", "0.60402286", "0.60339326", "0.60323584", "0.60320884", "0.60217136", "0.6016433", "0.6006251", "0.6004029", "0.59902656", "0.5978445", "0.595987", "0.59518445", "0.59518445", "0.59379196", "0.59368575", "0.59368575", "0.5929535", "0.59198487", "0.5916477", "0.59132767", "0.59122163", "0.5911277", "0.5903694", "0.5903041", "0.59021443", "0.58895767", "0.58865553", "0.58865553", "0.58865553", "0.58865553", "0.58865553", "0.5882473", "0.5882075", "0.58756346", "0.58704114", "0.58685917", "0.58685917", "0.58685917", "0.58685917" ]
0.68834156
2
Route methods Main page
def root render :json => JSONResponse.json(0, "Welcome!") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def routes; end", "def routes; end", "def routes; end", "def routes; end", "def routes; end", "def routes; end", "def routes; end", "def routes; end", "def routes; end", "def routes; end", "def routes; end", "def route_index; end", "def route\n #TODO\n end", "def _routes; end", "def _roda_main_route(_)\n end", "def custom_routes; end", "def route14\n end", "def router; end", "def routes\n routes_method.call\n end", "def homepage\n end", "def homepage\n end", "def route() request.route end", "def homepage\n end", "def homepage\n end", "def GET; end", "def routes\n raise NotImplementedError\n end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def index; end", "def named_route; end", "def route_name; end", "def route_name; end", "def hellopage\nend", "def home; end", "def routes(&block); end", "def routes(&block); end", "def url_for_main; end", "def url_for_main; end", "def home\n\t\t# Home Page\n\tend", "def home\n\n end", "def home\n\n end", "def home\n\n end", "def home\n\n end", "def handle_routes\n instance_exec(@_roda_app.request, &self.class.router_block)\n end", "def home\n end", "def home\n end", "def home\n end", "def home\n end", "def home\nend", "def main\n respond_to do |format|\n format.html # index.html.erb\n end\n end", "def home\n end", "def home\n end", "def home\n end", "def home\n end", "def home\n end", "def home\n end", "def home\n end", "def home\n end", "def home\n end", "def home\n end", "def home\n end", "def home\n end", "def home\n end", "def home\n end", "def home\n end", "def home\n end", "def home\n end", "def home\n end", "def home\n end", "def home\n end", "def home\n end" ]
[ "0.7879078", "0.7879078", "0.7879078", "0.7879078", "0.7879078", "0.7879078", "0.7879078", "0.7879078", "0.7879078", "0.7879078", "0.7879078", "0.7760167", "0.7628666", "0.7268596", "0.7265262", "0.70528877", "0.699742", "0.6870333", "0.68204576", "0.6798485", "0.6798485", "0.6785903", "0.67843646", "0.67843646", "0.6761694", "0.6659261", "0.66042674", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.66034395", "0.6530294", "0.65294147", "0.65294147", "0.6523006", "0.6510762", "0.65048057", "0.65048057", "0.64952445", "0.64952445", "0.6479431", "0.6478172", "0.6478172", "0.6478172", "0.6478172", "0.64650875", "0.64626527", "0.64626527", "0.64626527", "0.64626527", "0.6461515", "0.64590216", "0.64577246", "0.64577246", "0.64577246", "0.64577246", "0.64577246", "0.64577246", "0.64577246", "0.64577246", "0.64577246", "0.64577246", "0.64577246", "0.64577246", "0.64577246", "0.64577246", "0.64577246", "0.64577246", "0.64577246", "0.64577246", "0.64577246", "0.64577246", "0.64577246" ]
0.0
-1
Exception rescuing method. Integer codes are used for systemwide exception, the alphanumeric codes are for more specific errors. A regular exception
def exception_json(exception,code=500) render :json => Status::Errors.exception_json(exception, code).to_json, :status => code end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def raise(exception); end", "def rescue_action(e) raise e end", "def rescue_action(e) raise e end", "def rescue_action(e) raise e end", "def rescue_action(e) raise e end", "def rescue_from(exception); end", "def rescue_action(e); raise e; end", "def exception; end", "def exception; end", "def exception; end", "def exception; end", "def exception; end", "def underlying_exception=(_arg0); end", "def exception_class; end", "def exception(*rest) end", "def exception_handler; end", "def exception(command, exception)\n end", "def continued_exception=(_arg0); end", "def exceptions; end", "def original_exception; end", "def original_exception=(_arg0); end", "def exception\n raise \"It's a bad one!\"\n end", "def raise_exc\n raise\n rescue\n end", "def underlying_exception; end", "def exception_handler(ex)\n \nend", "def raise(*rest) end", "def raise(*rest) end", "def wrapped_exception; end", "def processerror(exception)\n case exception\n\n when RestClient::NotAcceptable #406\n raise RequestFailureException, \"Request failure\"\n when RestClient::Unauthorized #401\n raise RequestFailureException, \"Unauthorized access\"\n when RestClient::ResourceNotFound #404\n raise RequestFailureException, \"Incorrect request parameters. Check your url and the input xml\"\n when RestClient::InsufficientStorage # 507\n raise RequestFailureException, \"Account is full.User cannot make any more requests\"\n when RestClient::ServiceUnavailable # 503 => 'Service Unavailable',\n raise RequestFailureException, \"Your API has been throttled for now. Please try again later\"\n\n when ArgumentError\n raise exception\n\n else\n puts exception.message\n raise UnhandledException\n\n\n end\n\n end", "def raise_error(code, msg = nil)\n raise Exception.new(code: code, message: msg)\n end", "def raise_exc\n <<-CODE\n t1 = stack_pop();\n cpu_raise_exception(state, c, t1);\n CODE\n end", "def catch_exceptions; end", "def handle_perform_error(_e); end", "def exceptions\n end", "def continued_exception; end", "def pass_exception\n throw :next_exception_handler\n end", "def handle_generic_error(exception)\n end", "def exceptions_app=(_arg0); end", "def exceptions_app=(_arg0); end", "def processCrash; raise \"Abstract Exception: AbstractBeezwaxCrashProcessor.processCrash must be extended\"; end", "def exception(ex)\n raise NotImplementedError.new(\"Method 'exception' not implemented by '#{self.class.name}'\")\n end", "def exception(arg0, arg1, *rest)\n end", "def exception\n\t\t@exception\n\tend", "def exception_with_internal_code(e, code, msg, internal_code, data = {})\n\n Result::Base.exception(\n e, {\n error: code,\n error_message: msg,\n data: data,\n http_code: internal_code\n }\n )\n end", "def my_method\n\nrescue\n\nend", "def raise(exception_klass = T.unsafe(nil)); end", "def serve_exception(_exception); end", "def raise_exception\n\tbegin\n\t\tputs \"I am before the raise 1\"\n\t\traise 'An error has occured during the process'\n\t\tputs 'After the raise'\n\trescue\n\t\tputs 'Rescued for the first time'\n\tend\nend", "def raise(*args)\n Kernel.raise(*args)\n end", "def foo\n bar\nrescue StandardError\n raise 'foo error'\nend", "def eval_exception(*args)\n eval(*args).exception\n end", "def exception_codes\n return Egregious.exception_codes\n end", "def raise_exception \n puts 'I am before the raise.' \n raise 'An error has occuredzzzz' \n puts 'I am after the raise' \nend", "def x\n # ...\nrescue\n # ...\nend", "def raise!\n raise ReRaisedError.new(message, error_class)\n end", "def foo\n return raise\n#> xxxxxx\n end", "def exception_details(e, msg); end", "def exception(params)\n update_attributes(\n {\n :res_message => \"Exception\",\n :status => 'EXCEPTION'\n }.merge(params)\n )\n end", "def method_one\n begin\n raise \"some error\"\n rescue\n puts \"got an error\"\n end\nend", "def run_custom_exception_handling(exception)\n case handler = custom_exception_handler(exception)\n when String\n write handler \n when Symbol\n self.send(custom_exception_handler(exception))\n end\n end", "def raise_an_exception\n puts \"Going to cause an exception.\"\n # If you include a string, this is a generic RuntimeError\n # It is not rescued.\n # An un-rescued exception will cause the current Ruby process\n # to exit with error code 1 (error code 0 indicates normal\n # execution, anything else something anomalous)\n # You can view the error code of a process in most Unix-like\n # systems by typing echo $? at the prompt after execution.\n raise \"I am the exception\"\n puts \"This line will never be executed\"\nend", "def log_error(exception); end", "def enter_exception_context(exception); end", "def exception(exception = {})\n raise Teabag::RunnerException\n end", "def abort_on_exception=(_arg0); end", "def error code=nil, message=nil\n if code\n error = Lux::Error.new code\n error.message = message if message\n raise error\n else\n Lux::Error::AutoRaise\n end\n end", "def exception(message)\n StandardError.new(message)\n end", "def error(exception) nil ; end", "def abort_on_exception(*) end", "def exception(return_code)\n error = OpenNebula.is_error?(return_code)\n\n raise OneProvisionLoopException, return_code.message if error\n end", "def exception(return_code)\n error = OpenNebula.is_error?(return_code)\n\n raise OneProvisionLoopException, return_code.message if error\n end", "def event_processing_failed(exception, payload, raw_payload, dead_letter_queue_name)\n # do nothing\n end", "def handle_error(e)\n raise e\n end", "def reraise\n raise $!.class, $!.message, caller[1..-1]\nend", "def raise_rescue\n begin\n puts 'I am before the raise.'\n raise 'An error has occured.'\n puts 'I am after the raise.'\n rescue RuntimeError # 指定捕获异常的类型\n puts 'I am rescue!'\n end\n puts 'I am after the rescue.'\nend", "def raise(*args)\n ::Object.send(:raise, *args)\n end", "def abort_on_exception=(*) end", "def custom_exception_handler(exception)\n custom_exception_handlers[exception.to_s]\n end", "def exit_exception; end", "def identify_error\n begin\n yield\n rescue => ex\n ex.message.insert(0, \"#{@id} error: \")\n raise\n end\n end", "def error job, exception\n if tracetop = exception.backtrace&.first\n # Extract the file and line # from the stack top\n tracetop = \" at<br>\" + tracetop.match(/(.*:[\\d]*)/).to_s.if_present || tracetop\n tracetop.sub! Rails.root.to_s+'/', ''\n end\n errors.add :base, exception.to_s+tracetop\n self.status = :bad if processing? # ...thus allowing others to set the status\n end", "def rescue_with_handler(exception)\n to_return = super\n if to_return\n verbose = self.class.exception_notifiable_verbose && respond_to?(:logger) && !logger.nil?\n logger.info(\"[RESCUE STYLE] rescue_with_handler\") if verbose\n data = get_exception_data\n status_code = status_code_for_exception(exception)\n #We only send email if it has been configured in environment\n send_email = should_email_on_exception?(exception, status_code, verbose)\n #We only send web hooks if they've been configured in environment\n send_web_hooks = should_web_hook_on_exception?(exception, status_code, verbose)\n the_blamed = ExceptionNotification::Notifier.config[:git_repo_path].nil? ? nil : lay_blame(exception)\n rejected_sections = %w(request session)\n # Debugging output\n verbose_output(exception, status_code, \"rescued by handler\", send_email, send_web_hooks, nil, the_blamed, rejected_sections) if verbose\n # Send the exception notification email\n perform_exception_notify_mailing(exception, data, nil, the_blamed, verbose, rejected_sections) if send_email\n # Send Web Hook requests\n ExceptionNotification::HooksNotifier.deliver_exception_to_web_hooks(ExceptionNotification::Notifier.config, exception, self, request, data, the_blamed) if send_web_hooks\n pass_it_on(exception, ENV, verbose)\n end\n to_return\n end", "def test_exception_notification\n raise 'Testing, 1 2 3.'\n end", "def keep_it_in\n raise \"rawr\"\nrescue\n # ahem\nend", "def error(msg, exc: nil)\n must \"message\", msg, be: String\n\n tell(colorize(\"☠ \", :magenta) + colorize(msg, :red))\n\n if exc\n raise exc.new(msg)\n else\n exit(-1)\n end\n end", "def recover_from(_error); end", "def exceptions_app; end", "def exceptions_app; end", "def handle_exception(exception)\n end", "def handle_exception(&block)\r\n yield\r\n\r\n rescue TypeError\r\n return Parsers::Message.invalid_type\r\n rescue Exception\r\n return Parsers::Message.unexpected_error\r\n end", "def exception_on_syntax_error=(_arg0); end", "def error(ex) [:error, ex]; end", "def raise(fiber, *arguments); end", "def error_number(exception) # :nodoc:\n raise NotImplementedError\n end", "def notify_exception_raised exception\n end", "def re_raise_error(body)\n raise Unavailable, body.fetch(:message)\n end", "def error(message)\n raise Error, message, caller\n end", "def raise_error\n code = lib.tcidbecode( @db )\n msg = lib.tcidberrmsg( code )\n raise Error.new(\"[ERROR #{code}] : #{msg}\")\n end", "def render_exception(ex)\n error_code = ex.respond_to?(:code) ? ex.code : 1\n message = ex.message\n internal_error = true\n field = ex.respond_to?(:field) ? ex.field : nil\n\n case ex\n when OpenShift::ValidationException\n return render_error(:unprocessable_entity, nil, nil, nil, nil, get_error_messages(ex.resource))\n\n when Mongoid::Errors::Validations\n field_map =\n case ex.document\n when Domain then requested_api_version <= 1.5 ? {\"namespace\" => \"id\"} : {\"namespace\" => \"name\"}\n end\n messages = get_error_messages(ex.document, field_map || {})\n return render_error(:unprocessable_entity, nil, nil, nil, nil, messages)\n\n when Mongoid::Errors::InvalidFind\n status = :not_found\n message = \"No resource was requested.\"\n internal_error = false\n\n when Mongoid::Errors::DocumentNotFound\n status = :not_found\n model = ex.klass\n\n target =\n if ComponentInstance >= model then target = 'Cartridge'\n elsif CartridgeInstance >= model then target = 'Cartridge'\n elsif CartridgeType >= model then target = 'Cartridge'\n elsif GroupInstance >= model then target = 'Gear group'\n else model.to_s.underscore.humanize\n end\n\n message =\n if ex.unmatched.length > 1\n \"The #{target.pluralize.downcase} with ids #{ex.unmatched.map{ |id| \"'#{id}'\"}.join(', ')} were not found.\"\n elsif ex.unmatched.length == 1\n \"#{target} '#{ex.unmatched.first}' not found.\"\n else\n if name = (\n (Domain >= model and ex.params[:canonical_namespace].presence) or\n (Application >= model and ex.params[:canonical_name].presence) or\n (ComponentInstance >= model and ex.params[:cartridge_name].presence) or\n (CartridgeInstance >= model and ex.params[:name].presence) or\n (CartridgeType >= model and ex.params[:name].presence) or\n (Alias >= model and ex.params[:fqdn].presence) or\n (CloudUser >= model and ex.params[:login].presence) or\n (CloudUser >= model and ex.params[:_id].presence) or\n (SshKey >= model and ex.params[:name].presence)\n )\n \"#{target} '#{name}' not found.\"\n else\n \"The requested #{target.downcase} was not found.\"\n end\n end\n error_code =\n if Cartridge >= model then 129\n elsif ComponentInstance >= model then 129\n elsif SshKey >= model then 118\n elsif GroupInstance >= model then 101\n elsif Authorization >= model then 129\n elsif Domain >= model then 127\n elsif Alias >= model then 173\n elsif Application >= model then 101\n else error_code\n end\n internal_error = false\n\n when OpenShift::UserException\n status = ex.response_code || :unprocessable_entity\n error_code, node_message, messages = extract_node_messages(ex, error_code, message, field)\n message = node_message || \"Unable to complete the requested operation. \\nReference ID: #{request.uuid}\"\n messages.push(Message.new(:error, message, error_code, field))\n return render_error(status, message, error_code, field, nil, messages, false)\n\n when OpenShift::AccessDeniedException\n status = :forbidden\n internal_error = false\n\n when OpenShift::AuthServiceException\n status = :internal_server_error\n message = \"Unable to authenticate the user. Please try again and contact support if the issue persists. \\nReference ID: #{request.uuid}\"\n\n when OpenShift::DNSException, OpenShift::DNSLoginException\n status = :internal_server_error\n\n when OpenShift::LockUnavailableException\n status = :internal_server_error\n message ||= \"Another operation is already in progress. Please try again in a minute.\"\n internal_error = false\n\n when OpenShift::NodeUnavailableException\n Rails.logger.error \"Got Node Unavailable Exception\"\n status = :internal_server_error\n message = \"\"\n if ex.resultIO\n error_code = ex.resultIO.exitcode\n message = ex.resultIO.errorIO.string.strip + \"\\n\" unless ex.resultIO.errorIO.string.empty?\n Rail.logger.error \"message: #{message}\"\n end\n message ||= \"\"\n message += \"Unable to complete the requested operation due to: #{ex.message}. Please try again and contact support if the issue persists. \\nReference ID: #{request.uuid}\"\n\n when OpenShift::ApplicationOperationFailed\n status = :internal_server_error\n error_code, node_message, messages = extract_node_messages(ex, error_code, message, field)\n messages.push(Message.new(:error, node_message, error_code, field)) unless node_message.blank?\n message = \"#{message}\\nReference ID: #{request.uuid}\"\n return render_error(status, message, error_code, field, nil, messages, internal_error)\n\n when OpenShift::NodeException, OpenShift::OOException\n status = :internal_server_error\n error_code, message, messages = extract_node_messages(ex, error_code, message, field)\n message ||= \"unknown error\"\n message = \"Unable to complete the requested operation due to: #{message}\\nReference ID: #{request.uuid}\"\n\n # just trying to make sure that the error message is the last one to be added\n messages.push(Message.new(:error, message, error_code, field))\n\n return render_error(status, message, error_code, field, nil, messages, internal_error)\n else\n status = :internal_server_error\n message = \"Unable to complete the requested operation due to: #{message}\\nReference ID: #{request.uuid}\"\n end\n\n Rails.logger.error \"Reference ID: #{request.uuid} - #{ex.message}\\n #{ex.backtrace.join(\"\\n \")}\" if internal_error\n\n render_error(status, message, error_code, field, nil, nil, internal_error)\n end", "def raise(*args)\n ::Object.send(:raise, *args)\n end", "def exception\n @context[:exception]\n end" ]
[ "0.7165418", "0.7155438", "0.7155438", "0.7155438", "0.7155438", "0.71400726", "0.71260273", "0.68586934", "0.68586934", "0.68586934", "0.68586934", "0.68586934", "0.682984", "0.6779175", "0.6762418", "0.6739181", "0.6687594", "0.6675988", "0.6666675", "0.66664976", "0.66628015", "0.66547346", "0.6650851", "0.656904", "0.6567295", "0.65595114", "0.65595114", "0.65582603", "0.653996", "0.65055054", "0.64802444", "0.64686584", "0.6411366", "0.63978994", "0.63937163", "0.6384438", "0.6376052", "0.6363312", "0.6363312", "0.6345907", "0.6337904", "0.630711", "0.6305252", "0.62991625", "0.62639576", "0.6253936", "0.624483", "0.6237415", "0.6200379", "0.6169264", "0.6145789", "0.6129011", "0.61239386", "0.61157906", "0.61141753", "0.61140776", "0.60979456", "0.60727787", "0.606361", "0.603597", "0.60358214", "0.60152113", "0.60101056", "0.59965706", "0.5985578", "0.5981363", "0.5968615", "0.5966038", "0.59649634", "0.59606415", "0.59606415", "0.5954688", "0.59501773", "0.59261984", "0.59196705", "0.5918051", "0.5904789", "0.58964694", "0.58894795", "0.5887928", "0.58825696", "0.58774173", "0.58762217", "0.5872756", "0.58689576", "0.58678067", "0.5855915", "0.5855915", "0.58465713", "0.58452797", "0.58439016", "0.5843305", "0.58394575", "0.5837228", "0.58366185", "0.5827775", "0.58269143", "0.5825202", "0.58237857", "0.5817933", "0.5817162" ]
0.0
-1
No route was found.
def no_route_exception_json(exception) code = 404 render :json => Status::Errors.exception_json(exception, code).to_json, :status => code end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def undefined_route\n routing_error!\n end", "def no_route\n self.response[:body] = \"route not found for: '#{self.env['REQUEST_URI']}'\"\n self.response[:status_code] = 404\n end", "def no_routes\n # no need to do anything here either.\n end", "def no_routes\n end", "def routing_error\n render_not_found\n end", "def not_found\n raise ActionController::RoutingError.new('Not Found')\n end", "def error_route_not_found\n render 'errors/route_not_found', status: :not_found rescue last_chance\n end", "def raise_not_found\n\t\traise ActionController::RoutingError.new(\"No route matches #{params[:unmatched_route]}\")\n\tend", "def handle_route_not_found\n raise ActionController::RoutingError.new(params[:path])\n end", "def not_found\n raise ActionController::RoutingError, 'Not Found'\n end", "def not_found\n raise ActionController::RoutingError.new 'Not found'\n end", "def not_found\n raise ActionController::RoutingError.new('Not Found')\n end", "def not_found\n raise ActionController::RoutingError.new('Not Found')\n end", "def not_found\n raise ActionController::RoutingError.new('Not Found')\n end", "def not_found\n raise ActionController::RoutingError.new('Not Found')\n end", "def not_found\n raise ActionController::RoutingError.new('Not Found')\n end", "def not_found\n raise ActionController::RoutingError.new('Not Found')\n end", "def not_found\n raise ActionController::RoutingError.new 'Not Found'\n end", "def not_found(path)\n raise ActionController::RoutingError.new(\"Route not found for #{path}\")\n end", "def raise_not_found!\n\n raise ActionController::RoutingError.new(\"No route matches #{params[:unmatched_route]}\")\n\n end", "def not_found\n rescue_404(ActionController::RoutingError.new(\"No route matches #{request.request_method} #{request.path}\"))\n end", "def route_not_found\n return redirect_to root_url(area: nil), status: 301\n end", "def path_not_found\n render json: {\n error: 'No route matches.'\n }, status: :not_found\n end", "def not_found(message='Not Found')\n raise ActionController::RoutingError.new(message)\n end", "def route_eval\n super\n rescue ActiveRecord::RecordNotFound\n not_found\n end", "def not_found! redirect = root_path\n raise ActionController::RoutingError.new(\"Sorry, I could not find the requested item!\")\n end", "def routing_error\n redirect_to \"/404\"\n end", "def not_found\n raise ActionController::RoutingError.new('Page Not Found. Please contact the system administrator.')\n end", "def not_found\n raise ActionController::RoutingError.new('Not Found')\n rescue\n render_404\n end", "def test_no_route_single_connection\n routes = Routes.new ''\n assert_equal('NO SUCH ROUTE', routes.find_by_exact_stops('a', 'b').to_s)\n end", "def route_not_found\n report_to_rollbar(\"#{request.method}:#{request.original_url} - Unknown/Unauthenticated route accessed\") if Rails.env.production?\n flash[:error] = t('errors.404_main') if current_user.present?\n respond_to do |format|\n format.html { redirect_to '/' }\n format.js { render :js => \"App.Helpers.navigateTo('/', true);\" }\n end\n end", "def route_error\n \t@route_err = \"What the heck! I don't know that one, are you sure that's the address you wanted? Click me to return to the home page.\"\n end", "def index\n raise ActionController::RoutingError.new('Not Found')\n end", "def test_find_route_empty\n @south_america = Init.set_up_map('../JSON/test_data.json')\n santiago = @south_america.vertices[@south_america.metros['santiago']]\n route = santiago.find_route(@south_america.metros['bogota'])\n assert_equal(0, route.length)\n assert_instance_of(Array, route)\n end", "def routes_not_found\n respond_to do |f|\n f.html{ render :template => \"errors/404\", :status => 404}\n end\n end", "def route\n #TODO\n end", "def test_no_route_with_single_connection\n routes = Routes.new ''\n assert_equal('NO SUCH ROUTE', routes.find_by_exact_stops('a', 'b').to_s)\n end", "def any_empty_routing?\n self.empty?(self, \"routings\", false)\n end", "def try_route\n\t\t\t\thttp_method = request.http_method\n\t\t\t\thttp_method = :GET if http_method == :HEAD\n\t\t\t\treturn unless available_endpoint\n\n\t\t\t\troute = available_endpoint[http_method]\n\t\t\t\treturn unless route || available_endpoint.allow\n\n\t\t\t\thalt(405, nil, 'Allow' => available_endpoint.allow) unless route\n\t\t\t\tstatus 200\n\t\t\t\texecute_route route\n\t\t\t\ttrue\n\t\t\tend", "def not_found\n raise ActionController::RoutingError.new('Permalink Not Found')\n end", "def not_found\n render status: :not_found\n end", "def render_404\n raise ActionController::RoutingError.new('Not Found')\n end", "def route_index; end", "def blank; render :plain => \"Not Found.\", :status => 404 end", "def route\n @route\n end", "def routing\n referer = request.env['HTTP_REFERER']\n if referer.present? && referer.include?(request.host)\n Rails.logger.fatal \"#{referer} directs to non-existent route: \" \\\n \"#{request.protocol}#{request.host_with_port}#{request.fullpath}\"\n else\n Rails.logger.warn 'There was an attempt to access non-existent route: ' \\\n \"#{request.protocol}#{request.host_with_port}#{request.fullpath}\"\n end\n render file: Rails.root.join('public', '404.html'), status: :not_found\n end", "def not_found\n render plain: \"not found\"\n end", "def route_name; end", "def route_name; end", "def not_found\n\n render_error( :not_found )\n\n end", "def resource_not_found\n yield\n rescue ActiveRecord::RecordNotFound\n redirect_to root_url, :notice => \"Room not found.\"\n end", "def page_not_found\n render_404\n end", "def route14\n end", "def not_found\n render nothing: true, status: 404\n end", "def not_found; end", "def not_found\n render_error status: :not_found, body: 'page not found'\n end", "def get_default_route\n return @m_default_route\n end", "def routing_error\n head 400\n end", "def argument_not_found\n static_404_page\n end", "def route_index\n route via: :get, path: '', member: false\n end", "def empty?\n @routes.empty?\n end", "def routing_mismatch\n raise ::ActionController::RoutingError,\"URL not supported\"\n end", "def not_found\n render json: nil, status: :not_found\n end", "def get_routes\n raise \"Method not implemented\"\n end", "def not_found(body = nil)\n error(404, body)\n end", "def rescue_not_found\n render nothing: true, status: 404\n end", "def not_found\n return app_not_found unless core.request?\n render_core_exception :not_found\n end", "def check_request_for_route(request)\n match = ::Merb::Router.match(request)\n if match[0].nil? && match[1].empty?\n raise ::Merb::ControllerExceptions::BadRequest, \"No routes match the request. Request uri: #{request.uri}\"\n else\n match[1]\n end\n end", "def _routes; end", "def routing_error\n raise ActionController::RoutingError.new(params[:path])\n end", "def record_not_found\n puts \"RecordNotFound\"\n redirect_to request.referrer || root_path\n end", "def route() request.route end", "def not_found\n render :nothing => true, :status => 404\n end", "def suggest\n raise ActionController::RoutingError.new('Not Found')\n end", "def record_not_found\n redirect_to four_oh_four_url\n end", "def method_undefined(id)\n\t\t\t\t\treset_routing_cache\n\t\t\t\tend", "def not_found\n respond_with 404\n end", "def show_not_found\n controller.show_not_found\n end", "def resource_not_found\n\t\tyield\n\trescue ActiveRecord::RecordNotFound\n\t\tredirect_to root_url, :notice => \"Room Category not found.\"\n\tend", "def routes; end", "def routes; end", "def routes; end", "def routes; end", "def routes; end", "def routes; end", "def routes; end", "def routes; end", "def routes; end", "def routes; end", "def routes; end", "def not_found\n response_error(code: 404, message: 'Object not found.')\n end", "def routing_number; end", "def default_route\n @default_route ||= '/'\n end", "def run(request, response)\n matching_route = match(request)\n\n if matching_route.nil?\n response.status = 404\n\n response.write(\"Sorry! The requested URL #{request.path} was not not found!\")\n else\n matching_route.run(request, response)\n end\n end", "def method_undefined(id)\n\t\t\t\treset_routing_cache\n\t\t\tend", "def not_found generator, req, res, message = nil\n message ||= \"The page <kbd>#{ERB::Util.h req.path}</kbd> was not found\"\n res.body = generator.generate_servlet_not_found message\n res.status = 404\n end", "def not_found\n status 404\n body \"not found\\n\"\n end", "def not_found\n status 404\n body \"not found\\n\"\n end", "def not_found\n status 404\n body \"not found\\n\"\n end", "def respond_resource_not_found(path)\n log(\"#{path} Not Found\")\n make_response(nil, false, 404, \"Not Found\")\n end", "def get_default_response\n \"oaf: Not Found\\n---\\n404\"\n end" ]
[ "0.8046172", "0.7991195", "0.76937324", "0.76676756", "0.74779207", "0.7408969", "0.73745126", "0.73096585", "0.72957605", "0.726977", "0.72595406", "0.7224247", "0.7224247", "0.7224247", "0.7224247", "0.7224247", "0.7224247", "0.72233516", "0.72087944", "0.71538496", "0.7047991", "0.69864583", "0.6968166", "0.68632966", "0.6829004", "0.67841005", "0.67341024", "0.6731154", "0.67187774", "0.6706873", "0.66564566", "0.6643292", "0.6616806", "0.6584847", "0.6516992", "0.65164435", "0.6511473", "0.6507287", "0.64941907", "0.64857435", "0.6459318", "0.64467376", "0.64414763", "0.6429839", "0.635483", "0.63473433", "0.63180995", "0.63160855", "0.63160855", "0.63123655", "0.6276339", "0.6253404", "0.6248094", "0.6248045", "0.6233059", "0.6211204", "0.6211061", "0.6198738", "0.61871403", "0.61685306", "0.61328995", "0.6132039", "0.6106859", "0.60995096", "0.6094053", "0.6090067", "0.6088573", "0.6085874", "0.6081941", "0.60668004", "0.6063985", "0.6059933", "0.60494244", "0.60375386", "0.602907", "0.60177875", "0.60162747", "0.60014933", "0.59965533", "0.59954643", "0.59954643", "0.59954643", "0.59954643", "0.59954643", "0.59954643", "0.59954643", "0.59954643", "0.59954643", "0.59954643", "0.59954643", "0.5988197", "0.5984685", "0.59838766", "0.5973341", "0.5972638", "0.5972372", "0.59710544", "0.59710544", "0.59710544", "0.59705615", "0.59699106" ]
0.0
-1
The resource was not found or is gone.
def does_not_exist_json(exception=nil) message = exception.message if !exception.nil? exception = AppError::UndefinedRouteOrActionError.new code = exception.code render :json => Status::Errors.exception_json(exception, code, message).to_json, :status => code end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resource_not_found\n flash.now.alert = \"notifications.document.not_found\"\n @info = { id: params[:id] }\n render \"shared/html/404\" and return\n end", "def handle_resource_not_found(msg = 'Not found.')\r\n flash.now[:notice] = msg\r\n @web_analytics.page_stack = ['Admin', 'Resource Not Found']\r\n @web_analytics.error_page = true\r\n @left_rail_ad_pixels = -1 # make sure no ads are shown\r\n render :template => 'common/resource_not_found', :status => 404, :layout => 'application'\r\n false\r\n end", "def resource_exists?\n reload!\n @exists = true\n rescue Google::Cloud::NotFoundError\n @exists = false\n end", "def not_found\n render status: :not_found\n end", "def render_destroy_error\n render json: @resource, status: :not_found\n end", "def not_found\n render :template => \"shared/rescues/not_found\", :status => 404 \n end", "def not_found\n response_error(code: 404, message: 'Object not found.')\n end", "def record_not_found_message\n resource_name&.present? ? I18n.t(:x_not_found, name: resource_name&.singularize&.titleize) : I18n.t(:not_found)\n end", "def not_found\n\n render_error( :not_found )\n\n end", "def not_found\n\t\tself.status = 404\n\t\tself.headers = {}\n\t\tself.content = [\"Nothing Found\"]\n\t\tself\n\tend", "def not_found; end", "def respond_resource_not_found(path)\n log(\"#{path} Not Found\")\n make_response(nil, false, 404, \"Not Found\")\n end", "def render_404\n render_error(\"The remote resource was not found\")\n end", "def not_found\n\n r = Result::Base.error(\n {\n internal_id: 'ac_1',\n general_error_identifier: 'resource_not_found',\n http_code: GlobalConstant::ErrorCode.not_found\n }\n )\n\n return render_api_response(r)\n\n end", "def record_not_found\n render :partial => \"shared/error\", :layout => \"one_box\", :status => 404, :locals => {:error_title => 'No hemos encontrado lo que buscabas', :error_message => 'Puedes haber tecleado mal la dirección o la página puede haber sido movida.'}\n end", "def render_not_found\n\t\tflash[:notice] = 'The object you tried to access does not exist!'\n\t\tredirect_to root_path\n\tend", "def render_missing\r\n RenderError.new('404')\r\n end", "def resource_not_found\n\t\tyield\n\trescue ActiveRecord::RecordNotFound\n\t\tredirect_to root_url, :notice => \"Room Category not found.\"\n\tend", "def not_found\n raise ActionController::RoutingError.new('Not Found')\n end", "def resource_url; nil end", "def status_not_found\n @status = 404\n @e.error 'The requested page does not exist.', 404\n throw :exit\n end", "def action_delete\n if @current_resource.exist?\n converge_by \"Delete #{r.path}\" do\n backup unless ::File.symlink?(r.path)\n ::File.delete(r.path)\n end\n r.updated_by_last_action(true)\n load_new_resource_state\n r.exist = false\n else\n Chef::Log.debug \"#{r.path} does not exists - nothing to do\"\n end\n end", "def not_found\n render_error status: :not_found, body: 'page not found'\n end", "def destroy\n render :file => \"public/404.html\"\n end", "def render_404\n raise ActionController::RoutingError.new('Not Found')\n end", "def not_found\n render plain: \"not found\"\n end", "def resource_failed(resource, action, exception)\n puts COLOR_RED\n puts \"failed to handle resource --> :#{action} #{resource}\"\n puts COLOR_RESET\n puts \"#{exception}\"\n end", "def not_found\n raise ActionController::RoutingError.new('Page Not Found. Please contact the system administrator.')\n end", "def record_not_found\n \t\trender :file => File.join(RAILS_ROOT, 'public', '404.html'), :status => 404\n \tend", "def not_found\n render :status => 404\n end", "def not_found\n raise ActionController::RoutingError.new 'Not found'\n end", "def doesnt_exist\n\t\tputs \"That item doesn't exist.\"\n\t\tget_item\n\tend", "def record_not_found\n render :file => File.join(RAILS_ROOT, 'public', '404.html'), :status => 404\n end", "def record_not_found\n render :file => File.join(RAILS_ROOT, 'public', '404.html'), :status => 404\n end", "def record_not_found\n render :file => File.join(RAILS_ROOT, 'public', '404.html'), :status => 404\n end", "def update\n render :file => \"public/404.html\"\n end", "def missing?\n status == 404\n end", "def record_not_found\n render :file => File.join(::Rails.root.to_s, 'public', '404.html'), :status => 404\n end", "def record_not_found!\n render partial: 'errors/404', status: 404 && return\n end", "def not_found\n render nothing: true, status: 404\n end", "def service_unavailable\n\n end", "def not_found\n raise ActionController::RoutingError.new('Not Found')\n end", "def not_found\n raise ActionController::RoutingError.new('Not Found')\n end", "def not_found\n raise ActionController::RoutingError.new('Not Found')\n end", "def not_found\n raise ActionController::RoutingError.new('Not Found')\n end", "def not_found\n raise ActionController::RoutingError.new('Not Found')\n end", "def not_found\n raise ActionController::RoutingError.new('Not Found')\n end", "def not_found\n raise ActionController::RoutingError.new 'Not Found'\n end", "def render_404\n render(\n json: {\n error_messages: ['Resource does not exist'],\n error_code: 'NOT_FOUND'\n },\n status: 404\n )\n end", "def not_found\n render json: nil, status: :not_found\n end", "def error_route_not_found\n render 'errors/route_not_found', status: :not_found rescue last_chance\n end", "def rescue_not_found\n render nothing: true, status: 404\n end", "def resource_not_found\n yield\n rescue ActiveRecord::RecordNotFound\n redirect_to root_url, :notice => \"Room Category not found.\"\n end", "def record_not_found\n render :file => File.join(RAILS_ROOT, 'public', '404.html'), :status => 404\n end", "def record_not_found\n render :file => File.join(RAILS_ROOT, 'public', '404.html'), :status => 404\n end", "def record_not_found\n render :file => File.join(RAILS_ROOT, 'public', '404.html'), :status => 404\n end", "def record_not_found\n render :file => File.join(RAILS_ROOT, 'public', '404.html'), :status => 404\n end", "def record_not_found\n render :file => File.join(RAILS_ROOT, 'public', '404.html'), :status => 404\n end", "def record_not_found\n render :file => File.join(RAILS_ROOT, 'public', '404.html'), :status => 404\n end", "def record_not_found\n render :file => File.join(RAILS_ROOT, 'public', '404.html'), :status => 404\n end", "def not_found\n raise ActionController::RoutingError, 'Not Found'\n end", "def not_found\n render :nothing => true, :status => 404\n end", "def show_not_found\n render_json_error(code: :show_not_found, status: :not_found)\n end", "def record_not_found\n render 'shared/not_found' # Assuming you have a template named 'record_not_found'\n end", "def failed_resource?\n @failed_resource ||= false\n end", "def document_not_found\n render \"common/document_not_found\"\n end", "def not_found\n respond_with 404\n end", "def not_found! redirect = root_path\n raise ActionController::RoutingError.new(\"Sorry, I could not find the requested item!\")\n end", "def error_404\n render 'error/error404'\n end", "def not_destroyed(err)\n render json: {errors: err.record}, status: :bad_request\n end", "def record_not_found\n render file: 'public/404.zh-TW.html', stats: :not_found\n end", "def resource_not_found\n yield\n rescue ActiveRecord::RecordNotFound\n redirect_to root_url, :notice => \"Room not found.\"\n end", "def resource_not_found_for(env)\n raise case env[:url].path\n when %r{\\A(/_db/[^/]+)?/_api/document} then Ashikawa::Core::DocumentNotFoundException\n when %r{\\A(/_db/[^/]+)?/_api/collection} then Ashikawa::Core::CollectionNotFoundException\n when %r{\\A(/_db/[^/]+)?/_api/index} then Ashikawa::Core::IndexNotFoundException\n else Ashikawa::Core::ResourceNotFound\n end\n end", "def resource_not_found_for(env)\n raise case env[:url].path\n when /\\A\\/_api\\/document/ then Ashikawa::Core::DocumentNotFoundException\n when /\\A\\/_api\\/collection/ then Ashikawa::Core::CollectionNotFoundException\n when /\\A\\/_api\\/index/ then Ashikawa::Core::IndexNotFoundException\n else Ashikawa::Core::ResourceNotFound\n end\n end", "def show_not_found\n controller.show_not_found\n end", "def handle_not_found_error!\n raise Common::Exceptions::UnprocessableEntity.new(detail: 'Person Not Found')\n 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 object_not_found\n render json: 'Object not found', status: :not_found\n end", "def response_not_found\n render status: 404,\n json: {\n source: {\n pointer: request.original_url\n },\n errors: [ { message: \"Not Found\" } ]\n }\n end", "def not_found\n raise ActionController::RoutingError.new('Not Found')\n rescue\n render_404\n end", "def record_not_found\n render file: \"#{Rails.root}/public/404.html\", layout: false, status: :not_found\n end", "def not_found\n respond_not_found\n end", "def destroy\n\t\tif Rails.env.production?\n\t\t\tRestClient.patch(\"https://lensshift-drive.firebaseio.com/resources_deleted/#{@resource_item.google_doc_id}.json\", @resource_item.to_json)\n\t\t\tRestClient.delete(\"https://lensshift-drive.firebaseio.com/resources/#{@resource_item.google_doc_id}.json\")\n\t\tend\n\t\t@resource_item.destroy\n\t respond_to do |format|\n\t format.html { redirect_to fellow_resource_items_url, notice: 'Resource item was successfully destroyed.' }\n\t format.json { head :no_content }\n\t end\n\tend", "def object_not_found?\n @code == ERROR_OBJECT_NOT_FOUND\n end", "def resource_exists?(relative_path)\n rest.get(relative_path)\n true\n rescue Net::HTTPClientException => e\n raise unless e.response.code == \"404\"\n\n false\n end", "def not_found!\n [404, {\"Content-Type\" => \"text/plain\"}, [\"Jsus doesn't know anything about this entity\"]]\n end", "def unsuccessful\n end", "def blank; render :plain => \"Not Found.\", :status => 404 end", "def record_not_found\n flash[:danger] = 'Record Not Found'\n redirect_to (request.referrer || root_path)\n end", "def not_found\n rescue_404(ActionController::RoutingError.new(\"No route matches #{request.request_method} #{request.path}\"))\n end", "def resource_text\n nil\n end", "def record_not_found\n render :file => Rails.root.join('public','404.html'), :status => \"404 Not Found\", layout: false\n end", "def not_found\n \trender file: \"#{Rails.root}/public/404.html\", status: 404\n end", "def render_404\n render 'web/404', status: 404\n end", "def file_not_found(path)\n raise \"File not mapped in Chance instance: #{path}\"\n end", "def test_delete_not_found\n request = Http::Request.new('DELETE', '/file2')\n response = self.request(request)\n\n assert_equal(\n 404,\n response.status,\n \"Incorrect status code. Response body: #{response.body_as_string}\"\n )\n end", "def not_found\n render file: 'public/404', status: 404, formats: [:html]\n end", "def not_found\n \trender file: \"#{Rails.root}/public/404.html\", layout: true, status: 404\n end", "def return_not_found\n return_error(error_code: 404, message: 'Not Found')\n end", "def not_found\n status 404\n body \"not found\\n\"\n end", "def not_found\n status 404\n body \"not found\\n\"\n end" ]
[ "0.636349", "0.62843853", "0.62494034", "0.6230792", "0.62205577", "0.6143138", "0.61423594", "0.6133038", "0.6109996", "0.6062923", "0.60106754", "0.60067475", "0.598609", "0.5983417", "0.59780145", "0.5967421", "0.5930613", "0.58750075", "0.58740735", "0.5855029", "0.5852587", "0.5839956", "0.5838483", "0.58075076", "0.579052", "0.5783477", "0.57808065", "0.5761382", "0.57538235", "0.5743234", "0.5742685", "0.572305", "0.57209516", "0.57209516", "0.57209516", "0.5708666", "0.56995076", "0.5692066", "0.56913185", "0.5689631", "0.56813854", "0.5679036", "0.5679036", "0.5679036", "0.5679036", "0.5679036", "0.5679036", "0.56787", "0.56649876", "0.5662078", "0.5660289", "0.56587106", "0.5657993", "0.5657908", "0.5657908", "0.5657908", "0.5657908", "0.5657908", "0.5657908", "0.5657908", "0.5652066", "0.56494176", "0.56305724", "0.5630361", "0.5616549", "0.5611264", "0.55947953", "0.5585165", "0.55848813", "0.5583777", "0.55801123", "0.55761105", "0.5570095", "0.55641687", "0.5563336", "0.5562735", "0.5558562", "0.55442464", "0.5539145", "0.5532521", "0.55300385", "0.5528673", "0.55266225", "0.55219436", "0.55134046", "0.5512719", "0.5506596", "0.54923046", "0.54906833", "0.5489987", "0.54888463", "0.5488596", "0.5483932", "0.54746747", "0.5472811", "0.5472204", "0.54720074", "0.54635876", "0.54571164", "0.54549813", "0.54549813" ]
0.0
-1
Method is not allowed.
def record_not_unique_json(exception) code = 405 original_message = exception.message exception = ActiveRecord::RecordNotUnique.new(Status::Errors::ERROR_NON_UNIQUE_DB_ID["message"]) render :json => Status::Errors.exception_json(exception, code, original_message).to_json, :status => code end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def `(*args); forbidden(__method__); end", "def private_method\n end", "def ignore_method_conflicts; end", "def operation_method\n raise 'Not implemented!'\n end", "def http_method\n raise \"Implement in child class\"\n end", "def protected_method\n end", "def private_method\n\tend", "def private_method\n\tend", "def method_not_allowed\n [\n 405,\n { CONTENT_TYPE => 'text/plain', 'X-Cascade' => 'pass' },\n [\"#{Utils::HTTP_STATUS_CODES[405]}\\n\"]\n ]\n end", "def method\r\nend", "def check_only_methods\n end", "def my_fare\n\traise NotImplementedError,\n\t \"This class #{self.class.to_s} can not respond to the method::: #{__method__.to_s}\"\n end", "def method\n\t\t# code code\n\tend", "def private_method; end", "def methods; end", "def methods; end", "def methods; end", "def methods; end", "def method_missing(*args)\n\t\t\traise \"Method missing: #{args.inspect}\"\n\t\tend", "def private_method\n end", "def delete(*)\n unavailable_method\n end", "def abstract_method\n method_not_implemented\n end", "def textMethod\n\t\traise \"Ceci est une methode abstraite. This is an abstact method.\";\n\tend", "def protected_method\n\tend", "def allowed_method(method=nil)\n if method.class == Symbol && !block_given?\n @j_del.java_method(:allowedMethod, [Java::IoVertxCoreHttp::HttpMethod.java_class]).call(Java::IoVertxCoreHttp::HttpMethod.valueOf(method))\n return self\n end\n raise ArgumentError, \"Invalid arguments when calling allowed_method(method)\"\n end", "def expected_method; end", "def signature\n raise NotImplementedError, _(\"%{class} has not implemented method %{method}\") %{class: self.class, method: __method__}\n end", "def method2 # will be 'protected'\n #...\n end", "def demoMethod\n\t\traise \"Ceci est une methode abstraite. This is an abstact method.\";\n\tend", "def method_missing(wh,*therest)\n # xxx internal methods must be protected at some point\n end", "def allowed?() raise NotImplementedError end", "def a_private_method\n\tend", "def operation\n raise NotImplementedError, \"#{self.class} has not implemented method '#{__method__}'\"\n end", "def delete\n unavailable_method\n end", "def required_operations1\n raise NotImplementedError, \"#{self.class} has not implemented method '#{__method__}'\"\n end", "def create(*)\n unavailable_method\n end", "def method_name\n\n end", "def method_name\n\n end", "def method_name\n\n end", "def method2 # will be 'protected'\r\n\t\t#...\r\n\tend", "def method_name\n end", "def method2 # will be 'protected'\n #...\n end", "def method4 # and this will be 'public'\r\n\t\t#...\r\n\tend", "def respond_to_missing?(method_name, include_private = false)\n valid?(method_name) || super\n end", "def verb\n raise NotImplementedError.new('Must override')\n end", "def http_method(request)\n raise NotImplementedError\n end", "def http_method(request)\n raise NotImplementedError\n end", "def allow_registration(method); end", "def public_method; end", "def method4 # and this will be 'public'\n #...\n end", "def protected_method\n end", "def method_missing meth, *args\n raise NoMethodError.new(\"undefined method `#{meth}' for \"<<\n \"\\\"#{self}\\\":#{self.class}\")\n end", "def methods() end", "def method\n @method\n end", "def method\n @method\n end", "def onSudokuMethod\n\t\traise \"Ceci est une methode abstraite. This is an abstact method.\";\n\tend", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_missing(method, *args)\n # Break if first argument was not a model record\n return unless args[0].instance_of? model\n\n # Super if allowed_methods not defined or in not included in array\n am = self.class.allowed_methods\n super if am.nil? || !am.include?(method)\n\n resend_method(method, args)\n end", "def create\n unavailable_method\n end", "def method4 # and this will be 'public'\n #...\n end", "def denied\n end", "def delete(*)\n unavailable_method\n end", "def delete(*)\n unavailable_method\n end", "def delete(*)\n unavailable_method\n end", "def delete(*)\n unavailable_method\n end", "def delete(*)\n unavailable_method\n end", "def delete(*)\n unavailable_method\n end", "def allow(_image)\n puts \" +++ If you're seeing this, #{self.class.name}.#{__method__} was not overridden\"\n end", "def access_denied\n end", "def check_instance_method_existance!(method_name)\n raise NoMethodError.new(\"undefined method `#{method_name}' for #{to_s}\") unless crud_instance_methods.include?(method_name.to_sym)\n end", "def method_undefined(*) end", "def perform\n raise Errors::AbstractMethod\n end", "def [](index)\n raise NoMethodError, %(this method must be redefined in subclasses)\n end", "def other_public_method\n end", "def method_of_instance; end", "def method_of_instance; end", "def method_of_instance; end", "def method_of_instance; end" ]
[ "0.73048013", "0.73048013", "0.73048013", "0.73048013", "0.73048013", "0.73048013", "0.73048013", "0.73048013", "0.73048013", "0.73048013", "0.73048013", "0.73048013", "0.71526605", "0.7023407", "0.6977093", "0.69003445", "0.6798938", "0.67812485", "0.67418903", "0.67418903", "0.67205316", "0.6715194", "0.67032355", "0.6684107", "0.6619169", "0.65698516", "0.6566947", "0.6566947", "0.6566947", "0.6566947", "0.6542567", "0.6530313", "0.6529977", "0.6518551", "0.6498021", "0.6494152", "0.6486858", "0.6449331", "0.6417217", "0.6410765", "0.6395407", "0.6390216", "0.6383253", "0.63830113", "0.63823605", "0.6381108", "0.6377792", "0.637736", "0.6350016", "0.6350016", "0.6350016", "0.63473606", "0.6346718", "0.6336081", "0.63319564", "0.6329395", "0.6324062", "0.6308047", "0.6308047", "0.6305825", "0.63022846", "0.6292739", "0.6284851", "0.6279672", "0.62781703", "0.62722826", "0.62722826", "0.6268214", "0.62583226", "0.62583226", "0.62583226", "0.62583226", "0.62583226", "0.62583226", "0.62583226", "0.62583226", "0.62583226", "0.62583226", "0.62583226", "0.62583226", "0.6257589", "0.6252393", "0.6250708", "0.6246869", "0.6243325", "0.6243325", "0.6243325", "0.6243325", "0.6243325", "0.6243325", "0.6242747", "0.6242667", "0.62346494", "0.62315816", "0.62271994", "0.62097037", "0.62057364", "0.6195841", "0.6195841", "0.6195841", "0.6195841" ]
0.0
-1
Invalid JSON used for our configuration.
def invalid_json_json(exception) code = 500 render :json => Status::Errors.exception_json("We are currently experiencing issues with our data server, please try again soon.", code).to_json, :status => code end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_format\n JSON.parse(content) && nil if content\n rescue JSON::ParserError => err\n err.message\n end", "def validate_format\n JSON.parse(content) && nil if content\n rescue JSON::ParserError => err\n err.message\n end", "def fix_malformed_json(malformed_json)\n return malformed_json.gsub(/([a-z][a-zA-Z0-9_]+):(?!\\s)/, '\"\\1\":')\n end", "def valid_json(json)\n JSON(json)\n #NOTE: Rescuing TypeError too in case json is not a String\n rescue ::JSON::ParserError, TypeError\n nil\n end", "def raise_bad_format\r\n error_message = ErrorMessage.new(\"400\", \"Api:et stödjer inte det begärda formatet.\",\r\n \"Felaktig begäran. Kontakta utvecklaren.\")\r\n render json: error_message, status: :bad_request\r\n end", "def missing_params(e)\n \trender json: { message: e.message }, status: :unprocessable_entity\n end", "def error_base\n {\n code: JSONAPI::VALIDATION_ERROR,\n status: :unprocessable_entity\n }\n end", "def invalid_json_response\n <<~RESPONSE\n {\n foo : bar\n }\n RESPONSE\n end", "def record_invalid(exception)\n render json: exception.record.errors, status: :unprocessable_entity\n end", "def json_parser_error_class\n ::JSON::ParserError\n end", "def ensure_json_request\n return render_message({status:ERR_STATUS,responseMessage: NOT_ACCEPTABLE_MESSAGE, responseCode: NOT_ACCEPTABLE }) unless request.format == :json\n end", "def on_parse_error(e)\n message = \"Invalid JSON\"\n [400, {'Content-Length' => message.length}, [message]]\n end", "def validate_format\n data = JSON.decode(data) if data.class == Hash\n JSON.parse(data) && nil if data.present?\n rescue JSON::ParserError\n nil\n end", "def json\n data = yield\n raise_error = false\n\n begin\n JSON.parse(data)\n rescue JSON::JSONError\n # We retried already, raise the issue and be done\n raise VagrantPlugins::Parallels::Errors::JSONParseError, data: data if raise_error\n\n # Remove garbage before/after json string[GH-204]\n data = data[/({.*}|\\[.*\\])/m]\n\n # Remove all control characters unsupported by JSON [GH-219]\n data.tr!(\"\\u0000-\\u001f\", '')\n\n raise_error = true\n retry\n end\n end", "def sanitise_json(client_conf_right)\n begin\n file_right = JSON.parse(File.read(client_conf_right))\n file_right = file_right[0] if (file_right.length <= 1) && (file_right.kind_of?(Array))\n return file_right\n end\n rescue JSON::ParserError => error\n puts \"Error parsing json in conf, Fix invalid json and run the script again. #{client_conf_right} : See #{error}\"\n exit (1)\n end", "def sanitise_json(client_conf_right)\n begin\n file_right = JSON.parse(File.read(client_conf_right))\n file_right = file_right[0] if (file_right.length <= 1) && (file_right.kind_of?(Array))\n return file_right\n end\n rescue JSON::ParserError => error\n puts \"Error parsing json in conf, Fix invalid json and run the script again. #{client_conf_right} : See #{error}\"\n exit (1)\n end", "def parse_config_file\n JSON.parse(File.read(CONFIG_FILE))\n rescue Errno::ENOENT\n abort \"#{CONFIG_FILE} does not exist\"\n rescue Errno::EACCES\n abort \"#{CONFIG_FILE} can't be read\"\n rescue JSON::ParserError\n abort \"#{CONFIG_FILE} is not valid JSON\"\n end", "def render_unknown_format\n format = sanitize(params[:format]) || ''\n errors = JsonApiServer.errors(\n status: 406,\n title: I18n.t('json_api_server.render_unknown_format.title'),\n detail: I18n.t('json_api_server.render_unknown_format.detail', name: format)\n )\n render json: errors.to_json, status: 406\n end", "def bad_request(object)\n render json: object, status: 400\n end", "def hacer_json_valido(json)\n \n if (json.chars.first =='{' && json.chars.last=='}')\n json.insert(0,\"[\")\n json.append(\"]\")\n end\n \n return json\n\n end", "def invalid_data\n {\n :title => \"\",\n :description => nil,\n :parent_id => \"ss\"\n } \n end", "def validation_error_as_json\n Jbuilder.encode do |json|\n json.error 'Validation Failed'\n end\n end", "def data_json\n\t\tbegin\n\t\t\tJSON.parse(@client_input) if !@client_form_bool and @client_json_bool\n\t\trescue => ex\n\t\t\t@client_json_bool = false\n\t\t\t{ :bool => false, :code => 0, :info => 'bad client json data' }\n\t\tend\n\tend", "def failure_json\n { errors: 'Sorry you are not eligible for WellMatch' }\n end", "def missing_parameters(object)\n render json: object, status: 422\n end", "def valid_json(json)\n JSON.parse(json)\n return true\n rescue JSON::ParserError => e\n return false\n end", "def unprocessable_entity(record)\n status 422\n errors = { \"errors\" => record.errors.full_messages }\n\n json errors\n end", "def validate_as_json(response)\n JSON.parse(response)\n rescue JSON::NestingError\n raise Client::Error::InvalidResponseContent, 'Too deep response'\n rescue JSON::ParserError\n raise Client::Error::InvalidResponseContent, 'Unexpected response'\n rescue JSON::MissingUnicodeSupport\n raise Client::Error::InvalidResponseContent, 'Invalid character in response'\n rescue JSON::UnparserError\n raise Client::Error::InvalidResponseContent, 'Unable to parse response'\n rescue JSON::JSONError\n raise Client::Error::InvalidResponseContent, 'Invalid response'\n end", "def process_action(*args)\n super\n rescue ActionDispatch::Http::Parameters::ParseError => exception\n json_response(nil ,400, :bad_request)\n end", "def auth_error(e)\n json_response({ message: e.message }, :unprocessable_entity)\n end", "def validate_key!(key)\n unless key.is_a?(String) or key.is_a?(Symbol)\n raise SketchUpJSON::JSONEncodeError, \"This hash can not generate valid JSON\"\n end\n end", "def errors_from_json(json)\n render('layouts/json_errors', errors: json ) unless json.blank?\n end", "def render_parameter_missing_response(exception)\n render json: {error: exception.message}, status: 422\n end", "def bad_request\n render status: :bad_request, json: {\n errors: ['Invalid Request', 'Missing one or more required fields.'],\n }\n end", "def validate_json_credentials(json_key)\n json_key_hash = Fog::JSON.decode(json_key)\n\n unless json_key_hash.key?(\"client_email\") || json_key_hash.key?(\"private_key\")\n raise ArgumentError.new(\"Invalid Google JSON key\")\n end\n end", "def not_good(status = 406)\n render json: {\n result: 'Unfilled params',\n message: 'Please Fill the Correct params',\n status: 'Not_acceptable'\n }, status: status\n end", "def error\n response_json.fetch(\"error\", \"\")\n end", "def json_error(*args, &block)\n json = json_plain(*args)\n json[0].should.be.false\n if block_given? \n yield json[1]\n end\n json[1]\n end", "def json_fail(message)\n { status: 'fail', data: { message: message } }\n end", "def safeguarded_json\n # Make sure this is actually JSON\n hash = JSON.parse(params[:json])\n\n # Refuse to handle more than 12 chickens at once. What are you, a factory farmer??\n raise \"Too many birds\" if hash.size > 12\n\n return params[:json]\n end", "def parse_json str\n JSON.parse str rescue raise ConfigError, \"Invalid JSON\"\n end", "def test_illegal_string_parsing\n \n bad_json = 'not even close to legal json format'\n assert_equal( Graph.new().parse_json_string(bad_json), false )\n \n valid_not_csair_json = ' { \"some_key\" : [ {\"bla\" : \"bla\" } ] } '\n assert_equal( Graph.new().parse_json_string(valid_not_csair_json), false )\n \n no_routes_key_json = ' { \"metros\" : [ {\n \"code\" : \"SCL\" ,\n \"name\" : \"Santiago\" ,\n \"country\" : \"CL\" ,\n \"continent\" : \"South America\" ,\n \"timezone\" : -4 ,\n \"coordinates\" : {\"S\" : 33, \"W\" : 71} ,\n \"population\" : 6000000 ,\n \"region\" : 1\n } ] } ' \n assert_equal( Graph.new().parse_json_string(no_routes_key_json), false ) \n \n no_metros_key_json = ' { \"routes\" : [ { \"ports\" : [\"SCL\" , \"LIM\"],\n \"distance\" : 2453 } ] } '\n assert_equal( Graph.new().parse_json_string(no_metros_key_json), false )\n \n end", "def valid_json(string) \n\tJSON.parse(string) \n\treturn true \n\trescue JSON::ParserError \n\treturn false \nend", "def render_invalid_record_message(invalid)\n render json: {error: invalid.record.errors.full_messages}, status: :unprocessable_entity\n end", "def supports_json?\n false\n end", "def supports_json?\n false\n end", "def four_zero_zero(e)\n render json: jsonData(e), status: :bad_request\n end", "def readable_json(json)\n\t\t JSON.parse(json) rescue nil\n\t\tend", "def validate_json data\n JSON::Validator.fully_validate(\"schema.json\", data)\n end", "def invalid_authentication\n #render json: {errors: ['Invalid Request']}, status: :unauthorized\n error!('Invalid Request', :unauthorized)\n end", "def check_request_format\n unless request.content_type == 'application/json'\n error = ErrorSerializer.serialize({ format: \"Invalid request format. Only JSON requests are supported.\" })\n render json: error, status: :unsupported_media_type\n end\n end", "def render_params_missing_error\n render :json => { error: I18n.t('api.errors.parameters') },\n :status => :bad_request\n end", "def bad_request\n [ 400, {'Content-Type'=>'text/plain', 'Content-Length'=>'0'},\n [''] ]\n end", "def schema=(value)\n json = value.is_a?(String) ? ActiveRecord::Coders::JSON.load(value.strip) : value\n super(json)\n rescue JSON::ParserError\n errors.add(:schema, :invalid_json)\n end", "def invalid_user_params\n # invalid_user_params object:\n {\n user: {\n name: \"blah\",\n password: \"blah\"\n }\n }\n end", "def bad_request(message)\n render json: {\n errors: message,\n status: :bad_request\n }, status: 400\n end", "def wrong_params?\n if has_not_mandatory_params?\n render json: { message: \"Wrong data params\" }, status: 400\n end\n end", "def catch_bad_format_param\n if ['json', 'rss'].include? params[:format]\n render plain: \"Invalid parameter: we do not provide search results in #{params[:format]} format.\", status: 406\n end\n end", "def bad_request(error)\n json_response({ message: error.message }, :bad_request)\n end", "def assert_valid_json(res)\n require 'json'\n assert_content_type res, \"application/json\"\n begin\n JSON.parse(res.body)\n rescue JSON::ParserError => e\n flunk build_message(\"\", \"String <?> is not valid JSON. The Parser Error was: #{e.message}\", res.body)\n end\n end", "def parse_engine_config(raw)\n raw ? JSON.parse(raw) : {}\nend", "def parsed_error\n default = %({\"error_description\": \"#{message}\"})\n value = response_value(:body, fallback: default)\n\n JSON.parse(value)\n end", "def render_error\n render json: { errors: @address.errors.full_message }, status: unprocessable_entity\n end", "def json_render_errors(errors)\n json_fail errors\n end", "def status_code; 422; end", "def status_code; 422; end", "def status_code; 422; end", "def status_code; 422; end", "def bad_request\n render :json => {:success=>false, :error_code=> 400, :error_msg=>\"Bad Request\"}\n end", "def json_options\n { except: %i[created_at updated_at password_digest] }\n end", "def content_type_is_json_but_invalid_json_provided?\n content_type_json? && ((request_body_required? || any_request_body?) && invalid_json?)\n end", "def londons_rescue\n render json: { error: \"Gym not found\"}, status: 422\n end", "def list_invalid_properties\n invalid_properties = Array.new\n if @format.nil?\n invalid_properties.push('invalid value for \"format\", format cannot be nil.')\n end\n\n invalid_properties\n end", "def four_twenty_two(e)\n json_response({ message: e.message}, :unprocessable_entity)\nend", "def invalid_token\n render json: {\n error: \"Invalid Authenticition Token\",\n status: 400\n }, :status => 403\n end", "def unauthorized_request(e)\n render json: jsonData(e), status: :unauthorized\n end", "def ensure_json_request\n return if params[:format] == 'json' || request.headers['Accept'] =~ /json/\n head :not_acceptable\n end", "def read_json(throw_missing: T.unsafe(nil)); end", "def validate_json(message,schema)\n begin\n JSON::Validator.validate!(schema, message)\n rescue JSON::Schema::ValidationError => e\n logger.error \"JSON validating: #{e.to_s}\"\n return e.to_s + \"\\n\"\n end\n nil\n end", "def render_422(object)\n errors = JsonApiServer.validation_errors(object)\n render json: errors.to_json, status: 422\n end", "def validate!(hash)\n begin\n ::JSON::Validator.validate!(@schema_impl.schema,hash)\n rescue JSON::Schema::ValidationError => e\n # TODO: Not very nice error messages. Maybe make them betterer?\n raise\n end\n end", "def unprocessable_entity(error)\n json_response({ message: error.message }, :unprocessable_entity)\n end", "def valid_json?(json)\n JSON.parse(json)\n true\n rescue JSON::ParserError\n false\n end", "def params_validation\n errors = validate_params(params)\n return json_response(errors, :unprocessable_entity) if errors.present?\n end", "def failure\n failure = {failure: \"Uh oh! Looks like something didn't go quite right.\"}\n render json: failure\n end", "def parsed_config\n @parsed_config ||= begin\n JSON.parse(config[:json_config], symbolize_names: true)\n rescue JSON::ParserError\n JSON.parse(File.read(config[:json_config]),\n symbolize_names: true)\n end\n end", "def ignore_bad_data(val = nil)\n \t(config :ignore_bad_data => val) unless val.nil?\n \tstate[:ignore_bad_data]\n end", "def DISABLED_test_json\n require 'json'\n require 'json/pure'\n my_hash = JSON.parse('{\"hello\": \"goodbye\"}')\n JSON.generate(my_hash)\n end", "def handle_invalid_token\n render json: {\n success: false,\n errors: [\"The deposit token you provided was invalid.\"]\n }\n end", "def exception_on_syntax_error; end", "def render_unprocessable_entity(error)\n json_response({ error: { message: error.message } }, :unprocessable_entity)\n end", "def check_course_template_updated_data_validity(course_template_data)\n schema = {\n 'type' => 'object',\n 'required' => %w(Name Code),\n 'properties' => {\n 'Name' => { 'type' => 'string' },\n 'Code' => { 'type' => 'string' }\n }\n }\n JSON::Validator.validate!(schema, course_template_data, validate_schema: true)\nend", "def json_error(message = 'An error occurred')\n { status: 'error', message: message }\n end", "def four_twenty_two(e)\n render json: jsonData(e), status: :unprocessable_entity\n end", "def catch_bad_request_headers\n if request.headers[\"accept\"] == \"application/json\"\n render plain: \"Invalid request header: we do not provide a JSON version of our search results.\", status: 406\n end\n end", "def bad_format_error(response, msg, format)\n response.status = 400\n erb \"format missing or not supported: #{CourseList.safe_html_escape(format)}\"\n end", "def validate_config\n %w(api_token_secret_key account_alias recipe server groups).each {|key|\n raise_config_error(\"Invalid or empty #{key}\") if is_error? key, config_value(key)\n }\n end", "def as_json(options={})\n super(options.merge({:except => [:errors, :validation_context]}))\n end", "def render_unprocessable_entity(obj)\n render json: nil_protection(obj), status: :unprocessable_entity\n end", "def json_resource_errors\n { message: resource.errors.full_messages.first }\n end" ]
[ "0.66833407", "0.66833407", "0.65797335", "0.6351251", "0.6296096", "0.6244065", "0.61983657", "0.6115238", "0.6089773", "0.6044581", "0.6027647", "0.6011292", "0.60111916", "0.59835905", "0.59801924", "0.59801924", "0.59425426", "0.59346706", "0.5933757", "0.5876584", "0.5863525", "0.5850273", "0.5836138", "0.58188874", "0.5814467", "0.57662255", "0.57547", "0.5746793", "0.57388", "0.5733894", "0.5725215", "0.5692826", "0.5673701", "0.567242", "0.5665017", "0.56357366", "0.5621195", "0.56190795", "0.5618974", "0.5616097", "0.5596122", "0.558676", "0.5568745", "0.55656576", "0.55644125", "0.55644125", "0.5561799", "0.5557017", "0.5548667", "0.55482155", "0.5542826", "0.5537974", "0.5515888", "0.5511881", "0.5506528", "0.5495502", "0.54946595", "0.54940903", "0.5493742", "0.5485617", "0.54496825", "0.544486", "0.5438677", "0.54315406", "0.54267913", "0.54267913", "0.54267913", "0.54267913", "0.54252046", "0.5423969", "0.5419723", "0.541463", "0.5413188", "0.541239", "0.5403223", "0.54019785", "0.54017645", "0.5401455", "0.5390351", "0.53815323", "0.53803515", "0.5377936", "0.53772444", "0.53608507", "0.535933", "0.5356547", "0.5346012", "0.53457", "0.53434575", "0.53429353", "0.533775", "0.5337716", "0.5320071", "0.5316689", "0.5302235", "0.52949846", "0.5293912", "0.5289824", "0.5287975", "0.5286822" ]
0.67612433
0
All possible pairs of pieces
def pairs @pieces.combination(2).to_a end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pairs\n seq = to_a\n seq.zip([*seq[1..-1], unit.advance(to)])\n end", "def all_pairs\n all_pairs = self.pairs + self.reverse_pairs\n all_pairs.uniq!\n end", "def every_possible_pairing_of_word(arr)\n i1 = arr\n i2 = []\n i1.combination(2).to_a\nend", "def pairs(ring)\n ring.each_cons(2).to_a << [ring.last, ring.first]\nend", "def combinations(n)\n \n end", "def to_lazy_pairs(slots)\n slots.each_cons(2)\n end", "def each_pair\n\t\t\t# Ruby defines #combination and #permutation for iteration of those sorts of sets\n\t\t\t\n\t\t\t# counter = wrapping_counter @head_index, @tail_index, @queue.size\n\t\t\t\n\t\t\t# counter.each_index do |index|\n\t\t\t# \ti = counter[index]\n\t\t\t\t\n\t\t\t# \tcounter[(index+1)..-1].each do |j|\n\t\t\t# \t\tyield @queue[i], @queue[j]\n\t\t\t# \tend\n\t\t\t# end\n\t\t\t\n\t\t\t# using #permutation means that the order will not be guaranteed\n\t\t\twrapping_counter(@head_index, @tail_index, @queue.size).permutation(2) do |i, j|\n\t\t\t\tyield @queue[i], @queue[j]\n\t\t\tend\n\t\tend", "def pairs # :yields: progA, progB\n n = @hill.length\n (0 .. n-2).each do |idA|\n (idA+1 .. n-1).each do |idB|\n yield @hill[idA], @hill[idB]\n end\n end\n end", "def id_pairs # :yields: idA, progA, idB, progB\n n = @hill.length\n (0 .. n-2).each do |idA|\n (idA+1 .. n-1).each do |idB|\n yield idA, @hill[idA], idB, @hill[idB]\n end\n end\n end", "def every_possible_pairing_of_students(array)\n array.combination(2)\nend", "def every_possible_pairing_of_students(array)\n array.combination(2)\nend", "def each_combination\n \n end", "def pairs\n letters = split('')\n pairs = []\n letters.each.with_index do |letter, i|\n next_letter = letters[i + 1]\n pairs << letter + next_letter unless next_letter.nil?\n end\n pairs\n end", "def chord_pairs\n pairs = []\n @chords.each_cons(2) { |c, d| pairs << [c, d] }\n return pairs\n end", "def print_all_possible_ordered_pairs(items)\n items.each do |first_item|\n items.each do |second_item|\n puts first_item, second_item\n end\n end\nend", "def combos\n first.product(*tail)\n end", "def pairs_for_run(run)\r\n\t\ttemp = Array.new\r\n\t\t0.upto(run.size-2) do |index1|\r\n\t\t\t(index1+1).upto(run.size-1) do |index2|\r\n\t\t\t\ttemp << ([] << run[index1] << run[index2])\r\n\t\t\tend\r\n\t\tend\r\n\t\ttemp\r\n\tend", "def findPairs(set)\n 0.upto(@size-1) do |n|\n (n+1).upto(@size-1) do |m|\n if (set[n].possible.size == 2 && set[n].possible ==\nset[m].possible)\n eliminateExcept(set, [m,n], set[n].possible)\n end\n end\n end\n end", "def skittle_combos(skittles)\n skittles.combination(2).map(&:sort).uniq\nend", "def pair; end", "def generatePairs\n for i in [email protected] do \n for j in i+1 [email protected] do\n tmppairs = Pairs.new i,j\n for k in [email protected][i].elementsArr.length do\n for h in [email protected][j].elementsArr.length do \n tmppair = Pair.new k,h #there we store the index of value but not the true value\n @parameters.paramsArr[i].elementsArr[k].addTimes\n @parameters.paramsArr[j].elementsArr[h].addTimes\n tmppairs.addPair tmppair #temppairs just like ABpairs not all AB AC BC\n \n end\n end\n @pairs << tmppairs #@pairs is all the pairs like AB AC BC \n end\n end\n\n #if has limit then update the pairs with limit conditions\n if @haslimit\n \tputs \"update pairs with limit....\"\n updatePairsWithLimit\n end\n end", "def doPair(needsToBePlaintiff, needsToBeDefense)\n proposed_pairings = []\n (1...needsToBeDefense.length).each do |i|\n proposed_pairings << [needsToBePlaintiff[i], needsToBeDefense[i]]\n end\n return proposed_pairings\n end", "def combinations(arr)\n pairs = [] # this is 1d\n\n arr.each_with_index do |ele1, idx1| # compare this element to others in the array via a nested loop\n arr.each_with_index do |ele2, idx2|\n if idx2 > idx1 # make sure only looking at new things\n pairs << [ele1, ele2] # shovel array into pairs\n end\n end \n end\n\n return pairs # will be a 2d array by now\n\nend", "def every_possible_pairing_of_students(array)\n\tn = ['Bob', 'Dave', 'Clive']\n\tn.combination(2)\nend", "def all_combinations(the_list)\n results = []\n the_list.each { |item|\n the_list.each { |inner_item|\n results << [item, inner_item]\n }\n }\n results\nend", "def winning_combos\n [[0, 1, 2], [3, 4, 5], [6, 7, 8],\n [0, 3, 6], [1, 4, 7], [2, 5, 8],\n [0, 4, 8], [2, 4, 6]]\n end", "def mixed_pairs\nend", "def uniq_combinations_by_piece\n joins = combinations.keys\n\n joins.each do |join|\n combinations[join].reject! do |comb|\n comb.uniq { |c| c[:piece] }.size < comb.size\n end\n end\n end", "def combine_parts(parts)\n\t\t\tparts.size.downto(1).with_object([]) do |i, arr|\n\t\t\t\tarr.push(*parts.combination(i).to_a)\n\t\t\tend\n\t\t\t# variants.uniq!.reject!(&:empty?)\n\t\tend", "def generate_combos(n, item1, item2, item3, u1, u2, u3)\n used = []\n success = 0\n while (success < n)\n new_triplet = make_triplet(item1, item2, item3)\n if (triplet_included(new_triplet, used))\n # do nothing\n else\n success += 1\n used.push(new_triplet)\n end\n end\n end", "def pair_up(arr, target_product)\n end", "def potential_pairs\n potentials = []\n teams.each do |team|\n team.members.each do |member|\n if member != self && member != self.last_pair && member.paired == false\n potentials << member\n end\n end\n end\n potentials\n end", "def print_pairs(array)\n i = 0\n while i < array.length\n j = i + 1\n while j < array.length\n num1 = array[i]\n num2 = array[j]\n puts \"#{array[i]} , #{array[j]}\"\n j+= 1\n end\n i+= 1\n end\nend", "def combinations(groups)\n (0...groups.size)\n .to_a\n .combination(2)\n .to_a\n .sort { |a, b| (a.last - a.first) - (b.last - b.first) }\n .map { |s, f| yield s..f }\nend", "def caterpillar_method\n result=[]\n i=0\n while(i<self.size/2)\n j=i+1\n while (self[j] && (yield self[i],self[j]))\n result<<[self[i],self[j]]\n j+=1\n end\n i+=1\n end\n return result\n end", "def print_pairs(arr)\n i = 0\n while i < arr.length\n j = 0\n while j < arr.length\n\n puts \"#{arr[i]},#{arr[j]}\"\n j += 1\n end\n i += 1\n end\nend", "def combinations(arr)\n pairs = []\n\n arr.each.with_index do |el1, i1|\n arr.each.with_index do |el2, i2|\n if i2 > i1\n pairs << [el1, el2]\n end\n end\n end\n return pairs\nend", "def print_pairs(array)\n i = 0\n while i < array.length\n j= 0\n while j < array.length\n num1 = array[i]\n num2 = array[j]\n puts \"#{array[i]} , #{array[j]}\"\n j+= 1\n end\n i+= 1\n end\nend", "def combos\n result = []\n radixs = reverse.map(&:size)\n inject(1){|r, i| r * i.size}.times{ |step|\n result << foldr(lambda{ |i, r|\n radix = radixs[r.size]\n r.unshift i[step % radix]\n step /= radix unless radix.nil?\n r\n }, [])\n }\n result\n end", "def realizar_combates\n length = @entrenadores.length\n (0..length - 1).each do |entrenador1|\n (entrenador1 + 1..length - 1).each do |entrenador2|\n combatir([@entrenadores[entrenador1], @entrenadores[entrenador2]])\n end\n end\n end", "def generate_pairs(point_array)\n pair_list = []\n\n point_array.each_index do |index|\n this_point = point_array[index]\n next_point = point_array[index + 1]\n\n if next_point\n pair_list << [this_point, next_point]\n end\n end\n\n pair_list\n end", "def remix pairs\n alcohols = pairs.map{ |pair| pair[0] }\n mixers = pairs.map{ |pair| pair[1] }\n \n mixed_pairs = alcohols.zip mixers.shuffle\n \n while mixed_pairs.any? { |pair| pairs.include? pair }\n mixed_pairs = alcohols.zip mixers.shuffle\n end\n \n mixed_pairs\nend", "def every_possible_pairing_of_students(array)\n # 1 - 1st with 2nd, 3rd ... final\n i = 1\n current_student = 0\n max = array.size\n new_array = []\n array.each {|student|\n # 3 - final does nothing\n while i < max\n new_array << [student,array[i]]\n i += 1\n end\n # 2 - 2nd with 3rd, 4th ... final\n current_student += 1\n i = 1 + current_student\n }\n new_array\nend", "def combos(cards)\n cards.to_a.combination(3).to_a\n end", "def get_combinatorial_pairs_nmatrix(vector)\n # Initialize the output vector\n out = get_pairs_output_vector vector, :combinatorial\n # Shorthand for the number of elements\n vs = vector.shape[0]\n \n # Iterates through each element in the original vector\n (0...vs-1).each do |i|\n # The range of elements in the output we will be modifying\n r = get_combinatorial_range(vs, i)\n # Assigns the primary element in each pair\n assign_range_slice(out, vector.rank(0, i), 0, r)\n # Assigns the comparison element in each pair\n assign_range_slice(out, vector.rank(0, (i+1)...vs), 1, r)\n end\n out\n end", "def each_pair\n self.each_pair_index do |i, j|\n yield self[i], self[j]\n yield self[j], self[i]\n end\n end", "def generate_combinations( n )\n\t# => since the first combination will replace ALL digits and the last one\n\t# => won't replace anything both won't be necessary\n\treturn [ true, false ].repeated_permutation( n ).to_a[ 1..-2 ]\nend", "def mixed_combinations\n combination_generator.mixed_combinations\n end", "def combinations(arr)\n pairs = []\n\n arr.each_with_index do |ele1, idx1|\n arr.each_with_index do |ele2, idx2|\n if idx2 > idx1\n pairs << [ele1, ele2]\n end\n end\n end\n\n return pairs \n\nend", "def combinations(*args)\n # initialize an array for the result\n array_new = []\n # combine the last two arguments (arrays)\n args[-2].each do |y|\n args[-1].each do |z|\n array_new.push(([y, z]).flatten)\n end\n end\n # get rid or last two arguments (arrays) that were combined above\n args.pop(2)\n # add the combined array (of last two elements) to args\n args.push(array_new)\n # if there are still more arguments to process call this function recursively\n if args.length > 1\n array_new = combinations(*args)\n end\n return array_new\nend", "def to_pairs\n each_pair.to_a\n end", "def get_adjacent_pairs_large(vector)\n responds_to_arguments vector, [:rank, :shape]\n # Set up the output matrix\n out = get_pairs_output_vector vector\n [0, 1].each do |i|\n out.rank(*pairs_args(out, 1, i), :reference)[*slice_args(out)]= vector.rank(*pairs_args(vector, 0, i))\n end\n out\n end", "def panoramic_pairs(landmarks)\n n = landmarks.length - 1\n pairs = []\n\n (0...n).each do |i|\n pairs << [landmarks[i], landmarks[i + 1]]\n end\n\n pairs << [landmarks[-1], landmarks[0]]\n pairs\nend", "def each_pair(*) end", "def all_combinations(the_list)\n\tresults = []\n\tthe_list.each do |item|\n\t\tthe_list.each do |inner_item|\n\t\t\tresults.push([item, inner_item])\n\t\tend\n\tend\n\treturn results\nend", "def generate_pairs\n students.shuffle.each_slice(2).to_a\n end", "def switchPairs(a)\n if a.length % 2 == 0\n (0..a.length-1).each do |i|\n if i % 2 == 0\n a[i], a[i+1] = a[i+1], a[i]\n end\n end\n else\n (0..a.length-2).each do |i|\n if i % 2 == 0\n a[i], a[i+1] = a[i+1], a[i]\n end\n end\n end\n return a\nend", "def win_possibilities(piece)\n\t\t[ [ [piece[0],piece[1]],[piece[0]+1,piece[1]],[piece[0]+2,piece[1]],[piece[0]+3,piece[1]] ],\n\t\t[ [piece[0]-1,piece[1]],[piece[0],piece[1]],[piece[0]+1,piece[1]],[piece[0]+2,piece[1]] ],\n\t\t[ [piece[0]-2,piece[1]],[piece[0]-1,piece[1]],[piece[0],piece[1]],[piece[0]+1,piece[1]] ],\n\t\t[ [piece[0]-3,piece[1]],[piece[0]-2,piece[1]],[piece[0]-1,piece[1]],[piece[0],piece[1]] ],\n\t\t[ [piece[0],piece[1]],[piece[0],piece[1]+1],[piece[0],piece[1]+2],[piece[0],piece[1]+3] ],\n\t\t[ [piece[0],piece[1]-1],[piece[0],piece[1]],[piece[0],piece[1]+1],[piece[0],piece[1]+2] ],\n\t\t[ [piece[0],piece[1]-2],[piece[0],piece[1]-1],[piece[0],piece[1]],[piece[0],piece[1]+1] ],\n\t\t[ [piece[0],piece[1]-3],[piece[0],piece[1]-2],[piece[0],piece[1]-1],[piece[0],piece[1]] ],\n\t\t[ [piece[0],piece[1]],[piece[0]+1,piece[1]+1],[piece[0]+2,piece[1]+2],[piece[0]+3,piece[1]+3] ],\n\t\t[ [piece[0]-1,piece[1]-1],[piece[0],piece[1]],[piece[0]+1,piece[1]+1],[piece[0]+2,piece[1]+2] ],\n\t\t[ [piece[0]-2,piece[1]-2],[piece[0]-1,piece[1]-1],[piece[0],piece[1]],[piece[0]+1,piece[1]+1] ],\n\t\t[ [piece[0]-3,piece[1]-3],[piece[0]-2,piece[1]-2],[piece[0]-1,piece[1]-1],[piece[0],piece[1]] ],\n\t\t[ [piece[0],piece[1]],[piece[0]+1,piece[1]-1],[piece[0]+2,piece[1]-2],[piece[0]+3,piece[1]-3] ],\n\t\t[ [piece[0]-1,piece[1]+1],[piece[0],piece[1]],[piece[0]+1,piece[1]-1],[piece[0]+2,piece[1]-2] ],\n\t\t[ [piece[0]-2,piece[1]+2],[piece[0]-1,piece[1]+1],[piece[0],piece[1]],[piece[0]+1,piece[1]-1] ],\n\t\t[ [piece[0]-3,piece[1]+3],[piece[0]-2,piece[1]+2],[piece[0]-1,piece[1]+1],[piece[0],piece[1]] ] ]\n\tend", "def every_possible_pairing_of_word(arr)\n reformed_array = []\n index = 0\n arr.each do |entry|\n arr.each do |entry2|\n if reformed_array.include? [entry, entry2]\n \n elsif reformed_array.include? [entry2, entry]\n elsif entry != entry2 \n reformed_array.insert(index, [entry, entry2])\n index += 1\n end\n end\n end\n return reformed_array\nend", "def multiply_all_pairs(first, second)\n\n muliplicants = []\n\n first.each do |f|\n second.each do |s|\n muliplicants << f * s\n end\n end\n\n muliplicants.sort\nend", "def make_nested_pairs(*args)\n if args.size == 0\n return nil\n end\n Pair.new(args[0], make_nested_pairs(*args[1..-1]))\n end", "def pairs(factors)\n pairs = []\n # only have to iterate thru half the list of factors, since beyond the\n # halfway line has already been accounted for in the pairs\n (factors.size/2).times do |i|\n pairs << Pair.new(factors[i], factors.last/factors[i])\n end\n pairs\nend", "def round_robin(list, pairs = [])\n \n length = list.length\n halfway = (length / 2.0).ceil\n first_half = list[0..halfway - 1]\n second_half = list[halfway..]\n\n\n if length <= 2\n\n first = first_half[0]\n second = second_half[0] || ''\n pairs << [first, second] unless first == second\n\n return pairs\n else\n halfway.times do\n second_halves_used = []\n first_half.each do |first|\n found_second = false\n second_half.each do |second|\n next if second_halves_used.include?(second)\n next if pairs.any? { |pair| (pair[0] == first && pair[1] == second) || (pair[1] == first && pair[0] == second) }\n\n # second_half.delete(second)\n found_second = true\n pairs << [first, second]\n second_halves_used << second\n break\n end\n unless found_second\n pairs << [first, '']\n end\n end\n end\n pairs = round_robin(first_half, pairs)\n pairs = round_robin(second_half, pairs)\n return pairs\n end\nend", "def all_combinations(ingredients, total_to_allocate = 100)\n first_ingredient = ingredients.first\n remaining_ingredients = ingredients[1..-1]\n\n if remaining_ingredients.any?\n (0..total_to_allocate).flat_map do |tbsp|\n all_combinations(\n remaining_ingredients,\n total_to_allocate - tbsp\n ).flat_map do |rmc|\n rmc.merge({ first_ingredient => tbsp })\n end\n end\n else\n [{ first_ingredient => total_to_allocate }]\n end\nend", "def print_all_pairs(arrays)\n\n arrays.each_with_index do |e,i|\n c = i\n index = c+=1\n pairs = []\n (arrays.length - index).times do |n|\n if e < arrays[index+n]\n pair = \"(#{e}, #{arrays[index+n]})\"\n pairs.push(pair) \n end\n end\n\n if not pairs.empty? \n p pairs.join(\", \")\n end\n end\nend", "def cantor_pairing(*xs)\n CantorPairingFunction.cantor_pairing(*xs)\n end", "def all_combinations(first, *rest)\r\n return first if rest == []\r\n rest = all_combinations(*rest)\r\n combs = []\r\n first.each do |v1|\r\n rest.each do |v2|\r\n combs << v1 + v2\r\n end\r\n end\r\n combs\r\nend", "def f(n)\n # your code here\n result = []\n possibles = (2..n).flat_map{ |s| [*2..n].combination(s).map(&:join).to_a }\n p possibles\n possibles.each do |i|\n x = 0\n temp_arr = []\n temp = i.split('').map { |j| j.to_i }\n p temp\n while x < temp.length do \n if i[x + 1] != i[x] + 1 || i[x + 1] == nil\n temp_arr << i[x]\n end\n x += 1\n end\n result << temp_arr\n end\n result.length\nend", "def switch_pairs(list)\n new_list = []\n (list.length / 2).times do\n new_list << list[1]\n new_list << list[0]\n list.delete_at(0)\n list.delete_at(0)\n end\n if list[0]\n new_list << list[0]\n end\n return new_list\nend", "def swap_pairs(array)\nend", "def full_pairs\n match_items.reject do |pair|\n pair[0].nil? || pair[1].nil?\n end\n end", "def switchPairs(strings)\n highest_index = strings.length - 1\n i = 0\n until i == highest_index\n strings[i], strings[i + 1] = strings[i + 1], strings[i] if i % 2 == 0\n i += 1\n end\n return strings\nend", "def pairs\n @analysis[:pairs]\n end", "def each_word_pair_v1\n words.each_con(2) {|array| yield array[0],array[1]}\n end", "def display_pairs\n @display_pairs = []\n pairs.each do |pair|\n i = 0\n result = \"\"\n while i < pair.count\n result << \"#{create_hand(pair[i])}\"\n result << ' and ' if i != (pair.count - 1)\n i += 1\n end\n @display_pairs << result if result != \"\"\n end\n @display_pairs\n end", "def pairings(project: nil)\n sprints = project&.sprints.presence || Sprint.all\n\n Pairing\n .for_sprint(sprints)\n .where(member1_id: id)\n .or(\n Pairing\n .for_sprint(sprints)\n .where(member2_id: id)\n )\n end", "def chat_participants \n friends.map do |friend|\n friend.combination(2).to_a\n end.flatten(1)\nend", "def pair_params\n end", "def solution(pairs)\n puts pairs\n pairs.each.map{|k,v| \"#{k}: #{v}\"}.join(\",\")\nend", "def lexical_combinations(strings)\n l = []\n if strings.length == 1\n l.add(strings)\n else\n strings.each do |letter|\n others = strings.except(letter)\n lexical_combinations(others).each do |subcombo|\n l.add([letter] + subcombo)\n l.add([letter + subcombo.first] + subcombo.butfirst)\n end\n end\n end\n l\nend", "def find_triplets(non_reduced_possibilities)\n non_reduced_possibilities.group_by {|e| e}.map { |e| e[0] if e[1][2]}.compact\n end", "def test_combine_proper_working\n fictive_draw = %w(a b c d e f g)\n fictive_combinations = combine(fictive_draw)\n expected_combinations = 2**fictive_draw.size - 1\n assert_equal expected_combinations, fictive_combinations.length\n end", "def solution2(pairs)\r\n # TODO: complete\r\n pairs.map{|k,v| \"#{k} = #{v}\"}.join(',')\r\nend", "def print_unordered_pairs(arr)\n for i in 0..arr.length-1\n for j in (i + 1)..arr.length-1\n puts arr[i].to_s + \",\" + arr[j].to_s\n end\n end\n return\nend", "def build_pieces\n (1..8).each do |i|\n Pawn.new(2, i, \"white\") \n end\n Rook.new(1, 1, \"white\")\n Knight.new(1, 2, \"white\")\n Bishop.new(1, 3, \"white\")\n Queen.new(1, 4, \"white\")\n King.new(1, 5, \"white\")\n Bishop.new(1, 6, \"white\")\n Knight.new(1, 7, \"white\")\n Rook.new(1, 8, \"white\")\n (1..8).each do |i|\n Pawn.new(7, i, \"black\") \n end\n Rook.new(8, 1, \"black\")\n Knight.new(8, 2, \"black\")\n Bishop.new(8, 3, \"black\")\n Queen.new(8, 4, \"black\")\n King.new(8, 5, \"black\")\n Bishop.new(8, 6, \"black\")\n Knight.new(8, 7, \"black\")\n Rook.new(8, 8, \"black\")\n end", "def combinations(nums)\n start, one, two, three, *rest = nums\n\n return 1 if two.nil?\n return combinations([one, two]) if three.nil?\n return combinations([one, two, three]) + combinations([two, three]) if rest.empty?\n \n combinations([one, two, three, *rest]) + combinations([two, three, *rest]) + combinations([three, *rest])\nend", "def panoramic_pairs(landmarks)\n #make a new array for pairs of landmarks\n #starting with first landmakr, iterate through array and add two landmakrs to pair of landmarks\n\n pairs_of_landmarks = []\n\n idx = 0\n while idx < landmarks.length\n next_landmark = landmarks[idx + 1] || landmarks[0]\n pairs_of_landmarks << [landmarks[idx], next_landmark]\n idx += 1\n end\n\n pairs_of_landmarks\nend", "def find_pairs_and_multiples\n set.each do |number|\n corresponding_number = TOTAL - number\n next unless set.include?(corresponding_number)\n\n puts corresponding_number * number\n break # as we only need the first pair\n end\n end", "def combinations(arr)\n res = []\n i = arr.length\n arr.each {|el|tem = [],ind= arr.index(el), (i-ind).times {i =ind, tem.push(el),tem.push(arr[i -= 1]) }}\nend", "def transposition\n (0...length-1).map { |i|\n string[0...i] +\n string[i+1, 1] +\n string[i,1] +\n string[i+2..-1]\n }.uniq\n end", "def find_pairs(arr, sum)\n arr.combination(2).find_all { |x, y| x + y == sum }\nend", "def pairs()\n g1 = generator(512, 16807) # 65 \n g2 = generator(191, 48271) # 191\n \n total = 0\n 40e6.to_i.times do \n v1 = g1.next.to_s(2).rjust(16,'0')\n v2 = g2.next.to_s(2).rjust(16,'0')\n \n total += 1 if v1[-16,16] == v2[-16,16]\n end\n \n total\nend", "def compositions(n, k, &block)\n # yields all \"compositions\" (i.e., all permutations of all\n # partitions) of n into k parts\n if block_given?\n if k == 1\n yield([n])\n else\n n.step(by:-1, to:0).each do |p|\n compositions(n-p, k-1) {|c|\n yield([p] + c)\n }\n end\n end\n else\n to_enum(:compositions, n, k)\n end\nend", "def combinations_to(elements, k)\n result = []\n (1..k).each do |i|\n result |= combinations(elements, i)\n end\n result << []\n result\n end", "def solve\n perms = (1..9).to_a.permutation.map {|p| p.join}\n prods = []\n\n perms.each do |p|\n (1..2).each do |len|\n a, b, c = p[0, len].to_i, p[len..4].to_i, p[5, 4].to_i\n prods << c if a * b == c\n end\n end\n \n prods.uniq.reduce( :+ )\n end", "def cantor_pairing(n, m)\n (n + m) * (n + m + 1) / 2 + m\nend", "def combinations(arr)\n\n arr.each_with_index do |ele1, idx|\n arr.each_with_index do |ele2, idx2|\n puts ele1 + ele2\n end\n end\n\nend", "def pair_product(arr, num) \n\nend", "def possibilities(x, y, letter)\n p = []\n for i in x-1..x+1\n for j in y-1..y+1\n # if [i, j] isn't in the grid or not on the cross center on [x, y], continue\n if ((i < 0 || i >= self.size || j < 0 || j >= self.size) || (x-i != 0 && y-j != 0) || (i == x && j == y))\n next\n end\n\n if (@grid[i][j] == letter)\n p.push({x: i, y: j})\n end\n end\n end\n return p\n end" ]
[ "0.65870905", "0.6571787", "0.65041363", "0.64706194", "0.64641786", "0.64543986", "0.64086646", "0.638834", "0.6382433", "0.63481873", "0.63481873", "0.6337747", "0.63077456", "0.62984926", "0.6297608", "0.6271361", "0.6243481", "0.6235391", "0.6190097", "0.6187677", "0.61661416", "0.61579144", "0.61073816", "0.6042528", "0.6037412", "0.6027785", "0.6026384", "0.6024539", "0.6016406", "0.60160905", "0.6002129", "0.5930667", "0.59222263", "0.590714", "0.58952343", "0.58853894", "0.58805615", "0.5878761", "0.5876273", "0.5864763", "0.5856922", "0.58467007", "0.58433205", "0.5837839", "0.5836279", "0.5820155", "0.5804928", "0.58042306", "0.57989347", "0.57753974", "0.5764006", "0.5730664", "0.57233393", "0.5714283", "0.57127833", "0.57012784", "0.5699683", "0.5680881", "0.5673474", "0.5658102", "0.5642453", "0.5642349", "0.56311077", "0.5626025", "0.5624014", "0.56226736", "0.5620452", "0.56193405", "0.5617947", "0.55926824", "0.5587197", "0.5584287", "0.5578981", "0.5576998", "0.5569769", "0.55645686", "0.55372316", "0.553697", "0.55329245", "0.5526987", "0.5524176", "0.5523371", "0.5521213", "0.55194855", "0.55145967", "0.55109215", "0.5510402", "0.55061394", "0.5504669", "0.5501149", "0.54991853", "0.5495923", "0.5494931", "0.54890996", "0.5487114", "0.54718244", "0.5468351", "0.5463889", "0.54617906" ]
0.810931
1
GET /kansei_buhins/1 GET /kansei_buhins/1.json
def show @kansei_buhin = KanseiBuhin.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @kansei_buhin } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @buchung = Buchung.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @buchung }\n end\n end", "def show\n @lich_su_binh_bau = LichSuBinhBau.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lich_su_binh_bau }\n end\n end", "def show\n @bili = Bili.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bili }\n end\n end", "def show\n @bruger = Bruger.find_by_id(current_user.id)\n @onske = Onske.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @onske }\n end\n end", "def show\n @bahan = Bahan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bahan }\n end\n end", "def show\n @basin = Basin.find(params[:id])\n\n @client = YahooWeather::Client.new \n @response = @client.fetch_by_location('Massingir, Gaza, Mz','c')\n @reponse2 = @client.fetch_by_location('Louis Trichardt, Limpopo, South Africa','c')\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @basin }\n\n end\n end", "def show\n\n\n @buisness = Buisness.find(params[:id])\n\n if @buisness==nil\n render text: \"Cannot find the specified buisness in the database\"\n end\n render json: @buisness\n end", "def show\n @giang_vien = GiangVien.find(params[:id])\n\n respond_to do |format| \n format.json { render json: @giang_vien }\n end\n end", "def index\n if session[:kunde_id] == nil\n @buchungs = Buchung.all\n else\n @buchungs = Buchung.find(:all, :conditions => ['kunde_id = ?',session[:kunde_id]], :order =>\"anfangszeit ASC\") \n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @buchungs }\n end\n end", "def index\n @buisnesses = Buisness.all\n\n render json: @buisnesses \n end", "def show\n @bilhete = Bilhete.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bilhete }\n end\n end", "def show\n @bico = Bico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bico }\n end\n end", "def show\n @begivenhed = Begivenhed.find(params[:id])\n @bruger = Bruger.find_by_id(current_user.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @begivenhed }\n end\n end", "def show\n @bitacora = Bitacora.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bitacora }\n end\n end", "def new\n @bokin = Bokin.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @bokin }\n end\n end", "def show\n @konyu_rireki = KonyuRireki.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @konyu_rireki }\n end\n end", "def index\n\t\tboats = Boat.all\n \trender json: boats, status: 200\n\tend", "def show\n @nhan_xet = NhanXet.where(:chi_tiet_binh_bau_id => params[:id])\n\n respond_to do |format|\n format.json { render json: @nhan_xet.collect{|i| {:NoiDung => i.NoiDung, :created_at =>i.created_at.strftime(\"Ngày %d/%m/%Y lúc %H:%M\"), :MaUser => i.user.MaUser,:TenUser => i.user.HoTen, :TenTruong => i.truong.TenTruong}} }\n end\n end", "def show\n @nguoi_dung = NguoiDung.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @nguoi_dung }\n end\n end", "def show\n @pengeluaran_bulanan = PengeluaranBulanan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pengeluaran_bulanan }\n end\n end", "def show\n @byoin = Byoin.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @byoin }\n end\n end", "def show\n @bergain = Bergain.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bergain }\n end\n end", "def show\n @bergain = Bergain.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bergain }\n end\n end", "def new\n @kansei_buhin = KanseiBuhin.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kansei_buhin }\n end\n end", "def index\n @kifus = Kifu.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @kifus }\n end\n end", "def index\n # Block execution if there is no current user\n if(current_user.blank?)\n return render json:{\n errors: \"true\",\n message: \"User not connected\"\n }, status: 401\n end\n\n user = User.find(current_user.id)\n logement = Logement.find_by(id:params[:logement_id])\n bain_demi = BainDemi.find_by(logement_id: params[:logement_id])\n bain_entier = BainEntier.find_by(logement_id: params[:logement_id])\n cuisine = Cuisine.find_by(logement_id: params[:logement_id])\n kit= Kitchenette.find_by(logement_id: params[:logement_id])\n\n \n render json:{\n bain_demi:bain_demi, bain_entier:bain_entier, cuisine:cuisine, kit:kit\n }\n end", "def index\n @interno_unidads = InternoUnidad.all\n render json: @interno_unidads\n end", "def show\n bike = Bike.find(params[:id]);\n render json: {status: 'SUCCESS', message:'Loaded bike', data:bike}, status: :ok\n end", "def index\n @bot_bingo_numbers = BotBingoNumber.all\n\n respond_to do |format|\n format.html # index.html.erb\n # frommat.json { render json: @bot_bingo_numbers }\n end\n end", "def index\n @himalayas ||= Himalaya.limit(10).order('id desc')\n @descuentos ||= Descuento.limit(10).order('id desc')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @himalayas }\n end\n end", "def show\n @penjualan_bahan = PenjualanBahan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @penjualan_bahan }\n end\n end", "def show\n @borc = Borc.where(:UyeId => current_user.uid).find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @borc }\n end\n end", "def show\n @guille = Guille.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @guille }\n end\n end", "def show\n @boat = Boat.find(params[:id])\n\n render json: @boat\n end", "def show\n @bike = Bike.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bike }\n end\n end", "def index\n @compte_bancaires = CompteBancaire.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json :@compte_bancaires }\n end\n end", "def show\n @nabe = Nabe.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @nabe }\n end\n end", "def show\n @bruschettum = Bruschettum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bruschettum }\n end\n end", "def show\n @ubication = Ubication.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ubication }\n end\n end", "def index\n @brags = Brag.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @brags }\n end\n end", "def show\n @kolegiji = Kolegiji.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kolegiji }\n end\n end", "def show\n @bordado = Bordado.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bordado }\n end\n end", "def show\n @beer = BreweryDB.beer(params[:id]) \n render json: @beer\n end", "def show\n render json: @used_bike, serializer: Web::V1::UsedBikeSerializer\n end", "def show\n @kullanici = Kullanici.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kullanici }\n end\n end", "def show\n render json: @bike #serializer: Web::V1::BikeSerializer\n end", "def index\n @uchronias = Uchronia.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @uchronias }\n end\n end", "def show\n @hasil = Hasil.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hasil }\n end\n end", "def index\n @bitacoras = Bitacora.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bitacoras }\n end\n end", "def getbatteries\n puts params\n buildid = params[\"buildingid\"]\n\n batteries = Battery.where(:building_id => buildid)\n\n puts batteries.inspect\n puts \"#################################################\"\n \n respond_to do |format|\n format.json { render json: batteries }\n end\n end", "def show\n @api_haiku = Api::Haiku.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @api_haiku }\n end\n end", "def show\n @sluzby = Sluzby.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sluzby }\n end\n end", "def show\n @uchronia = Uchronia.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @uchronia }\n end\n end", "def new\n @binh_bau = BinhBau.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @binh_bau }\n end\n end", "def index\n @banks = Bank.all\n render json: @banks\n end", "def show\n @kolegij = Kolegij.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kolegij }\n end\n end", "def show\n @baton = Baton.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @baton }\n end\n end", "def show\n @banda = Banda.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @banda }\n end\n end", "def show\n @bb = Bb.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bb }\n end\n end", "def index\n @himalayas = Himalaya.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @himalayas }\n end\n end", "def show\n @registro_bovino = RegistroBovino.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @registro_bovino }\n end\n end", "def show\n @m_beli_nota_second_d = MBeliNotaSecondD.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @m_beli_nota_second_d }\n end\n end", "def show\n @sinh_vien = SinhVien.where(ma_sinh_vien: params[:id]).first\n # Resque.enqueue(GvLogger, params[:id])\n if @sinh_vien and @sinh_vien.trucnhat\n respond_to do |format| \n format.json { render json: JSON.parse(@sinh_vien.trucnhat)[\"days\"].sort_by }\n end\n else\n respond_to do |format| \n format.json { render json: nil }\n end\n end\n end", "def show\n @sabio = Sabio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sabio }\n end\n end", "def index\n @bounties = Bounty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @bounties }\n end\n end", "def show\n @incucai = Incucai.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @incucai }\n end\n end", "def index\n @balloons = Balloon.order('created_at DESC');\n render json: {status: 'SUCCESS', message:'Loaded balloons', data:@balloons},status: :ok\n end", "def index\n @buchungs = Buchung.all\n end", "def show\n @ginasio = Ginasio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @ginasio }\n end\n end", "def show\n @hijo = Hijo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hijo }\n end\n end", "def index\n @used_bikes = UsedBike.all\n\n render json: @used_bikes, each_serializer: Web::V1::UsedBikeSerializer\n end", "def index\n url = \"https://data.cityofchicago.org/resource/x2n5-8w5q.json\"\n options = { :body => {:status => text}, :basic_auth => @auth }\n @response = HTTParty.get(url, options)\n\n @crime = Hash.new\n\n #@crime['block'] = @response[0]['block']\n @crime = @response\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gittos }\n end\n end", "def get_batterie_by_building\n @battery = Battery.where(building_id: params[:building_id])\n respond_to do |format| \n format.json { render :json => @battery }\n end\n \n end", "def show\n @kb = Kb.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @kb }\n end\n end", "def index\n @budgets = Budget.find_owned_by current_user\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @budgets }\n end\n end", "def index\n @aboutshetuans = Aboutshetuan.order(\"created_at desc\").page params[:page]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @aboutshetuans }\n end\n end", "def show\n @bloque = Bloque.find(params[:id])\n\n render json: @bloque\n end", "def new \n @buchung = Buchung.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @buchung }\n end\n end", "def index\n @tagihans = Tagihan.all\n @tagihans = @tagihans.select { |x| x.user_id == params[:user_id].to_i }\n render json: { items: @tagihans }\n end", "def show\n @weibo = Weibo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @weibo }\n end\n end", "def show\n @compte_bancaire = CompteBancaire.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json :@compte_bancaire }\n end\n end", "def show\n @jamaat = Jamaat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @jamaat }\n end\n end", "def index\n @biddings = Bidding.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @biddings }\n end\n end", "def show\n @boat = Boat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json {render json: @boat}\n end\n end", "def index\n @instituicoes = Instituicao.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @instituicoes }\n end\n end", "def index\n @verbindungs = Verbindung.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @verbindungs }\n end\n end", "def show\n @kazoku = Kazoku.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @kazoku }\n end\n end", "def show\n @weibo = Weibo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @weibo }\n end\n end", "def show\n @leito = Leito.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @leito }\n end\n end", "def index\n @ruas = Rua.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ruas }\n end\n end", "def show\n @baggage = Baggage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @baggage }\n end\n end", "def show\n @jugador = Jugador.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @jugador }\n end\n end", "def show\n @kisalli = Kisalli.find_by_key(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kisalli }\n end\n end", "def show\n @instituicao = Instituicao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @instituicao }\n end\n end", "def show\n @title = t('view.banks.show_title')\n @bank = Bank.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bank }\n end\n end", "def index\n @bids = Bid.where(\"auction_id = ?\", params[:auction_id])\n\n render json: @bids\n end", "def index\n @birds = Bird.all.to_a\n begin\n respond_to do |format|\n format.json { render json: {items: @birds, description: \"List all visible birds in the registry\", additionalProperties: false, title: \"POST /birds [request]\",:status => OK } }\n end\n rescue => e\n render json: ({:status => INTERNAL_SERVER_ERROR})\n end\n end", "def show\n @osoba = Osoba.find(params[:id])\n\n render json: @osoba\n end", "def show\n @huerto = Huerto.find_by_id(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @huerto }\n end\n end", "def index\n @kraje = Kraj.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @kraje }\n end\n end" ]
[ "0.6994087", "0.67499775", "0.6714746", "0.66419196", "0.6632724", "0.6623885", "0.6596611", "0.6568357", "0.65605146", "0.6483976", "0.6471406", "0.64261603", "0.63488626", "0.6325662", "0.6310468", "0.6304809", "0.6282256", "0.6273688", "0.6264302", "0.62628794", "0.62309545", "0.6223107", "0.6223107", "0.6222956", "0.621941", "0.62097806", "0.6188554", "0.6179169", "0.6173663", "0.6167288", "0.61647683", "0.61584014", "0.61464614", "0.61390936", "0.61379033", "0.6132258", "0.6131764", "0.61215264", "0.6121191", "0.6121174", "0.6120042", "0.6111096", "0.61097854", "0.61088157", "0.61004335", "0.60981584", "0.6096912", "0.60957", "0.608959", "0.60814995", "0.608056", "0.6078103", "0.6070108", "0.60606706", "0.6057299", "0.60543674", "0.6053122", "0.6045041", "0.60423875", "0.6041312", "0.6038655", "0.60324675", "0.6028735", "0.602694", "0.6025814", "0.6024861", "0.60210437", "0.6013494", "0.6012664", "0.5988209", "0.5985061", "0.5983768", "0.59772253", "0.597683", "0.5973815", "0.5968853", "0.5967698", "0.59669787", "0.59634393", "0.5962839", "0.5960887", "0.5956293", "0.5954576", "0.595392", "0.5953148", "0.5951452", "0.59499353", "0.5945964", "0.59457815", "0.59314406", "0.59291214", "0.5923503", "0.5918786", "0.59184873", "0.5917863", "0.59133965", "0.5906328", "0.590591", "0.5904041", "0.5903179" ]
0.7059854
0
GET /kansei_buhins/new GET /kansei_buhins/new.json
def new @kansei_buhin = KanseiBuhin.new respond_to do |format| format.html # new.html.erb format.json { render json: @kansei_buhin } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @bokin = Bokin.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @bokin }\n end\n end", "def new \n @buchung = Buchung.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @buchung }\n end\n end", "def new\n @byoin = Byoin.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @byoin }\n end\n end", "def new\n @hasil = Hasil.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hasil }\n end\n end", "def new\n @binh_bau = BinhBau.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @binh_bau }\n end\n end", "def new\n @nabe = Nabe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nabe }\n end\n end", "def new\n @bruger_id = current_user.id\n @bruger = Bruger.find_by_id(@bruger_id)\n @onske = Onske.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @onske }\n end\n end", "def new\n @huati = Huati.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @huati }\n end\n end", "def new\n @basin = Basin.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @basin }\n end\n end", "def new\n @title = t('view.banks.new_title')\n @bank = Bank.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bank }\n end\n end", "def new\n @bili = Bili.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bili }\n end\n end", "def new\n @u = U.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @u }\n end\n end", "def new\n @sinh_vien = SinhVien.new\n\n respond_to do |format| \n format.json { render json: @sinh_vien }\n end\n end", "def new\n @baton = Baton.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @baton }\n end\n end", "def new\n @bilhete = Bilhete.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bilhete }\n end\n end", "def new\n @tenni = Tenni.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tenni }\n end\n end", "def new\n @tupian = Tupian.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tupian }\n end\n end", "def new\n @breadcrumb = 'create'\n @bank = Bank.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bank }\n end\n end", "def new\n @monit = Monit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @monit }\n end\n end", "def new\n @sotrudniki = Sotrudniki.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sotrudniki }\n end\n end", "def create\n @kansei_buhin = KanseiBuhin.new(params[:kansei_buhin])\n\n respond_to do |format|\n if @kansei_buhin.save\n format.html { redirect_to @kansei_buhin, notice: 'Kansei buhin was successfully created.' }\n format.json { render json: @kansei_buhin, status: :created, location: @kansei_buhin }\n else\n format.html { render action: \"new\" }\n format.json { render json: @kansei_buhin.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @lich_su_binh_bau = LichSuBinhBau.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lich_su_binh_bau }\n end\n end", "def new\n @sezione = Sezione.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sezione }\n end\n end", "def new\n @borrow = Borrow.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @borrow }\n end\n end", "def new\n @kolegij = Kolegij.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kolegij }\n end\n end", "def new\n @giang_vien = GiangVien.new\n\n respond_to do |format| \n format.json { render json: @giang_vien }\n end\n end", "def new\n @hijo = Hijo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hijo }\n end\n end", "def new\n @mi = Mi.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mi }\n end\n end", "def new\n @lei = Lei.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lei }\n end\n end", "def new\n @bitacora = Bitacora.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bitacora }\n end\n end", "def new\n @nguoi_dung = NguoiDung.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nguoi_dung }\n end\n end", "def new\n authorize! :manage, LopMonHocSinhVien\n @lop_mon_hoc_sinh_vien = @lop_mon_hoc.lop_mon_hoc_sinh_viens.build\n respond_to do |format|\n format.html { render :layout => (request.headers['X-PJAX'] ? false : true)}\n format.json { render json: @lop_mon_hoc_sinh_vien }\n end\n end", "def new\n @bico = Bico.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bico }\n end\n end", "def new\n @guille = Guille.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @guille }\n end\n end", "def new\n @jamaat = Jamaat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @jamaat }\n end\n end", "def new\n @tieu_chi = TieuChi.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tieu_chi }\n end\n end", "def new\n @kolegiji = Kolegiji.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kolegiji }\n end\n end", "def new\n @indicativo = Indicativo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @indicativo }\n end\n end", "def new\n @lbaa = Lbaa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lbaa }\n end\n end", "def new\n @kullanici = Kullanici.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kullanici }\n end\n end", "def new\n @bid = Bid.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bid }\n end\n end", "def new\n @bid = Bid.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bid }\n end\n end", "def new\n @boat = Boat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json {render json: @boat}\n end\n end", "def new\n @pengeluaran_bulanan = PengeluaranBulanan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pengeluaran_bulanan }\n end\n end", "def new\n @sep_signup = SepSignup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sep_signup }\n end\n end", "def new\n @cita = Cita.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cita }\n end\n end", "def new\n @pinglun = Pinglun.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pinglun }\n end\n end", "def new\n @sitio_entrega = SitioEntrega.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sitio_entrega }\n end\n end", "def new\n @db_pekerjaan = DbPekerjaan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @db_pekerjaan }\n end\n end", "def new\n @kazoku = Kazoku.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @kazoku }\n end\n end", "def new\n @pushup = Pushup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pushup }\n end\n end", "def new\n @minicurso = Minicurso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @minicurso }\n end\n end", "def new\n @instituicao = Instituicao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @instituicao }\n end\n end", "def new\n @human = Human.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @human }\n end\n end", "def new\n @selecao = Selecao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @selecao }\n end\n end", "def new\n @pun = Pun.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pun }\n end\n end", "def new\n @bank = Bank.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bank }\n end\n end", "def new\n @caballo = Caballo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @caballo }\n end\n end", "def new\n @broad = Broad.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @broad }\n end\n end", "def new\n @seguidore = Seguidore.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @seguidore }\n end\n end", "def new\n @unp = Unp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unp }\n end\n end", "def new\n @bb = Bb.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bb }\n end\n end", "def new\n @monnaie = Monnaie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @monnaie }\n end\n end", "def new\n @inning = Inning.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @inning }\n end\n end", "def new\n @suplente = Suplente.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @suplente }\n end\n end", "def new\n @borc = Borc.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @borc }\n end\n end", "def new\n @jugadore = Jugadore.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @jugadore }\n end\n end", "def new\n @lieu = Lieu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lieu }\n end\n end", "def new\n @ubication = Ubication.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ubication }\n end\n end", "def new\n @kisalli = Kisalli.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kisalli }\n end\n end", "def new\n @chaine = Chaine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @chaine }\n end\n end", "def new\n @verbindung = Verbindung.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @verbindung }\n end\n end", "def new\n @spaethi = Spaethi.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spaethi }\n end\n end", "def new\n @uset = Uset.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @uset }\n end\n end", "def new\n @spiel = Spiel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spiel }\n end\n end", "def new\n @ci = Ci.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ci }\n end\n end", "def new\n @recinto = Recinto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recinto }\n end\n end", "def new\n @human = Human.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @human }\n end\n end", "def new\n @nyan = Nyan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nyan }\n end\n end", "def new\n @nave = Nave.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nave }\n end\n end", "def new\n @registro_bovino = RegistroBovino.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @registro_bovino }\n end\n end", "def new\n @brain = Brain.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @brain }\n end\n end", "def new\n @koti = Koti.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @koti }\n end\n end", "def new\n @have = Have.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @have }\n end\n end", "def new\n @jam = Jam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @jam }\n end\n end", "def new\n @ginasio = Ginasio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @ginasio }\n end\n end", "def new\n @kraj = Kraj.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kraj }\n end\n end", "def new\n @borrow_request = BorrowRequest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @borrow_request }\n end\n end", "def new\n @bounty = Bounty.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @bounty }\n end\n end", "def new\n @sabio = Sabio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sabio }\n end\n end", "def new\n @habit = Habit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @habit }\n end\n end", "def new\n @habit = Habit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @habit }\n end\n end", "def new\n @ninja = Ninja.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ninja }\n end\n end", "def new\n @asociado = Asociado.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @asociado }\n end\n end", "def new\n @sluzby = Sluzby.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sluzby }\n end\n end", "def new\n @borrower = Borrower.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @borrower }\n end\n end", "def new\n @borrower = Borrower.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @borrower }\n end\n end", "def new\n @tiezi = Tiezi.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tiezi }\n end\n end", "def new\n @hetong = Hetong.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hetong }\n end\n end", "def new\n @sitio = Sitio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sitio }\n end\n end" ]
[ "0.761673", "0.7569702", "0.75649667", "0.7459997", "0.74100906", "0.74056053", "0.7312473", "0.7308684", "0.72923225", "0.72871196", "0.72633046", "0.72590375", "0.724607", "0.7232557", "0.72045356", "0.72044945", "0.7200093", "0.71833986", "0.71821725", "0.71812034", "0.7164719", "0.71579164", "0.7146089", "0.7137701", "0.71358037", "0.7134686", "0.7126524", "0.71232766", "0.71176296", "0.71098703", "0.71031135", "0.7095244", "0.7085361", "0.7084341", "0.7067002", "0.7061597", "0.7053919", "0.70495254", "0.70492345", "0.70330966", "0.70322263", "0.70322263", "0.7025291", "0.70192397", "0.7018877", "0.7014946", "0.7014585", "0.70141387", "0.70099825", "0.7005282", "0.70043147", "0.69956136", "0.69876766", "0.6986015", "0.6984713", "0.6983693", "0.698148", "0.6981087", "0.6979889", "0.69796383", "0.6974655", "0.6974559", "0.69739", "0.6971075", "0.69688797", "0.696796", "0.6967785", "0.6967333", "0.69654334", "0.6964759", "0.69601136", "0.6957566", "0.6955595", "0.69527215", "0.69503736", "0.6946653", "0.694533", "0.69453174", "0.69443136", "0.6938823", "0.69384456", "0.69365406", "0.6933517", "0.69320273", "0.69275326", "0.69273186", "0.6926266", "0.6924181", "0.6920507", "0.6918641", "0.6917638", "0.6917638", "0.69085354", "0.6905773", "0.6904863", "0.69030297", "0.69030297", "0.6895098", "0.68931454", "0.68910265" ]
0.7692929
0
POST /kansei_buhins POST /kansei_buhins.json
def create @kansei_buhin = KanseiBuhin.new(params[:kansei_buhin]) respond_to do |format| if @kansei_buhin.save format.html { redirect_to @kansei_buhin, notice: 'Kansei buhin was successfully created.' } format.json { render json: @kansei_buhin, status: :created, location: @kansei_buhin } else format.html { render action: "new" } format.json { render json: @kansei_buhin.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @bakusokukun = Bakusokukun.new(bakusokukun_params)\n\n respond_to do |format|\n if @bakusokukun.save\n format.html { redirect_to @bakusokukun, notice: 'Bakusokukun was successfully created.' }\n format.json { render :show, status: :created, location: @bakusokukun }\n else\n format.html { render :new }\n format.json { render json: @bakusokukun.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @current_bijou = current_rockhound;\n # @bijou = Bijou.new(bijou_params)\n\n @new_bijou = @current_bijou.bijous.build(bijou_params)\n\n respond_to do |format|\n if @new_bijou.save\n format.html { redirect_to @bijou, notice: 'Bijou was successfully created.' }\n format.json { render :show, status: :created, location: @bijou }\n else\n format.html { render :new }\n format.json { render json: @bijou.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @basin = Basin.new(params[:basin])\n\n respond_to do |format|\n if @basin.save\n format.html { redirect_to @basin, notice: 'Basin was successfully created.' }\n format.json { render json: @basin, status: :created, location: @basin }\n else\n format.html { render action: \"new\" }\n format.json { render json: @basin.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bahan = Bahan.new(params[:bahan])\n\n respond_to do |format|\n if @bahan.save\n format.html { redirect_to @bahan, notice: 'Bahan was successfully created.' }\n format.json { render json: @bahan, status: :created, location: @bahan }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bahan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bokin = Bokin.new(params[:bokin])\n \n @bokin.name = current_user.name\n @bokin.photourl = current_user.screen_name\n \n \n respond_to do |format|\n if @bokin.save\n format.html { redirect_to @bokin, :notice => 'Bokin was successfully created.' }\n format.json { render :json => @bokin, :status => :created, :location => @bokin }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @bokin.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @sinh_vien = SinhVien.new(params[:sinh_vien])\n\n respond_to do |format|\n if @sinh_vien.save \n format.json { render json: @sinh_vien, status: :created, location: @sinh_vien }\n else \n format.json { render json: @sinh_vien.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @nhaxuatban = Nhaxuatban.new(nhaxuatban_params)\n\n respond_to do |format|\n if @nhaxuatban.save\n format.html { redirect_to @nhaxuatban, notice: \"Nhaxuatban was successfully created.\" }\n format.json { render :show, status: :created, location: @nhaxuatban }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @nhaxuatban.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @zf_bjietu = ZfBjietu.new(zf_bjietu_params)\n\n respond_to do |format|\n if @zf_bjietu.save\n format.html { redirect_to @zf_bjietu, notice: 'Zf bjietu was successfully created.' }\n format.json { render :show, status: :created, location: @zf_bjietu }\n else\n format.html { render :new }\n format.json { render json: @zf_bjietu.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bien = Bien.new(bien_params)\n\n respond_to do |format|\n if @bien.save\n format.html { redirect_to @bien, notice: 'Bien was successfully created.' }\n format.json { render :show, status: :created, location: @bien }\n else\n format.html { render :new }\n format.json { render json: @bien.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @nha_xuat_ban = NhaXuatBan.new(nha_xuat_ban_params)\n\n respond_to do |format|\n if @nha_xuat_ban.save\n format.html { redirect_to @nha_xuat_ban, notice: \"Nha xuat ban was successfully created.\" }\n format.json { render :show, status: :created, location: @nha_xuat_ban }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @nha_xuat_ban.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @buisness = Buisness.new(buisness_params)\n\n respond_to do |format|\n if @buisness.save\n format.html { redirect_to @buisness, notice: 'Buisness was successfully created.' }\n format.json { render :show, status: :created, location: @buisness }\n else\n format.html { render :new }\n format.json { render json: @buisness.errors, status: :unprocessable_entity }\n end\n end\n end", "def accept\n\t\t# byebug\n\t\t#Khi chap nhan 1 yeu cau thi:\n\t\t#B1: Gan role bussiness cho nguoi do\n\t\t#B2: Tao Bussiness cho nguoi do\n\t\t#B3: Tao ra chi nhanh dau tien cho nguoi do\n\t\tuser = @bussiness_request.user\n\t\tif user.is_bussiness_admin?\n\t\t\t#Neu da la bussiness_admin thi ko the nang cap, do do bo qua request do\n\t\t\t#bang cach gan no bang da duyet\n\t\t\t@bussiness_request.status_id = BussinessRequestStatus.da_duyet_status.id\n\t\t\t@bussiness_request.timeless.save\n\t\t\trender json: {message: 'Đã là tài khoản doanh nghiệp'}, status: :ok, content_type: 'application/json'\n\t\telse\n\n\t\t\t#B2: Tao Bussiness cho nguoi do\n\t\t\tbussiness = Bussiness.new\n\t\t\tbussiness.name = @bussiness_request.name\n\t\t\tbussiness.category = @bussiness_request.category\n\t\t\tbussiness.user_id = user.id\n\n\t\t\tif bussiness.save\n\t\t\t\tuser.roles ||=[]\n\t\t\t\tuser.roles << Role.bussiness_admin_role\n\t\t\t\t#B3: Tao ra chi nhanh dau tien cho nguoi do\n\t\t\t\tbranch = Branch.new\n\t\t\t\tbranch.name = @bussiness_request.name\n\t\t\t\tbranch.address = @bussiness_request.address\n\t\t\t\tbranch.phone = @bussiness_request.phone\n\t\t\t\tbranch.coordinates = [@bussiness_request.longitude, @bussiness_request.latitude]\n\t\t\t\tbranch.bussiness_id = bussiness.id\n\t\t\t\t#tao url_alias tam\n\t\t\t\tbranch.url_alias = RemoveAccent.remove_accent(@bussiness_request.name).gsub(/ /,\"\")\n\t\t\t\tbranch.begin_work_time = \"7:00\"\n\t\t\t\tbranch.end_work_time = \"24:00\"\n\n\t\t\t\tif branch.save\n\n\t\t\t\t\t@bussiness_request.status_id = BussinessRequestStatus.da_duyet_status.id\n\t\t\t\t\t@bussiness_request.timeless.save\n\t\t\t\t\t#Tao ra thong bao\n\t\t\t\t\t#Neu da lo deny va nguoi do chua xem thong bao deny thi xoa no\n\t\t\t\t\tNotificationChange.delete_notification_change user, @bussiness_request, current_user, @bussiness_request, NotificationCategory.tu_choi_cap_tai_khoan_doanh_nghiep\n\t\t\t\t\tNotificationChange.create_notification user, @bussiness_request, current_user, @bussiness_request, NotificationCategory.chap_nhan_yeu_cau_doanh_nghiep\n\t\t\t\t\t#Kich hoat thanh cong\n\t\t\t\t\trender json: {message: 'Kích hoạt thành công tài khoản doanh nghiệp'}, status: :created, content_type: 'application/json'\n\t\t\t\telse\n\t\t\t\t\trender json: {\n\t\t\t\t\t\tmessage: 'Lỗi xảy ra khi tạo branch',\n\t\t\t\t\t\terrors: branch.errors\n\t\t\t\t\t\t}, status: :bad_request\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\trender json: {\n\t\t\t\t\t\tmessage: 'Lỗi xảy ra khi tạo bussiness',\n\t\t\t\t\t\terrors: bussiness.errors\n\t\t\t\t\t\t}, status: :bad_request\n\t\t\t\t\tend\n\n\t\t\t\tend\n\t\t\tend", "def create\n # raise = true //เผื่ออยากเอาไว้ลองใช้\n @betum = Betum.new(betum_params)\n\n respond_to do |format|\n if @betum.save\n format.html { redirect_to @betum, notice: 'Betum was successfully created.' }\n format.json { render :show, status: :created, location: @betum }\n else\n format.html { render :new }\n format.json { render json: @betum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ujumbe = current_user.ujumbes.build(ujumbe_params)\n @user = current_user\n\n respond_to do |format|\n if @ujumbe.save\n format.html { redirect_to edit_ujumbe_path(@ujumbe), notice: 'Ujumbe was successfully created. You can now complete it' }\n format.json { render action: 'show', status: :created, location: @ujumbe }\n else\n format.html { render action: 'new' }\n format.json { render json: @ujumbe.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @byoin = Byoin.new(params[:byoin])\n\n respond_to do |format|\n if @byoin.save\n format.html { redirect_to @byoin, notice: 'Byoin was successfully created.' }\n format.json { render json: @byoin, status: :created, location: @byoin }\n else\n format.html { render action: \"new\" }\n format.json { render json: @byoin.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bbhk = Bbhk.new(bbhk_params)\n\n respond_to do |format|\n if @bbhk.save\n format.html { redirect_to @bbhk, notice: 'Bbhk was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bbhk }\n else\n format.html { render action: 'new' }\n format.json { render json: @bbhk.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @bokin = Bokin.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @bokin }\n end\n end", "def create\n @seihinn = Seihinn.new(seihinn_params)\n\n respond_to do |format|\n if @seihinn.save\n format.html { redirect_to @seihinn, notice: \"Seihinn was successfully created.\" }\n format.json { render :show, status: :created, location: @seihinn }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @seihinn.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bonificacion = Bonificacion.new(bonificacion_params)\n\n respond_to do |format|\n if @bonificacion.save\n format.html { redirect_to @bonificacion, notice: 'Bonificacion was successfully created.' }\n format.json { render :show, status: :created, location: @bonificacion }\n else\n format.html { render :new }\n format.json { render json: @bonificacion.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bonificacion = Bonificacion.new(bonificacion_params)\n\n respond_to do |format|\n if @bonificacion.save\n format.html { redirect_to @bonificacion, notice: 'Bonificacion was successfully created.' }\n format.json { render :show, status: :created, location: @bonificacion }\n else\n format.html { render :new }\n format.json { render json: @bonificacion.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @riyu_monshin = RiyuMonshin.new(riyu_monshin_params)\n\n respond_to do |format|\n if @riyu_monshin.save\n format.html { redirect_to @riyu_monshin, notice: 'Riyu monshin was successfully created.' }\n format.json { render :show, status: :created, location: @riyu_monshin }\n else\n format.html { render :new }\n format.json { render json: @riyu_monshin.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lich_su_binh_bau = LichSuBinhBau.new(params[:lich_su_binh_bau])\n @lich_su_binh_bau[:user_id] = session[:FBUser][:id]\n\n respond_to do |format|\n if @lich_su_binh_bau.save\n #CHECK ĐỂ TĂNG LƯỢT BÌNH BẦU\n @bbau = @lich_su_binh_bau.chi_tiet_truong.chi_tiet_binh_bau.binh_bau\n @lsbb_ = []\n @bbau.chi_tiet_binh_baus.each{ |b1| b1.chi_tiet_truongs.each {|b2| b2.lich_su_binh_baus.each{|b3| @lsbb_.push(b3)}}}\n if @lsbb_.select{ |a| a[:user_id] == session[:FBUser][:id]}.count()<2 \n @bbau[:LuotBinhBau]+=1\n @bbau.save\n end\n\n format.html { redirect_to \"/\", notice: 'Lich su binh bau was successfully created.' }\n else\n @lsbb = LichSuBinhBau.where(\"user_id = ? and chi_tiet_truong_id= ?\",@lich_su_binh_bau[:user_id],@lich_su_binh_bau[:chi_tiet_truong_id]).first\n @lsbb[:SoDiem] = @lich_su_binh_bau[:SoDiem]\n @lsbb.save\n format.html { redirect_to \"/\" }\n end\n end\n end", "def create\n @bonificacion = Bonificacion.new(bonificacion_params)\n\n respond_to do |format|\n if @bonificacion.save\n format.html { redirect_to @bonificacion, notice: 'Bonificación fue creado exitosamente.' }\n format.json { render :show, status: :created, location: @bonificacion }\n else\n format.html { render :new }\n format.json { render json: @bonificacion.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n buch_params = buchung_params\n\n jahr = buch_params['start(1i)']\n monat = buch_params['start(2i)']\n tag = buch_params['start(3i)']\n stunde = buch_params['start(4i)']\n minuten = nil\n ende_uhrzeit = buch_params['ende']\n\n start_buchung = Time.mktime(jahr, monat, tag, stunde)\n ende_buchung = Time.mktime(jahr, monat, tag, ende_uhrzeit)\n\n @buchung = Buchung.new(buchung_params)\n @buchung.start = start_buchung\n @buchung.ende = ende_buchung\n\n\n respond_to do |format|\n if @buchung.save\n format.html { redirect_to @buchung, notice: 'Buchung was successfully created.' }\n format.json { render :show, status: :created, location: @buchung }\n else\n format.html { render :new }\n format.json { render json: @buchung.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bilhete = Bilhete.new(params[:bilhete])\n\n respond_to do |format|\n if @bilhete.save\n format.html { redirect_to @bilhete, notice: 'Bilhete was successfully created.' }\n format.json { render json: @bilhete, status: :created, location: @bilhete }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bilhete.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bok = Bok.new(bok_params)\n\n respond_to do |format|\n if @bok.save\n format.html { redirect_to @bok, notice: 'Bok was successfully created.' }\n format.json { render :show, status: :created, location: @bok }\n else\n format.html { render :new }\n format.json { render json: @bok.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n\n respond_to do |format|\n if @huati.save\n format.html { redirect_to @huati, notice: 'Huati was successfully created.' }\n format.json { render json: @huati, status: :created, location: @huati }\n else\n format.html { render action: \"new\" }\n format.json { render json: @huati.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bonu = Bonu.new(bonu_params)\n @user = @bonu.user\n\n respond_to do |format|\n if @bonu.save\n @user.addValue(@bonu.amount)\n format.html { redirect_to root_url, notice: 'Bonu was successfully created.' }\n format.json { render :show, status: :created, location: @bonu }\n else\n format.html { render :new }\n format.json { render json: @bonu.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bruschettum = Bruschettum.new(params[:bruschettum])\n params[:ingredient].each{|ingr|\n @bruschettum.ingredients << Ingredient.find_by_name(ingr)\n }\n\n\n respond_to do |format|\n if @bruschettum.save\n format.html { redirect_to @bruschettum, notice: 'Bruschetta è stata creata con successo.' }\n format.json { render json: @bruschettum, status: :created, location: @bruschettum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bruschettum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @houmon = Houmon.new(houmon_params)\n\n\n\n respond_to do |format|\n \n #測定値(漏洩電流、絶縁抵抗)がnilの場合0を代入\n if @houmon.tenkenkekka.sokutei.roueidenryu_ikkatsu.nil? then\n @houmon.tenkenkekka.sokutei.roueidenryu_ikkatsu=0\n end\n if @houmon.tenkenkekka.sokutei.zetsuenteikou_ikkatsu.nil? then\n @houmon.tenkenkekka.sokutei.zetsuenteikou_ikkatsu=0\n end\n #調査結果を判定して格納\n #絶縁一括が0<0.02のとき、絶縁不良0.02未満とし、絶縁一括が0<0.1のとき絶縁不良0.1未満とする。その他は良好\n if @houmon.tenkenkekka.sokutei.zetsuenteikou_ikkatsu !=0 && @houmon.tenkenkekka.sokutei.zetsuenteikou_ikkatsu < 0.1 then\n if @houmon.tenkenkekka.sokutei.zetsuenteikou_ikkatsu !=0 && @houmon.tenkenkekka.sokutei.zetsuenteikou_ikkatsu < 0.02 then\n @houmon.tenkenkekka.chosakekka_code = 3\n else \n @houmon.tenkenkekka.chosakekka_code = 2\n end\n else\n @houmon.tenkenkekka.chosakekka_code = 1\n end\n \n #調査実績を判定して格納\n #在宅かつ問診未実施なら終了、以外完了\n #不在のとき、絶縁一括のみ入力があればメガ終了とする。漏洩一括に入力があればリーク終了とする\n\n @fuga = @houmon.tenkenkekka.monshin.jisshi_umu\n if @houmon.zaitakufuzai.id == 1\n if @houmon.tenkenkekka.monshin.jisshi_umu == '2' \n @houmon.tenkenkekka.chosajisseki_code = 2\n else\n @houmon.tenkenkekka.chosajisseki_code = 1\n end\n else\n if @houmon.tenkenkekka.sokutei.roueidenryu_ikkatsu == 0 && @houmon.tenkenkekka.sokutei.zetsuenteikou_ikkatsu != 0\n @houmon.tenkenkekka.chosajisseki_code = 4\n else\n @houmon.tenkenkekka.chosajisseki_code = 3\n end\n end\n #なおかつ最新実績として交付モデルにも更新する\n @kofu_for_newestjisseki = Kofu.find(params[:houmon][:kofu_id])\n @kofu_for_newestjisseki.newest_chosajisseki_code = @houmon.tenkenkekka.chosajisseki_code\n \n \n \n \n if @houmon.save && @kofu_for_newestjisseki.save\n\n # Season2用暫定 ここから -->\n @@h = {}\n @@h.store(:chosa_ym, session[:when_year]+session[:when_month]) # セッション内の年月を調査年月とする\n @@h.store(:chosain_id, session[:whoami_id]) # セッション内のログインIDを調査員IDとする\n @@h.store(:kofu_kensu, # 調査年月+調査員IDで交付の件数をカウント\n Kofu.where(chosa_ym: session[:when_year]+session[:when_month]).where(chosain_id: session[:whoami_id]).count)\n @@h.store(:datetime_now, DateTime.now.in_time_zone)\n STDOUT.puts(\"Rails2Unicage:\"+@@h.to_json) # Unicageへの引き渡しのため標準出力にJSONで出す\n\n # 確認用にLV1フォルダ内にファイルを作って出力\n f = File.open(\"./LV1/#{Time.now.strftime(\"%Y%m%d_%H%M%S\")}.txt\", 'a')\n f.puts(\"Rails2Unicage:\"+@@h.to_json)\n f.close\n # <-- Season2用暫定 ここまで\n\n format.html { redirect_to @houmon, notice: '点検結果が正常に登録されました。' }\n format.json { render :show, status: :created, location: @houmon }\n else\n \n format.html { redirect_to :back }\n format.json { render json: @houmon.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @giang_vien = GiangVien.new(params[:giang_vien])\n\n respond_to do |format|\n if @giang_vien.save \n format.json { render json: @giang_vien, status: :created, location: @giang_vien }\n else \n format.json { render json: @giang_vien.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @shujukujiaoben = Shujukujiaoben.new(shujukujiaoben_params)\n\n respond_to do |format|\n if @shujukujiaoben.save\n format.html { redirect_to @shujukujiaoben, notice: 'Shujukujiaoben was successfully created.' }\n format.json { render :show, status: :created, location: @shujukujiaoben }\n else\n format.html { render :new }\n format.json { render json: @shujukujiaoben.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @uang_masuk = UangMasuk.new(uang_masuk_params)\n\n respond_to do |format|\n if @uang_masuk.save\n format.html { redirect_to uang_masuks_path, notice: 'Uang masuk was successfully created.' }\n else\n format.html { render :new }\n format.json { render json: @uang_masuk.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n \n respond_to do |format| \n @buchung = Buchung.new(params[:buchung]) \n if @buchung.save \n if @buchung.status==\"B\"\n format.html { redirect_to @buchung, notice: 'Buchung war erfolgreich.' }\n else\n format.html { redirect_to @buchung, notice: 'Reservierung war erfolgreich.' }\n end\n format.json { render json: @buchung, status: :created, location: @buchung }\n else \n format.html { render action: \"new\" }\n format.json { render json: @buchung.errors, status: :unprocessable_entity }\n end \n end \n end", "def new\n @binh_bau = BinhBau.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @binh_bau }\n end\n end", "def buchung_params\n params.require(:buchung).permit(:status, :start, :ende, :typ)\n end", "def create\n @boat = Boat.new(params[:boat])\n\n @model = Model.where(:valm_malli => params[:boat][:valm_malli]).first\n\n if @model.nil?\n @model = Model.new\n @model.korkeus = @boat.korkeus\n @model.leveys = @boat.leveys\n @model.pituus = @boat.pituus\n @model.syvyys = @boat.syvyys\n @model.uppouma = @boat.uppouma\n @model.valm_malli = @boat.valm_malli\n @model.tyyppi = @boat.tyyppi\n @model.save\n end\n\n @laituri_idt = Dock.all.map(&:id)\n @laituri_idt.insert(0,nil)\n\n @vapaat_laituripaikat = Berth.where(:dock_id => 1).all.map(&:number)\n @vapaat_laituripaikat.insert(0,nil)\n parse_jno_from_omistajatxtbox\n changejnoToId\n respond_to do |format|\n if @boat.valid? && @onkoOk #&& check_for_only_one_payer\n check_dock_and_berth(format)\n @boat.save\n format.html { redirect_to @boat, notice: 'Vene luotiin onnistuneesti.' }\n format.json { render json: @boat, status: :created, location: @boat }\n else\n format.html { flash.now[:alert] = @member == nil ? 'Jäsentä ei löytynyt' : 'Tuntematon virhe'\n render action: \"new\" }\n format.json { render json: @boat.errors, status: :unprocessable_entity }\n end\n end\n\n end", "def new\n @kansei_buhin = KanseiBuhin.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kansei_buhin }\n end\n end", "def create\n @trinh_do_boi_duong = TrinhDoBoiDuong.new(trinh_do_boi_duong_params)\n\n respond_to do |format|\n if @trinh_do_boi_duong.save\n format.html { redirect_to @trinh_do_boi_duong, notice: 'Trinh do boi duong was successfully created.' }\n format.json { render :show, status: :created, location: @trinh_do_boi_duong }\n else\n format.html { render :new }\n format.json { render json: @trinh_do_boi_duong.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @binh_bau = BinhBau.new(params[:binh_bau])\n @flag = 0\n if params[:tieuchis] == nil\n @binh_bau.errors.add(\"Tieuchis\", \"Chưa chọn tiêu chí\")\n @flag = 1\n else\n params[:tieuchis].each do |tieuchi|\n par = tieuchi.to_s + \"-truongs\"\n if params[par.to_s] == nil\n @binh_bau.errors.add(\"Truongs\",\"Có tiêu chí chưa chọn trường\")\n @flag = 1\n break\n end\n end\n end\n if @binh_bau.NgayKetThuc < DateTime.now\n @binh_bau.errors.add(:NgayKetThuc,\" nhỏ hơn ngày hiện tại\")\n @flag = 1\n end\n if @binh_bau.NgayBatDau < DateTime.now\n @binh_bau.errors.add(:NgayBatDau,\" nhỏ hơn ngày hiện tại\")\n @flag = 1\n end\n if @binh_bau.NgayKetThuc < @binh_bau.NgayBatDau\n @binh_bau.errors.add(:NgayKetThuc,\" bé hơn NgayBatDau\")\n @flag = 1\n end\n respond_to do |format|\n if @flag == 0 && @binh_bau.save\n @dstruong = []\n params[:tieuchis].each do |tieuchi|\n @chitiet = ChiTietBinhBau.new(:binh_bau_id => @binh_bau.id, :tieu_chi_id => tieuchi)\n @tieu_chi = TieuChi.find(tieuchi)\n @tieu_chi.SoLuongBinhBau += 1\n @tieu_chi.save\n @chitiet.save\n\n par = tieuchi.to_s + \"-truongs\"\n params[par.to_s].each do |truong|\n @chitiettruong = ChiTietTruong.new(:chi_tiet_binh_bau_id => @chitiet.id, :truong_id => truong)\n @dstruong.push(truong)\n @chitiettruong.save\n end\n end\n Truong.find(@dstruong).uniq.each do |truong|\n truong.SoLuongBinhBau += 1\n truong.save\n end\n format.html { redirect_to admin_binh_baus_url, notice: 'Binh bau was successfully created.' }\n format.json { render json: @binh_bau, status: :created, location: @binh_bau }\n else\n format.html { render action: \"new\" }\n format.json { render json: @binh_bau.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @nhan_xet = NhanXet.new(params[:nhan_xet])\n @nhan_xet[:user_id] = session[:FBUser][:id]\n respond_to do |format|\n if @nhan_xet.save\n format.html { render json: {:NoiDung => @nhan_xet.NoiDung, :created_at =>@nhan_xet.created_at.strftime(\"Ngày %d/%m/%Y lúc %H:%M\"), :MaUser => @nhan_xet.user.MaUser,:TenUser => @nhan_xet.user.HoTen, :TenTruong => @nhan_xet.truong.TenTruong}}\n end\n end\n end", "def create\n @betum = Betum.new(params[:betum])\n\n respond_to do |format|\n if @betum.save\n format.html { redirect_to :back, notice: 'You have been successfully registered!' }\n format.json { render json: @betum, status: :created, location: @betum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @betum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @boook = Boook.new(boook_params)\n\n respond_to do |format|\n if @boook.save\n format.html { redirect_to @boook, notice: 'Boook was successfully created.' }\n format.json { render :show, status: :created, location: @boook }\n else\n format.html { render :new }\n format.json { render json: @boook.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @penjualan_bahan = PenjualanBahan.new(params[:penjualan_bahan])\n\n respond_to do |format|\n if @penjualan_bahan.save\n format.html { redirect_to @penjualan_bahan, notice: 'Penjualan bahan was successfully created.' }\n format.json { render json: @penjualan_bahan, status: :created, location: @penjualan_bahan }\n else\n format.html { render action: \"new\" }\n format.json { render json: @penjualan_bahan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @buisiness = Buisiness.new(buisiness_params)\n\n respond_to do |format|\n if @buisiness.save\n format.html { redirect_to @buisiness, notice: 'Buisiness was successfully created.' }\n format.json { render :show, status: :created, location: @buisiness }\n else\n format.html { render :new }\n format.json { render json: @buisiness.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @spkj_bsb = SpkjBsb.new(params[:spkj_bsb])\n # @spkj_bsb.tname=current_user.name\n @spkj_bsb.user_id = current_user.id\n @spkj_bsb.uid = current_user.uid\n @spkj_bsb.sp_s_52=current_user.user_s_province\n @spkj_bsb.sp_i_state=1\n @spkj_bsb.save\n respond_to do |format|\n format.html { redirect_to(\"/spkj_bsbs\") }\n format.json { render json: @spkj_bsb }\n end\n end", "def create\n @bicicletum = Bicicletum.new(bicicletum_params)\n\n respond_to do |format|\n if @bicicletum.save\n format.html { redirect_to @bicicletum, notice: 'Bicicletum was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bicicletum }\n else\n format.html { render action: 'new' }\n format.json { render json: @bicicletum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @sluzby = Sluzby.new(params[:sluzby])\n\n respond_to do |format|\n if @sluzby.save\n format.html { redirect_to @sluzby, notice: 'Sluzby was successfully created.' }\n format.json { render json: @sluzby, status: :created, location: @sluzby }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sluzby.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @kuaisufenfawenjian = Kuaisufenfawenjian.new(kuaisufenfawenjian_params)\n\n respond_to do |format|\n if @kuaisufenfawenjian.save\n format.html { redirect_to @kuaisufenfawenjian, notice: 'Kuaisufenfawenjian was successfully created.' }\n format.json { render :show, status: :created, location: @kuaisufenfawenjian }\n else\n format.html { render :new }\n format.json { render json: @kuaisufenfawenjian.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @kokuin = Kokuin.new(kokuin_params)\n\n respond_to do |format|\n if @kokuin.save\n format.html { redirect_to admin_kokuin_path(@kokuin), notice: 'Kokuin was successfully created.' }\n format.json { render action: 'show', status: :created, location: @kokuin }\n else\n format.html { render action: 'new' }\n format.json { render json: @kokuin.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @kemboi = Kemboi.new(kemboi_params)\n\n respond_to do |format|\n if @kemboi.save\n format.html { redirect_to @kemboi, notice: 'Kemboi was successfully created.' }\n format.json { render action: 'show', status: :created, location: @kemboi }\n else\n format.html { render action: 'new' }\n format.json { render json: @kemboi.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bikestand = Bikestand.new(bikestand_params)\n\n respond_to do |format|\n if @bikestand.save\n format.html { redirect_to @bikestand, notice: 'Bikestand was successfully created.' }\n format.json { render :show, status: :created, location: @bikestand }\n else\n format.html { render :new }\n format.json { render json: @bikestand.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @kingsizeb = Kingsizeb.new(kingsizeb_params)\n\n respond_to do |format|\n if @kingsizeb.save\n format.html { redirect_to @kingsizeb, notice: 'Kingsizeb was successfully created.' }\n format.json { render :show, status: :created, location: @kingsizeb }\n else\n format.html { render :new }\n format.json { render json: @kingsizeb.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @nguoi_dung = NguoiDung.new(params[:nguoi_dung])\n\n respond_to do |format|\n if @nguoi_dung.save\n format.html { redirect_to @nguoi_dung, notice: 'Nguoi dung was successfully created.' }\n format.json { render json: @nguoi_dung, status: :created, location: @nguoi_dung }\n else\n format.html { render action: \"new\" }\n format.json { render json: @nguoi_dung.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bourbon = Bourbon.new(bourbon_params)\n\n respond_to do |format|\n if @bourbon.save\n format.html { redirect_to @bourbon, notice: 'Bourbon was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bourbon }\n else\n format.html { render action: 'new' }\n format.json { render json: @bourbon.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #raise penduduk_params.to_yaml\n @penduduk = Penduduk.new(penduduk_params)\n @golongan_darahs = GolonganDarah.all\n @agamas = Agama.all\n @pekerjaans= Pekerjaan.all\n @status_keluargas = StatusKeluarga.all\n @pendidikans = Pendidikan.all\n @kelurahans = Kelurahan.all\n @kecamatans = Kecamatan.all\n @kabupatens = Kabupaten.all\n @penghasilans = Penghasilan.all \n respond_to do |format|\n if @penduduk.save\n format.html { redirect_to @penduduk, notice: 'Penduduk was successfully created.' }\n format.json { render :show, status: :created, location: @penduduk }\n else\n format.html { render :new }\n format.json { render json: @penduduk.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pingguodingshirenwu = Pingguodingshirenwu.new(pingguodingshirenwu_params)\n\n respond_to do |format|\n if @pingguodingshirenwu.save\n format.html { redirect_to @pingguodingshirenwu, notice: 'Pingguodingshirenwu was successfully created.' }\n format.json { render :show, status: :created, location: @pingguodingshirenwu }\n else\n format.html { render :new }\n format.json { render json: @pingguodingshirenwu.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @meibo = Meibo.new(meibo_params)\n\n respond_to do |format|\n if @meibo.save\n format.html { redirect_to @meibo, notice: '名簿は正常に作成されました。' }\n format.json { render :show, status: :created, location: @meibo }\n else\n format.html { @meibos = Meibo.page(params[:page]).per(@@kensu) ; render :index }\n format.json { render json: @meibo.errors, status: :unprocessable_entity }\n end\n end\n end", "def laporan_kinerja_pegawai_bimkat_sumteng_params\n params.require(:laporan_kinerja_pegawai_bimkat_sumteng).permit(:bulan, :tahun, :tautan)\n end", "def create\n @laporan_kinerja_pegawai_bimkat_sumteng = LaporanKinerjaPegawaiBimkatSumteng.new(laporan_kinerja_pegawai_bimkat_sumteng_params)\n\n respond_to do |format|\n if @laporan_kinerja_pegawai_bimkat_sumteng.save\n format.html { redirect_to @laporan_kinerja_pegawai_bimkat_sumteng, notice: 'Laporan kinerja pegawai bimkat sumteng telah berhasil dibuat.' }\n format.json { render :show, status: :created, location: @laporan_kinerja_pegawai_bimkat_sumteng }\n else\n format.html { render :new }\n format.json { render json: @laporan_kinerja_pegawai_bimkat_sumteng.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @brite_td_asbarabasi_rt_waxman = BriteTdAsbarabasiRtWaxman.new(brite_td_asbarabasi_rt_waxman_params)\n\n respond_to do |format|\n if @brite_td_asbarabasi_rt_waxman.save\n format.html { redirect_to @brite_td_asbarabasi_rt_waxman, notice: 'Brite td asbarabasi rt waxman was successfully created.' }\n format.json { render :show, status: :created, location: @brite_td_asbarabasi_rt_waxman }\n else\n format.html { render :new }\n format.json { render json: @brite_td_asbarabasi_rt_waxman.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @kishangarh_marble = KishangarhMarble.new(kishangarh_marble_params)\n\n respond_to do |format|\n if @kishangarh_marble.save\n format.html { redirect_to kishangarh_marbles_url, notice: 'Kishangarh marble was successfully created.' }\n format.json { render action: 'show', status: :created, location: @kishangarh_marble }\n else\n format.html { render action: 'new' }\n format.json { render json: @kishangarh_marble.errors, status: :unprocessable_entity }\n end\n end\n end", "def new \n @buchung = Buchung.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @buchung }\n end\n end", "def create\n @bunny = Bunny.new(bunny_params)\n\n respond_to do |format|\n if @bunny.save\n format.html { redirect_to @bunny, notice: 'Bunny was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bunny }\n else\n format.html { render action: 'new' }\n format.json { render json: @bunny.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\tboat = Boat.new(boat_params)\n \tif boat.save\n \t\trender json: boat, status: 201\n \tend\n\tend", "def bakusokukun_params\n params.require(:bakusokukun).permit(:Time_JST, :Num_of_Pages)\n end", "def bijou_params\n params.require(:bijou).permit(:name, :description)\n end", "def create\n # @bonu = Bonus.new(bonus_params)\n #\n # if @bonus.save\n # render :show, status: :created, location: @bonus\n # else\n # render json: @bonus.errors, status: :unprocessable_entity\n # end\n end", "def create_bepaid_bill\n # Don't touch real web services during of test database initialization\n return if Rails.env.test?\n\n user = self\n\n bp = BePaid::BePaid.new Setting['bePaid_baseURL'], Setting['bePaid_ID'], Setting['bePaid_secret']\n\n amount = user.monthly_payment_amount\n\n #amount is (amoint in BYN)*100\n bill = {\n request: {\n amount: (amount * 100).to_i,\n currency: 'BYN',\n description: 'Членский взнос',\n email: '[email protected]',\n notification_url: 'https://hackerspace.by/admin/erip_transactions/bepaid_notify',\n ip: '127.0.0.1',\n order_id: '4444',\n customer: {\n first_name: 'Cool',\n last_name: 'Hacker',\n },\n payment_method: {\n type: 'erip',\n account_number: 444,\n permanent: 'true',\n editable_amount: 'true',\n service_no: Setting['bePaid_serviceNo'],\n }\n }\n }\n req = bill[:request]\n req[:email] = user.email\n req[:order_id] = user.id\n req[:customer][:first_name] = user.first_name\n req[:customer][:last_name] = user.last_name\n req[:payment_method][:account_number] = user.id\n\n begin\n res = bp.post_bill bill\n logger.debug JSON.pretty_generate res\n rescue => e\n logger.error e.message\n logger.error e.http_body if e.respond_to? :http_body\n user.errors.add :base, \"Не удалось создать счёт в bePaid, проверьте лог\"\n end\n end", "def zf_bjietu_params\n params.require(:zf_bjietu).permit(:biaotixingming, :zhanghu, :shouji, :jiaoyihao, :shijian)\n end", "def create\n @ra_khoi_dang = RaKhoiDang.new(ra_khoi_dang_params)\n\n respond_to do |format|\n if @ra_khoi_dang.save\n format.html { redirect_to @ra_khoi_dang, notice: 'Ra khoi dang was successfully created.' }\n format.json { render :show, status: :created, location: @ra_khoi_dang }\n else\n format.html { render :new }\n format.json { render json: @ra_khoi_dang.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @boat = Boat.new(boat_params)\n\n if @boat.save\n render json: @boat, status: :created, location: @boat\n else\n render json: @boat.errors, status: :unprocessable_entity\n end\n end", "def create\n @bocconi = Bocconi.new(bocconi_params)\n\n respond_to do |format|\n if @bocconi.save\n format.html { redirect_to @bocconi, notice: 'Bocconi was successfully created.' }\n format.json { render :show, status: :created, location: @bocconi }\n else\n format.html { render :new }\n format.json { render json: @bocconi.errors, status: :unprocessable_entity }\n end\n end\n end", "def bonu_params\n params.require(:bonu).permit(:user_id, :amount)\n end", "def create\n @injhas_special_biryani_dish = InjhasSpecialBiryaniDish.new(injhas_special_biryani_dish_params)\n\n respond_to do |format|\n if @injhas_special_biryani_dish.save\n format.html { redirect_to @injhas_special_biryani_dish, notice: 'Injhas special biryani dish was successfully created.' }\n format.json { render :show, status: :created, location: @injhas_special_biryani_dish }\n else\n format.html { render :new }\n format.json { render json: @injhas_special_biryani_dish.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @beach = Beach.new(beach_params)\n\n respond_to do |format|\n if @beach.save\n format.html { redirect_to @beach, notice: \"Beach was successfully created.\" }\n format.json { render :show, status: :created, location: @beach }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @beach.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ba = Ba.new(ba_params)\n respond_to do |format|\n if @ba.save\n format.html { redirect_to :back, notice: 'ベストアンサーを選択しました' }\n format.json { render :show, status: :created, location: @ba }\n else\n format.html { render :new }\n format.json { render json: @ba.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @jiankong = Jiankong.new(jiankong_params)\n\n respond_to do |format|\n if @jiankong.save\n format.html { redirect_to @jiankong, notice: 'Jiankong was successfully created.' }\n format.json { render :show, status: :created, location: @jiankong }\n else\n format.html { render :new }\n format.json { render json: @jiankong.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cetak_blok = CetakBlok.new(cetak_blok_params)\n\n respond_to do |format|\n if @cetak_blok.save\n format.html { redirect_to cetak_bloks_url, notice: 'Cetak blok was successfully created.' }\n format.json { render :show, status: :created, location: @cetak_blok }\n else\n format.html { render :new }\n format.json { render json: @cetak_blok.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #ederrafo seteo como nuevo\n @user = User.new(params[:user])\n if @user.save\n @wise = Wise.new(:website => params[:wise][:website],\n :apellation => params[:wise][:apellation],\n :banck_account => params[:wise][:banck_account],\n :bank => params[:wise][:bank],\n :user_id => @user.id,\n :summary => params[:wise][:summary],\n :guy => 1 \n )\n respond_to do |format|\n if @wise.save\n format.html { redirect_to @wise, :notice => 'Wise was successfully created.' }\n format.json { render :json => @wise, :status => :created, :location => @wise }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @wise.errors, :status => :unprocessable_entity }\n end\n end\n end\n end", "def create\n @kuaisujiaobenzhixing = Kuaisujiaobenzhixing.new(kuaisujiaobenzhixing_params)\n\n respond_to do |format|\n if @kuaisujiaobenzhixing.save\n format.html { redirect_to @kuaisujiaobenzhixing, notice: 'Kuaisujiaobenzhixing was successfully created.' }\n format.json { render :show, status: :created, location: @kuaisujiaobenzhixing }\n else\n format.html { render :new }\n format.json { render json: @kuaisujiaobenzhixing.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @begivenhed = Begivenhed.new(params[:begivenhed])\n @begivenhed.bruger_id = current_user.id\n respond_to do |format|\n if @begivenhed.save\n format.html { redirect_to @begivenhed, notice: 'Begivenhed was successfully created.' }\n format.json { render json: @begivenhed, status: :created, location: @begivenhed }\n else\n format.html { render action: \"new\" }\n format.json { render json: @begivenhed.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @informasi_pengumuman = InformasiPengumuman.new(informasi_pengumuman_params)\n @informasi_pengumuman.pengguna_id = current_pengguna.id\n \n respond_to do |format|\n if @informasi_pengumuman.save\n format.html { redirect_to @informasi_pengumuman, notice: 'Informasi pengumuman was successfully created.' }\n format.json { render :show, status: :created, location: @informasi_pengumuman }\n else\n format.html { render :new }\n format.json { render json: @informasi_pengumuman.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @inquilino = Inquilino.new(inquilino_params)\n respond_to do |format|\n if @inquilino.save\n #@pagamento = Pagamento.create(mes: @inquilino.dataVencimento.to_s, pago: @inquilino.pago, inquilino_id: @inquilino.id)\n #@mensalidade = Mensalidade.create(inquilino_id: @inquilino.id, pagamento_id: @pagamento.id)\n #@mensalidade = Mensalidade.create(pago: @inquilino.pago, inquilino_id: @inquilino.id)\n @mesa = @inquilino.dataVencimento\n @cont = 0\n 12.times do\n @cont += 1\n @mes = @mesa + @cont.month\n @mensalidades = Mensalidade.create(inquilino_id: @inquilino.id, mes: @mes, pago: false)\n end\n #\n @whatsapp = Whatsapp.create(inquilino_id: @inquilino.id, numero: \" \", endereco: \" \")\n\n format.html {redirect_to @inquilino, notice: 'Inquilino criado com sucesso!.'}\n format.json {render :show, status: :created, location: @inquilino}\n else\n format.html {render :new}\n format.json {render json: @inquilino.errors, status: :unprocessable_entity}\n end\n end\n end", "def create\n @riyu_okunai = RiyuOkunai.new(riyu_okunai_params)\n\n respond_to do |format|\n if @riyu_okunai.save\n format.html { redirect_to @riyu_okunai, notice: 'Riyu okunai was successfully created.' }\n format.json { render :show, status: :created, location: @riyu_okunai }\n else\n format.html { render :new }\n format.json { render json: @riyu_okunai.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @currentgwamokid = params[:currentgwamokid]\n @sigan = Sigan.new(sigan_params)\n\n respond_to do |format|\n if @sigan.save\n format.html { redirect_to @sigan, notice: 'Sigan was successfully created.' }\n format.json { render :show, status: :created, location: @sigan }\n else\n format.html { render :new }\n format.json { render json: @sigan.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @bruger_id = current_user.id\n @bruger = Bruger.find_by_id(@bruger_id)\n @onske = Onske.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @onske }\n end\n end", "def create\n @baton = Baton.new(params[:baton])\n\n respond_to do |format|\n if @baton.save\n format.html { redirect_to @baton, notice: 'Baton was successfully created.' }\n format.json { render json: @baton, status: :created, location: @baton }\n else\n format.html { render action: \"new\" }\n format.json { render json: @baton.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @laporan_guru_agama_katolik = LaporanGuruAgamaKatolik.new(laporan_guru_agama_katolik_params)\n @laporan_guru_agama_katolik.pengguna_id = current_pengguna.id\n\n respond_to do |format|\n if @laporan_guru_agama_katolik.save\n format.html { redirect_to @laporan_guru_agama_katolik, notice: 'Laporan guru agama katolik was successfully created.' }\n format.json { render :show, status: :created, location: @laporan_guru_agama_katolik }\n else\n format.html { render :new }\n format.json { render json: @laporan_guru_agama_katolik.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bico = Bico.new(params[:bico])\n\n respond_to do |format|\n if @bico.save\n format.html { redirect_to @bico, notice: 'Bico was successfully created.' }\n format.json { render json: @bico, status: :created, location: @bico }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bico.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @banda = Banda.new(params[:banda])\n\n respond_to do |format|\n if @banda.save\n format.html { redirect_to @banda, notice: 'Banda was successfully created.' }\n format.json { render json: @banda, status: :created, location: @banda }\n else\n format.html { render action: \"new\" }\n format.json { render json: @banda.errors, status: :unprocessable_entity }\n end\n end\n end", "def keihi_params\n params.require(:keihi).permit(:date, :kamoku_id_id, :tekiyou, :kingaku)\n end", "def create\n @data_keagamaan_katolik.user_id = current_user.id\n\n respond_to do |format|\n if @data_keagamaan_katolik.save\n format.html { redirect_to @data_keagamaan_katolik, notice: 'Data keagamaan katolik was successfully created.' }\n format.json { render :show, status: :created, location: @data_keagamaan_katolik }\n else\n format.html { render :new }\n format.json { render json: @data_keagamaan_katolik.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @kundenkonto = Kundenkonto.new(kundenkonto_params)\n\n respond_to do |format|\n if @kundenkonto.save\n format.html { redirect_to @kundenkonto, notice: 'Kundenkonto was successfully created.' }\n format.json { render action: 'show', status: :created, location: @kundenkonto }\n else\n format.html { render action: 'new' }\n format.json { render json: @kundenkonto.errors, status: :unprocessable_entity }\n end\n end\n end", "def riyu_monshin_params\n params.require(:riyu_monshin).permit(:atai)\n end", "def create\n @yaopin = Yaopin.new(params[:yaopin])\n\n respond_to do |format|\n if @yaopin.save\n format.html { redirect_to @yaopin, notice: 'Yaopin was successfully created.' }\n format.json { render json: @yaopin, status: :created, location: @yaopin }\n else\n format.html { render action: \"new\" }\n format.json { render json: @yaopin.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @beach = Beach.new(beach_params)\n\n respond_to do |format|\n if @beach.save\n format.html { redirect_to @beach, notice: 'Beach was successfully created.' }\n format.json { render :show, status: :created, location: @beach }\n else\n format.html { render :new }\n format.json { render json: @beach.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bixi = Bixi.new(bixi_params)\n\n respond_to do |format|\n if @bixi.save\n format.html { redirect_to @bixi, notice: 'Bixi was successfully created.' }\n format.json { render :show, status: :created, location: @bixi }\n else\n format.html { render :new }\n format.json { render json: @bixi.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pengeluaran_bulanan = PengeluaranBulanan.new(params[:pengeluaran_bulanan])\n\n respond_to do |format|\n if @pengeluaran_bulanan.save\n format.html { redirect_to @pengeluaran_bulanan, notice: 'Pengeluaran bulanan was successfully created.' }\n format.json { render json: @pengeluaran_bulanan, status: :created, location: @pengeluaran_bulanan }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pengeluaran_bulanan.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bordado = Bordado.new(params[:bordado])\n\n respond_to do |format|\n if @bordado.save\n format.html { redirect_to @bordado, notice: 'Bordado was successfully created.' }\n format.json { render json: @bordado, status: :created, location: @bordado }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bordado.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6347688", "0.633545", "0.6265529", "0.6234046", "0.62215424", "0.62206763", "0.6160601", "0.61543286", "0.6086408", "0.60515094", "0.60469353", "0.60360444", "0.598602", "0.59747726", "0.5949141", "0.594166", "0.5935959", "0.591948", "0.5917004", "0.5917004", "0.59156334", "0.5913773", "0.59070456", "0.5900745", "0.58916336", "0.5891236", "0.5884546", "0.5868576", "0.5866894", "0.58387077", "0.58372676", "0.58367145", "0.5836691", "0.58363545", "0.5831569", "0.58206046", "0.5807545", "0.57921076", "0.57906055", "0.57724977", "0.57694006", "0.5766299", "0.5763377", "0.57607836", "0.5729703", "0.572908", "0.5722644", "0.57189673", "0.5716265", "0.57137823", "0.57103807", "0.57096475", "0.5704167", "0.5694227", "0.5680728", "0.5672035", "0.5665688", "0.56600904", "0.5657736", "0.5655461", "0.56369245", "0.5631252", "0.56302935", "0.5625479", "0.56233114", "0.5620328", "0.5620105", "0.56153786", "0.561397", "0.56135297", "0.56130123", "0.56129587", "0.5612559", "0.5608981", "0.5607185", "0.559658", "0.55926466", "0.55916446", "0.5583897", "0.5583859", "0.55764985", "0.557303", "0.557258", "0.55696386", "0.55685145", "0.5567114", "0.55658835", "0.5561474", "0.5559144", "0.55492127", "0.5548598", "0.55474174", "0.5546701", "0.5545184", "0.5542183", "0.554045", "0.5539356", "0.5539353", "0.55387753", "0.5529584" ]
0.684998
0
PUT /kansei_buhins/1 PUT /kansei_buhins/1.json
def update @kansei_buhin = KanseiBuhin.find(params[:id]) respond_to do |format| if @kansei_buhin.update_attributes(params[:kansei_buhin]) format.html { redirect_to @kansei_buhin, notice: 'Kansei buhin was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @kansei_buhin.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @sinh_vien = SinhVien.find(params[:id])\n\n respond_to do |format|\n if @sinh_vien.update_attributes(params[:sinh_vien]) \n format.json { head :no_content }\n else \n format.json { render json: @sinh_vien.errors, status: :unprocessable_entity }\n end\n end\n end", "def restobooking\n @buchung = Buchung.find(params[:id])\n @buchung.status='B' \n \n respond_to do |format|\n if @buchung.update_attributes(params[:buchung])\n format.html { redirect_to @buchung, notice: 'Buchung wurde erfolgreich geaendert.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @buchung.errors, status: :unprocessable_entity }\n end\n end \n end", "def update\n @binh_bau = BinhBau.find(params[:id])\n respond_to do |format|\n if @binh_bau.update_attributes(params[:binh_bau])\n format.html { redirect_to @binh_bau, notice: 'Binh bau was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @binh_bau.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bijou.update(bijou_params)\n format.html { redirect_to @bijou, notice: 'Bijou was successfully updated.' }\n format.json { render :show, status: :ok, location: @bijou }\n else\n format.html { render :edit }\n format.json { render json: @bijou.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @giang_vien = GiangVien.find(params[:id])\n\n respond_to do |format|\n if @giang_vien.update_attributes(params[:giang_vien]) \n format.json { head :no_content }\n else \n format.json { render json: @giang_vien.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bonu.update(bonu_params)\n format.html { redirect_to @bonu, notice: 'Bonu was successfully updated.' }\n format.json { render :show, status: :ok, location: @bonu }\n else\n format.html { render :edit }\n format.json { render json: @bonu.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @basin = Basin.find(params[:id])\n\n respond_to do |format|\n if @basin.update_attributes(params[:basin])\n format.html { redirect_to @basin, notice: 'Basin was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @basin.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @osoba = Osoba.find(params[:id])\n\n if @osoba.update(params[:osoba])\n head :no_content\n else\n render json: @osoba.errors, status: :unprocessable_entity\n end\n end", "def update\n @buchung = Buchung.find(params[:id])\n \n respond_to do |format|\n if @buchung.update_attributes(params[:buchung])\n format.html { redirect_to @buchung, notice: 'Buchung wurde erfolgreich geaendert.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @buchung.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @seihinn.update(seihinn_params)\n format.html { redirect_to @seihinn, notice: \"Seihinn was successfully updated.\" }\n format.json { render :show, status: :ok, location: @seihinn }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @seihinn.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @zf_bjietu.update(zf_bjietu_params)\n format.html { redirect_to @zf_bjietu, notice: 'Zf bjietu was successfully updated.' }\n format.json { render :show, status: :ok, location: @zf_bjietu }\n else\n format.html { render :edit }\n format.json { render json: @zf_bjietu.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @bahan = Bahan.find(params[:id])\n\n respond_to do |format|\n if @bahan.update_attributes(params[:bahan])\n format.html { redirect_to @bahan, notice: 'Bahan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bahan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @ginasio = Ginasio.find(params[:id])\n\n respond_to do |format|\n if @ginasio.update_attributes(params[:ginasio])\n format.html { redirect_to @ginasio, :flash => { :success => 'Dados do ginasio alterados com successo!' } }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @ginasio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bien.update(bien_params)\n format.html { redirect_to @bien, notice: 'Bien was successfully updated.' }\n format.json { render :show, status: :ok, location: @bien }\n else\n format.html { render :edit }\n format.json { render json: @bien.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n respond_to do |format|\r\n if @sivic_banco.update(sivic_banco_params)\r\n format.html { redirect_to @sivic_banco, notice: 'Registro alterado com sucesso.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: 'edit' }\r\n format.json { render json: @sivic_banco.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n @lich_su_binh_bau = LichSuBinhBau.find(params[:id])\n\n respond_to do |format|\n if @lich_su_binh_bau.update_attributes(params[:lich_su_binh_bau])\n format.html { redirect_to @lich_su_binh_bau, notice: 'Lich su binh bau was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lich_su_binh_bau.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @boat.update(boat_params)\n head :no_content\n else\n render json: @boat.errors, status: :unprocessable_entity\n end\n end", "def update\n chi_tiet = ChiTietGioHang.find(params[:id])\n respond_to do |format|\n if @chi_tiet_gio_hang.update(update_chi_tiet_gio_hang_params)\n format.html { redirect_to :back, notice: 'Giỏ hàng đã được cập nhật' }\n format.json { render :show, status: :ok, location: @chi_tiet_gio_hang }\n else\n format.html { render :edit }\n format.json { render json: @chi_tiet_gio_hang.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @api_haiku = Api::Haiku.find(params[:id])\n\n respond_to do |format|\n if @api_haiku.update_attributes(params[:api_haiku])\n format.html { redirect_to @api_haiku, notice: 'Haiku was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @api_haiku.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \n\n respond_to do |format|\n if @huati.update_attributes(params[:huati])\n format.html { redirect_to @huati, notice: 'Huati was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @huati.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bbhk.update(bbhk_params)\n format.html { redirect_to @bbhk, notice: 'Bbhk was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bbhk.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @sinnoh.update(sinnoh_params)\n format.html { redirect_to @sinnoh, notice: 'Sinnoh was successfully updated.' }\n format.json { render :show, status: :ok, location: @sinnoh }\n else\n format.html { render :edit }\n format.json { render json: @sinnoh.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @keihi.update(keihi_params)\n format.html { redirect_to @keihi, notice: 'Keihi was successfully updated.' }\n format.json { render :show, status: :ok, location: @keihi }\n else\n format.html { render :edit }\n format.json { render json: @keihi.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @boat = Boat.find(params[:id], :include => [:members])\n @dockold = Dock.find(params[:Laituri]) unless params[:Laituri].blank?\n @berthold = @berth = Berth.where(:dock_id => @dockold.id, :number => params[:Laituripaikka]) unless params[:Laituri].blank?\n #@boat = Boat.find(params[:id])\n #changejnoToId\n parse_jno_from_omistajatxtbox\n change_jno_to_id_for_update\n if params[:boat][:BoatsMembers_attributes] == nil\n @onkoOk = false\n end\n\n @laituri_idt = Dock.all.map(&:id)\n @laituri_idt.insert(0,nil)\n\n @vapaat_laituripaikat = Berth.where(:dock_id => 1).all.map(&:number)\n @vapaat_laituripaikat.insert(0,nil)\n\n respond_to do |format|\n if @onkoOk && check_for_only_one_payer && @boat.update_attributes(params[:boat])\n check_dock_and_berth(format)\n format.html { redirect_to @boat, notice: 'Veneen muokkaus onnistui.' }\n format.json { head :no_content }\n else\n format.html {\n flash[:notice] = 'Virhe.'\n render action: \"edit\"\n }\n format.json { render json: @boat.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @kemboi.update(kemboi_params)\n format.html { redirect_to @kemboi, notice: 'Kemboi was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @kemboi.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @buchung.update(buchung_params)\n format.html { redirect_to @buchung, notice: 'Buchung was successfully updated.' }\n format.json { render :show, status: :ok, location: @buchung }\n else\n format.html { render :edit }\n format.json { render json: @buchung.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @boook.update(boook_params)\n format.html { redirect_to @boook, notice: 'Boook was successfully updated.' }\n format.json { render :show, status: :ok, location: @boook }\n else\n format.html { render :edit }\n format.json { render json: @boook.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @riyu_okunai.update(riyu_okunai_params)\n format.html { redirect_to @riyu_okunai, notice: 'Riyu okunai was successfully updated.' }\n format.json { render :show, status: :ok, location: @riyu_okunai }\n else\n format.html { render :edit }\n format.json { render json: @riyu_okunai.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @tagihan.update(tagihan_params)\n render json: @tagihan\n else\n render json: @tagihan.errors, status: :unprocessable_entity\n end\n end", "def update\n @squishee_cup = SquisheeCup.find(params[:id])\n puts params.to_json\n respond_to do |format|\n if @squishee_cup.update_attributes(params[:squishee_cup])\n format.html { redirect_to @squishee_cup, notice: 'Squishee cup was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @squishee_cup.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @ho_khau.update(ho_khau_params)\n format.html { redirect_to @ho_khau, notice: \"Ho khau was successfully updated.\" }\n format.json { render :show, status: :ok, location: @ho_khau }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @ho_khau.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @my_boice.update(my_boice_params)\n format.html { redirect_to @my_boice, notice: 'My boice was successfully updated.' }\n format.json { render :show, status: :ok, location: @my_boice }\n else\n format.html { render :edit }\n format.json { render json: @my_boice.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @sin = Sin.find(params[:id])\n\n respond_to do |format|\n if @sin.update_attributes(params[:sin])\n format.html { redirect_to @sin, notice: 'Binge was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sin.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bunny.update(bunny_params)\n format.html { redirect_to @bunny, notice: 'Bunny was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bunny.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bakusokukun.update(bakusokukun_params)\n format.html { redirect_to @bakusokukun, notice: 'Bakusokukun was successfully updated.' }\n format.json { render :show, status: :ok, location: @bakusokukun }\n else\n format.html { render :edit }\n format.json { render json: @bakusokukun.errors, status: :unprocessable_entity }\n end\n end\n end", "def bloquea \r\n @sivic_turma = SivicTurma.find(params[:id])\r\n @sivic_turma.update(:DATA_bloqueio => Time.now, :user_bloqueio => current_user.id)\r\n\r\n respond_to do |format|\r\n format.html { redirect_to sivic_turmas_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def update\n respond_to do |format|\n if @syohin.update(syohin_params)\n format.html { redirect_to @syohin, notice: 'Syohin was successfully updated.' }\n format.json { render :show, status: :ok, location: @syohin }\n else\n format.html { render :edit }\n format.json { render json: @syohin.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @sabio = Sabio.find(params[:id])\n\n respond_to do |format|\n if @sabio.update_attributes(params[:sabio])\n format.html { redirect_to @sabio, notice: 'El Sabio fue actualizado.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sabio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @shujukujiaoben.update(shujukujiaoben_params)\n format.html { redirect_to @shujukujiaoben, notice: 'Shujukujiaoben was successfully updated.' }\n format.json { render :show, status: :ok, location: @shujukujiaoben }\n else\n format.html { render :edit }\n format.json { render json: @shujukujiaoben.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @nhaxuatban.update(nhaxuatban_params)\n format.html { redirect_to @nhaxuatban, notice: \"Nhaxuatban was successfully updated.\" }\n format.json { render :show, status: :ok, location: @nhaxuatban }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @nhaxuatban.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @okugai.update(okugai_params)\n format.html { redirect_to @okugai, notice: 'Okugai was successfully updated.' }\n format.json { render :show, status: :ok, location: @okugai }\n else\n format.html { render :edit }\n format.json { render json: @okugai.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @riyu_monshin.update(riyu_monshin_params)\n format.html { redirect_to @riyu_monshin, notice: 'Riyu monshin was successfully updated.' }\n format.json { render :show, status: :ok, location: @riyu_monshin }\n else\n format.html { render :edit }\n format.json { render json: @riyu_monshin.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @byoin = Byoin.find(params[:id])\n\n respond_to do |format|\n if @byoin.update_attributes(params[:byoin])\n format.html { redirect_to @byoin, notice: 'Byoin was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @byoin.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @currentgwamokid = params[:currentgwamokid]\n respond_to do |format|\n if @sigan.update(sigan_params)\n format.html { redirect_to @sigan, notice: 'Sigan was successfully updated.' }\n format.json { render :show, status: :ok, location: @sigan }\n else\n format.html { render :edit }\n format.json { render json: @sigan.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @trinh_do_boi_duong.update(trinh_do_boi_duong_params)\n format.html { redirect_to @trinh_do_boi_duong, notice: 'Trinh do boi duong was successfully updated.' }\n format.json { render :show, status: :ok, location: @trinh_do_boi_duong }\n else\n format.html { render :edit }\n format.json { render json: @trinh_do_boi_duong.errors, status: :unprocessable_entity }\n end\n end\n end", "def actualizacion \n fiesta.update (params[:id]) \n render json: fiesta\n end", "def update\n respond_to do |format|\n if @obsah.update(obsah_params)\n format.html { redirect_to @obsah, notice: 'Obsah was successfully updated.' }\n format.json { render :show, status: :ok, location: @obsah }\n else\n format.html { render :edit }\n format.json { render json: @obsah.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @meibo.update(meibo_params)\n format.html { redirect_to @meibo, notice: '名簿は正常に更新されました。' }\n format.json { render :show, status: :ok, location: @meibo }\n else\n format.html { render :edit }\n format.json { render json: @meibo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @meibo.update(meibo_params)\n format.html { redirect_to @meibo, notice: '名簿は正常に更新されました。' }\n format.json { render :show, status: :ok, location: @meibo }\n else\n format.html { render :edit }\n format.json { render json: @meibo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @hobby_sotr.update(hobby_sotr_params)\n format.html { redirect_to @hobby_sotr, notice: 'Hobby sotr was successfully updated.' }\n format.json { render :show, status: :ok, location: @hobby_sotr }\n else\n format.html { render :edit }\n format.json { render json: @hobby_sotr.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @spkj_bsb=SpkjBsb.find(params[:id])\n @spkj_bsb.update_attributes(params[:spkj_bsb])\n\n respond_to do |format|\n format.html { redirect_to(\"/spkj_bsbs\") }\n format.json { render json: @spkj_bsb }\n end\n end", "def update\n respond_to do |format|\n if @nha_xuat_ban.update(nha_xuat_ban_params)\n format.html { redirect_to @nha_xuat_ban, notice: \"Nha xuat ban was successfully updated.\" }\n format.json { render :show, status: :ok, location: @nha_xuat_ban }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @nha_xuat_ban.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tubuyaki.update(tubuyaki_params)\n format.html { redirect_to @tubuyaki, notice: 'Tubuyaki was successfully updated.' }\n format.json { render :show, status: :ok, location: @tubuyaki }\n else\n format.html { render :edit }\n format.json { render json: @tubuyaki.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @kiban.update(kiban_params)\n format.html { redirect_to @kiban, notice: 'Kiban was successfully updated.' }\n format.json { render :show, status: :ok, location: @kiban }\n else\n format.html { render :edit }\n format.json { render json: @kiban.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bingo.update(bingo_params)\n format.html { redirect_to @bingo, notice: \"Bingo was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bingo }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bingo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @kingsizeb.update(kingsizeb_params)\n format.html { redirect_to @kingsizeb, notice: 'Kingsizeb was successfully updated.' }\n format.json { render :show, status: :ok, location: @kingsizeb }\n else\n format.html { render :edit }\n format.json { render json: @kingsizeb.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @sekilas_info.update(sekilas_info_params)\n format.html { redirect_to @sekilas_info, notice: 'Sekilas info was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sekilas_info.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @kumo.update(kumo_params)\n format.html { redirect_to kumos_path, notice: 'Kumo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @kumo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bread.update(bread_params)\n format.html { redirect_to @bread, notice: 'パン情報を編集した.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bread.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @bruschettum = Bruschettum.find(params[:id])\n @bruschettum.ingredients.clear\n params[:ingredient].each{|ingr|\n @bruschettum.ingredients << Ingredient.find_by_name(ingr)\n }\n\n respond_to do |format|\n if @bruschettum.update_attributes(params[:bruschettum])\n format.html { redirect_to @bruschettum, notice: 'Bruschettum was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bruschettum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bok.update(bok_params)\n format.html { redirect_to @bok, notice: 'Bok was successfully updated.' }\n format.json { render :show, status: :ok, location: @bok }\n else\n format.html { render :edit }\n format.json { render json: @bok.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @yaopin = Yaopin.find(params[:id])\n\n respond_to do |format|\n if @yaopin.update_attributes(params[:yaopin])\n format.html { redirect_to @yaopin, notice: 'Yaopin was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @yaopin.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bocconi.update(bocconi_params)\n format.html { redirect_to @bocconi, notice: 'Bocconi was successfully updated.' }\n format.json { render :show, status: :ok, location: @bocconi }\n else\n format.html { render :edit }\n format.json { render json: @bocconi.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @hijo.update(hijo_params)\n format.html { redirect_to @hijo, notice: 'El hijo fué actualizado exitosamente.' }\n format.json { render :show, status: :ok, location: @hijo }\n else\n format.html { render :edit }\n format.json { render json: @hijo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bow.update(bow_params)\n format.html { redirect_to @bow, notice: 'Bow was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bow.errors, status: :unprocessable_entity }\n end\n end\n end", "def update \n retorno = {erro: \"322\" ,body: \"\"}\n if @usuario.update(valid_request?)\n retorno = {erro: \"000\", body: {evento_id: @usuario.id, usuario_nome: @usuario.nome}}\n end\n render json: retorno.to_json\n end", "def update\n respond_to do |format|\n if @kai2_tuan7.update(kai2_Kai2Tuan7_params)\n format.html { redirect_to edit_kai2_tuan7_path(@kai2_tuan7), notice: 'Kai2 Kai2Tuan7 was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @kai2_tuan7.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @kniha.update(kniha_params)\n format.html { redirect_to @kniha, notice: 'Kniha was successfully updated.' }\n format.json { render :show, status: :ok, location: @kniha }\n else\n format.html { render :edit }\n format.json { render json: @kniha.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @kintai.update(kintai_params)\n format.html { redirect_to @kintai, notice: 'Kintai was successfully updated.' }\n format.json { render :show, status: :ok, location: @kintai }\n else\n format.html { render :edit }\n format.json { render json: @kintai.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @houmon.update(houmon_params)\n format.html { redirect_to @houmon, notice: 'Houmon was successfully updated.' }\n format.json { render :show, status: :ok, location: @houmon }\n else\n format.html { render :edit }\n format.json { render json: @houmon.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @johari.update(johari_params)\n format.html { redirect_to @johari, notice: 'Johari was successfully updated.' }\n format.json { render :show, status: :ok, location: @johari }\n else\n format.html { render :edit }\n format.json { render json: @johari.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #@title = @header = \"Изменение торговой марки\"\n respond_to do |format|\n if @boat_series.update(boat_series_params)\n #format.html { redirect_to @boat_series, notice: 'Торговая марка успешно изменена' }\n format.json { render json: @boat_series.to_json }\n else\n #format.html { render :edit }\n format.json { render json: @boat_series.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @jiankong.update(jiankong_params)\n format.html { redirect_to @jiankong, notice: 'Jiankong was successfully updated.' }\n format.json { render :show, status: :ok, location: @jiankong }\n else\n format.html { render :edit }\n format.json { render json: @jiankong.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bixi.update(bixi_params)\n format.html { redirect_to @bixi, notice: 'Bixi was successfully updated.' }\n format.json { render :show, status: :ok, location: @bixi }\n else\n format.html { render :edit }\n format.json { render json: @bixi.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @kokuin.update(kokuin_params)\n format.html { redirect_to admin_kokuin_path, notice: 'Kokuin was successfully updated.' }\n format.json { render action: 'show', status: :ok, location: @kokuin }\n else\n format.html { render action: 'edit' }\n format.json { render json: @kokuin.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @buisness.update(buisness_params)\n format.html { redirect_to @buisness, notice: 'Buisness was successfully updated.' }\n format.json { render :show, status: :ok, location: @buisness }\n else\n format.html { render :edit }\n format.json { render json: @buisness.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @shouji.update(shouji_params)\n format.html { redirect_to @shouji, notice: 'Shouji was successfully updated.' }\n format.json { render :show, status: :ok, location: @shouji }\n else\n format.html { render :edit }\n format.json { render json: @shouji.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @hijo = Hijo.find(params[:id])\n\n respond_to do |format|\n if @hijo.update_attributes(params[:hijo])\n format.html { redirect_to @hijo, notice: 'Hijo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @hijo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :update_almacen,Sigesp::Solicitud\n if @sigesp_solicitud.update(sigesp_solicitud_alamcen_params)\n return render json: { url: sigesp_solicitudsalmacen_path(@sigesp_solicitud)} \n else\n return render json:@sigesp_solicitud.errors ,status: :unprocessable_entity\n end \n end", "def update\n respond_to do |format|\n if @socio_dados_banco.update(socio_dados_banco_params)\n format.html { redirect_to @socio_dados_banco, notice: 'Socio dados banco was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @socio_dados_banco.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bonificacion.update(bonificacion_params)\n format.html { redirect_to @bonificacion, notice: 'Bonificacion was successfully updated.' }\n format.json { render :show, status: :ok, location: @bonificacion }\n else\n format.html { render :edit }\n format.json { render json: @bonificacion.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bonificacion.update(bonificacion_params)\n format.html { redirect_to @bonificacion, notice: 'Bonificacion was successfully updated.' }\n format.json { render :show, status: :ok, location: @bonificacion }\n else\n format.html { render :edit }\n format.json { render json: @bonificacion.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @kishangarh_marble.update(kishangarh_marble_params)\n format.html { redirect_to @kishangarh_marble, notice: 'Kishangarh marble was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @kishangarh_marble.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bourbon.update(bourbon_params)\n format.html { redirect_to @bourbon, notice: 'Bourbon was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bourbon.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @kennkoukiroku.update(kennkoukiroku_params)\n format.html { redirect_to kennkoukirokus_path, notice: \"健康記録を更新しました\" }\n format.json { render :show, status: :ok, location: @kennkoukiroku }\n else\n format.html { render :edit }\n format.json { render json: @kennkoukiroku.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @kota_stone.update(kota_stone_params)\n format.html { redirect_to kota_stones_url, notice: 'Kota stone was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @kota_stone.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @control_bay.update(control_bay_params)\n format.html { redirect_to ['control',@bay], notice: 'La bahía fue actualizada exitosamente.' }\n format.json { render :show, status: :ok, location: @bay }\n else\n format.html { render :edit }\n format.json { render json: @bay.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @buoy.update(buoy_params)\n format.html { redirect_to @buoy, notice: 'Buoy was successfully updated.' }\n format.json { render :show, status: :ok, location: @buoy }\n else\n format.html { render :edit }\n format.json { render json: @buoy.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @sinh_vien = SinhVien.new(params[:sinh_vien])\n\n respond_to do |format|\n if @sinh_vien.save \n format.json { render json: @sinh_vien, status: :created, location: @sinh_vien }\n else \n format.json { render json: @sinh_vien.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @admin_bait = Bait.find(params[:id])\n\n respond_to do |format|\n if @admin_bait.update_attributes(params[:admin_bait])\n format.html { redirect_to @admin_bait, notice: 'Bait was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin_bait.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @kuaisufenfawenjian.update(kuaisufenfawenjian_params)\n format.html { redirect_to @kuaisufenfawenjian, notice: 'Kuaisufenfawenjian was successfully updated.' }\n format.json { render :show, status: :ok, location: @kuaisufenfawenjian }\n else\n format.html { render :edit }\n format.json { render json: @kuaisufenfawenjian.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @registro_bovino = RegistroBovino.find(params[:id])\n\n respond_to do |format|\n if @registro_bovino.update_attributes(params[:registro_bovino])\n #format.html { redirect_to @registro_bovino, notice: 'Registro bovino was successfully updated.' }\n format.html { redirect_to action: \"index\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @registro_bovino.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # authorize @becario\n respond_to do |format|\n if @becario.update(becario_params)\n format.html { redirect_to @becario, notice: 'Becario was successfully updated.' }\n format.json { render :show, status: :ok, location: @becario }\n else\n format.html { render :edit }\n format.json { render json: @becario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @bico = Bico.find(params[:id])\n\n respond_to do |format|\n if @bico.update_attributes(params[:bico])\n format.html { redirect_to @bico, notice: 'Bico was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bico.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bicicletum.update(bicicletum_params)\n format.html { redirect_to @bicicletum, notice: 'Bicicletum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bicicletum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @supermarket = Supermarket.find(params[:id]) \n respond_to do |format|\n if @supermarket.update(supermarket_params)\n format.json { render json: @supermarket, status: :ok }\n end\n end\n end", "def update\n respond_to do |format|\n if @shogi.update(shogi_params)\n format.html { redirect_to @shogi, notice: 'Shogi was successfully updated.' }\n format.json { render :show, status: :ok, location: @shogi }\n else\n format.html { render :edit }\n format.json { render json: @shogi.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bicicletum.update(bicicletum_params)\n format.html { redirect_to @bicicletum, notice: 'Bicicleta Actualizada.' }\n format.json { render :show, status: :ok, location: @bicicletum }\n else\n format.html { render :edit }\n format.json { render json: @bicicletum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @bili = Bili.find(params[:id])\n\n respond_to do |format|\n if @bili.update_attributes(params[:bili])\n format.html { redirect_to @bili, notice: 'Bili was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bili.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @spice.update(spice_params)\n head :no_content\n else\n render json: @spice.errors, status: :unprocessable_entity\n end\n end" ]
[ "0.68814063", "0.670075", "0.65591913", "0.6488539", "0.6405582", "0.6348251", "0.6337876", "0.63248795", "0.6289802", "0.6284423", "0.6229172", "0.62042034", "0.61847705", "0.6167284", "0.6149205", "0.61369705", "0.61307514", "0.61276966", "0.6114106", "0.61093235", "0.6100495", "0.60909945", "0.60854", "0.6078393", "0.60692567", "0.60380024", "0.6037882", "0.60368544", "0.6033904", "0.6031018", "0.6028793", "0.6025374", "0.6023372", "0.60214204", "0.601044", "0.5995591", "0.59918594", "0.5989297", "0.5987388", "0.5982942", "0.5974573", "0.59664994", "0.5965847", "0.5964516", "0.5957412", "0.595723", "0.5956955", "0.59524274", "0.59524274", "0.594965", "0.59396315", "0.59391975", "0.5936665", "0.5933816", "0.5931364", "0.59298533", "0.5929837", "0.59286225", "0.59271425", "0.59268844", "0.5926184", "0.59215724", "0.5921043", "0.59200764", "0.591982", "0.5917501", "0.59154505", "0.5910341", "0.59102654", "0.5908935", "0.59034777", "0.590058", "0.58976156", "0.58930564", "0.58909184", "0.5889681", "0.5880868", "0.58690053", "0.5867134", "0.5864655", "0.58537894", "0.5852657", "0.5843344", "0.5842778", "0.5838203", "0.5830943", "0.5829802", "0.58270216", "0.5824536", "0.5822252", "0.58208406", "0.58205825", "0.5814629", "0.58141446", "0.58092135", "0.5806653", "0.5806119", "0.5803376", "0.5802843", "0.5802771" ]
0.685274
1
DELETE /kansei_buhins/1 DELETE /kansei_buhins/1.json
def destroy @kansei_buhin = KanseiBuhin.find(params[:id]) @kansei_buhin.destroy respond_to do |format| format.html { redirect_to kansei_buhins_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @sinh_vien = SinhVien.find(params[:id])\n @sinh_vien.destroy\n\n respond_to do |format| \n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @giang_vien = GiangVien.find(params[:id])\n @giang_vien.destroy\n\n respond_to do |format| \n format.json { head :no_content }\n end\n end", "def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end", "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def delete(path)\n RestClient.delete request_base+path\n end", "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def destroy\n @binh_bau = BinhBau.find(params[:id])\n @binh_bau.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_binh_baus_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ujumbe.destroy\n respond_to do |format|\n format.html { redirect_to ujumbes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bahan = Bahan.find(params[:id])\n @bahan.destroy\n\n respond_to do |format|\n format.html { redirect_to bahans_url }\n format.json { head :no_content }\n end\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def destroy\n client=Client.find_by_id(params[:id])\n if client != nil\n if client.destroy\n head 204\n end\n else\n head 404\n end\n end", "def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end", "def destroy\n @uginuce.sheep.update status:'na farmi'\n @uginuce.destroy\n respond_to do |format|\n format.html { redirect_to uginuces_url }\n format.json { head :no_content }\n end\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def destroy\n @humanidades1 = Humanidades1.find(params[:id])\n @humanidades1.destroy\n\n respond_to do |format|\n format.html { redirect_to humanidades1s_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bicicletum.destroy\n respond_to do |format|\n format.html { redirect_to bicicleta_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @uchronia = Uchronia.find(params[:id])\n @uchronia.destroy\n\n respond_to do |format|\n format.html { redirect_to uchronias_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ra_khoi_dang.destroy\n respond_to do |format|\n format.html { redirect_to ra_khoi_dangs_url, notice: 'Ra khoi dang was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @basin = Basin.find(params[:id])\n @basin.destroy\n\n respond_to do |format|\n format.html { redirect_to basins_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @baton = Baton.find(params[:id])\n @baton.destroy\n\n respond_to do |format|\n format.html { redirect_to batons_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def destroy\n @trinh_do_boi_duong.destroy\n respond_to do |format|\n format.html { redirect_to trinh_do_boi_duongs_url, notice: 'Trinh do boi duong was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @riyu_okunai.destroy\n respond_to do |format|\n format.html { redirect_to riyu_okunais_url, notice: 'Riyu okunai was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @secubat_client = SecubatClient.find(params[:id])\n @secubat_client.destroy\n\n respond_to do |format|\n format.html { redirect_to secubat_clients_url }\n format.json { head :ok }\n end\n end", "def delete\n request(:delete)\n end", "def destroy\n @himalaya.destroy\n\n respond_to do |format|\n format.html { redirect_to himalayas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lich_su_binh_bau = LichSuBinhBau.find(params[:id])\n @lich_su_binh_bau.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_lich_su_binh_baus_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @sivic_banco.destroy\r\n respond_to do |format|\r\n format.html { redirect_to sivic_bancos_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @bijou.destroy\n respond_to do |format|\n format.html { redirect_to bijous_url, notice: 'Bijou was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @injhas_special_biryani_dish.destroy\n respond_to do |format|\n format.html { redirect_to injhas_special_biryani_dishes_url, notice: 'Injhas special biryani dish was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @kota_stone.destroy\n respond_to do |format|\n format.html { redirect_to kota_stones_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @nguoi_dung = NguoiDung.find(params[:id])\n @nguoi_dung.destroy\n\n respond_to do |format|\n format.html { redirect_to nguoi_dungs_url }\n format.json { head :ok }\n end\n end", "def destroy \n @buchung = Buchung.find(params[:id])\n @buchung.destroy\n\n respond_to do |format|\n format.html { redirect_to buchungs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @kai2_tuan7.destroy\n respond_to do |format|\n format.html { redirect_to kai2_Kai2Tuan7s_url }\n format.json { head :no_content }\n end\n end", "def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end", "def destroy\n @api_haiku = Api::Haiku.find(params[:id])\n @api_haiku.destroy\n\n respond_to do |format|\n format.html { redirect_to api_haikus_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ginasio = Ginasio.find(params[:id])\n @ginasio.destroy\n\n respond_to do |format|\n format.html { redirect_to ginasios_url, :flash => { :notice => 'Ginasio apagado.' } }\n format.json { head :ok }\n end\n end", "def destroy\n @himalaya = Himalaya.find(params[:id])\n @himalaya.destroy\n\n respond_to do |format|\n format.html { redirect_to himalayas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bakusokukun.destroy\n respond_to do |format|\n format.html { redirect_to bakusokukuns_url, notice: 'Bakusokukun was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @kumo.destroy\n respond_to do |format|\n format.html { redirect_to kumos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @seguidore = Seguidore.find(params[:id])\n @seguidore.destroy\n\n respond_to do |format|\n format.html { redirect_to seguidores_url }\n format.json { head :ok }\n end\n end", "def destroy\n \n @huati.destroy\n\n respond_to do |format|\n format.html { redirect_to manage_huatis_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @surah.destroy\n respond_to do |format|\n format.html { redirect_to surahs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sabio = Sabio.find(params[:id])\n @sabio.destroy\n\n respond_to do |format|\n format.html { redirect_to sabios_url }\n format.json { head :ok }\n end\n end", "def destroy\n @chaine = Chaine.find(params[:id])\n @chaine.destroy\n\n respond_to do |format|\n format.html { redirect_to chaines_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @jednani.destroy\n respond_to do |format|\n format.html { redirect_to jednanis_url }\n format.json { head :no_content }\n end\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def delete\n render :json => @fiestas.delete_at(params[:id].to_i)\n end", "def delete_from_entzumena\n headline = Headline.where({:source_item_type => params[:source_item_type], :source_item_id => params[:source_item_id]}).first\n if headline.destroy\n render :json => true, :status => 200\n else\n render :json => false, :status => :error\n end\n end", "def destroy\n @kisalli = Kisalli.find_by_key(params[:id])\n @kisalli.destroy\n\n respond_to do |format|\n format.html { redirect_to kisallis_url }\n format.json { head :no_content }\n end\n end", "def delete\n supprimer = SondageService.instance.supprimerSondage(params[:id])\n (supprimer) ? (render json: true, status: :ok) : (render json: false, status: :not_found)\nend", "def destroy\n @kishangarh_marble.destroy\n respond_to do |format|\n format.html { redirect_to kishangarh_marbles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @dhokebaaz.destroy\n respond_to do |format|\n format.html { redirect_to dhokebaazs_url, notice: 'Dhokebaaz was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @byoin = Byoin.find(params[:id])\n @byoin.destroy\n\n respond_to do |format|\n format.html { redirect_to byoins_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tubuyaki.destroy\n respond_to do |format|\n format.html { redirect_to tubuyakis_url, notice: 'Tubuyaki was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @shujukujiaoben.destroy\n respond_to do |format|\n format.html { redirect_to shujukujiaobens_url, notice: 'Shujukujiaoben was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @kullanici = Kullanici.find(params[:id])\n @kullanici.destroy\n\n respond_to do |format|\n format.html { redirect_to kullanicis_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @riyu_monshin.destroy\n respond_to do |format|\n format.html { redirect_to riyu_monshins_url, notice: 'Riyu monshin was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n\n @chi_tiet_gio_hang.destroy\n respond_to do |format|\n format.html { redirect_to gio_hang_path(set_gio_hang), notice: 'Hàng hóa đã được xóa khỏi giỏ hàng' }\n format.json { head :no_content }\n end\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def destroy\n @hijo.destroy\n respond_to do |format|\n format.html { redirect_to agente_hijos_url, notice: 'El hijo fué eliminado exitosamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @kanri_daicho.destroy\n respond_to do |format|\n format.html { redirect_to kanri_daichos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @kemboi.destroy\n respond_to do |format|\n format.html { redirect_to kembois_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @gran_unidad.destroy\n respond_to do |format|\n format.html { redirect_to gran_unidad_index_url }\n format.json { head :no_content }\n end\n end", "def borrar \n\n fiesta.destroy\n render json: fiesta \n end", "def destroy\n @bicicletum.destroy\n respond_to do |format|\n format.html { redirect_to bicicleta_url, notice: 'Bicicleta eliminada.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @trein_consul_comercial.destroy\n respond_to do |format|\n format.html { redirect_to trein_consul_comercials_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @seihinn.destroy\n respond_to do |format|\n format.html { redirect_to seihinns_url, notice: \"Seihinn was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @ho_khau.destroy\n respond_to do |format|\n format.html { redirect_to ho_khaus_url, notice: \"Ho khau was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def delete\n start { |connection| connection.request http :Delete }\n end", "def destroy\n @socio_dados_banco.destroy\n respond_to do |format|\n format.html { redirect_to socio_dados_bancos_url }\n format.json { head :no_content }\n end\n end", "def delete(path, params)\n headers = {:Authorization => \"token #{token}\", :content_type => :json, :accept => :json}\n res = RestClient.delete(\"#{github_api_uri}/#{path}\", params.to_json, headers)\n Yajl.load(res)\n end", "def destroy\n @zf_bjietu.destroy\n respond_to do |format|\n format.html { redirect_to zf_bjietus_url, notice: 'Zf bjietu was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end", "def destroy\n @rishabh.destroy\n respond_to do |format|\n format.html { redirect_to rishabhs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @kolegiji = Kolegiji.find(params[:id])\n @kolegiji.destroy\n\n respond_to do |format|\n format.html { redirect_to kolegijis_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asignatura = Asignatura.find(params[:id])\n @asignatura.destroy\n\n respond_to do |format|\n format.html { redirect_to asignaturas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asignatura = Asignatura.find(params[:id])\n @asignatura.destroy\n\n respond_to do |format|\n format.html { redirect_to asignaturas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @kegiatan.destroy\n respond_to do |format|\n format.html { redirect_to kegiatans_url, notice: 'Kegiatan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tantosha.destroy\n # @tantosha.delete\n respond_to do |format|\n format.html { redirect_to tantoshas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bustour.destroy\n respond_to do |format|\n format.html { redirect_to bustours_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asthenium.destroy\n respond_to do |format|\n format.html { redirect_to asthenia_url }\n format.json { head :no_content }\n end\n end", "def destroy\n return if new_record?\n \n @api.delete \"/items/#{shortcode_url}.json\"\n end", "def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end", "def destroy\n # @bill_quorum = BillQuorum.find(params[:id])\n @bill_quorum.destroy\n\n respond_to do |format|\n format.html { redirect_to bill_quorums_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @kai2_ji7.destroy\n respond_to do |format|\n format.html { redirect_to kai2_ji7s_url }\n format.json { head :no_content }\n end\n end", "def do_delete(uri = \"\")\n @connection.delete do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n end\n end", "def destroy\n @informasi_berita_terkini.destroy\n respond_to do |format|\n format.html { redirect_to informasi_berita_terkini_index_url, notice: 'Informasi berita terkini telah berhasil dihapus.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @data_pendidikan_agama_katolik.destroy\n respond_to do |format|\n format.html { redirect_to data_pendidikan_agama_katolik_index_url, notice: 'Data pendidikan agama katolik was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n \n end", "def destroy\n @prueba_json.destroy\n respond_to do |format|\n format.html { redirect_to prueba_jsons_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @zakaz = Zakaz.find(params[:id])\n @zakaz.destroy\n\n respond_to do |format|\n format.html { redirect_to zakazs_url }\n format.json { head :ok }\n end\n end", "def destroy\n @data_keagamaan_katolik.destroy\n respond_to do |format|\n format.html { redirect_to data_keagamaan_katolik_index_url, notice: 'Data keagamaan katolik was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.7151887", "0.71441704", "0.6996511", "0.6974747", "0.6937264", "0.68778795", "0.68375856", "0.68362015", "0.68356115", "0.6816617", "0.68122745", "0.6806453", "0.67842805", "0.67842805", "0.67842805", "0.67842805", "0.67731696", "0.6773065", "0.67719656", "0.675696", "0.67565006", "0.67550457", "0.6750524", "0.67482346", "0.67410153", "0.6734545", "0.6730531", "0.6727494", "0.6725121", "0.67217636", "0.671385", "0.67085904", "0.6707566", "0.6707384", "0.67073023", "0.67064697", "0.6700977", "0.6695095", "0.66931707", "0.6692768", "0.6692084", "0.6684226", "0.66823024", "0.6681794", "0.6679276", "0.6677964", "0.6676162", "0.6671631", "0.66714925", "0.66640925", "0.6661687", "0.66611767", "0.66610724", "0.6659384", "0.66565424", "0.66460264", "0.66450155", "0.66403663", "0.6639988", "0.66329265", "0.66316736", "0.6624182", "0.66222864", "0.6619627", "0.6619242", "0.6617323", "0.6617323", "0.66155744", "0.66135675", "0.6610865", "0.66083246", "0.66077405", "0.660613", "0.6600711", "0.6595828", "0.65953237", "0.65944403", "0.659422", "0.65941066", "0.6593337", "0.6591518", "0.65848047", "0.65834486", "0.6578622", "0.6578622", "0.6576296", "0.657524", "0.6572656", "0.6567054", "0.6564373", "0.6561674", "0.65587157", "0.655723", "0.65541464", "0.65536094", "0.6552494", "0.654967", "0.6548892", "0.6547817", "0.65478104" ]
0.72041744
0
Search params : buhinNm katashikiCdFrom katashikiCdTo katashikiNm
def search # 検索条件設定 conditions = KanseiBuhin.where("1 = ?", 1) conditions = conditions.where("\"buhinNm\" LIKE ?", params[:buhinNm] + "%") if params[:buhinNm] != "" conditions = conditions.where("\"katashikiCd\" >= ?", params[:katashikiCdFrom].to_i) if params[:katashikiCdFrom] != "" conditions = conditions.where("\"katashikiCd\" <= ?", params[:katashikiCdTo].to_i) if params[:katashikiCdTo] != "" conditions = conditions.where("\"katashikiNm\" LIKE ?", params[:katashikiNm] + "%") if params[:katashikiNm] != "" logger.debug(conditions) records = conditions.count limit = params[:rows].to_i page = params[:page].to_i if records > 0 n = records.quo(limit) total_pages = n.ceil else total_pages = 0 end # 検索開始 start = limit * page - limit; @kanseiBuhins = conditions.find( :all, :offset => start, :limit => limit, :order => "\"buhinCd\"") # 値の格納 @responce = { total: total_pages.to_s, page: params[:page], records: records.to_s, rows: @kanseiBuhins } #logger.debug(@responce) respond_to do |format| format.html # index.html.erb format.json { render json: @responce } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def condicion_search(pparams, phash, pmodel)\n cp = 0\n pv = 0\n cad = ' '\n\n pparams.each do |k,v|\n if (k != 'utf8' and k != 'action' and k != 'controller' and k != 'srchmodel' and k != 'page') \n\t\n\t if v.rstrip != ''\n\t\t\n\t \tif pv > 0\n\t\t\tcad += \" AND \"\n\t\tend\n\t\t\n\t\tif k.to_s == \"searchfield\"\n\t\t \n \t\t if es_entero(v)\n\t\t \tif pmodel.hsearch_fields[0]==\"codigo\" or pmodel.hsearch_fields[0]==\"cliente_cod\"\n\t\t\t cad += pmodel.hsearch_fields[0]+\" = '#{v}' \"\n\t\t\telse\n\t\t\t cad += pmodel.hsearch_fields[0]+\" = #{v} \"\n\t\t\tend\n\t\t else\n\t\t sr = v.to_s\n\t\t\tif pmodel.hsearch_fields[0]==\"codigo\"\n\t\t\t cad += pmodel.hsearch_fields[1]+\" LIKE '%#{sr.capitalize}%'\"\t\n\t\t\telse \n\t\t\t cad += pmodel.hsearch_fields[1]+\"||to_char(\"+pmodel.hsearch_fields[0]+\",'99999') LIKE '%#{sr.capitalize}%'\"\t\n\t\t\tend\t \n\t\t end\n\t\n\t\telse #si no es searchfield\n\t \t\n \t\t tipo = phash[k].type\n\t\t case tipo\n\t\t when :string, :text\n\t\t sr = v.to_s\n\t\t\t if k.to_s == \"codigo\" or k.to_s == \"cliente_cod\" \n\t\t\t\t cad += \"upper(\"+k + \") = '#{sr.upcase}'\"\n\t\t\t else\n\t\t\t\t cad += \"upper(\"+k + \") like '%#{sr.upcase}%'\" \n\t\t\t end\t\t\n\t\t when :date, :datetime, :timestamp\n\t\t\t cad += k + \" = '#{v}'\"\n\t\t else\n\t\t\t cad += k + \" = #{v} \"\n\t end\n\t\tend #del searchfield\n\t\tpv += 1\n\t end \n\t cp += 1\n end\n end #del each\n \n if cp == 0\n \" 1 = 0\"\n else\n if pv == 0\n\t \" 1 = 1 \"\n else\n\t cad\n end \n end \nend", "def search_params\n params.require(:search).permit(:result_no, :generate_no, :last_result_no, :last_generate_no, :e_no, :sub_no, :main_no, :i_no, :i_name, :value)\n end", "def search_params search\n search = Hash.new\n [:writing, :kana, :romaji, :def_de, :def_en, :def_fr].each do |field|\n search[field] = \"%#{params[:search]}%\"\n end\n search\n end", "def filtering_params(params)\n params.slice(:omnisearch)\n end", "def search_param_params\n params.require(:search_param).permit(:name, :mount, :flange_focal_distance, :sensor_size, :work_length, :work_lenght_round, :xiangyuan)\n end", "def search\n conditions = KonyuRireki.where(\"konyu_rirekis.\\\"delFlg\\\" = ?\", 0)\n conditions = add_condition_int(conditions, \"konyu_rirekis.\\\"kokyakuId\\\"\", :kokyakuIdFrom, :kokyakuIdTo)\n conditions = add_condition_int(conditions, \"konyu_rirekis.\\\"hokenShubetsuCd1\\\"\", :hokenShubetsuCd1)\n conditions = add_condition_int(conditions, \"konyu_rirekis.\\\"hokenShubetsuCd2\\\"\", :hokenShubetsuCd2)\n conditions = add_condition_date(conditions, \"\\\"juchuDt\\\"\", :juchuDtFrom, :juchuDtTo)\n conditions = add_condition_name(conditions, \"byoins.\\\"byoinNm\\\"\", :byoinNm)\n conditions = add_condition_date(conditions, \"\\\"kariAwaseDt\\\"\", :kariAwaseDtFrom, :kariAwaseDtTo)\n conditions = add_condition_name(conditions, \"kokyakus.\\\"kokyakuNm1\\\"\", :kokyakuNm1)\n conditions = add_condition_name(conditions, \"kokyakus.\\\"kokyakuNm2\\\"\", :kokyakuNm2)\n conditions = add_condition_name(conditions, \"konyu_rirekis.\\\"shohinNm\\\"\", :shohinNm)\n conditions = add_condition_date(conditions, \"\\\"nohinDt\\\"\", :nohinDtFrom, :nohinDtTo)\n conditions = add_condition_name(conditions, \"kokyakus.\\\"kokyakuNmKana1\\\"\", :kokyakuNmKana1)\n conditions = add_condition_name(conditions, \"kokyakus.\\\"kokyakuNmKana2\\\"\", :kokyakuNmKana2)\n conditions = add_condition_userNm(conditions, \"ust\", :uketsukeSesakuTantoNm)\n conditions = add_condition_date(conditions, \"\\\"kofuDt\\\"\", :kofuDtFrom, :kofuDtTo)\n conditions = add_condition_str(conditions, \"konyu_rirekis.\\\"shubetsuKn\\\"\", :shubetsuKn)\n conditions = add_condition_userNm(conditions, \"kat\", :kariAwaseTantoNm)\n conditions = add_condition_date(conditions, \"\\\"nyukinDt\\\"\", :nyukinDtFrom, :nyukinDtTo)\n conditions = add_condition_name(conditions, \"seihins.\\\"hinmeiNm\\\"\", :hinmeiNm)\n conditions = add_condition_userNm(conditions, \"nt\", :nohinTantoNm)\n conditions = add_condition_date(conditions, \"\\\"oshiinDt\\\"\", :oshiinDtFrom, :oshiinDtTo)\n conditions = add_condition_userNm(conditions, \"mt\", :mitsumoriTantoEigyoNm)\n conditions = add_condition_date(conditions, \"\\\"kanryoDt\\\"\", :kanryoDtFrom, :kanryoDtTo)\n conditions = add_condition_date(conditions, \"\\\"mitsumoriDt\\\"\", :mitsumoriDtFrom, :mitsumoriDtTo)\n\n # 検索に必要なSQL文を取得する\n select, joins = get_select_stmt(:select)\n\n records = conditions.count(:joins => joins)\n limit = params[:rows].to_i\n page = params[:page].to_i\n if records > 0\n n = records.quo(limit)\n total_pages = n.ceil\n else\n total_pages = 0\n end\n start = limit * page - limit;\n\n @konyu_rirekis = conditions.find(\n :all,\n :select => select,\n :joins => joins,\n :offset => start,\n :limit => limit,\n :order => \"konyu_rirekis.\\\"kokyakuId\\\" ASC\")\n\n @responce = {\n total: total_pages.to_s,\n page: params[:page],\n records: records.to_s,\n rows: @konyu_rirekis\n }\n logger.debug(@responce)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @responce }\n end\n end", "def search_params\n params.require(:search).permit(:tabella, :campo, :argomento, :data, :occorrenze, :tipo)\n end", "def search_params\n [params[:label], params[:search]].join(\" \").strip\n end", "def search_params\n params.require(:search).permit(:keyword, :zona, :last_run,:zone_id)\n end", "def search_params\n # params[:search]\n end", "def search\n conditions = Kokyaku.where(\"\\\"delFlg\\\" = ?\", 0)\n conditions = conditions.where(\"\\\"kokyakuId\\\" >= ?\", params[:kokyaku][:kokyakuIdFrom].to_i) if params[:kokyaku][:kokyakuIdFrom] != \"\"\n conditions = conditions.where(\"\\\"kokyakuId\\\" <= ?\", params[:kokyaku][:kokyakuIdTo].to_i) if params[:kokyaku][:kokyakuIdTo] != \"\"\n conditions = conditions.where(\"\\\"kokyakuNm1\\\" LIKE ?\", \"%\" + params[:kokyaku][:kokyakuNm1] + \"%\") if params[:kokyaku][:kokyakuNm1] != \"\"\n conditions = conditions.where(\"\\\"kokyakuNm2\\\" LIKE ?\", \"%\" + params[:kokyaku][:kokyakuNm2] + \"%\") if params[:kokyaku][:kokyakuNm2] != \"\"\n conditions = conditions.where(\"\\\"kokyakuNmKana1\\\" LIKE ?\", \"%\" + params[:kokyaku][:kokyakuNmKana1] + \"%\") if params[:kokyaku][:kokyakuNmKana1] != \"\"\n conditions = conditions.where(\"\\\"kokyakuNmKana2\\\" LIKE ?\", \"%\" + params[:kokyaku][:kokyakuNmKana2] + \"%\") if params[:kokyaku][:kokyakuNmKana2] != \"\"\n conditions = conditions.where(\"\\\"seibetsu\\\" = ?\", params[:kokyaku][:seibetsu]) if params[:kokyaku][:seibetsu] != \"\"\n\n # 生年月日は「元号」「年」「月」「日」を連結して比較する\n adapter = Rails.configuration.database_configuration[Rails.env]['adapter']\n logger.debug(adapter)\n if adapter == \"sqlite3\" then\n # for sqlite\n tanjoDtCondition = str_sql_concat(\"SUBSTR('0'||\\\"tanjoGengo\\\",-1,1)\", \"SUBSTR('00'||\\\"tanjoYear\\\",-2,2)\", \"SUBSTR('00'||\\\"tanjoMonth\\\",-2,2)\", \"SUBSTR('00'||\\\"tanjoDay\\\",-2,2)\")\n else\n # for mysql、postgres\n tanjoDtCondition = str_sql_concat(\"LPAD(CAST(\\\"tanjoGengo\\\" AS char), 1, '0') \", \" LPAD(CAST(\\\"tanjoYear\\\" AS char), 2, '0') \", \" LPAD(CAST(\\\"tanjoMonth\\\" AS char), 2, '0') \", \" LPAD(CAST(\\\"tanjoDay\\\" AS char), 2, '0')\")\n end\n\n if adapter == \"mysql2\" then\n # for mysql\n strIntegerType = \"SIGNED\"\n else\n # for sqlite、postgres\n strIntegerType = \"INTEGER\"\n end\n\n if params[:kokyaku][:tanjoGengoFrom].present? || params[:kokyaku][:tanjoYearFrom].present? || params[:kokyaku][:tanjoMonthFrom].present? || params[:kokyaku][:tanjoDayFrom].present?\n tanjoGengoFrom = \"0\"\n tanjoYearFrom = \"00\"\n tanjoMonthFrom = \"00\"\n tanjoDayFrom = \"00\"\n\n if params[:kokyaku][:tanjoGengoFrom].present?\n tanjoGengoFrom = format(\"%01d\", params[:kokyaku][:tanjoGengoFrom])\n end\n if params[:kokyaku][:tanjoYearFrom].present?\n tanjoYearFrom = format(\"%02d\", params[:kokyaku][:tanjoYearFrom])\n end\n if params[:kokyaku][:tanjoMonthFrom].present?\n tanjoMonthFrom = format(\"%02d\", params[:kokyaku][:tanjoMonthFrom])\n end\n if params[:kokyaku][:tanjoDayFrom].present?\n tanjoDayFrom = format(\"%02d\", params[:kokyaku][:tanjoDayFrom])\n end\n\n tanjoDtFrom = (tanjoGengoFrom.to_s + tanjoYearFrom.to_s + tanjoMonthFrom.to_s + tanjoDayFrom.to_s).to_i\n conditions = conditions.where(\"CAST(\" + tanjoDtCondition + \" AS \" + strIntegerType + \" ) >= ?\", tanjoDtFrom)\n end\n\n if params[:kokyaku][:tanjoGengoTo].present? || params[:kokyaku][:tanjoYearTo].present? || params[:kokyaku][:tanjoMonthTo].present? || params[:kokyaku][:tanjoDayTo].present?\n tanjoGengoTo = \"9\"\n tanjoYearTo = \"99\"\n tanjoMonthTo = \"99\"\n tanjoDayTo = \"99\"\n\n if params[:kokyaku][:tanjoGengoTo].present?\n tanjoGengoTo = format(\"%01d\", params[:kokyaku][:tanjoGengoTo])\n end\n if params[:kokyaku][:tanjoYearTo].present?\n tanjoYearTo = format(\"%02d\", params[:kokyaku][:tanjoYearTo])\n end\n if params[:kokyaku][:tanjoMonthTo].present?\n tanjoMonthTo = format(\"%02d\", params[:kokyaku][:tanjoMonthTo])\n end\n if params[:kokyaku][:tanjoDayTo].present?\n tanjoDayTo = format(\"%02d\", params[:kokyaku][:tanjoDayTo])\n end\n\n tanjoDtTo = (tanjoGengoTo.to_s + tanjoYearTo.to_s + tanjoMonthTo.to_s + tanjoDayTo.to_s).to_i\n conditions = conditions.where(\"CAST(\" + tanjoDtCondition + \" AS \" + strIntegerType + \" ) <= ?\", tanjoDtTo)\n end\n\n conditions = conditions.where(\"\\\"postNo\\\" LIKE ?\", params[:kokyaku][:postNo] + \"%\") if params[:kokyaku][:postNo] != \"\"\n conditions = conditions.where(\"address1 LIKE ?\", \"%\" + params[:kokyaku][:address1] + \"%\") if params[:kokyaku][:address1] != \"\"\n conditions = conditions.where(\"address2 LIKE ?\", \"%\" + params[:kokyaku][:address2] + \"%\") if params[:kokyaku][:address2] != \"\"\n conditions = conditions.where(\"tel1 LIKE ?\", params[:kokyaku][:tel1] + \"%\") if params[:kokyaku][:tel1] != \"\"\n conditions = conditions.where(\"tel2 LIKE ?\", params[:kokyaku][:tel2] + \"%\") if params[:kokyaku][:tel2] != \"\"\n conditions = conditions.where(\"fax LIKE ?\", params[:kokyaku][:fax] + \"%\") if params[:kokyaku][:fax] != \"\"\n conditions = conditions.where(str_sql_concat(\"COALESCE(sb1.\\\"shobyoNm\\\", '') \", \"COALESCE(sb2.\\\"shobyoNm\\\", '') \", \"COALESCE(sb3.\\\"shobyoNm\\\", '') \") + \" LIKE ?\", \"%\" + params[:kokyaku][:shobyoNm] + \"%\") if params[:kokyaku][:shobyoNm] != \"\"\n conditions = conditions.where(\"\\\"gakkoNm\\\" LIKE ?\", \"%\" + params[:kokyaku][:gakkoNm] + \"%\") if params[:kokyaku][:gakkoNm] != \"\"\n #logger.debug(conditions)\n\n\n # 検索に必要なSQL文を取得する\n select, joins = get_select_stmt\n\n records = conditions.count(:joins => joins)\n\n limit = params[:rows].to_i\n page = params[:page].to_i\n if records > 0\n n = records.quo(limit)\n total_pages = n.ceil\n else\n total_pages = 0\n end\n start = limit * page - limit;\n @kokyakus = conditions.find(\n :all,\n :select => select,\n :joins => joins,\n # :joins => \"LEFT OUTER JOIN shobyos shobyo2 ON shobyos.shobyoCd = kokyakus.shobyouCd2\",\n # :joins => \"LEFT OUTER JOIN shobyos shobyo3 ON shobyos.shobyoCd = kokyakus.shobyouCd3\",\n # :include => [:shobyo],\n :offset => start,\n :limit => limit,\n :order => \"\\\"kokyakuId\\\" DESC\")\n\n @responce = {\n total: total_pages.to_s,\n page: params[:page],\n records: records.to_s,\n rows: @kokyakus\n }\n #logger.debug(@responce)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @responce }\n end\n end", "def search_params\n params.require(:search).permit(:searchType, :fullTextSearch, :flightNumber, :pic, :sic, :airfield, :revenue, :memberName, :dateStart, :dateEnd, :prepMin, :prepMax, :caterMin, :caterMax, :depMin, :depMax, :flightMin, :flightMax, :arrMin, :arrMax, :maintMin, :maintMax, :catering, :maint, :createdBy, :hasComments, :save_search, :save_search_name, :overallmin, :overallmax, :user_id)\n end", "def search_params\n params.require(:search).permit(:ris)\n end", "def search\n\n end", "def search_params\n params.permit(:search_string)\n end", "def search\n\n #conditions = Byoin.where(\"\\\"byoinCd\\\" NOT ?\", nil)\n conditions = Byoin.where(\"1 = ?\", 1)\n conditions = conditions.where(\"\\\"byoinNm\\\" LIKE ?\", params[:byoinNm] + \"%\") if params[:byoinNm] != \"\"\n logger.debug(conditions)\n\n records = conditions.count\n limit = params[:rows].to_i\n page = params[:page].to_i\n if records > 0\n n = records.quo(limit)\n total_pages = n.ceil\n else\n total_pages = 0\n end\n start = limit * page - limit;\n @byoins = conditions.find(\n :all, \n :offset => start, \n :limit => limit,\n :order => \"\\\"byoinCd\\\" DESC\")\n\n @responce = {\n total: total_pages.to_s,\n page: params[:page],\n records: records.to_s,\n rows: @byoins\n }\n #logger.debug(@responce)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @responce }\n end\n end", "def filtering_params(params)\n unless params[:search]\n return []\n end\n # {\"price_from\"=>\"50.000\",\n # \"price_till\"=>\"\",\n # \"property_type\"=>\"propertyTypes.bungalow\",\n # \"locality\"=>\"#<OpenStruct value=\\\"provincias.cadiz\\\", label=\\\"Cádiz\\\">\",\n # \"zone\"=>\"#<OpenStruct value=\\\"provincias.ciudadReal\\\", label=\\\"Ciudad Real\\\">\",\n # \"count_bedrooms\"=>\"6\",\n # \"count_bathrooms\"=>\"\",\n # \"property_state\"=>\"propertyStates.brandNew\"}\n params[:search].slice(:in_locality, :in_zone, :for_sale_price_from, :for_sale_price_till, :for_rent_price_from,\n :for_rent_price_till, :property_type, :property_state, :count_bathrooms, :count_bedrooms)\n end", "def search_params\n params[:name]\n end", "def usersearch_params\n\n params.permit( :q , :usersearch => [:keyword , :country_id , :language_id , :category_id , :news_source_id])\n\n end", "def search\n\n \tparser = AddressParser.new\n \taddress_hash = {}\n \t\n \tunless params[:location].nil?\n\t \tif is_number?(params[:location]) then \n\t \t\t# zip code\n\t\t \taddress_hash = parser.zip.parse(params[:location])\n\t\telsif params[:location].length == 2 then\n\t\t\t# state only\n\t\t\tparams[:location] = params[:location].strip.upcase\n\t\t\taddress_hash = parser.state.parse(params[:location])\n\t\telse\n\t\t\t# city, state, zip\n\t\t\tbegin address_hash = parser.csz.parse(params[:location])\n\t\t\t\trescue\n\t\t\t\t# city\n\t\t\t \taddress_hash = parser.city1.parse(params[:location]) unless params[:location].nil?\n\t\t\tend \n\t\tend\n\tend\n\t\n\t# new hash for search keys\n\tskeys = {}\n\t\n\tif address_hash[:city] then \n\t\tskeys[\"CIT\"] = /#{address_hash[:city]}/i\n\t\tparams['city'] = address_hash[:city]\n\tend\n\tif address_hash[:city1] then \n\t\tskeys[\"CIT\"] = /#{address_hash[:city1]}/i\n\t\tparams['city'] = address_hash[:city]\n\tend\n \tif address_hash[:state] then \n \t\tskeys[\"STATE\"] = \"#{address_hash[:state]}\" \n \t\tparams['state'] = address_hash[:state]\n \tend\n \tif address_hash[:zip] then \n \t\tskeys[\"ZP\"] = address_hash[:zip].to_s \n \t\t#params['zip'] = CGI::escape(address_hash[:zip])\n \t\tparams['zip'] = address_hash[:zip]\n \tend\n \t\n \tif(params.has_key?('bathrooms') ) then\n \t\tskeys[\"BTH\"] = \"#{params[:bathrooms].to_f}\"\n \tend\n \t\n \tif(params.has_key?('bedrooms') ) then\n \t\tskeys[\"BR\"] = params[:bedrooms].to_i\n \tend\n\n \tif(params.has_key?('minyear') ) then\n \t\tskeys[\"BLT-MIN\"] = params[:minyear].to_i\n \tend\n \t\n \tif(params.has_key?('maxyear') ) then\n \t\tskeys[\"BLT-MAX\"] = params[:minyear].to_i\n \tend\n \t\n \tif(params.has_key?('price_low') ) then\n \t\tskeys[\"LP-MIN\"] = params[:price_low].to_i\n \tend\n \t\n \tif(params.has_key?('price_high') ) then\n \t\tskeys[\"LP-MAX\"] = params[:price_high].to_i\n \tend\n \t\n \tif(params.has_key?('zipcode') ) then\n \t\tskeys[\"ZP\"] = params[:zipcode]\n \tend\n\t\n\tquery = {}\n\n\tskeys.each do |key, value|\n\t\tcase key\n\t\t\t when 'BTH'\n\t\t\t query.merge!({ key.to_sym.gte => value.to_f })\n\t\t\t when 'BR'\n\t\t\t query.merge!({ key.to_sym.gte => value.to_i })\n\t\t\t when 'BLT-MIN'\n\t\t\t \tif value.to_i > 0 then\n\t\t\t \t\tquery.merge!({ 'BLT'.to_sym.gte => value.to_i })\n\t\t\t \tend\n\t\t\t when 'BLT-MAX'\n\t\t\t \tif value.to_i > 0 then\n\t\t\t \t\tquery.merge!({ 'BLT'.to_sym.lte => value.to_i })\n\t\t\t \tend\n\t\t\t when 'LP-MIN'\n\t\t\t \tif value.to_i > 0 then\n\t\t\t \t\tquery.merge!({ 'LP'.to_sym.gte => value.to_i })\n\t\t\t \tend\n\t\t\t when 'LP-MAX'\n\t\t\t \tif value.to_i > 0 then\n\t\t\t \t\tquery.merge!({ 'LP'.to_sym.lte => value.to_i })\n\t\t\t \tend\n\t\t\t when 'ZP'\n\t\t\t \tif value != \"\" then\n\t\t\t \t\tquery.merge!({ 'ZP'.to_sym => value })\n\t\t\t \tend\n\t\t\t when 'CIT', 'STATE', 'ZP'\n\t\t\t query.merge!({ key.to_sym => value })\n\t\t end\n\tend\n\t\t\n \t@listings = Listing.where( query ).paginate({\n\t\t :sort => :LP.desc,\n\t\t :per_page => 10, \n\t\t :page => params[:page],\n\t\t})\n \t\n \trender :template => 'find/search', :collection => @listings\n \t \t\n end", "def search_params\n params.fetch(:search, {})\n end", "def search_params\n params.fetch(:search, {})\n end", "def search_params\n params.fetch(:search, {})\n end", "def parse_search; end", "def params(search_string)\n { text: search_string, city: CITY, country: COUNTRY, key: KEY }.compact\n end", "def search_params\n params.require(:q).permit(:the_bat_gteq, :the_bat_lteq, :the_bat_gt, {:team_id_in => []}, :player_h_name_or_name_cont)\n end", "def searched_params\n params.require(:searched).permit(:name, :contact_id, :number, :email, :cell, :fulladdress, :contact_ids,{:user_ids => []})\n end", "def searcher_params\n params.require(:searcher).permit(:name, :surname, :skills, :phone, :experience, :user_id, :profession, :wtime, :country_id, :city_id, :payment, :value)\n end", "def search_params\n params.require(:search).permit(:search_string)\n end", "def search_params\n params.require(:search).permit(:num_weeks, :num_seats, :start_date, :student_name, :course_id, :user_id, :city_id, :country_id)\n end", "def search \n\n end", "def search_params\n params.fetch(:genius, {})\n end", "def search_params\n params.require(:search).permit(:country_iso_code, :semester_of_matriculation, :semester_of_deregistration, :federal_state_name, :grade, :number_of_semester, :number_of_semesters, :discipline_name, :graduation_status, :gender, :nationality, :location_name, :minimum_age, :maximum_age, :search_category, :search_series, :department_number, :teaching_unit_name, :kind_of_degree)\n end", "def deal_search_word_params\n params[:deal_search_word]\n end", "def search_params\n params.require(:search).permit(:genre, :business_id, :band_name)\n end", "def index\n @cetak_bloks = params[:q] ? CetakBlok.search_for(params[:q]) : CetakBlok.all \n end", "def search params = {}\n send_and_receive search_path(params), params.reverse_merge(qt: blacklight_config.qt)\n end", "def search\n\n end", "def search_params\n params.permit(:zip_code)\n end", "def search_params\n params.require(:search).permit(:search_id, :search_phrase)\n end", "def search_params\n params.require(:search_string)\n end", "def set_search_params \n # TODO: figure out how to do this without having to change params to symbols\n symbolic_params = {}\n search_params.each_pair do |key, value|\n symbolic_params.merge!(key.to_sym => value)\n end\n @search_params = symbolic_params\n end", "def index \n #忽略\n @q = Addtype.search(params[:q]) \n if params[:q].nil? \n @addtypes=Addtype.order(:id).page(params[:page]).per(10)\n else \n if params[:q][\"name_cont\"].lstrip.rstrip==\"\"\n @addtypes=Addtype.order(:id).page(params[:page]).per(10)\n else\n search = params[:q][\"search_cont\"]\n @addtypes = Addtype.where( \" #{search} like ?\", \"%#{params[:q][\"name_cont\"]}%\" ).page(params[:page]).per(10)\n end\n end \n end", "def index\n @myjobs = Myjob.where(\"company like (?) OR experince =? Location like (?) OR technology like (?)\",\"#{params[:search_com]}\",\"#{params[:search_exp]}\",\"%#{params[:search_location]}%\",\"%#{params[:search_tec]}%\")\n conditions = []\n if params[:search_com].present?\n conditions[0] = \"company like (?)\"\n conditions << \"#{params[:search_com]}\"\n end\n if params[:search_exp].present?\n if conditions[0].present?\n conditions[0] += \" OR company like (?)\"\n else\n conditions[0] += \"company like (?)\"\n end\n conditions << \"#{params[:search_com]}\"\n end\n\n @myjobs = Myjob.where(conditions)\n # binding.pry\n end", "def search(criteria = {})\r\n \r\n end", "def isearch_params\n params[:isearch]\n end", "def search\n end", "def filtering_params(params)\n params.slice(:term)\n end", "def setup_search_options\n @original_search_parameter = params[:search]\n params[:search] ||= \"\"\n params.keys.each do |param|\n if param =~ /(\\w+)_id$/\n unless params[param].blank?\n query = \"#{$1} = #{params[param]}\"\n params[:search] += query unless params[:search].include? query\n end\n end\n end\n end", "def search_naver_params\n params.require(:search_naver).permit(:issue_title, :issue_rank, :issue_today_total, :issue_date, :issue_time)\n end", "def search; end", "def search_params\n params[:unit_price] = params[:unit_price].delete('.').to_i if params[:unit_price]\n params.permit(:id, :name, :description, :unit_price, :merchant_id, :created_at, :updated_at)\n # end\n\n end", "def search(query); end", "def index\n if !params[:bank_j_search].blank? && !params[:bank_cd_search].blank?\n @bankms = Bankm.where([\"bank_j LIKE ? AND bank_cd LIKE ?\",\n \"%#{params[:bank_j_search]}%\",\n \"%#{params[:bank_cd_search]}%\"]).sort_by{|bankm| (bankm.bank_cd)}\n elsif !params[:bank_j_search].blank?\n @bankms = Bankm.search(params[:bank_j_search]).sort_by{|bankm| (bankm.bank_cd)}\n elsif !params[:bank_cd_search].blank?\n @bankms = Bankm.search(params[:bank_cd_search]).sort_by{|bankm| (bankm.bank_cd)}\n elsif !params[:bank_j_select].blank?\n @bankms = Bankm.where(\"bank_j LIKE ?\", \"#{params[:bank_j_select]}\").sort_by{|bankm| (bankm.bank_cd)}\n elsif !params[:bank_all].blank?\n @bankms = Bankm.order(\"bank_cd\")\n else\n redirect_to root_path\n end\n end", "def search(params)\n raise NotImplementedError\n end", "def search_params\n params.require(:search).permit(:term)\n end", "def search_params\n params.require(:search).permit(:term)\n end", "def search_params\n params.require(:search).permit(:term)\n end", "def search_params\n params.require(:search).permit(:query)\n end", "def search\r\nend", "def search\n end", "def search\n end", "def search\n end", "def search\n end", "def search\n end", "def search\n end", "def search\n end", "def search\n end", "def search\n end", "def search\n end", "def search_monitor_params\n params.permit(:title, :tenderTitle, :valueFrom, :valueTo, :buyer, :sort_by, :sort_direction, :submission_date_to, :submission_date_from, codeList:[], countryList:[], statusList:[], keywordList:[], status: [])\n end", "def search\n Api.search_all_apis params[:postcode]\n end", "def search_process\n @search_text =params[:q].to_s\n all =params[:all].to_s\n exact =params[:exact].to_s\n any =params[:any].to_s\n none =params[:none].to_s\n advanced_query=\"\"\n\n if all != \"\"\n all =all.split(' ')\n all_like =all.map { |x| \"keyword like \" + \"'%\" + x + \"%'\" }\n all_like =all_like.join(' and ')\n advanced_query=all_like\n end\n\n if exact != \"\" && all != \"\"\n exact =\"'%\"+exact+\"%'\"\n advanced_query = advanced_query + \" and keyword like \" + exact\n end\n\n if exact != \"\" && all == \"\"\n exact =\"'%\"+exact+\"%'\"\n advanced_query = \"keyword like \" + exact\n end\n\n if any != \"\" and (all != \"\" or exact != \"\")\n any =any.split(' ')\n any_like =any.map { |x| \"keyword like \" + \"'%\" + x + \"%'\" }\n any_like =any_like.join(' or ')\n advanced_query = advanced_query + \" and (\" + any_like + \")\"\n end\n\n if any != \"\" and all == \"\" and exact == \"\"\n any =any.split(' ')\n any_like =any.map { |x| \"keyword like \" + \"'%\" + x + \"%'\" }\n any_like =any_like.join(' or ')\n advanced_query = \"(\" + any_like + \")\"\n end\n\n if none != \"\" and (all != \"\" or exact != \"\" or any != \"\")\n none =none.split(' ')\n none_not_like=none.map { |x| \"keyword not like \" + \"'%\" + x + \"%'\" }\n\n none_not_like=none_not_like.join(' and ')\n\n advanced_query=advanced_query + \" and \" + none_not_like\n\n end\n\n if none != \"\" and all == \"\" and exact == \"\" and any == \"\"\n none =none.split(' ')\n none_not_like=none.map { |x| \"keyword not like \" + \"'%\" + x + \"%'\" }\n\n none_not_like=none_not_like.join(' and ')\n\n advanced_query= none_not_like\n end\n\n\n advanced_query = \"SELECT Model_ID FROM keyword_symbol_tables WHERE \"+advanced_query\n\n parameter_search_text=@search_text.split.join(\" \")\n keyword_array =parameter_search_text.split(' ')\n keyword_count =keyword_array.size\n\n connection = ActiveRecord::Base.connection\n\n if all != \"\" or exact != \"\" or any != \"\" or none != \"\"\n @resultset = connection.execute(\"#{advanced_query}\");\n else\n @resultset = connection.execute(\"call keyword_search('#{parameter_search_text}',#{keyword_count})\");\n end\n\n ActiveRecord::Base.clear_active_connections!\n\n @resultset_strings = @resultset.map { |result| result.to_s.gsub(/[^0-9A-Za-z]/, '') }\n\n @model_ids =Array.new\n @model_names =Array.new\n @model_types =Array.new\n\n @resultset_strings.each do |result|\n\n substring=result[0..4]\n\n if substring == \"NMLCL\"\n cell=Cell.find_by_Cell_ID(result.to_s)\n name=cell.Cell_Name\n type=\"Cell\"\n end\n\n if substring == \"NMLCH\"\n channel=Channel.find_by_Channel_ID(result.to_s)\n name =channel.Channel_Name\n type =\"Channel\"\n end\n\n\n if substring == \"NMLNT\"\n network=Network.find_by_Network_ID(result.to_s)\n name =network.Network_Name\n type =\"Network\"\n end\n\n if substring == \"NMLSY\"\n synapse=Synapse.find_by_Synapse_ID(result.to_s)\n name =synapse.Synapse_Name\n type =\"Synapse\"\n end\n\n @model_ids.push(result)\n @model_names.push(name)\n @model_types.push(type)\n\n end\n\n if @model_ids.count != 0\n\n render :partial => 'keyword_results_list',\n :locals => {\n :model_ids => @model_ids,\n :model_names => @model_names,\n :model_types => @model_types\n }\n\n else\n\n render :partial => 'no_results'\n\n end\n\n end", "def filtering_params(params)\n\t params.slice(:search, :title, :content)\n\tend", "def search\n if params.has_key?('search')\n @orders = Order.search(params['search'])\n else\n @orders = []\n end\n params['search'] ||= {}\n @s_rate_name = params.has_key?('search') ? params[:search][:rate_name] : \"\"\n @s_rate_time_of_day = params.has_key?('search') ? params[:search][:times_of_day] : \"\"\n @s_rate_how_far = params.has_key?('search') ? params[:search][:rate_how_far] : \"\"\n @s_auto_model = params.has_key?('search') ? params[:search][:auto_model] : \"\"\n @s_auto_class = params.has_key?('search') ? params[:search][:auto_class] : \"\"\n @s_auto_color = params.has_key?('search') ? params[:search][:auto_color] : \"\"\n end", "def fetch_custom_search_params; end", "def search_term\n params[:searchTerm]\n end", "def set_search\n @query = params.require(:search).permit(:query)\n end", "def hp_search_params\n params.require(:hp_search).permit(:name, :zipcode)\n end", "def search_params\r\n\t params.permit(:title_keywords, :employer_keywords, :job_type_select)\r\n\tend", "def set_search_query\n if (params[:search] === nil)\n @search_query = nil\n elsif (params[:search].match(/^[-+]?([1-8]?\\d(\\.\\d+)?|90(\\.0+)?),\\s*[-+]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$/))\n @search_query = params[:search].delete(' ').split(',')\n else (params[:search])\n @search_query = params[:search]\n end\n end", "def perform_search\n terms = { vehicle_year: 2006,\n vehicle_brand: \"Yamaha\",\n vehicle_model: \"Yz250\",\n vehicle_submodel: \"-- Base\",\n category_name: \"Complete Wheel Assembly\" }\n perform_search(terms)\n end", "def search(word)\n \n end", "def search \n @cars = Car.all \n if params[:search].blank? \n redirect_to(cars_path, alert: \"Empty field!\") \n else \n @parameter = params[:search].downcase \n @results = Car.all.where(\"lower(make) LIKE :search\", search: @make) \n end \n end", "def search\n search_params = \"%#{params[:search_params]}%\"\n @code_programs = CodeProgram.where(\"city like ? OR keywords like ? OR mission_description like? OR organization_name like?\", search_params, search_params, search_params, search_params)\n puts \"yo\"\n p @code_programs\n render :index\n end", "def index\n #@owners = Owner.all\n if params[:q]\n @owners = Owner.where(\"nombre LIKE '%\"+params[:q]+\"%' or clave LIKE '%\"+params[:q]+\"%'\")\n end\n\n end", "def articles_search_params\n params.fetch(:q, {}).permit(:title_or_body_cont, :tags_name_in)\n end", "def fees_student_structure_search_logic # student search fees structure\n query = params[:query]\n unless query.length < 3\n @students_result = Student.find(:all,\n :conditions => [\"first_name LIKE ? OR middle_name LIKE ? OR last_name LIKE ?\n OR admission_no = ? OR (concat(first_name, \\\" \\\", last_name) LIKE ? ) \",\n \"#{query}%\", \"#{query}%\", \"#{query}%\", \"#{query}\", \"#{query}\"],\n :order => \"batch_id asc,first_name asc\") unless query == ''\n else\n @students_result = Student.find(:all,\n :conditions => [\"admission_no = ? \", query],\n :order => \"batch_id asc,first_name asc\") unless query == ''\n end\n render :layout => false\n end", "def index\n\n if params[:search]\n @rhs = Rh.search(params[:search]) \n else \n @rhs = Rh.order(\"Nome\")\n end\n\n end", "def search_params\n params.require(:search).permit(:latest_time, {days: []}, :earliest_time, {status_list: []}, :term_id, :required_ccodes, {search_courses_attributes: [:department_id, :course_num]})\n end", "def add_search_to_params(search)\n if !search.empty?\n pars = search[1..-1].split('&')\n\n pars.each do |par|\n pair = par.split('=')\n @params[ pair[0] ] = pair[1] if pair.length == 2\n end\n end\n end", "def search_params\n params.require(:search).permit(:ticker, :year, :filing )\n end", "def query_param\n return unless search_query\n \"search=#{search_query}&phrase=true\"\n end", "def search_param\n params[:loans][:search] if params[:loans] || nil\n end", "def search_process\r\nsearch_text=params[:q].to_s\r\nall=params[:all].to_s\r\nexact=params[:exact].to_s\r\nany=params[:any].to_s\r\nnone=params[:none].to_s\r\nadvanced_query=\"\"\r\n\r\nif all != \"\"\r\nall=all.split(' ')\r\nall_like=all.map {|x| \"keyword like \" + \"'%\" + x + \"%'\" }\r\nall_like=all_like.join(' and ')\r\nadvanced_query=all_like\r\nend\r\n\r\nif exact != \"\" && all != \"\"\r\nexact=\"'%\"+exact+\"%'\"\r\nadvanced_query = advanced_query + \" and keyword like \" + exact\r\nend\r\n\r\nif exact != \"\" && all == \"\"\r\nexact=\"'%\"+exact+\"%'\"\r\nadvanced_query = \"keyword like \" + exact\r\nend\r\n\r\nif any != \"\" and ( all != \"\" or exact != \"\" )\r\nany=any.split(' ')\r\nany_like=any.map { |x| \"keyword like \" + \"'%\" + x + \"%'\" }\r\nany_like=any_like.join(' or ')\r\nadvanced_query = advanced_query + \" and (\" + any_like + \")\"\r\nend\r\n\r\nif any != \"\" and all == \"\" and exact == \"\"\r\nany=any.split(' ')\r\nany_like=any.map { |x| \"keyword like \" + \"'%\" + x + \"%'\" }\r\nany_like=any_like.join(' or ')\r\nadvanced_query = \"(\" + any_like + \")\"\r\nend\r\n\r\nif none != \"\" and (all != \"\" or exact != \"\" or any != \"\")\r\nnone=none.split(' ')\r\nnone_not_like=none.map { |x| \"keyword not like \" + \"'%\" + x + \"%'\" }\r\n\r\nnone_not_like=none_not_like.join(' and ')\r\n\r\nadvanced_query=advanced_query + \" and \" + none_not_like\r\n\r\nend\r\n\r\nif none != \"\" and all == \"\" and exact == \"\" and any == \"\"\r\nnone=none.split(' ')\r\nnone_not_like=none.map { |x| \"keyword not like \" + \"'%\" + x + \"%'\" }\r\n\r\nnone_not_like=none_not_like.join(' and ')\r\n\r\nadvanced_query= none_not_like\r\nend\r\n\r\n\r\n\r\n\r\n\r\nadvanced_query = \"SELECT Model_ID FROM keyword_symbol_tables WHERE \"+advanced_query\r\nputs \"\\n\\n***********************************\\n\\n\"+advanced_query+\"\\n\\n**********************\\n\\n\"\r\n\r\nparameter_search_text=search_text.split.join(\" \")\r\n keyword_array=parameter_search_text.split(' ')\r\n keyword_count=keyword_array.size\r\n\r\nconnection = ActiveRecord::Base.connection();\r\nif all != \"\" or exact != \"\" or any != \"\" or none != \"\"\r\n@resultset = connection.execute(\"#{advanced_query}\");\r\nelse\r\n@resultset = connection.execute(\"call keyword_search('#{parameter_search_text}',#{keyword_count})\");\r\nend\r\nActiveRecord::Base.clear_active_connections!()\r\n\r\[email protected] do |res|\r\nputs res\r\nend\r\n@resultset_strings = @resultset.map { |result| result.to_s.gsub(/[^0-9A-Za-z]/, '')}\r\n@model_ids=Array.new\r\n@model_names=Array.new\r\n@model_types=Array.new\r\n@resultset_strings.each do |result|\r\nsubstring=result[0..4]\r\nputs\"\\n\\n************\"+substring\r\nif substring == \"NMLCL\"\r\ncell=Cell.find_by_Cell_ID(result.to_s)\r\nname=cell.Cell_Name\r\ntype=\"Cell\"\r\nend\r\n\r\nif substring == \"NMLCH\"\r\nchannel=Channel.find_by_Channel_ID(result.to_s)\r\nname=channel.Channel_Name\r\ntype=\"Channel\"\r\nend\r\n\r\n\r\nif substring == \"NMLNT\"\r\nnetwork=Network.find_by_Network_ID(result.to_s)\r\nname=network.Network_Name\r\ntype=\"Network\"\r\nend\r\n\r\n#if substring == \"NMLSY\"\r\n#name=Synapse.find_by_Synapse_ID(result.to_s)\r\n#type=\"Syanpse\"\r\n#end\r\n\r\n@model_ids.push(result)\r\n@model_names.push(name)\r\n@model_types.push(type)\r\nputs \"result-\"+result+\"name-\"+name.to_s\r\nend\r\n\r\nif @model_ids.count != 0\r\nrender :partial => 'keyword_results_list',:locals => {:model_ids => @model_ids,:model_names => @model_names,:model_types => @model_types}\r\nelse\r\nrender :partial => 'no_results'\r\nend\r\n\r\n\r\n end", "def search_process\r\nsearch_text=params[:q].to_s\r\nall=params[:all].to_s\r\nexact=params[:exact].to_s\r\nany=params[:any].to_s\r\nnone=params[:none].to_s\r\nadvanced_query=\"\"\r\n\r\nif all != \"\"\r\nall=all.split(' ')\r\nall_like=all.map {|x| \"keyword like \" + \"'%\" + x + \"%'\" }\r\nall_like=all_like.join(' and ')\r\nadvanced_query=all_like\r\nend\r\n\r\nif exact != \"\" && all != \"\"\r\nexact=\"'%\"+exact+\"%'\"\r\nadvanced_query = advanced_query + \" and keyword like \" + exact\r\nend\r\n\r\nif exact != \"\" && all == \"\"\r\nexact=\"'%\"+exact+\"%'\"\r\nadvanced_query = \"keyword like \" + exact\r\nend\r\n\r\nif any != \"\" and ( all != \"\" or exact != \"\" )\r\nany=any.split(' ')\r\nany_like=any.map { |x| \"keyword like \" + \"'%\" + x + \"%'\" }\r\nany_like=any_like.join(' or ')\r\nadvanced_query = advanced_query + \" and (\" + any_like + \")\"\r\nend\r\n\r\nif any != \"\" and all == \"\" and exact == \"\"\r\nany=any.split(' ')\r\nany_like=any.map { |x| \"keyword like \" + \"'%\" + x + \"%'\" }\r\nany_like=any_like.join(' or ')\r\nadvanced_query = \"(\" + any_like + \")\"\r\nend\r\n\r\nif none != \"\" and (all != \"\" or exact != \"\" or any != \"\")\r\nnone=none.split(' ')\r\nnone_not_like=none.map { |x| \"keyword not like \" + \"'%\" + x + \"%'\" }\r\n\r\nnone_not_like=none_not_like.join(' and ')\r\n\r\nadvanced_query=advanced_query + \" and \" + none_not_like\r\n\r\nend\r\n\r\nif none != \"\" and all == \"\" and exact == \"\" and any == \"\"\r\nnone=none.split(' ')\r\nnone_not_like=none.map { |x| \"keyword not like \" + \"'%\" + x + \"%'\" }\r\n\r\nnone_not_like=none_not_like.join(' and ')\r\n\r\nadvanced_query= none_not_like\r\nend\r\n\r\n\r\n\r\n\r\n\r\nadvanced_query = \"SELECT Model_ID FROM keyword_symbol_tables WHERE \"+advanced_query\r\nputs \"\\n\\n***********************************\\n\\n\"+advanced_query+\"\\n\\n**********************\\n\\n\"\r\n\r\nparameter_search_text=search_text.split.join(\" \")\r\n keyword_array=parameter_search_text.split(' ')\r\n keyword_count=keyword_array.size\r\n\r\nconnection = ActiveRecord::Base.connection();\r\nif all != \"\" or exact != \"\" or any != \"\" or none != \"\"\r\n@resultset = connection.execute(\"#{advanced_query}\");\r\nelse\r\n@resultset = connection.execute(\"call keyword_search('#{parameter_search_text}',#{keyword_count})\");\r\nend\r\nActiveRecord::Base.clear_active_connections!()\r\n\r\[email protected] do |res|\r\nputs res\r\nend\r\n@resultset_strings = @resultset.map { |result| result.to_s.gsub(/[^0-9A-Za-z]/, '')}\r\n@model_ids=Array.new\r\n@model_names=Array.new\r\n@model_types=Array.new\r\n@resultset_strings.each do |result|\r\nsubstring=result[0..4]\r\nputs\"\\n\\n************\"+substring\r\nif substring == \"NMLCL\"\r\ncell=Cell.find_by_Cell_ID(result.to_s)\r\nname=cell.Cell_Name\r\ntype=\"Cell\"\r\nend\r\n\r\nif substring == \"NMLCH\"\r\nchannel=Channel.find_by_Channel_ID(result.to_s)\r\nname=channel.Channel_Name\r\ntype=\"Channel\"\r\nend\r\n\r\n\r\nif substring == \"NMLNT\"\r\nnetwork=Network.find_by_Network_ID(result.to_s)\r\nname=network.Network_Name\r\ntype=\"Network\"\r\nend\r\n\r\n#if substring == \"NMLSY\"\r\n#name=Synapse.find_by_Synapse_ID(result.to_s)\r\n#type=\"Syanpse\"\r\n#end\r\n\r\n@model_ids.push(result)\r\n@model_names.push(name)\r\n@model_types.push(type)\r\nputs \"result-\"+result+\"name-\"+name.to_s\r\nend\r\n\r\nif @model_ids.count != 0\r\nrender :partial => 'keyword_results_list',:locals => {:model_ids => @model_ids,:model_names => @model_names,:model_types => @model_types}\r\nelse\r\nrender :partial => 'no_results'\r\nend\r\n\r\n\r\n end", "def parse_search(q)\n # TODO continue\n end", "def search\n @filters = params.slice(:university)\n\n if params[:search].present?\n \n @tutor_profiles = TutorProfile.where(\"teaching_subject LIKE :teaching_subject or degree_subject LIKE :teaching_subject\", {teaching_subject: \"%#{params[:search]}%\"}).where(@filters)\n else\n @tutor_profiles = TutorProfile.where(@filters).paginate(:page => params[:page], :per_page => 10)\n end\n end", "def params\n split_query_string.flat_map do |keyword|\n [\"%#{keyword}%\".mb_chars.downcase.to_s] * query_for_one_keyword.count('?')\n end\n end", "def search\n @users = User.all.order(:user_id)\n if params[:search][:annual].present?\n @users = @users.where(\"annual like '%\" + params[:search][:annual] + \"%' \").order(:user_id) \n end\n if params[:search][:name].present?\n @users = @users.where(\"name like '%\" + params[:search][:name] + \"%' \").order(:user_id)\n end\n @name = params[:search][:name]\n @annual = params[:search][:annual]\n render :index\n end" ]
[ "0.7197508", "0.7154766", "0.7128347", "0.66906446", "0.6652284", "0.6590838", "0.6584998", "0.65368295", "0.6529783", "0.64963645", "0.64767474", "0.6461192", "0.64584184", "0.64435095", "0.6378344", "0.63622606", "0.6336679", "0.63351846", "0.63103896", "0.630408", "0.63023233", "0.63023233", "0.63023233", "0.6277171", "0.6269341", "0.625579", "0.6253829", "0.6250303", "0.62113404", "0.6203135", "0.6184457", "0.61755365", "0.6167888", "0.61527485", "0.6152283", "0.6149952", "0.6145393", "0.6120651", "0.609769", "0.6095979", "0.6086098", "0.60853803", "0.60770667", "0.60769385", "0.60768795", "0.6067373", "0.60523987", "0.6051091", "0.60503435", "0.6046476", "0.6045611", "0.6038443", "0.60253984", "0.6024292", "0.60211957", "0.6020734", "0.6020734", "0.6020734", "0.6014818", "0.6014355", "0.6013828", "0.6013828", "0.6013828", "0.6013828", "0.6013828", "0.6013828", "0.6013828", "0.6013828", "0.6013828", "0.6013828", "0.6008877", "0.6008188", "0.6000194", "0.59958917", "0.59934837", "0.599268", "0.5990954", "0.5986333", "0.5982669", "0.5976687", "0.59719783", "0.5969199", "0.5958096", "0.59486526", "0.59345764", "0.5932298", "0.5930209", "0.59261465", "0.59247917", "0.5922266", "0.591025", "0.5909318", "0.5908226", "0.5905733", "0.5893086", "0.5893086", "0.5892084", "0.5873522", "0.5868135", "0.58677596" ]
0.67663586
3
Strips down a string to only regex [09]. Bang method. Replaces in place.
def strip_numbers!(phone_number) phone_number.replace(phone_number.scan(NUMBERS_ONLY_REGEX).join) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mask_with_gsub s\n s.gsub(/\\d[\\d\\s-]+\\d/) do |broad_match|\n masked = nil\n match_from = 0\n mi = 0\n broad_digits = broad_match.scan(/\\d/).map{|v| v.to_i }\n next broad_match if broad_digits.length < 14\n while true\n found, match_start, match_len = iterate(broad_digits, mi)\n if found\n mi += match_start + 1\n n = match_from\n masked = broad_match[0..-1] if not masked\n while match_start > 0\n match_start -= 1 if DIGITS[broad_match[n]]\n n += 1\n end\n match_from = -1\n while match_len > 0\n if DIGITS[broad_match[n]]\n match_from = n + 1 if match_from < 0\n masked[n] = 'X'\n match_len -= 1\n end\n n += 1\n end\n else\n break\n end\n end\n masked || broad_match\n end\n end", "def strip_nongsm_chars!(replacement = \"\")\n # Should this be a patch to String?\n\n # keeping them here in canse I need them\n # basic alpha\n # '@','£','$','¥','è','é','ù','ì','ò','Ç',\"\\n\",'Ø','ø',\"\\r\",'Å','å',\n # 'Δ','_','Φ','Γ','Λ','Ω','Π','Ψ','Σ','Θ','Ξ','Æ','æ','ß','É',' ',\n # '!','\"','#','¤','%','&','\\'','(',')','*','+',',','-','.','/','0',\n # '1','2','3','4','5','6','7','8','9',':',';','<','=','>','?','¡',\n # 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',\n # 'Q','R','S','T','U','V','W','X','Y','Z','Ä','Ö','Ñ','Ü','§','¿',\n # 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p',\n # 'q','r','s','t','u','v','w','x','y','z','ä','ö','ñ','ü','à'\n #\n # extended alpha\n # '|','^','€','{','}','[',']','~','\\\\'\n\n allowed = '@£$¥èéùìòÇ'+\"\\n\"+'Øø'+\"\\r\"+'ÅåΔ_ΦΓΛΩΠΨΣΘΞÆæßÉ'+' '+Regexp.escape('!\"#¤%&\\'()*+,-.')+'\\/'+Regexp.escape('0123456789:;<=>?¡ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüà|^€{}[]~\\\\')\n\n map = {\n /á|â|ã/ => \"a\",\n /ê|ẽ|ë/ => \"e\",\n /í|î|ï/ => \"i\",\n /ó|ô|õ/ => \"o\",\n /ú|ů|û/ => \"u\",\n /ç/ => \"Ç\"\n }\n\n map.each do |key, value|\n self.gsub!(key, value)\n end\n\n pattern = Regexp.new( \"[^\"+allowed+\"]\" )\n self.gsub!(pattern,\"\")\n end", "def wash! string\n string.gsub! /\\e\\[[0-9]+m/, \"\"\n end", "def apply!(str)\n str.gsub! regexp, ''\n end", "def clean! number\n number.gsub!(@@basic_cleaning_pattern, EMPTY_STRING) || number\n end", "def fake_bin(s)\n # Insert you code here...\n # Got it wrong so many times...\n # s.gsub(/[0-4][5-9]/, '0''1')\n # s.gsub(/[0-4 5-9]/, 0-4 => '0' 5-9 =>'1')\n # s.gsub(/[0-4 5-9]/, 0-4 => 0 5-9 =>1)\n # s.gsub(/[0-4 5-9]/, 0-4 => 0 5-9 =>1)\n # s.gsub(/[0-4 5-9]/, '0' '1')\n # s = s.gsub(/0-4]/, '0') && s.gsub(/5-9]/, '1')\n\n# Finally!\n s.gsub(/[01234]/, '0').gsub(/[56789]/, '1') #append a second gsub onto the s\nend", "def string_cleaner(str)\n\tnew_string = \"\"\n\tstr.each_char do |char|\n\t\tif char.match(/[0-9]/)\n\t\t\tnew_string << char\n\t\tend\n\tend\n\treturn new_string\n\t\nend", "def clean\n @number.gsub!(/\\D/,\"\")\n\n if has_11_digits? and starts_with_1?\n @number = @number[1..-1] \n elsif invalid_length?\n @number = nil\n end\n end", "def filter_string(string)\n string.delete(\"^0-9\").to_i\nend", "def strip(str); end", "def remove_octals(string)\n command = string\n string.gsub(/^0\\d|\\D0\\d/) do |oct|\n dec = oct.sub(\"0\", \"\")\n command = command.sub(oct, dec)\n end\n command\nend", "def strip str\n str.gsub /(\\x0F|\\x1D|\\02|\\03([0-9]{1,2}(,[0-9]{1,2})?)?)/, \"\"\n end", "def crunch_regex(text)\n # (?=) is a positive look ahead. Looks ahead and matches but does not include\n # it in the result.\n text.gsub(/(.)(?=\\1)/,\"\")\nend", "def cleanup_noregexp str\n str2 = ''\n str.chars.each do |chr|\n case chr.downcase\n when ('a'..'z')\n str2 << chr\n else\n str2 << ' '\n end\n end\n str2.squeeze(' ')\nend", "def filter_string(string)\n string.gsub(/[^0-9a-fA-F]/, '').upcase\n end", "def clean_bibnum(num)\n /\\d{7}/.match(num).to_s\n end", "def crunch_regex(string)\n string.gsub(/(.)\\1+/, '\\1')\nend", "def regex_strip(string)\n return string.gsub(/[^\\p{L}\\p{N}]/u, \" \")\n end", "def purify\n #self.gsub!(\"\\u0000\", '').delete!('\\\\0').squeeze!('\\\\').tr!('\\\\','/').delete_at(length-1)\n self.gsub!(/(?:\\u0000)(.+)/,'')\n self.gsub!('\\\\n', 10.chr)\n self\n end", "def hide_serial(string)\n\treturn string.gsub(/\\d{6}-\\d{2}-(\\d{4})/, 'XXXXXX-XX-\\1')\nend", "def strip_non_digits\n country_code.gsub!(/[^\\d]/, '') unless country_code.blank?\n local_number.gsub!(/[^\\d]/, '') unless local_number.blank?\n extension.gsub!(/[^\\d]/, '') unless extension.blank?\n end", "def sanitise(str)\n str.gsub(/[^a-zA-Z0-1]+/, \"_\")[0, 20]\n end", "def extra_clean_str(str)\n str = str.downcase.gsub @extra_ua_filter, ''\n str = str.gsub(/[^\\x20-\\x7F]/, '')\n str.strip\n end", "def clean(input)\n input.to_s.gsub(/[^0-9]/, '')\n end", "def strip_unprintable_characters(s)\n s.tr(8204.chr, \"\")\nend", "def remove!(pattern)\n gsub! pattern, ''\n end", "def hide_last_four(string)\n string.gsub!(/-\\d{4}/,\"-****\")\nend", "def cleaned s, whitelist=%w[ref]\r\n\ts ||= ''\r\n\twhitelist << '---' # prevent empty (?!) in regexes\r\n\t\r\n\ts.gsub(/'{2,3}/, '').gsub(/<(?!#{whitelist.join '|'})(?!\\/(?:#{whitelist.join '|'}))[^>]+>/, '')\r\nend", "def map_and_remove_nine(input, digits_to_number, number_to_digits)\n digits = input.find { |digits| digits.size == 6 && number_to_digits[4].subset?(digits) }\n map_and_remove(9, digits, digits_to_number, number_to_digits, input)\nend", "def fix_issn str\n return str if str.length == 9 && str[4] == '-'\n str.sub!(\"(ISSN)\", \"\")\n str.strip!\n return str.insert(4, '-') if str.length == 8\n return str\n end", "def filter_chars\n # In Python we apply a string to a regexp,\n # but in Ruby we apply a regexp to a string, that's why we don't have to append\n $stack.push($stack.pop().gsub(Regexp.compile('[\\W_]+'), ' ').downcase)\nend", "def replace_encoded(str, regex)\n str.scan(regex).each do |x|\n str = str.sub(\"#{x[0]}[#{x[1]}]\", x[1] * x[0].to_i)\n end\n str\nend", "def crunch(string)\n clean_string = ''\n string.each_char do |letter|\n clean_string << letter unless letter == clean_string[-1]\n end\n clean_string\nend", "def cleanup_new(string)\n string.tr(' -/:-@[-`{-~',' ')\nend", "def hide_all_sins(string)\n match = /\\s(\\d{3}-\\d{3}-\\d{3})(\\D|$)/.match(string)\n unless match == nil\n string.gsub! /\\d{3}-\\d{3}/, \"XXX-XXX\"\n end\n string\n end", "def without_numbered_capture_groups\n # unescaped ('s can exist in character classes, and character class-style code can exist inside comments.\n # this removes the comments, then finds the character classes: escapes the ('s inside the character classes then \n # reverse the string so that varaible-length lookaheads can be used instead of fixed length lookbehinds\n as_string_reverse = self.to_s.reverse\n no_preceding_escape = /(?=(?:(?:\\\\\\\\)*)(?:[^\\\\]|\\z))/\n reverse_character_class_match = /(\\]#{no_preceding_escape}[\\s\\S]*?\\[#{no_preceding_escape})/\n reverse_comment_match = /(\\)#{no_preceding_escape}[^\\)]*#\\?\\(#{no_preceding_escape})/\n reverse_start_paraenthese_match = /\\(#{no_preceding_escape}/\n reverse_capture_group_start_paraenthese_match = /(?<!\\?)\\(#{no_preceding_escape}/\n \n reversed_but_fixed = as_string_reverse.gsub(/#{reverse_character_class_match}|#{reverse_comment_match}/) do |match_data, more_data|\n # if found a comment, just remove it\n if (match_data.size > 3) and match_data[-3..-1] == '#?('\n ''\n # if found a character class, then escape any ()'s that are in it\n else\n match_data.gsub reverse_start_paraenthese_match, '\\\\('.reverse\n end\n end\n # make all capture groups non-capture groups\n reversed_but_fixed.gsub! reverse_capture_group_start_paraenthese_match, '(?:'.reverse\n return Regexp.new(reversed_but_fixed.reverse)\n end", "def cleanup(str)\nstr.gsub!(/[^0-9A-Za-z]/, \" \").squeeze(\" \")\n\nend", "def pattern2regex(pattern); end", "def only_characters_and_numbers\n self.tr('^A-Za-z0-9', '')\n end", "def clean_numbers(original)\n number = original.delete(\"()-. \")\n\n if number.length == 10\n\n elsif number.length == 11\n if number.start_with?(\"1\")\n number = number[1..-1]\n else\n number = INVALID_PHONE\n end\n\n else\n number = INVALID_PHONE\n end\n return number\n end", "def without_garbage\n reg = Regexp.new /[#{String.characters.join}]+/\n self.scan(reg).join(\"\").gsub(\"\\n\", \" \").gsub(\"|\", \" \").gsub(\"-\", \" \")\n end", "def remove_brackets\n orig_date_str.delete('[]') if orig_date_str.match(BRACKETS_BETWEEN_DIGITS_REXEXP)\n end", "def clean(phone_number)\n phone_number.gsub(/\\D/, \"\")\nend", "def scrubString($string, $length = 0) \n $matches = array();\n \n self::clip($string, $length);\n\n preg_match_all(\"/([A-Z]|[0-9]|[a-z]|\\_|\\-|\\s|\\.|\\!|\\?|\\@)+/\", $string, $matches);\n return implode($matches[0]);\n end", "def hide_digits(string)\n string.gsub!(/\\d/,\"-\")\nend", "def crunch(string)\n string.gsub(/([a-z0-9])\\1+/, \"\\\\1\")\nend", "def repair(text); end", "def pig_it(text)\n text.gsub(/\\b([a-z0-9]?)([a-z0-9]+)\\b/i, '\\2\\1ay')\n # text.gsub(/\\b([a-z0-9])([a-z0-9]+)*\\b/i, '\\2\\1ay')\n # text.gsub(/([a-z0-9])([a-z0-9]+)*/i, '\\2\\1ay')\nend", "def clean_for_comp( address = '' )\n address.upcase.gsub /[^0-9A-Z]/, ''\nend", "def filter_string(s)\n s.delete('abcdefghijklmnopqrstuvwxyz ').to_i\nend", "def remove_crap(myString)\n\treturn myString.gsub(/\\v/, '/')\nend", "def cutinfo(string)\n inf=/\\024/=~string1\n inf=inf+2\n trans=string1[inf..-1]\nend", "def clean_phone_numbers(homephone)\r\n\thomephone = homephone.to_s.gsub(\"(\"|\")\"|\"-\"|\".\"|\" \"|\"/\",\"\")\r\n\tif homephone.length < 10 || homephone.length > 11\r\n\t\thomephone = \"0000000000\"\r\n\telsif homephone[0] != 1\r\n\t\thomephone = \"0000000000\"\r\n\telsif homephone.length = 11\r\n\t\thomephone.rjust(10)[1..10]\r\n\telse\r\n\t\thomephone\r\n\tend\r\nend", "def remove_char(s)\n s.slice(1..-2)\nend", "def remove_first(input, string); end", "def strip!() end", "def weirdFixString(str)\n idx = str.index(\"\\000\\000\")\n idx.nil? ? str : str[0..idx]\n end", "def remove_char(s)\n #s = string\n s = s[1..-2]\n return s\nend", "def sanitize_refpt2 refpt2\n refpt2.strip.gsub(/0[\\d]{1}\\./, \"\").gsub(\".\", \"\")\n end", "def undent\n gsub /^.{#{slice(/^ +/).length}}/, ''\n end", "def replace_binary(str)\n str.gsub(/[01]+/) { |bin| bin.to_i(2).to_s(10) }\n end", "def replace_binary(str)\n str.gsub(/[01]+/) { |bin| bin.to_i(2).to_s(10) }\n end", "def remove(pattern)\n gsub pattern, ''\n end", "def cleanup(string)\n string.gsub(/[^A-Za-z0-9]/, \" \").squeeze\nend", "def remove_char(s)\n s[1..-2]\nend", "def cleanup(string)\n new_string = ''\n\n string.chars.each_with_index do |char, index|\n char_alphanumeric = char.match(/[a-z0-9]/)\n if index == 0\n prior_char_alphanumeric = true\n else\n prior_char_alphanumeric = string[index - 1].match(/[a-z0-9]/)\n end\n\n\n # p [char_alphanumeric, prior_char_alphanumeric]\n\n if char_alphanumeric\n new_string << char\n elsif prior_char_alphanumeric\n new_string << ' '\n end\n end\n\n new_string\nend", "def hide_last_four(string)\n\treturn string.gsub(/(\\d{2})-(\\d{2})-\\d{4}/, '\\1-\\2-****')\nend", "def number_wang(number)\n if number.to_s.length > 11\n puts 'number is bad. just bad'\n end\n if number.to_s =~ /^\\d{10}$/\n puts 'number is good'\n end\n if number.to_s =~ /^1\\d{10}$/\n puts \"number is 11 digits long but that's ok\"\n new_number = number.to_s\n new_number.slice!(0)\n number = new_number.to_i\n puts number\n end\n if number.to_s =~ /^^1\\d{10}$/\n puts \"number is 11 digits long and it's not ok\"\n end\nend", "def promote_traditional!\n self.gsub!(TRADITIONAL_REGEX, $1) if self =~ TRADITIONAL_REGEX\n end", "def clean(string)\n string.gsub(/[',.!?:;]['s]/, \"\")\n\nend", "def prune_string(string)\n string.chomp.slice(0..pruned_width)\n end", "def hide_all_ssns(string)\n string.gsub /\\d{3}-\\d{2}-/, \"XXX-XX-\"\nend", "def cleanup(isbn_)\n isbn_.gsub(/[^0-9xX]/,'').gsub(/x/,'X') unless isbn_.nil? or isbn_.scan(/([xX])/).length > 1\n end", "def clean_phone_number(phone)\n clean_phone = phone.to_s.scan(/\\d/).join(\"\")\n if clean_phone.length == 11\n if clean_phone[0] == \"1\"\n clean_phone.sub(/[1]/, \"\")\n else\n \"0000000000\"\n end\n elsif clean_phone.length != 10\n \"0000000000\"\n else\n clean_phone\n end\nend", "def clean_zipcode(zipcode)\n zipcode.to_s.rjust(5, '0').slice(0, 5)\nend", "def _t(str)\n _f(str).gsub(/([0]+\\z)/, '')\n end", "def cleanup(string)\n\ts = string.gsub(/[^0-9a-z]/i, ' ')\n\ts.squeeze(\" \")\nend", "def unnormalize(string, doctype = T.unsafe(nil), filter = T.unsafe(nil), illegal = T.unsafe(nil)); end", "def remove_postcode(name)\n return name.gsub(/\\d{3,}/, '').strip\n end", "def map_and_remove_eight(input, digits_to_number, number_to_digits)\n digits = input.find { |digits| digits.size == 7 }\n map_and_remove(8, digits, digits_to_number, number_to_digits, input)\nend", "def hide_all_ssns(string)\n\tssn = /\\d{3}[^\\d]?\\d{2}[^\\d]/\n\n\tif ssn =~ string\n\t\tstring = string.gsub!(ssn,\"XXX-XX-\")\n\t\treturn string\n\telse\n\t\t#puts \"not match\"\n\t\treturn string\n\tend\nend", "def rsstrip!(str)\n str = Regexp.quote(str)\n self.gsub!(/(#{str})+$/, '')\n end", "def clean_string(string)\n return string.downcase.gsub(/[^a-z0-9]/, '')\nend", "def reserved_nets_regex; end", "def sanitize(string)\n string.gsub(ANSI_MATCHER, \"\")\n end", "def cleanup(string)\n string.gsub!(/^--- $/, \"\")\n end", "def clean_numbers(number)\n number.gsub /\\D/, ''\n end", "def remove_formatting(str)\n Name.clean_incoming_string(str.gsub(/[_*]/, ''))\n end", "def add_zero_to_1_to_9(str)\n str.sub(/(?<=\\D)\\d\\D?$/, '0\\0' )\n end", "def test_illegal_char\n\t\tassert_equal(\"877195GILL869x\", glosub(\"877195G IL--L869x\"))\n\tend", "def sanitize( str )\n return str.scan(/\\d|\\(|\\)|\\*|\\+|\\-|\\/|\\.|\\%/).to_s\n end", "def clean_record_name(record_name)\n if record_name.start_with?(\"\\\\052\")\n record_name.gsub! \"\\\\052\", \"*\"\n logger.debug(\"Replacing octal \\\\052 for * in: #{record_name}\")\n end\n\n record_name\n end", "def map_and_remove_zero(input, digits_to_number, number_to_digits)\n digits = input.find { |digits| digits.size == 6 && number_to_digits[7].subset?(digits) }\n map_and_remove(0, digits, digits_to_number, number_to_digits, input)\nend", "def cleanup(string)\n string.gsub(/[\\W\\d]/, ' ').gsub(/\\s+/, ' ')\nend", "def regex_replace_first(input, regex, replacement = NOTHING)\n input.to_s.sub(Regexp.new(regex), replacement.to_s)\n end", "def fix_useless_brackets(str)\n reg1 = /\\((-?\\d+([*\\/]\\d)*|-?x([*\\/]\\d)*)\\)/\n cur_el = str[reg1,1]\n while (!cur_el.nil?)\n str.sub!(reg1,cur_el)\n cur_el = str[reg1,1]\n end\n str\n end", "def scrapejunk(string)\n string.gsub('<script>', '').delete(';').gsub('</script>', '').gsub('window.scheduleMinebindings = ShiftNote.Bind(window.scheduleMinemodel)', '').gsub('window.scheduleMinemodel = ', '')\n end", "def maskify(cc)\n puts cc.gsub(/.(?=....)/, '#')\nend", "def stripped(string)\n string.chars.gsub(/[^\\x20-\\x7E]/, '')\n end", "def sanitized\n @original && @original.gsub(/[^0-9]+/, '') || ''\n end", "def strip_bbcode(string); end" ]
[ "0.62181395", "0.5844184", "0.5745595", "0.5744678", "0.56577194", "0.5624906", "0.559134", "0.55723304", "0.55545276", "0.55288786", "0.5519982", "0.5513152", "0.55078536", "0.5496632", "0.54901123", "0.54710954", "0.53745997", "0.5371303", "0.53585887", "0.5350577", "0.53397113", "0.52723354", "0.527079", "0.5255632", "0.525324", "0.524984", "0.52486175", "0.5244364", "0.5244326", "0.5237314", "0.522227", "0.5215192", "0.5191415", "0.5187093", "0.5168412", "0.5167003", "0.5165367", "0.5153536", "0.51526546", "0.51509184", "0.5144895", "0.514292", "0.51372916", "0.5129591", "0.51291275", "0.5118467", "0.511826", "0.5114046", "0.51001644", "0.5095394", "0.50901634", "0.5088189", "0.50805265", "0.50797194", "0.50789523", "0.5070896", "0.50648886", "0.5060471", "0.5059317", "0.5051228", "0.5049989", "0.5049989", "0.5047412", "0.5039402", "0.50383204", "0.5034021", "0.50301963", "0.5027053", "0.50246334", "0.5019641", "0.50140625", "0.50082", "0.500693", "0.4998441", "0.4993648", "0.49931613", "0.49915326", "0.4985656", "0.4985603", "0.49834567", "0.49796468", "0.4979147", "0.49768838", "0.49734384", "0.49720976", "0.49698696", "0.49682623", "0.49675697", "0.49607512", "0.49583912", "0.495649", "0.49561992", "0.4955236", "0.4940993", "0.4938866", "0.49377388", "0.493587", "0.49338064", "0.4931973", "0.49295735", "0.4929446" ]
0.0
-1
Removes the leading 1 for all phones if it's exactly 11 digits loing. Bang method. Replaces in place.
def remove_leading_one!(phone_number) return phone_number if phone_number.first != '1' # country code is applicable here return phone_number if phone_number.size != MIN_PHONE_DIGITS + 1 phone_number.replace(phone_number.slice(1..-1)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def phone_number_cleaner!\n @phone_number = @phone_number.gsub(/[^0-9]/, '')\n if @phone_number.to_s.size == 11 && @phone_number[0] == '1'\n @phone_number[0] = ''\n end\n end", "def phone_number_cleaner!\n @phone_number = @phone_number.gsub(/[^0-9]/, '')\n if @phone_number.to_s.size == 11 && @phone_number[0] == '1'\n @phone_number[0] = ''\n end\n end", "def clean_phone_number(phone)\n clean_phone = phone.to_s.scan(/\\d/).join(\"\")\n if clean_phone.length == 11\n if clean_phone[0] == \"1\"\n clean_phone.sub(/[1]/, \"\")\n else\n \"0000000000\"\n end\n elsif clean_phone.length != 10\n \"0000000000\"\n else\n clean_phone\n end\nend", "def fix_phone_number\n number = phone_number.to_s.gsub(/\\D/, '')\n number = number[1..-1] if number.starts_with?('1')\n self.phone_number = number\n end", "def clean\n @number.gsub!(/\\D/,\"\")\n\n if has_11_digits? and starts_with_1?\n @number = @number[1..-1] \n elsif invalid_length?\n @number = nil\n end\n end", "def normalize_phone_number\n if phone.present?\n phone.gsub!(/^1/, \"\")\n phone.gsub!(/[()-.]/,\"\")\n end\n end", "def normalize_phone_number\n \t# if phone.present && phone[0] == 1\n \t# \tphone[0].remove\n \t# if phone.present?\n \t# \tphone.gsub!(/^1/, \"\")\n \t# \tphone.gsub!(/[()-.],\"\")\n \t# end\n end", "def clean_phone_numbers(homephone)\r\n\thomephone = homephone.to_s.gsub(\"(\"|\")\"|\"-\"|\".\"|\" \"|\"/\",\"\")\r\n\tif homephone.length < 10 || homephone.length > 11\r\n\t\thomephone = \"0000000000\"\r\n\telsif homephone[0] != 1\r\n\t\thomephone = \"0000000000\"\r\n\telsif homephone.length = 11\r\n\t\thomephone.rjust(10)[1..10]\r\n\telse\r\n\t\thomephone\r\n\tend\r\nend", "def clean_phone_number(homephone)\r\n phone_number = homephone.gsub(/\\(|-|\\s+|\\)|\\.|\\+/, '')\r\n if phone_number.length < 10\r\n phone_number.rjust(20, '0')[0..9]\r\n elsif phone_number.length == 10\r\n phone_number\r\n elsif phone_number.length == 11 && phone_number[0].to_i == 1\r\n phone_number[1..10]\r\n elsif phone_number.length == 11 && phone_number[0].to_i != 1\r\n phone_number.rjust(10, '0')[0..9]\r\n elsif phone_number.length > 11\r\n phone_number.rjust(10,'0')[0..9]\r\n end \r\nend", "def normalize_phone_number(number)\n return number if number[0..1].eql?('+1')\n\n '+1' + number\n end", "def clean_numbers(original)\n number = original.delete(\"()-. \")\n\n if number.length == 10\n\n elsif number.length == 11\n if number.start_with?(\"1\")\n number = number[1..-1]\n else\n number = INVALID_PHONE\n end\n\n else\n number = INVALID_PHONE\n end\n return number\n end", "def reformat_phone\n phone = self.phone.to_s \n phone.gsub!(/[^0-9]/,\"\") \n self.phone = phone \n end", "def normalize_phone\n phone.gsub!(/[^0-9]/, '') if phone\n end", "def reformat_phone\n phone = self.phone.to_s # change to string in case input as all numbers \n phone.gsub!(/[^0-9]/,\"\") # strip all non-digits\n self.phone = phone # reset self.phone to new string\n end", "def reformat_phone\n phone = self.phone.to_s # change to string in case input as all numbers \n phone.gsub!(/[^0-9]/,\"\") # strip all non-digits\n self.phone = phone # reset self.phone to new string\n end", "def reformat_phone\n phone = self.phone.to_s # change to string in case input as all numbers \n phone.gsub!(/[^0-9]/,\"\") # strip all non-digits\n self.phone = phone # reset self.phone to new string\n end", "def reformat_phone\n phone = self.phone.to_s # change to string in case input as all numbers \n phone.gsub!(/[^0-9]/,\"\") # strip all non-digits\n self.phone = phone # reset self.phone to new string\n end", "def reformat_phone\n phone = self.phone.to_s # change to string in case input as all numbers \n phone.gsub!(/[^0-9]/,\"\") # strip all non-digits\n self.phone = phone # reset self.phone to new string\n end", "def reformat_phone\n phone = self.phone.to_s # change to string in case input as all numbers \n phone.gsub!(/[^0-9]/,\"\") # strip all non-digits\n self.phone = phone # reset self.phone to new string\n end", "def reformat_phone\n phone = self.phone.to_s # change to string in case input as all numbers \n phone.gsub!(/[^0-9]/,\"\") # strip all non-digits\n self.phone = phone # reset self.phone to new string\n end", "def reformat_phone\n phone = self.phone.to_s # change to string in case input as all numbers \n phone.gsub!(/[^0-9]/,\"\") # strip all non-digits\n self.phone = phone # reset self.phone to new string\n end", "def reformat_phone\n phone = self.phone.to_s # change to string in case input as all numbers \n phone.gsub!(/[^0-9]/,\"\") # strip all non-digits\n self.phone = phone # reset self.phone to new string\n end", "def reformat_phone\n phone = self.phone.to_s # change to string in case input as all numbers \n phone.gsub!(/[^0-9]/,\"\") # strip all non-digits\n self.phone = phone # reset self.phone to new string\n end", "def reformat_phone\n phone = self.phone.to_s # change to string in case input as all numbers \n phone.gsub!(/[^0-9]/,\"\") # strip all non-digits\n self.phone = phone # reset self.phone to new string\n end", "def reformat_phone\r\n phone = self.phone.to_s # change to string in case input as all numbers \r\n phone.gsub!(/[^0-9]/,\"\") # strip all non-digits\r\n self.phone = phone # reset self.phone to new string\r\n end", "def reformat_phone\n phone = self.phone.to_s # change to string in case input as all numbers\n phone.gsub!(/[^0-9]/,\"\") # strip all non-digits\n self.phone = phone # reset self.phone to new string\n end", "def reformat_phone\n phone = self.cell_phone.to_s # change to string in case input as all numbers\n phone.gsub!(/[^0-9]/,\"\") # strip all non-digits\n self.cell_phone = phone # reset self.phone to new string\n end", "def reformat_home_phone\n home_phone = self.home_phone.to_s # change to string in case input as all numbers \n home_phone.gsub!(/[^0-9]/,\"\") # strip all non-digits\n self.home_phone = home_phone # reset self.phone to new string\n end", "def clean_phone_numbers(phone)\n\treturn phone if phone.length == 10\n\treturn phone[1,phone.length] if phone.length == 11 && phone[0] == \"1\"\n\tnil\nend", "def strip_phone_number\n (self.phone.nil? ? \" \" : self.phone.gsub!(/[^0-9]/, \"\"))\n end", "def clean_phone_number(phone_number)\n\tdigits = phone_number.to_s.gsub(/\\W|^1/, '')\n\tif digits.length == 10\n\t\tputs \"#{digits} is a good number\"\n\telse\n\t\tputs \"Bad number\"\n\tend\nend", "def reformat_cell_phone\n cell_phone = self.cell_phone.to_s # change to string in case input as all numbers \n cell_phone.gsub!(/[^0-9]/,\"\") # strip all non-digits\n self.cell_phone = cell_phone # reset self.phone to new string\n end", "def reformat_cell_phone\n cell_phone = self.cell_phone.to_s # change to string in case input as all numbers \n cell_phone.gsub!(/[^0-9]/,\"\") # strip all non-digits\n self.cell_phone = cell_phone # reset self.phone to new string\n end", "def normalize_phone_number\n # stretch\n end", "def normalize_phone_number\n # stretch\n end", "def normalize_phone_number\n # stretch\n end", "def normalize_phone_number\n # stretch\n end", "def international_phone\n phone.gsub(/[^\\d]/, \"\").prepend('+1')\n end", "def clean(phone_number)\n phone_number.gsub(/\\D/, \"\")\nend", "def normalize_phone_number(phone,country_code=1)\n if phone\n phone = phone.to_s.sub(/^011/,\"+\")\n \"+\" + (phone.start_with?(\"+\") ? '' : country_code.to_s) + phone.gsub(/\\D/,'') \n end\n end", "def standardized_phone_number\n @standardized_phone_number ||= phone_number.gsub(/\\D/, '')\n end", "def convert_phone_nbr_scrp\n if self[0] == \"0\"\n self[0].gsub(\"0\", \"+33\") + self[1..-1]\n end\n end", "def update_phone_number\n begin\n self.phone_number = self.primary_phone.tr('^0-9', '')\n rescue\n return nil\n end\n end", "def text_phone\n ret = cell_phone.gsub(/[^0-9]*/, \"\")\n \n if ret[0] != 1\n ret = \"1\" + ret\n end\n\n \"+#{ret}\"\n end", "def strip_numbers!(phone_number)\n phone_number.replace(phone_number.scan(NUMBERS_ONLY_REGEX).join)\n end", "def stripped_case_number\n return unless case_number\n case_number.to_s.gsub(/^000/,'')\n end", "def convert9\r\n @phone.split(\"\").each do |c|\r\n c = 9 if @num_list.include?(c)\r\n @formatted_phone += c.to_s\r\n end\r\n end", "def phone_without_area_code(phone_number)\n number_to_phone(phone_number.sub(/^0121/, ''))\n end", "def format_phone_numbers\n\t\tif self.phone_number_1.present? and self.phone_number_1.length > 9\n\t\t\told = self.phone_number_1.gsub(/\\D/,'')\n\t\t\tnew_phone = \"(#{old[0..2]}) #{old[3..5]}-#{old[6..9]}\"\n\t\t\tself.phone_number_1 = new_phone\n\t\tend\n\t\tif self.phone_number_2.present? and self.phone_number_2.length > 9\n\t\t\told = self.phone_number_2.gsub(/\\D/,'')\n\t\t\tnew_phone = \"(#{old[0..2]}) #{old[3..5]}-#{old[6..9]}\"\n\t\t\tself.phone_number_2 = new_phone\n\t\tend\n\tend", "def update_mobile_phone_number\n begin\n self.mobile_phone_number = self.mobile_phone.tr('^0-9', '')\n rescue\n return nil\n end\n end", "def format_phone\n if @phone != nil\n @phone = self.phone.scan(/[0-9]/).join\n self.phone = @phone.length == 7 ? ActionController::Base.helpers.number_to_phone(@phone) : \n @phone.length == 10 ? ActionController::Base.helpers.number_to_phone(@phone, area_code: true) :\n @phone\n\n end\n end", "def standardize_number(num)\n #for testing we will accept +1 numbers\n if num.grep(/^\\+*\\s*1/).length == 1\n num = num.gsub(/^\\+/,'')\n num = \"+\" + num\n else\n num = num.gsub(/^\\+/,'')\n num = num.gsub(/^\\s*88/,'')\n num = \"+88\" + num\n end\n num.gsub(/\\s+/,'')\nend", "def format_phone_number\n if self.phone_number.nil?\n return false\n end\n raw_numbers = self.phone_number.gsub(/\\D/, '')\n if raw_numbers.size != 10\n return false\n end\n self.phone_number = \"(#{raw_numbers[0..2]}) #{raw_numbers[3..5]}-#{raw_numbers[6..9]}\"\n end", "def number_wang(number)\n if number.to_s.length > 11\n puts 'number is bad. just bad'\n end\n if number.to_s =~ /^\\d{10}$/\n puts 'number is good'\n end\n if number.to_s =~ /^1\\d{10}$/\n puts \"number is 11 digits long but that's ok\"\n new_number = number.to_s\n new_number.slice!(0)\n number = new_number.to_i\n puts number\n end\n if number.to_s =~ /^^1\\d{10}$/\n puts \"number is 11 digits long and it's not ok\"\n end\nend", "def normalize_phone_number(num)\n number = Phoner::Phone.parse(num)\n # Formats as (area code) XXX XXXX\n number = number.format('(%a) %f %l')\nend", "def phone_number_strip\n striped = self.number.gsub(/[^0-9,]|,[0-9]*$/,'')\n self.number = striped\n end", "def phone_number=(value)\n super(value.blank? ? nil : value.gsub(/[^\\d]/, ''))\n end", "def clear_personal_information\n number = String.new(self.cc_number)\n # How many spaces to replace with X's\n spaces_to_pad = number.length-4\n # Cut string\n new_number = number[spaces_to_pad,number.length]\n # Pad with X's\n new_number = new_number.rjust(spaces_to_pad, 'X')\n self.cc_number = new_number\n self.save\n # Return number in case we need it\n return new_number\n end", "def formatted_number(phone_number)\n number = phone_number.dup\n number = number.gsub(' ', '').gsub('.', '').gsub('-', '').gsub('/', '')\n\n PhoneNumber::MOBILE_PREFIXES.each do |prefix|\n if number.starts_with? prefix\n number = number.gsub prefix, \"0033#{prefix.last}\" #.last because last is 6 or 7\n break\n end\n end\n number\n end", "def normalize\n \tif !self.phone.nil?\n\t \tself.phone = self.phone.gsub(/[^a-z0-9]/i, '')\n\t \tif self.phone.length == 8\n\t \t\tarea_code = \"\"\n\t \t\tfirst = self.phone[0]\n\t \t\tif first == \"6\"\n\t \t\t\tarea_code = \"619\"\n\t \t\telsif first == \"8\"\n\t \t\t\tarea_code = \"858\"\n\t \t\tend\n\t \t\tself.phone = area_code + self.phone[1..-1]\n\t \t elsif self.phone.length == 10\n\t \t\t # do nothing for now\n\t \t else\n\t \t\t # do nothing for now\n\t \t end\n\t end\n end", "def clean_numbers(number)\n number.gsub /\\D/, ''\n end", "def clean number\n clean! number && number.dup\n end", "def normalize_phone_number\n return \"\" unless phone_number\n phone_number.gsub(/\\s|-|\\.|\\(|\\)/, \"\").downcase\n end", "def reformat_phone_ssn\n phone = self.phone.to_s # change to string in case input as all numbers \n phone.gsub!(/[^0-9]/,\"\") # strip all non-digits\n self.phone = phone # reset self.phone to new string\n ssn = self.ssn.to_s # change to string in case input as all numbers \n ssn.gsub!(/[^0-9]/,\"\") # strip all non-digits\n self.ssn = ssn # reset ssn.phone to new string\n end", "def normalize_phone(phone_number)\n raise \"Phone number is blank\" if phone_number.blank?\n raise \"Invalid phone number\" unless /^\\+?1?\\d{10}$/ =~ phone_number.strip\n SmsToolkit::PhoneNumbers.normalize(phone_number)\n end", "def phone_home=(new_number)\n write_attribute :phone_home, new_number.try(:gsub, /[^0-9]/i, '')\n end", "def leading_zero_on_single_digits(number)\n number > 9 ? number : \"0#{number}\"\n end", "def extra_characters\n if @number[0] == '+' && @number[1..2] != '00' && @number[1] != ' '\n @number = remove_plus\n elsif @number[0..1] == '00'\n @number = remove_double_zero\n end\n end", "def to_mobile( str )\n\tstr.dup\nend", "def format_phone_number\n\t\tunless self.phone_number.nil?\n\t\t\told = self.phone_number.gsub(/\\D/,'')\n\t\t\tnew_phone = \"(#{old[0..2]}) #{old[3..5]}-#{old[6..9]}\"\n\t\t\tself.phone_number = new_phone\n\t\tend\n\tend", "def clean_zipcode(zipcode)\r\n\tzipcode.to_s.rjust(5, \"0\")[0..4]\r\nend", "def format_phone_for_storage(phone)\n return phone if phone.blank?\n phone.gsub(/[^0-9]/, '')\n end", "def format_phone_for_storage(phone)\n return phone if phone.blank?\n phone.gsub(/[^0-9]/, '')\n end", "def clean! number\n number.gsub!(@@basic_cleaning_pattern, EMPTY_STRING) || number\n end", "def tel_num_sanitize\n self.tel_num = tel_num.gsub(/[^0-9]/, \"\")\n end", "def phone_mobile=(new_number)\n write_attribute :phone_mobile, new_number.try(:gsub, /[^0-9]/i, '')\n end", "def strip_non_phone_number_characters(number)\n number.gsub(/[-\\s\\.]/, '')\n end", "def cleanZipcode(zipcode)\n\tzipcode.to_s.rjust(5,\"0\")[0..4]\nend", "def clean_zipcode(zipcode)\n zipcode.to_s.rjust(5, '0').slice(0, 5)\nend", "def clean_zipcode(zipcode)\n zipcode.to_s.rjust(5, '0')[0..4]\nend", "def clean_zipcode(zipcode)\r\n\tzipcode.to_s.rjust(5,\"0\")[0..4]\r\nend", "def remove_spaces\n @number = @number.gsub(/\\s+/, '')\n end", "def phone_work=(new_number)\n write_attribute :phone_work, new_number.try(:gsub, /[^0-9]/i, '')\n end", "def no_to_use_as_reference\n self.id.to_s.rjust(11, '0')\n end", "def full_id9\n self.id.blank? ? '000000000' : self.id.to_s.rjust(9,'0')\n end", "def valid_phone_number\n\t\tnumber = self.number.scan(/\\d/).join('')\n\t\tnumber[0] = '' if number[0] == \"1\"\n\n\t\tif number.length != 10\n\t\t\terrors.add(:phone, \"must be a valid 10 digit phone number\")\n\t\telse\n\t\t\tself.number = number\n\t\tend\n\tend", "def clean_zipcode(zipcode)\n # if zipcode.nil? \n # zipcode = \"00000\"\n # elsif zipcode.length < 5\n # zipcode = zipcode.rjust(5, \"0\")\n # elsif zipcode.length > 5\n # zipcode = zipcode[0..4]\n # end\n \n zipcode.to_s.rjust(5, \"0\")[0..4]\nend", "def phone_number_value\n # byebug\n\n if self.phone_number.present?\n numbers_array = self.phone_number.split(\",\")\n numbers_array.each do |nn|\n nn = nn.gsub(\"-\",\"\").gsub(\"+91\",\"\").gsub(\" \",\"\") \n # byebug\n if nn.to_i.to_s.length != 10\n # byebug\n self.errors[:phone_number]<< \"must be 10 digit number\"\n end \n end\n end\n end", "def add_zero_to_1_to_9(str)\n str.sub(/(?<=\\D)\\d\\D?$/, '0\\0' )\n end", "def clean_zipcode(zipcode)\n zipcode.to_s.rjust(5,\"0\")[0..4]\nend", "def clean_zipcode(zipcode)\n zipcode.to_s.rjust(5,\"0\")[0..4]\nend", "def clean_zipcode(zipcode)\n zipcode.to_s.rjust(5,\"0\")[0..4]\nend", "def clean_zipcode(zipcode)\n zipcode.to_s.rjust(5,\"0\")[0..4]\nend", "def remove_invalid_phones\n indexers = Indexer.where(archive: false)\n num = 0\n indexers.each do |indexer|\n phones = indexer.phones\n if phones.any?\n num += 1\n invalid = Regexp.new(\"[0-9]{5,}\")\n valid_phones = phones.reject { |x| invalid.match(x) }\n\n reg = Regexp.new(\"[(]?[0-9]{3}[ ]?[)-.]?[ ]?[0-9]{3}[ ]?[-. ][ ]?[0-9]{4}\")\n result = valid_phones.select { |x| reg.match(x) }\n\n indexer.update_attribute(:phones, result)\n end\n end\n end", "def clean(input)\n input.to_s.gsub(/[^0-9]/, '')\n end", "def reformat_phone_and_ssn\n phone = self.phone.to_s # change to string in case input as all numbers \n phone.gsub!(/[^0-9]/,\"\") # strip all non-digits\n self.phone = phone # reset self.phone to new string\n\n ssn = self.ssn.to_s # change to string in case input as all numbers \n ssn.gsub!(/[^0-9]/,\"\") # strip all non-digits\n self.ssn = ssn # reset self.phone to new string\n end", "def clean_digit_lines(separated_digit_lines)\n separated_digit_lines.each do |chunk|\n chunk.delete_at(3)\n if chunk[0].length == 0\n chunk[0] = \" \"\n end\n end\nend", "def cleaned_num_str\n @cleaned_num_str ||= sans_whitespace_and_commas\n end", "def mobile_phone_number\n FFaker.numerify(\"#{mobile_phone_prefix}## ### ###\")\n end", "def internationalized_phone_number(phone_number)\n \t\"+1#{phone_number}\"\n end" ]
[ "0.85953337", "0.85953337", "0.8162959", "0.800507", "0.77260906", "0.75588286", "0.7555583", "0.75549054", "0.74827176", "0.7363044", "0.736168", "0.73244566", "0.7323565", "0.7160388", "0.71550757", "0.71550757", "0.71550757", "0.71550757", "0.7136527", "0.71287763", "0.71287763", "0.71287763", "0.71287763", "0.7127326", "0.7122497", "0.7094852", "0.70251346", "0.7012892", "0.698517", "0.69458133", "0.6918169", "0.6896103", "0.6896103", "0.6893713", "0.6893713", "0.6893713", "0.6893713", "0.683181", "0.67843497", "0.6774424", "0.67438126", "0.67347795", "0.6710764", "0.66109544", "0.66080076", "0.65839416", "0.65698314", "0.65471846", "0.6526042", "0.6510841", "0.64652586", "0.6439599", "0.6438245", "0.64312243", "0.6427071", "0.64205676", "0.63533396", "0.6342634", "0.6337094", "0.63031554", "0.63011855", "0.6294885", "0.6287331", "0.62772876", "0.6229505", "0.62196696", "0.62076646", "0.61997294", "0.6199435", "0.6192789", "0.61815184", "0.617916", "0.617916", "0.61727166", "0.616512", "0.61331165", "0.6130254", "0.61281246", "0.61099285", "0.6108106", "0.61027974", "0.6100009", "0.6096486", "0.6078033", "0.60667133", "0.6063382", "0.6060819", "0.60606045", "0.6055658", "0.60453343", "0.6044066", "0.6044066", "0.6044066", "0.60257095", "0.60256636", "0.60192776", "0.60175943", "0.6015671", "0.6010667", "0.6003776" ]
0.7833245
4
=== Params band data from facebook
def initialize(fb_data) @data = fb_data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_facebook_params\n\n @fb_details = request.env['omniauth.auth']\n redirect_to main_app.root_path if @fb_details.nil?\n\n @fb_data = Hash.new\n @fb_data[:email] = @fb_details[:info][:email]\n @fb_data[:firstname] = @fb_details[:info][:first_name]\n @fb_data[:lastname] = @fb_details[:info][:last_name]\n @fb_data[:fb_token] = @fb_details[:credentials][:token]\n @fb_data[:image] = @fb_details[:info][:image].concat(\"?type=#{SIZE}\")\n\n return @fb_data\n end", "def facebook_raw_params\n [ :name, :id ]\n end", "def get_fb_params\n\t\"user_photos,email\"\nend", "def facebook_profile_params\n [:id, :name, :email, :token, :token_type, :expiration, {:raw => facebook_raw_params} ]\n end", "def prepare_params(params)\n s_params = {}\n params.each_pair {|k,v| s_params[k.to_s] = v }\n s_params['api_key'] = FacebookApi.api_key\n s_params['v'] = FacebookApi::API_VERSION\n s_params['call_id'] = Time.now.to_f.to_s\n s_params['format'] = 'JSON'\n s_params['sig'] = FacebookApi.calculate_signature(s_params)\n s_params\n end", "def grab_info(name)\n\n\n\n\n result = HTTParty.get(\"https://graph.facebook.com/#{name}\")\n\n user_fb = JSON.parse(result)\n\n# id = result[\"id\"]\n# name = result[\"name\"]\n# gender = result[\"gender\"]\n# locale = result[\"locale\"]\n# un = result[\"username\"]\n\nend", "def show\n #@band = Band.find_by_fb_id(params[:id])\n @band = Band.find(params[:id])\n respond_with @band\n end", "def facebook_variables\n @facebooker_config = Facebooker::AdapterBase.facebooker_config\n @canvas_page_name = @facebooker_config['canvas_page_name']\n @application_base_url = 'http://apps.facebook.com/' + @canvas_page_name\n @api_key = @facebooker_config['api_key']\n @ajax_server = \"#{Facebooker::AdapterBase.facebooker_config['callback_url']}\"\n @facebook_session = facebook_session\n @scrollbar = session[:scrollbar]\n end", "def facebook_data_about(item, keys = {})\n begin\n res = JSON.parse(token_get(item) || \"{}\") \n keys[:as] ? res[keys[:as]] : res\n rescue SocketError, Errno::ECONNRESET, OAuth2::HTTPError, EOFError => e\n # TODO :: hoptoad\n nil\n end\n end", "def facebook\n\n end", "def fb_load_api\n\n\n end", "def query_parameters; end", "def fetch_facebook_params\n\n @fb_details = request.env['omniauth.auth']\n redirect_to main_app.root_path if @fb_details.nil?\n\n session[:email] = @fb_details[:info][:email]\n session[:firstname] = @fb_details[:info][:first_name]\n session[:lastname] = @fb_details[:info][:last_name]\n session[:fb_token] = @fb_details[:credentials][:token]\n\n end", "def save_facebook_data\n data = get_graph\n if !data.nil?\n self.facebook_id = data[\"id\"]\n self.name = data[\"name\"]\n self.category = data[\"category\"]\n self.likes = data[\"likes\"]\n self.save\n end\n self\n end", "def parse_signed_request\n Rails.logger.info \" Facebook application \\\"#{fb_app.namespace}\\\" configuration in use for this request.\"\n if request_parameter = request.params[\"signed_request\"]\n encoded_signature, encoded_data = request_parameter.split(\".\")\n decoded_signature = base64_url_decode(encoded_signature)\n decoded_data = base64_url_decode(encoded_data)\n @fbparams = HashWithIndifferentAccess.new(JSON.parse(decoded_data))\n Rails.logger.info \" Facebook Parameters: #{fbparams.inspect}\"\n end\n end", "def query_params; end", "def cachefacebook_interface_params\n params.require(:cachefacebook_interface).permit(:device, :port, :nodo, :gbpsrx, :gbpstx, :bps_max, :status, :last_bps_max, :last_status, :crecimiento, :egressRate, :time, :comment, :deviceindex)\n end", "def facebook\n end", "def parameters\n data[:parameters]\n end", "def userinfo(access_token) \n querystr = \"https://graph.facebook.com/me?access_token=\"+access_token\n\n uri = URI.parse(URI.encode(querystr))\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Get.new(uri.request_uri)\n response = http.request(request)\n result = JSON.parse(response.body)\n myinfo = {}\n if result['name']\n myinfo['name']=result['name']\n myinfo['fbid']=result['id']\n end\n return myinfo\n end", "def facebookad_params\n params[:facebookad][:resultsywant] = params[:facebookad][:resultsywant].join(',')\n params.require(:facebookad).permit(:resultsywant, :budget, :name, :email, :phonenumber)\n end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def offerwall_params\n TestChamber.current_device.query_params.merge({\n lad: \"0\",\n ad_tracking_enabled: \"true\",\n app_id: @app.id,\n app_version: @app.version,\n bridge_version: @app.bridge_version,\n exp: \"ow_coffee\",\n currency_selector: \"0\",\n reqp: \"1\",\n reqr: \"nzcdYaEvLaE5pv5jLab=\"\n })\n end", "def rdf_params\n params.require(:raw_data_file).permit(:bname, :base_cyclenum, :data_channels)\n end", "def base_params\n {\n v: PROTOCOL_VERSION,\n # Client ID\n cid: @user_id,\n # Tracking ID\n tid: TRACKING_ID,\n # Application Name\n an: APPLICATION_NAME,\n # Application Version\n av: Bolt::VERSION,\n # Anonymize IPs\n aip: true,\n # User locale\n ul: Locale.current.to_rfc,\n # Custom Dimension 1 (Operating System)\n cd1: @os\n }\n end", "def post_params\n params.require(:post).permit(:facebook_id, :content, :share_count, :like_count, :comment_count,:fanpage_id)\n end", "def facebook_ad_params\n params.require(:facebook_ad).permit(\n :campaign_name,\n :objective,\n :audience_location,\n :audience_group,\n :gender_preference,\n :detail,\n :total_budget,\n :start_on,\n :finish_on,\n :url,\n :headline,\n :best_pitch,\n :page_id,\n :image,\n )\n end", "def facebook_share_params\n params.require(:facebook_share).permit(:url, :post_id, :sharecount)\n end", "def fanpage_params\n params.require(:fanpage).permit(:name, :facebook_number, :category_id)\n end", "def skeleton_biz_data\n #TODO: User view for payload data\n end", "def request_data; end", "def amphibian_params\n base_params\n end", "def fbCall(path,params = {})\n params['access_token'] = self.token ? self.token['access_token'] : self.originalFriend.token['access_token']\n getJSON(\"https://graph.facebook.com#{path}\", params)\n end", "def facebook_pixel_params\n params.require(:facebook_pixel).permit(:pixel_id, :shop_id, :employee_user_id)\n end", "def params() request.params end", "def query_parameters\n end", "def social\n @data['social']\n end", "def current_parameters\n @interface.yahoo_url_parameters\n end", "def weibo\n @user.name = @info['name']\n @user.nickname = @info['nickname']\n @user.location = @info['location']\n @user.bio = @info['description']\n if @info['urls'].present?\n @user.website = @info['urls']['Website']\n @user.weibo = @info['urls']['Weibo']\n end\n\n @backinfo = {:weibo => Hash[\n \"info\" => env[\"omniauth.auth\"]['info'],\n \"raw_info\" => env[\"omniauth.auth\"]['extra']['raw_info']\n ]}\n make_it_done!\n=begin\nhttp://api.t.sina.com.cn/oauth/authorize?oauth_callback=http%3A%2F%2F0.0.0.0%3A3000%2Faccount%2Fauth%2Fweibo%2Fcallback&oauth_token=ed7d6c0c8a59519cebc380509b1fb8ee\n |\n |\n \\ /\nhttp://0.0.0.0:3000/account/auth/weibo/callback?oauth_token=6856d78727e5eb5cd28b900473822f29&oauth_verifier=483778\n\n\"omniauth.origin\"=>\"http://0.0.0.0:3000/\",\n\"omniauth.auth\" => {\"provider\"=>\"weibo\",\n \"uid\"=>1947145061,\n \"info\"=>\n {\"nickname\"=>\"劈哀思唯啊\",\n \"name\"=>\"劈哀思唯啊\",\n \"location\"=>\"北京\",\n \"image\"=>\"http://tp2.sinaimg.cn/1947145061/50/5628658224/1\",\n \"description\"=>\"\",\n \"urls\"=>{\"Website\"=>\"\", \"Weibo\"=>\"http://weibo.com/1947145061\"}},\n \"credentials\"=>\n {\"token\"=>\"099b1fee964d6bf1a3cf573ee187d04c\",\n \"secret\"=>\"c964cec77754617c2c49c088f420582b\"},\n \"extra\"=>\n {\"access_token\"=>\n #<OAuth::AccessToken:0x007fc0a3246790\n @consumer=\n #<OAuth::Consumer:0x007fc0a3388a18\n @http=#<Net::HTTP api.t.sina.com.cn:80 open=false>,\n @http_method=:post,\n @key=\"2867528422\",\n @options=\n {:signature_method=>\"HMAC-SHA1\",\n :request_token_path=>\"/oauth/request_token\",\n :authorize_path=>\"/oauth/authorize\",\n :access_token_path=>\"/oauth/access_token\",\n :proxy=>nil,\n :scheme=>:header,\n :http_method=>:post,\n :oauth_version=>\"1.0\",\n :realm=>\"OmniAuth\",\n :site=>\"http://api.t.sina.com.cn\"},\n @secret=\"7125b8f33ce1e530ed4f43ed9fcd6232\",\n @uri=#<URI::HTTP:0x007fc0a32502e0 URL:http://api.t.sina.com.cn>>,\n @params=\n {:oauth_token=>\"099b1fee964d6bf1a3cf573ee187d04c\",\n \"oauth_token\"=>\"099b1fee964d6bf1a3cf573ee187d04c\",\n :oauth_token_secret=>\"c964cec77754617c2c49c088f420582b\",\n \"oauth_token_secret\"=>\"c964cec77754617c2c49c088f420582b\",\n :user_id=>\"1947145061\",\n \"user_id\"=>\"1947145061\"},\n @response=#<Net::HTTPOK 200 OK readbody=true>,\n @secret=\"c964cec77754617c2c49c088f420582b\",\n @token=\"099b1fee964d6bf1a3cf573ee187d04c\">,\n \"raw_info\"=>\n {\"id\"=>1947145061,\n \"screen_name\"=>\"劈哀思唯啊\",\n \"name\"=>\"劈哀思唯啊\",\n \"province\"=>\"11\",\n \"city\"=>\"1000\",\n \"location\"=>\"北京\",\n \"description\"=>\"\",\n \"url\"=>\"\",\n \"profile_image_url\"=>\"http://tp2.sinaimg.cn/1947145061/50/5628658224/1\",\n \"domain\"=>\"\",\n \"gender\"=>\"m\",\n \"followers_count\"=>10,\n \"friends_count\"=>51,\n \"statuses_count\"=>67,\n \"favourites_count\"=>0,\n \"created_at\"=>\"Fri Mar 25 00:00:00 +0800 2011\",\n \"following\"=>false,\n \"allow_all_act_msg\"=>false,\n \"geo_enabled\"=>true,\n \"verified\"=>false,\n \"status\"=>\n {\"created_at\"=>\"Wed May 30 22:40:48 +0800 2012\",\n \"id\"=>3451515349633960,\n \"text\"=>\n \"May 18, 2012 - 夜幕降临前,Facebook位于俄勒冈州的Prineville新数据中心,美国。Facebook刚刚宣布首次公开募股(IPO)价格周四定为每\n \"source\"=>\n \"<a href=\\\"http://idai.ly\\\" rel=\\\"nofollow\\\">iDaily每日环球视野</a>\",\n \"favorited\"=>false,\n \"truncated\"=>false,\n \"in_reply_to_status_id\"=>\"\",\n \"in_reply_to_user_id\"=>\"\",\n \"in_reply_to_screen_name\"=>\"\",\n \"thumbnail_pic\"=>\n \"http://ww3.sinaimg.cn/thumbnail/740f1365jw1dtgq69aswij.jpg\",\n \"bmiddle_pic\"=>\n \"http://ww3.sinaimg.cn/bmiddle/740f1365jw1dtgq69aswij.jpg\",\n \"original_pic\"=>\n \"http://ww3.sinaimg.cn/large/740f1365jw1dtgq69aswij.jpg\",\n \"geo\"=>nil,\n \"mid\"=>\"3451515349633960\"}}}}\n=end\n end", "def facebook\n FbConnection\n end", "def site_data; end", "def set_facebook_info omni\n info = omni['info']\n self.email = info['email']\n self.first_name = info['first_name']\n self.last_name = info['last_name']\n\n # Get the large size image. Omniauth returns 'square' by default and thats\n # too small to use.\n if info['image'].present?\n self.remote_profile_image_url = info['image'].gsub(\"square\", \"large\")\n end\n end", "def data_params\n params.require('data')\n end", "def data\n Facebooker::Data.new(self)\n end", "def graph_params\n params.fetch(:graph, {})\n end", "def parsed_params\n \n end", "def wechat_valid_qrcode_scan_params(referrer)\n {\n 'ToUserName' => 'FAKE_VALID_USERNAME',\n 'FromUserName' => 'FAKE_VALID_FROMUSERNAME',\n 'CreateTime' => '1501489767',\n 'MsgType' => 'event',\n 'Event' => 'SCAN',\n 'EventKey' => \"{\\\"referrer\\\":{\\\"reference_id\\\":\\\"#{referrer.reference_id}\\\"} }\",\n 'Ticket' => 'gQH18DwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyUDNiRDF4R29ibC0xMDAwMDAwN04AAgR_jHhZAwQAAAAA'\n }\nend", "def raw_params(auth); end", "def query_params\n URI.encode_www_form(\n {\n affiliate:,\n access_key:,\n module_code:,\n url:,\n query:,\n position:,\n user_agent:\n }\n )\n end", "def data_url_parameters\n parameters = {\n :random_token => self.random_token,\n :host => Privly::Application.config.link_domain_host,\n :port => nil}\n return parameters\n end", "def fbuser_params\n params.require(:user).permit(:fb_id, :name, :email, :photo, :fb_info)\n end", "def show\n @facebook_blast = FacebookBlast.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @facebook_blast }\n end\n end", "def url_parameters\n \n if self.burn_after_date\n sharing_url_parameters = {\n :privlyApp => self.privly_application,\n :random_token => self.random_token,\n :privlyInject1 => true}\n else\n sharing_url_parameters = {\n :privlyApp => self.privly_application,\n :random_token => self.random_token,\n :privlyInject1 => true}\n end\n \n return sharing_url_parameters\n end", "def band_params\r\n params.require(:band).permit(:name, :genre, :description, :email,\r\n :url, :image, :songdemo1, :songdemo1_title,\r\n :songdemo2, :songdemo2_title,\r\n :zipcode, :radius)\r\n end", "def graph_params\n {fields: fields_as_string}\n end", "def feed_data\n params['comment'] ||= 0\n params['topic'] ||= 0\n data = Hash.new\n\n if(CFG['feed_demo_mode']) then\n #data = demo_data(Integer(params['comment'])+1)\n data = demo_data(100)\n else\n data['topic'] = Topic.next(params['topic'])\n data['comment'] = Post.next(params['comment'])\n end\n\n render nothing: true, json: data\n end", "def show\n @rating = Rating.where(club_id: @club.id, user_id: current_user.id).first \n @hash = Gmaps4rails.build_markers(@club) do |club, marker|\n marker.lat club.latitude\n marker.lng club.longitude\n end\n #Load facebook.yml info\n config = YAML::load(File.open(\"#{Rails.root}/config/facebook.yml\"));\n #Instantiate a new application with our app_id so we can get an access token\n my_app = FbGraph::Application.new(config['production']['app_id']);\n acc_tok = my_app.get_access_token(config['production']['client_secret']);\n #Instantiate a new page class using the page_id specified \n @page = FbGraph::Page.new(config['production']['page_id'], :access_token => acc_tok).fetch;\n #Get wall posts\n @wall = FbGraph::Page.new(config['production']['page_id'], :access_token => acc_tok).posts;\n #Grab the events from the page \n events = @page.events.sort_by{|e| e.start_time};\n #Grab the picture from the page \n picture = @page.picture;\n #Get the events that are upcoming\n @upcoming_events = events.find_all{|e| e.start_time >= Time.now};\n #Get the picture\n @fbpic = picture;\n #Get the events that have passed\n @past_events = events.find_all{|e| e.start_time < Time.now}.reverse;\n end", "def rc_facebook_check_params_signed_request\n return if rc_facebook.authorized? || !params[:signed_request]\n\n rc_facebook.parse_signed_request!(params[:signed_request])\n logger.debug(\"DEBUG: Facebook: detected signed_request,\" \\\n \" parsed: #{rc_facebook.data.inspect}\")\n\n if rc_facebook.authorized?\n rc_facebook_write_rg_fbs\n else\n logger.warn(\n \"WARN: Facebook: bad signed_request: #{params[:signed_request]}\")\n end\n end", "def oauth_hash_params(param)\n case param[:provider]\n when \"twitter\"\n {\n email: \"\",\n name: param[:info][:nickname]\n }\n when \"google_oauth2\"\n {\n email: param[:info][:email],\n name: param[:info][:name]\n }\n when \"facebook\"\n {\n email: param[:info][:email],\n name: param[:info][:name]\n }\n end\n end", "def data_params\n {\n data: {attributes: {content: content}}\n }\n end", "def request_params; end", "def socialParams\n params.permit( :name , :link)\n end", "def map_params(query)\n params = {\n bandName: query[:name] || \"\",\n exactBandMatch: (query[:exact] ? 1 : 0),\n genre: query[:genre] || \"\",\n yearCreationFrom: query[:year]&.begin || \"\",\n yearCreationTo: query[:year]&.end || \"\",\n bandNotes: query[:comment] || \"\",\n status: map_status(query[:status]),\n themes: query[:lyrical_themes] || \"\",\n location: query[:location] || \"\",\n bandLabelName: query[:label] || \"\",\n indieLabelBand: (query[:independent] ? 1 : 0),\n }\n\n params[:country] = []\n Array(query[:country]).each do |country|\n params[:country] << (country.is_a?(ISO3166::Country) ? country.alpha2 : (country || \"\"))\n end\n params[:country] = params[:country].first if params[:country].size == 1\n\n params\n end", "def facebook_page_params\n params.require(:facebook_page).permit(:facebook_page_id, :access_token, :created_dt)\n end", "def business_stream_params\n params.require(:business_stream).permit(:business_stream_name)\n end", "def get_channel_info()\r\n channel_id=params[0]\r\n site_id=params[1]\r\n channel=Channel.find(channel_id)\r\n chinfo=nil\r\n site=Site.find(site_id)\r\n if channel.nil? #Return nil if channel not found.\r\n logger.error \"No Channel Object found for channel id #{channel_id}.\"\r\n elsif site.nil? #Return nil if site not found.\r\n logger.error \"No site found for site id #{site_id}.\"\r\n else\r\n\r\n meas_list=Measurement.find_by_sql([\"select distinct measure_id as meas_id from measurements left join measures on measurements.measure_id=measures.id where site_id=? and channel_id=? and graph_flag=1\",site_id, channel_id])\r\n\r\n \r\n chinfo={}\r\n chinfo[:channel_id]=channel_id\r\n chinfo[:channel_nbr]=channel.channel\r\n chinfo[:channel_name]=channel.channel_name\r\n chinfo[:modulation]=channel.modulation\r\n chinfo[:channel_freq]=channel.channel_freq.to_f\r\n chinfo[:meas_list]=meas_list.collect { |meas| meas.meas_id}\r\n end\r\n respond_to do |format|\r\n format.amf { \r\n render :amf => chinfo\r\n }\r\n end\r\n end", "def frames\n value_parts[3]\n end", "def frames\n value_parts[3]\n end", "def create\n @band = Band.new(params[:band])\n @same_fb_id = Band.find_by_fb_id(@band.fb_id)\n if @same_fb_id == nil\n @band.save\n end\n respond_with @band\n end", "def get_parameters; end", "def get_parameters; end", "def band_params\n params.require(:band).permit(:bandname, :name, :bio, :website, :email, :password)\n end", "def facebook_user_data(data)\n raise \"SHOULD BE IMPLEMENT NEW USER DATA\"\n end", "def create_params\n herbarium_params.merge(\n name: \" Burbank <blah> Herbarium \",\n code: \"BH \",\n place_name: \"Burbank, California, USA\",\n email: \"[email protected]\",\n mailing_address: \"New Herbarium\\n1234 Figueroa\\nBurbank, CA, 91234\\n\\n\\n\",\n description: \"\\nSpecializes in local macrofungi. <http:blah>\\n\"\n )\n end", "def get_fb_sig_params(originalParams)\n\n # setup\n timeout = 5.years#2.hours #3.seconds #48*3600\n namespace = \"fb_sig\"\n prefix = \"#{namespace}_\"\n # get the params prefixed by \"fb_sig_\" (and remove the prefix)\n sigParams = {}\n originalParams.each do |k,v|\n oldLen = k.length\n newK = k.sub(prefix, \"\") \n if oldLen != newK.length \n sigParams[newK] = v\n end\n end\n # handle invalidation\n if (timeout and (sigParams[\"time\"].nil? or (Time.now.to_i - sigParams[\"time\"].to_i > timeout.to_i)))\n # invalidate if the timeout has been reached\n sigParams = {}\n end\n \n if !sig_params_valid?(sigParams, originalParams[namespace])\n # invalidate if the signatures don't match\n sigParams = {}\n end\n \n return sigParams\n \n end", "def new\n \n user = FbGraph::User.new('me', :access_token => User.first.token)\n \n user = user.fetch(:fields => \"picture,cover, photo\")\n \n @profile_picture = user.picture unless user.picture.nil?\n\n @cover_picture = user.raw_attributes[:cover][:source] unless user.raw_attributes[:cover].nil?\n \n #To fetch all friends photos\n @friend_photo= (user.friends).map(&:picture) \n \n @photo=[]\n @album=[]\n \n #~ #TO fetch user tagged photos\n #~ usr=user.photos\n #~ usr.each do |up|\n #~ photo = up.raw_attributes['images'].last\n #~ @photo << photo['source']\n #~ end\n \n #~ #TO fetch user all album photos\n #~ user.albums.each do |ua|\n #~ album=FbGraph::Album.new(ua.raw_attributes[:id])\n #~ album.photos(:access_token => User.first.token, :limit => 100).each do |ap|\n #~ photo = ap.raw_attributes['images'].last\n #~ @album << photo['source']\n #~ end\n #~ end\n #mosaic = Mosaicc.new\n Mosaicc.delay.image_perform\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @album }\n end\n end", "def prepare_info_for_facebook(oauth_info)\n { uid: oauth_info.uid.to_s,\n token: oauth_info.credentials.token,\n nickname: oauth_info.info.nickname || \"fbuser_#{uid}\",\n name: oauth_info.info.name,\n email: oauth_info.info.email }\n end", "def facebooklink_params\n params.require(:facebooklink).permit(:name, :url)\n end", "def fetch_details_from_facebook\n\t\t# graph = Koala::Facebook::API.new(self.token)\n\t\t# facebook_data = graph.get_object(\"me\")\n\t\t# self.username = facebook_data['username']\n\t\t# self.save\n\t\t# self.user.username = facebook_data['username'] if self.user.username.blank?\n\t\t# self.user.image = \"http://graph.facebook.com/\" + self.username + \"/picture?type=large\" if self.user.image.blank?\n\t\t# self.user.location = facebook_data['location'] if self.user.location.blank?\n\t\t# self.user.save\n\t\tself.user.has_facebook = true\n\t\tself.user.save\n\tend", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end" ]
[ "0.6691618", "0.66585964", "0.6610425", "0.626983", "0.604189", "0.59440887", "0.593055", "0.5708242", "0.5630635", "0.5604987", "0.5574742", "0.5546162", "0.5528427", "0.5517001", "0.5504377", "0.54545367", "0.5438522", "0.54376763", "0.54292977", "0.5410506", "0.5410479", "0.5408825", "0.5408825", "0.5408825", "0.5408825", "0.5408825", "0.5408825", "0.5408825", "0.5408825", "0.5408825", "0.5408825", "0.5408825", "0.5408825", "0.5408825", "0.5408825", "0.5408825", "0.5408825", "0.5408825", "0.5407904", "0.53917325", "0.5363465", "0.5328821", "0.5312363", "0.5300368", "0.52905476", "0.52876115", "0.52874106", "0.5285659", "0.52743363", "0.52719253", "0.5270625", "0.526365", "0.5251936", "0.5248827", "0.52385825", "0.5232742", "0.5228187", "0.5226593", "0.52197254", "0.5203148", "0.5202704", "0.5177632", "0.5172462", "0.5168864", "0.5162697", "0.51539904", "0.51523215", "0.5151132", "0.51486665", "0.5141582", "0.51400673", "0.51343346", "0.5132909", "0.5125505", "0.5121289", "0.5121285", "0.5117668", "0.5114416", "0.51096237", "0.5106464", "0.5099377", "0.509841", "0.50968635", "0.50968635", "0.5094732", "0.50935376", "0.50935376", "0.5087916", "0.50861615", "0.50847226", "0.5075762", "0.5071112", "0.5064936", "0.50503755", "0.50462323", "0.50412774", "0.50412774", "0.50412774", "0.50412774", "0.50412774" ]
0.62549525
4
Replace this with your real tests.
def test_index get :index assert_redirected_to :action => :unread end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testing\n # ...\n end", "def __dummy_test__\n end", "def tests; end", "def tests; end", "def spec; end", "def spec; end", "def self_test; end", "def self_test; end", "def test \n end", "def test_0_dummy\n\t\tend", "def test\n\n end", "def test\n end", "def test\n end", "def test\n end", "def private; 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_method\n end", "def before_test(test); end", "def before_test(test); end", "def graffiti_test\n end", "def test_truth\n end", "def test_should_get_index \n get :index\n assert_response :success #making sure the request was successful\n assert_not_nil (:products) # ensuring that it assigns a valid products instance variable.\n end", "def test_case; end", "def test_cases; end", "def running_test_case; end", "def test_connection\n end", "def testloop\n \n end", "def should; super end", "def test_nothing\n end", "def default_test\r\n end", "def my_tests\n end", "def test_setup\r\n \r\n end", "def test_intialize\r\n\tassert_equal 0, @test_prospector.current_gold\r\n\tassert_equal 0, @test_prospector.current_silver\r\n\tassert_equal 0, @test_prospector.total_gold\r\n\tassert_equal 0, @test_prospector.total_silver\r\n\tassert_equal 0, @test_prospector.move_count\r\n\tassert_nil @test_prospector.previous_location\r\n\tassert_equal 0, @test_prospector.num_days\r\n\tassert_equal 'Sutter Creek', @test_prospector.current_location\r\n end", "def testing_end\n end", "def test_next_song\n \n \n assert true\n end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def assertions; end", "def assertions; end", "def test_hack\n assert(true)\n end", "def setup\n\n end", "def setup\n\n end", "def setup\n\n end", "def test_attributes\n assert_equal \"Gallery 1\", @gallery.title\n assert @gallery.active?\n assert_equal \"f82dd0bd-4711-4578-ac47-4661257e69a6\", @gallery.guid\n end", "def teardown; end", "def teardown; 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 before_assert\n end", "def test_fake_rubies_found\n\t\ttest_main = Main.new(3, 4, 6)\n\t\ttest_graph = Graph.new(10)\n\t\ttest_main.fake_rubies_found(7)\n\t\ttest_main.fake_rubies_found(7)\n\t\tassert test_main.num_fake_rubies, 14\n\tend", "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 test_entry\n raise \"Implement this method in your test class\"\n end", "def tests_song_not_found\n assert_equal =\n end\n\nend", "def test_playlist\n end", "def test_listchunk_attributes\n\t\t\n\tend", "def love_test\nend", "def test_entry_attrs\n raise \"Implement this method in your test class\"\n end", "def test_truth\n assert true\n end", "def stest_method_1(test); end", "def teardown\r\n end", "def default_test\n end", "def test_037\n\n login\n\n #Create some PUs\n\n for i in 0..2\n create_pu('sample_pu'+i.to_s)\n end\n\n pus = Pu.find_all_by_name('sample_pu1')\n pu = pus.last\n pu.created_at =\"2009-05-08 11:30:50\"\n pu.save\n pus = Pu.find_all_by_name('sample_pu2')\n pu = pus.last\n pu.created_at =\"2008-05-08 14:30:50\"\n pu.save\n @@year = \"2009\"\n @@hour = \"14\"\n\n # Open PU management page\n open_pu_management_page_1\n\n # Arbitrary filtering is performed to PU name.\n assert_equal _(\"PU name\"), get_selected_label(\"find_box\")\n\n\n # you have no relevance\n filtering('3')\n assert !is_text_present('sample_pu1')\n assert !is_text_present('sample_pu2')\n assert is_text_present(_('A PU does not exist.'))\n sleep 2\n\n # Delete created data\n @@pu= Pu.find_by_name('sample_pu1')\n @@pu2= Pu.find_by_name('sample_pu2')\n @@pu.destroy\n @@pu2.destroy\n logout\n end", "def run_fe_tests\n end", "def after_test(_test); end", "def after_test(_test); end", "def after_test(_test); end", "def setup; end", "def tests=(_arg0); end", "def tests=(_arg0); end", "def test_truth\n april = riders(:rider_1)\n assert_equal \"April Jones\", april.name\n trigger = horses(:horse_1)\n assert_equal \"Trigger\", trigger.name\n event2 = events(:event_2)\n assert_equal \"5 Horse Scramble\", event2.name\n \n end", "def test_BooksForAnAuthor\n loginRegisterBazzarVoice\n writeReview \n assert true \n end" ]
[ "0.7446459", "0.6956364", "0.69155836", "0.69155836", "0.6864151", "0.6864151", "0.66406286", "0.66406286", "0.66253287", "0.6547665", "0.6524571", "0.6484549", "0.6484549", "0.6484549", "0.6403847", "0.6389188", "0.6389188", "0.6389188", "0.6389188", "0.6389188", "0.6389188", "0.6389188", "0.6389188", "0.6389188", "0.6389188", "0.6389188", "0.6389188", "0.6389188", "0.6389188", "0.6389188", "0.6389188", "0.6389188", "0.6389188", "0.6389188", "0.6385941", "0.6354074", "0.6354074", "0.6350063", "0.6317573", "0.6271346", "0.62341285", "0.6210424", "0.6183045", "0.61626923", "0.61574936", "0.6137384", "0.61362237", "0.61194503", "0.611745", "0.61087", "0.6098303", "0.606717", "0.6058555", "0.6057699", "0.6057699", "0.6057699", "0.6057699", "0.6045397", "0.6045397", "0.6029009", "0.60160005", "0.60160005", "0.60160005", "0.6014079", "0.5998994", "0.5998994", "0.5991374", "0.5991374", "0.5991374", "0.5991374", "0.5991374", "0.5991374", "0.5991374", "0.5989936", "0.59822077", "0.59556234", "0.59556234", "0.59556234", "0.59556234", "0.59556234", "0.59556234", "0.5950605", "0.59497803", "0.5943133", "0.59424186", "0.5932352", "0.59296894", "0.5929659", "0.5917424", "0.59144044", "0.5913393", "0.5905494", "0.5899468", "0.58910733", "0.58910733", "0.58910733", "0.5889112", "0.5883961", "0.5883961", "0.5880121", "0.5877717" ]
0.0
-1
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order
def two_sum(nums, target) results = [] i = 1 while i < nums.length diff = target - nums[i - 1] if nums[i..-1].include?(diff) idx = nums[i..-1].index(diff) results << i - 1 << idx + i end i += 1 end results end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solve(nums, target)\n nums.each_with_index do |e, i|\n nums.each_with_index do |e_, i_|\n return [i, i_] if ((e + e_ == target) && (i != i_))\n end\n end\nend", "def two_sum(nums, target)\n target_indexes = []\n nums.each_with_index do |primary, index|\n nums.each_with_index do |num, i|\n if primary + num == target && index != i\n target_indexes << index\n target_indexes << i\n end\n end\n end\n return target_indexes.uniq\nend", "def two_sum(numbers, target)\n\n numbers.each_with_index do |num, index|\n \n looking_for = target - num\n answer_2 = binary_search(numbers, index + 1, numbers.length - 1, looking_for)\n if !!answer_2\n return [index + 1, answer_2 + 1] \n end\n end\nend", "def two_sum(nums, target)\n result = []\n nums.each_with_index do |num, idx|\n find_num = target - num\n result = [idx, nums.index(find_num)] if nums.include?(find_num) && nums.index(find_num) != idx\n return result if result.length > 0\n end\n\n if result.length == 0\n return \"Target sum not found in array\"\n end\nend", "def two_sum(nums, target)\n hsh = Hash.new\n nums.each_with_index do |n, i|\n hsh[n] = i+1\n end\n \n nums.each_with_index do |val, ind|\n second = target - val\n if hsh.include?(second) && nums.index(second) != ind\n return [ind+1, nums.index(second)+1]\n end\n end\nend", "def two_sum(nums, target)\n nums.each_with_index do |num1, idx1|\n nums.each_with_index do |num2, idx2|\n if (num1 + num2 == target) && (idx1 != idx2)\n return [idx1, idx2]\n end\n end\n end\nend", "def two_sum(nums, target)\n sorted_nums = nums.sort\n\n last_index = sorted_nums.size - 1\n first_index = 0\n\n while true do\n if sorted_nums[last_index] + sorted_nums[first_index] > target\n last_index -= 1\n\n next\n end\n\n smaller_have_to_be = target - sorted_nums[last_index]\n\n while true do\n if sorted_nums[first_index] < smaller_have_to_be\n first_index += 1\n\n next\n end\n\n break\n end\n\n if sorted_nums[first_index] != smaller_have_to_be\n last_index -= 1\n next\n end\n\n break\n end\n\n # Find correct indexes ( because that indexs in sorted array )\n\n result = []\n nums.each_with_index do |number, index|\n if [sorted_nums[first_index], sorted_nums[last_index]].include?(number)\n result.push(index)\n end\n end\n\n result\nend", "def two_sum(nums, target)\n complements = Hash.new\n \n nums.each_with_index do |num, index|\n if complements.has_key? (target - num)\n return [complements[target - num], index]\n else\n complements[num] = index\n end\n end\n \n return []\nend", "def two_sum(numbers, target)\n arr = numbers\n num = target\n index_array = []\n return_array = []\n current_index = 0\n\n loop do\n idx_counter = current_index\n current_element = arr[current_index]\n\n loop do\n break if idx_counter >= arr.length - 1\n next_index = idx_counter + 1\n next_element = arr[next_index]\n if current_element + next_element == num\n index_array << current_index << next_index\n end\n idx_counter += 1\n end\n\n if return_array == []\n current_index += 1\n end\n break if return_array.reduce(:+) == num\n end\n\n p index_array\nend", "def two_sum(nums, target)\n nums.each_with_index do |num1, idx1|\n nums.each_with_index do |num2, idx2|\n next if idx1 == idx2\n return [idx1, idx2] if num1 + num2 == target\n end\n end\n return \"Couldn't find target value\"\nend", "def two_sum(nums, target)\n nums.each_with_index do |ele, i|\n check = target - ele\n return i, nums.index(check) if nums.include?(check) && i != nums.index(check)\n end\nend", "def two_sum(nums, target)\n indices_array = []\n i = 0\n while i < nums.length\n j = i + 1\n while j < nums.length\n if nums[i] + nums[j] == target\n indices_array << i\n indices_array << j\n end\n j += 1\n end\n i += 1\n end\n return indices_array\nend", "def two_sum(nums, target)\n hash_idx_nums = {}\n index_result_array = []\n for index in (0...nums.length)\n hash_idx_nums[index] = nums[index]\n end\n\n # nums.each do |num|\n # result = target - num\n # if hash_idx_nums.value?(result)\n # index_result_array << hash_idx_nums.key(result)\n # end\n # end\n for index in (0...nums.length)\n result = target - nums[index]\n \n if hash_idx_nums.value?(result) && hash_idx_nums.key(result) != index\n index_result_array << hash_idx_nums.key(result)\n end\n end\n p index_result_array\n return index_result_array[0], index_result_array[1]\nend", "def brute_force_two_sum(array, target)\n indexes = []\n array.each.with_index do |n1, index1|\n array.each.with_index do |n2, index2|\n indexes.push(index1) if target - n1 == n2 && index1 != index2\n end\n end\n indexes\nend", "def two_sum(nums, target)\n # i,j = 0, nums.length-1\n i = 0\n j = nums.length-1\n output = []\n while i < nums.length-1\n while j > i\n if nums[i] + nums[j] == target\n output << i << j\n end\n j-=1\n end\n i+=1\nend\nreturn output #returning index\nend", "def two_sum(nums, target)\n nums_hash = {}\n \n nums.each.with_index do |num, idx|\n nums_hash[num] = idx\n end\n \n nums.each.with_index do |num1, i|\n val = target - num1\n \n return [i, nums_hash[val]] if nums_hash[val] && nums_hash[val] != i\n end\nend", "def two_sum(numbers, target)\n numbers.each_with_index do |num, idx|\n # why `idx + 1`? because we don't want to include the number in our search\n # so if we start at idx 0, we want to search from 1..end for the complement\n # also, so we don't re-search smaller numbers, since this array is sorted.\n low = idx + 1\n high = numbers.size - 1\n search = target - num\n\n while low <= high\n mid = (low + high) / 2\n\n if numbers[mid] == search\n return [idx + 1, mid + 1] # NOT zero-indexed!\n elsif numbers[mid] > search\n # note we ignore including `mid` on next search for both `high` and `low`\n # and our first condition already takes care of `mid`\n high = mid - 1\n else\n low = mid + 1\n end\n end\n end\nend", "def two_sum(nums, target)\n hash = Hash.new\n nums.each_with_index do |num, index|\n findable = target - num\n if hash[findable]\n return [nums.index(findable), index]\n end\n hash[num] = findable\n end\n require 'pry'; binding.pry\nend", "def two_sum_binary(numbers, target)\n numbers.each_with_index do |num, i|\n j = binary_search(numbers, target - num, i+1)\n\n # +1 because we do both index1 and index2 are not zero-based\n return [i+1, j+1] unless j == -1\n end\n\n raise ArgumentError.new(\"No two sum solution\")\nend", "def twoSum(numbers, target)\n # solution\n result = []\n numbers.each do |i|\n y = numbers.length - 1\n while y > numbers.index(i) do \n if i + numbers[y] == target\n result << numbers.index(i) << y\n return result\n end\n y -= 1\n end\n end\nend", "def twoSum(numbers, target)\n (0...(numbers.size - 1)).each do |ind1|\n ((ind1 + 1)...numbers.size).each do |ind2|\n return [ind1, ind2] if numbers[ind1] + numbers[ind2] == target\n end\n end\nend", "def two_sum(nums, target)\n diff = {}\n\n nums.each_with_index do |num, idx|\n if diff[num]\n return [diff[num], idx]\n else\n diff[target - num] = idx\n end\n end\nend", "def two_sum(nums, target)\n if target_match = nums.combination(2).find { |pair| pair.sum == target }\n index1 = nums.index(target_match[0])\n nums.delete_at(nums.index(target_match[0]))\n index2 = nums.index(target_match[1]) + 1\n [index1, index2]\n end\nend", "def two_sum(nums, target)\n nums.map do | i |\n x = nums.index(i)+1\n if nums[x] + i == target\n return [nums.index(i),x]\n end\n end\nend", "def two_sum(numbers, target)\n size = numbers.length\n i = 0\n j = size - 1\n\n while numbers[i] + numbers[j] != target\n i += 1 if (numbers[i] + numbers[j]) < target\n j -= 1 if (numbers[i] + numbers[j]) > target\n end\n\n [i + 1, j + 1]\nend", "def two_sum(nums, target)\n seen = {}\n nums.each_with_index do |num, idx|\n return [seen[num], idx] if seen[num]\n\n seen[target - num] = idx\n end\nend", "def two_sum(nums, target)\n hash = {}\n nums.each_with_index do |num, idx|\n other_num = target - num\n other_num_idx = hash[other_num]\n return [other_num_idx, idx] if other_num_idx\n\n hash[num] = idx\n end\n []\nend", "def two_sum(nums, target)\n nums_hash = {}\n nums.each_with_index do |val, i|\n nums_hash[val] = i\n end\n\n nums.each_with_index do |ival, i|\n complement = target - ival\n next if nums_hash[complement] == i\n if nums_hash.key?(complement)\n return [i, nums_hash[complement]]\n end\n end\n []\nend", "def two_sum(nums, target)\n index_of_complement = {}\n (0...nums.size).each do |i|\n if index_of_complement.key?(nums[i]) \n return [index_of_complement[nums[i]], i] \n else\n index_of_complement[target - nums[i]] = i\n end\n end\nend", "def two_sum(nums, target)\n num_hash = Hash.new\n \n nums.each_with_index do |num, idx|\n diff = target - num\n if num_hash[diff]\n return idx < num_hash[diff] ? [idx, num_hash[diff]] : [num_hash[diff], idx]\n end\n num_hash[num] = idx\n end\n null\nend", "def two_sum(nums, target)\n hash = {}\n nums.each_with_index do |val, index|\n ans = target - val\n return [hash[ans], index] if hash.include?(ans)\n\n hash[val] = index\n end\nend", "def two_sum_ptr(nums, target)\n low, high = 0, nums.length - 1\n while( low < high)\n if(nums[low] + nums[high] == target)\n return [low + 1, high + 1]\n elsif nums[low] + nums[high] < target\n low += 1\n else\n high -= 1\n end\n end\nend", "def two_sum(nums, target)\n low = 0\n high = nums.length - 1\n\n while low < high\n sum = nums[low] + nums[high]\n\n if sum < target\n low += 1\n elsif sum > target\n high -= 1\n else\n return[low, high]\n end\n end\nend", "def search_range(nums, target)\n return [-1,-1] if nums.empty? || !nums.include?(target)\n output = [*nums.each_with_index]\n all_targets = output.find_all do |tuple|\n tuple[0] == target\n end\n [all_targets.first[1], all_targets.last[1]]\nend", "def two_sum(nums, target)\n hash = {}\n\n nums.each_with_index do |n, idx|\n differential = target - n\n return [hash[differential], idx] if hash[differential]\n hash[n] = idx\n end\nend", "def two_sum(nums, target)\n map = {}\n\n (0...nums.size).each do |i|\n current_value = nums[i]\n\n if map[target - current_value]\n return [map[target - current_value] + 1, i + 1]\n else\n map[current_value] = i\n end\n end\nend", "def okay_two_sum?(nums, target)\n output = []\n i = 0\n j = nums.length - 1\n \n while i != j\n sum = nums[i] + nums[j]\n\n if sum == target\n output << [i, j]\n end \n\n if sum <= target\n i += 1\n else\n j -= 1\n end\n end\n\n output\nend", "def adds_up(nums, target)\n\n i = 0\n while i < nums.length\n j = i + 1\n while j < nums.length\n if nums[i] == target - nums[j]\n return [i, j]\n end\n\n j += 1\n end\n\n i += 1\n end\n\n return []\nend", "def two_sum_2(nums, target)\n sorted_nums = merge_sort(nums)\n i, j = 0, sorted_nums.length-1\n while i < j\n sum = sorted_nums[i] + sorted_nums[j]\n if sum == target\n index1 = nums.index(sorted_nums[i])\n index2 = nums.index(sorted_nums[j])\n puts \"index1=#{index1+1}, index2=#{index2+1}\"\n return\n elsif sum < target\n i += 1\n else\n j -= 1\n end\n end\nend", "def two_sum(integers, target)\n # O(n)\n integers_with_index = integers.each_with_index.to_a\n # O(n*log(n))\n integers_with_index = integers_with_index.sort_by { |(n, _)| n }\n\n front, back = 0, integers_with_index.count - 1\n\n until front == back\n sum = integers_with_index[front][0] + integers_with_index[back][0]\n if sum == target\n return [integers_with_index[front][1], integers_with_index[back][1]].sort\n elsif sum > target\n back -= 1\n else\n front += 1\n end\n end\nend", "def two_sum(nums, target)\n\tnum_len = nums.length\n\tdic = {}\n\ti = 0 \n while i < num_len\t\n \tnumber = nums[i]\n \tif number == target / 2 && dic[number]\n \t\treturn [dic[number],i]\n \tend\n \tdic[number] = i\n \tmaybe = dic[target-number]\n \tif maybe && maybe != i\n \t\treturn [maybe,i]\n \t\tbreak\n \tend\n i += 1\n end\nend", "def two_sum(numbers, target)\n numbers.each_with_index do |n1, i1|\n numbers.each_with_index do |n2, i2|\n return [i1, i2] if (n1 + n2) == target && i1 != i2\n end\n end\nend", "def two_sum_indices(arr, target_sum)\n complements = {}\n arr.each_with_index do |el, i|\n complement, j = complements[target_sum - el] # these will both be nil if the complement doesn't exist\n return [i, j] if complement\n\n complements[el] = [el, i]\n end\n nil\nend", "def two_sum(nums, target)\n numbers_checked = {}\n\n nums.each do |num|\n other_part_of_pair = target - num\n if numbers_checked.has_key?(other_part_of_pair)\n return [nums.index(other_part_of_pair), nums.rindex(num)]\n else\n numbers_checked[num] = true\n end\n end\nend", "def two_sum(nums, target)\n h = {}\n nums.each_with_index do |a, i|\n n = target - a\n return [h[n], i] if h[n]\n h[a] = i\n end\nend", "def two_sum(nums, target)\n map = {}\n len = nums.length\n len.times do |i|\n complement = target - nums[i]\n if map.include? complement\n return [i, map[complement]]\n end\n map[nums[i]] = i\n end\n raise \"No solution !\"\nend", "def two_sum(nums, target)\n table = {}\n i = 0\n while i < nums.length\n table[target - nums[i]] = i\n i += 1\n end\n \n j = 0\n while j < nums.length\n if table.key?(nums[j]) && j != table[nums[j]]\n return [j, table[nums[j]]] \n end\n j += 1\n end\nend", "def two_sum(numbers, target)\n i = 0\n j = numbers.length - 1\n\n while i < j\n sum = numbers[i] + numbers[j]\n\n if target < sum\n j -= 1\n elsif target > sum\n i += 1\n else\n return [i + 1, j + 1]\n end\n end\nend", "def two_sum(array, target)\n num_hash = {}\n \n array.each_with_index do |num, index|\n difference = target - num\n if num_hash[difference]\n return [num_hash[difference], index]\n else\n num_hash[num] = index\n end\n end\nend", "def search_range(nums, target)\n emp = []\n if nums.include?(target)\n nums.each_with_index do |n,i|\n if n == target\n emp.push(i)\n end\n end\n\n emp.map {|n| [emp[0], emp[emp.length - 1]] }[0]\n\n else\n [-1,-1]\n end\nend", "def nums(target, *array)\n\tarray.each_with_index do |a, x|\n\t\tarray.each_with_index do |b, y|\n\t\t\tif x > y\n\t\t\t\tif a + b == target\n\t\t\t\t\treturn true\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\treturn false\nend", "def two_sum_indices(arr, target_sum)\n complements = {}\n arr.each_with_index do |el, i|\n complement, j = complements[target_sum - el] # these will both be nil if the complement doesn't exist\n return [i, j] if complement\n \n complements[el] = [el, i]\n end\n nil\nend", "def search_target(nums, target)\n return -1 if nums.empty? || !target\n start_ind = 0\n last_ind = nums.size - 1\n mid = (start_ind + last_ind) / 2\n\n #having condition as start_ind + 1 < last_ind will be helpful in find first/last position in function\n #also avoid infinite loop when the array only has two elements\n while start_ind + 1 < last_ind do \n mid = start_ind + (last_ind - start_ind) / 2\n if (nums[mid] == target)\n last_ind = mid\n elsif nums[mid] > target\n last_ind = mid\n else\n start_ind = mid\n end\n end\n\n #find first position\n #if we wanna find the last position, check last_ind first\n if nums[start_ind] == target\n return start_ind\n end\n\n if nums[last_ind] == target\n return last_ind\n end\n\n return -1\nend", "def one_pass_two_sum(array, target)\n hash = {}\n array.each.with_index do |i, index|\n complement = target - i\n if hash.has_key?(complement)\n return [hash.fetch(complement), index]\n end\n hash[i] = index\n end\nend", "def two_sum_indices?(arr, target_sum)\n summands = {}\n\n arr.each_with_index do |num, i|\n summand = target_sum - num\n return [target_sum[summand], i] if summands.key?(summand)\n\n summands[num] = i\n end\n\n false\nend", "def two_sum(numbers, target)\n low = 0\n high = numbers.size - 1\n\n until low == high\n sum = numbers[low] + numbers[high]\n case sum <=> target\n when 0\n return [low + 1, high + 1] # NOT zero-indexed!\n when 1 # sum > target\n high -= 1\n when -1 # sum < target\n low += 1\n end\n end\nend", "def two_sum_with_hash(nums, target)\n h = {}\n nums.each_with_index {|x, index| h[x] = index }\n nums.each_with_index do |row, index|\n diff = target - row\n if h.keys.include? diff and (not h[diff] == index)\n return index, h[diff]\n end\n end\nend", "def two_sum(numbers, target)\n n_index = {} \n (0...numbers.length).each do |i1|\n i2 = n_index[target - numbers[i1]]\n return [i1 + 1, i2 + 1].sort if i2 && i2 != i1 \n n_index[numbers[i1]] = i1\n end\nend", "def map_then_iterate_two_sum(array, target)\n hash = {}\n array.each.with_index do |i, index|\n hash[i] = index\n end\n indexes = []\n array.each.with_index do |ii, index|\n complement = target - ii \n if hash.has_key?(complement) && hash.fetch(complement) != index\n indexes.push(index, hash.fetch(complement))\n return indexes\n end\n end\nend", "def two_sum(numbers, target)\n hash={}\n numbers.each_with_index do |num,index|\n if(hash[num])\n return [hash[num], index+1]\n else\n hash[target-num] = index+1\n end\n end\nend", "def find_target(nums, target)\n return -1 if nums.empty? || !target\n start_ind = 0\n last_ind = nums.size - 1\n\n while (start_ind + 1 < last_ind) do\n mid = start_ind + (last_ind - start_ind) / 2\n\n if nums[mid] == target\n return mid\n end\n\n if nums[start_ind] < nums[mid]\n if nums[start_ind] <= target && target <= nums[mid]\n last_ind = mid\n else\n start_ind = mid\n end\n else\n if nums[mid] <= target && target <= nums[last_ind]\n start_ind = mid\n else\n last_ind = mid\n end\n end\n end\n\n return start_ind if nums[start_ind] == target\n return last_ind if nums[last_ind] == target\n return -1\nend", "def two_sum(nums, target)\n\n l,r = 0, nums.count-1\n\n results = []\n\n while l < r\n\n total = nums[l] + nums[r]\n if total == target\n results << [nums[l],nums[r]]\n l,r = l+1, r-1\n elsif total < target\n l += 1\n else\n r -= 1\n end\n end\n results\nend", "def find_target_sum_arrays(arr, target)\n helper(arr, target, arr.length - 1, [], 0)\nend", "def two_sum(nums, target)\n return 0 if !nums || nums.size < 2\n min = target\n left = 0\n right = nums.size - 1\n while left < right do \n diff = (nums[left] + nums[right] - target).abs\n min = [min, diff].min\n if nums[left] + nums[right] < target\n left += 1\n else\n right -= 1\n end\n end\n min\nend", "def two_sum_3(nums, target)\n len = nums.length\n hash = {}\n\n for i in (0...len)\n elt = nums[i]\n diff = target - elt\n # check to see if diff is in the hash; if so we found 2 numbers that add up to sum, that is diff and elt\n if hash[diff]\n index1 = nums.index(diff)\n puts \"index1=#{index1+1}, index2=#{i+1}\"\n return\n else\n hash[elt] = 1 # add the key elt to the hash\n end\n end\nend", "def two_sum(integers, target) \n checked = {}\n integers.each.with_index do |num, idx|\n diff = target - num\n checked[diff] ? (return true) : (checked[num] = idx)\n end\n false\nend", "def search(nums, target)\n nums.each_with_index do |num, index|\n return index if num == target\n end\n -1\nend", "def two_sum(array, target)\n found = Hash.new(false)\n goal = nil\n\n array.each do |el|\n goal = (target - el).abs\n return true if found[goal] && goal + el == target\n found[el] = true\n end\n\n false\nend", "def pair_sum(arr, target)\n # basic approach is nested loops scanning each element checking if its == to target\n result = []\n i = 0\n j = i + 1\n while i < arr.length\n while j < arr.length\n p i, j\n if i != j && arr[i] + arr[j] == target\n result << [i, j]\n end\n j += 1\n end\n i += 1\n j = i + 1\n end\n result\nend", "def sum_pairs(nums, target)\n results = []\n if nums.count < 2\n return results\n end\n nums.sort!\n (0..(nums.length - 2)).each do |first_index|\n second_index = first_index + 1\n until second_index == nums.length\n sum = nums[first_index] + nums[second_index]\n if sum == target\n results << [nums[first_index], nums[second_index]].sort\n end\n second_index += 1\n end\n end\n results.sort\nend", "def find_triplets(target)\n @nums.each do |num, occ|\n pair = find_pairs(target - num)\n return num * pair if pair != -1\n end\n end", "def two_sum(numbers, target)\n ##set hash\n hash = {}\n ##set array\n arr = []\n\n numbers.each_with_index do |val, idx|\n if hash.key?(target - val)\n arr.push(hash[target - val])\n arr.push(idx + 1)\n break\n else\n hash[val] = idx + 1\n end\n end\n\n arr\nend", "def two_sum_2_pointers(numbers, target)\n l_pointer = 0\n r_pointer = numbers.size - 1\n\n while l_pointer < r_pointer\n sum = numbers[l_pointer] + numbers[r_pointer]\n\n if sum < target\n l_pointer += 1\n elsif sum > target\n r_pointer -= 1\n else\n return [l_pointer + 1, r_pointer + 1]\n end\n end\n\n raise ArgumentError.new(\"No two sum solution\")\nend", "def okay_two_sum?(arr, target)\n sorted = quick_sort(arr)\n\n arr.each_with_index do |el, idx|\n p current = target - el\n bruh = bsearch(arr, current)\n next if bruh == idx\n return true unless bruh.nil?\n end\n\n return false\nend", "def bad_two_sum?(arr, target)\n sums = []\n arr.each_index do |i|\n (i+1...arr.length).each do |j|\n sums << arr[i] + arr[j]\n end\n end\n sums.include?(target)\nend", "def sum_pair(list, target)\n list.each do |a|\n list.each do |b|\n if a + b == target and list.index(a) != list.index(b)\n return [a, b]\n end\n end\n end\nend", "def search_range(nums, target)\n left = search(target, nums, :left)\n return [-1, -1] if left == nums.size || target != nums[left]\n [left, search(target + 1, nums, :right) - 1]\nend", "def two_sum(nums, target)\n\n numsSearch = {}\n nums.each_with_index do |value, index|\n ### Storing the value as index of hash\n second_value = numsSearch[target - value]\n\n ### checking if hash return value\n if second_value != nil\n return [second_value, index]\n end\n\n ### inserting the value as index and index as value in hash map\n numsSearch[value] = index\n end\n\n return []\nend", "def two_sum(nums, target)\n return 0 if !nums || nums.size < 2\n nums = nums.sort\n count = 0\n left = 0\n right = nums.size - 1\n while left < right do \n if nums[left] + nums[right] <= target\n count += right - left\n left += 1\n else\n right -= 1\n end\n end\n count\nend", "def two_sum?(arr, target)\n h = Hash.new\n arr.each_with_index do |val, i|\n h[val] = i\n end\n\n arr.each_index do |i|\n to_find = target - arr[i]\n return true if h[to_find] && h[to_find] != i\n end\n false\nend", "def two_sum?(arr, target)\n s1 = Set.new \n arr.each_with_index do |el, idx|\n return true if s1.include?(target-el)\n s1.add(el)\n end\n false\nend", "def okay_two_sum?(arr, target)\n arr.each_with_index do |el,idx|\n if bi_search(arr[idx+1..-1], target, el)\n return true\n end\n end\n false\nend", "def two_sum(arr, target) \n hash = {}\n \n i = 0\n for val in arr do\n val1 = arr[i]\n val2 = target - val1 \n if hash[val2] \n return [hash[val2], i]\n else\n hash[val1] = i \n end\n i += 1\n end\n\n nil \nend", "def okay_two_sum(arr, target)\n #O(n)\n arr.sort!\n i = 0\n j = arr.length - 1\n while i < j\n sum = arr[i] + arr[j]\n return true if sum == target\n if sum < target\n i += 1\n else\n j -= 1\n end\n end\n false\nend", "def okay_two_sum?(arr, target)\n arr = arr.sort\n arr.each_index do |i|\n to_find = target - arr[i]\n sub_arr = arr[0...i] + arr[i + 1..-1]\n return true if sub_arr.bsearch { |x| x == to_find }\n end\n false\nend", "def okay_two_sum?(arr, target)\n sorted_arr = arr.sort\n sorted_arr.each.with_index do |el, idx|\n target_pair = target - el\n if sorted_arr[idx+1..-1].bsearch{|n| n >= target_pair } == target_pair\n p target_pair\n return true\n end\n end\n false\nend", "def solve(nums)\n arr = nums.map {|num| num * num}\n arr.each_with_index do |el1, idx1|\n arr.each_with_index do |el2, idx2|\n if idx2 > idx1\n if arr.include?(el1 + el2)\n if (arr.index(el1 + el2) != idx1) && (arr.index(el1 + el2) != idx2)\n return true\n end\n end\n end\n end\n end\n false\nend", "def two_sum(nums, target)\n pointer1 = 0\n pointer2 = 1\n while (nums[pointer1] + nums[pointer2] != target)\n if nums[pointer1] + nums[pointer2] < target \n pointer1 += 1\n pointer2 += 1\n else \n pointer1 -= 1\n end \n end \n return [pointer1, pointer2]\nend", "def ok_two_sum(arr, target)\n sorted = quick_sort(arr)\n\n arr.each do |el|\n b_target = target - el\n return true if b_search(arr, b_target)\n end\n false\nend", "def okay_two_sum?(arr, target)\n arr.sort!\n\n arr.select! { |el| el < target }\n\n arr.each { |el| arr.include?(target - el) ? (return true) : next }\n false\nend", "def two_sum(array, target)\n\n !!array.uniq.combination(2).detect { |a, b| a + b == target }\nend", "def okay_two_sum?(arr, target)\n\n arr.each do |ele1| # O(n)\n # debugger\n found = arr.bsearch do |ele2|\n # debugger\n (target - ele1) == ele2\n end\n return true unless found.nil? || arr.index(found) == arr.index(ele1)\n end\n false\nend", "def okay_two_sum(arr, target)\n sorted = arr.sort\n sorted.each do |el|\n diff = target - el\n v = sorted.bsearch { |x| x == diff }\n return true unless v.nil?\n end\n \n false\nend", "def sorting_two_sum(array, target)\n arr = array.sort\n arr.each_with_index do |int, idx|\n search_array = array[0...idx] + array[(idx + 1)..-1]\n return true if search_array.bsearch { |x| x == target - int }\n end\n false\nend", "def okay_two_sums?(arr, target)\n arr.sort!\n\n arr.each do |num|\n return true if b_search?(arr, (target - num))\n end\n false\nend", "def good_two_sum?(arr, target)\n input_hash = Hash.new\n \n arr.each.with_index do |el, i|\n input_hash[el]=i\n end\n arr.each.with_index do |el, i|\n var = input_hash[target - el]\n return true if var && var !=i\n end\n false\nend", "def two_sum(nums)\n\n\t#option 1\n\n\t#Every index, add with other number\n\t\t#downfall -> n^2\n\n\t#Check first to last, like a palindrome (this won't work)\n\n\t#quick sort, add numbers up to 0\n\n\t#Every Index, add with other number\n\t\t#Iterate through array\n\t\tnums.each_with_index do |number, index|\n\t\t#iterate array with each individual number\n\t\t\tnums.each_with_index do |second_number, second_index|\n\t\t\t\t#skip if it is the same number\n\t\t\t\tnext if index == second_index\n\n\t\t\t\t#if there is a match, return starting & current index\n\t\t\t\tif (number + second_number == 0)\n\t\t\t\t\treturn [index, second_index]\n\t\t\t\tend\n\n\t\t\tend\n\n\t\tend\n\t\t#if there is no match, return nil (iterate through)\n\n\t\tnil\n\nend", "def okay_two_sum?(arr,target)\n ans = arr.sort #O(nlogn)\n\n ans.each do |ele|\n temp = ans.shift\n dif = target-temp\n return true if bsearch(arr,dif) == true\n end\n false\nend", "def bad_two_sum?(arr, target)\n found = false\n arr.each_with_index do |a, l|\n arr.each_with_index do |b, n|\n next if l == n\n found = true if arr[l] + arr[n] == target\n end\n end\n found\nend", "def two_sum_hash(numbers, target)\n n_index = {} \n (0...numbers.length).each do |i2|\n i1 = n_index[target - numbers[i2]] \n\n # We know that n[i2] > n[i1] because input array is sorted.\n return [i1 + 1, i2 + 1] if i1 && i1 != i2\n n_index[numbers[i2]] = i2\n end\nend" ]
[ "0.8469521", "0.8345762", "0.8170959", "0.8127601", "0.8094328", "0.8083254", "0.8068672", "0.80654836", "0.8061751", "0.80270284", "0.802096", "0.8012801", "0.79951936", "0.7922442", "0.7844856", "0.78387135", "0.78380305", "0.7817525", "0.7815674", "0.7802654", "0.7791424", "0.7780444", "0.7763385", "0.7725928", "0.77171195", "0.7715732", "0.7713154", "0.7706508", "0.7676885", "0.76442057", "0.76175386", "0.7575865", "0.75542676", "0.7545602", "0.74999684", "0.749063", "0.74890167", "0.7479284", "0.74781746", "0.7474573", "0.74630874", "0.7460523", "0.7447807", "0.74386585", "0.7436482", "0.7420249", "0.7411718", "0.7410106", "0.7404649", "0.73994136", "0.7398929", "0.7389125", "0.7377219", "0.73732346", "0.7345446", "0.73257005", "0.7322157", "0.7306099", "0.73059386", "0.7305203", "0.72894377", "0.7274274", "0.7273139", "0.72183746", "0.721659", "0.7205221", "0.719852", "0.7196354", "0.7193152", "0.71888137", "0.718335", "0.71816045", "0.71389484", "0.7132377", "0.71180505", "0.70753145", "0.7059304", "0.7047728", "0.7043749", "0.70425713", "0.70409316", "0.70407164", "0.70270437", "0.70242435", "0.70113605", "0.70010996", "0.6999558", "0.6996994", "0.6984944", "0.69743633", "0.6967165", "0.69666624", "0.69594735", "0.6949438", "0.69390965", "0.693665", "0.6932943", "0.69186664", "0.6918205", "0.6916111" ]
0.8027025
10
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this in place with constant memory. For example, Given input array nums = [1,1,2], Your function should return length = 2, with the first two elements of nums being 1 and 2 respectively. It doesn't matter what you leave beyond the new length.
def remove_duplicates(nums) puts nums.uniq.length end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_duplicates(array)\n array.uniq!.length\nend", "def remove_duplicates(nums)\n nums.uniq!\n return nums.length\nend", "def remove_duplicates(nums)\n \n return nums.length if nums.length <= 2\n prevNum = nums[0]\n i = 1\n arrLength = 1\n dupCount = 1\n while i<nums.length do\n if nums[i] == prevNum && dupCount < 2\n dupCount = dupCount + 1\n arrLength = arrLength + 1\n elsif nums[i] != prevNum\n prevNum = nums[i]\n dupCount = 1\n arrLength = arrLength + 1\n end\n i = i + 1\n end\n \n puts(arrLength)\n \nend", "def remove_duplicates(nums)\n counter = 0\n original_length = nums.length\n\n (1...nums.length).each do |i|\n if nums[i-1] == nums[i]\n counter += 1\n else\n nums[i-counter] = nums[i]\n end\n end\n\n return original_length - counter\nend", "def remove_duplicates(nums)\n counter = 0 # Establish a counter variable to keep track of the amount of duplicates\n original_length = nums.length # Hold a reference to the original length of the array because the array without duplicates will have less elements\n\n (1...nums.length).each do |i| # Iterate through the elements; there's no need to go to the end, where we'd end up with nil values since the value of the length of the array is going to hold an index out of bounds\n if nums[i-1] == nums[i] # Check to see if the element behind the current element and the current element are equivalent/duplicates\n counter += 1 # We only need to increment the counter because we've found a duplicate; nothing more and nothing less\n else\n nums[i-counter] = nums[i] # If two numbers are different from each other, push the current element as far back as the position of the last duplicated element; the streak of duplicates has ended and we've found a solo element; remember the arrays are sorted\n end\n end\n\n return original_length - counter # Return the new length by subtracting the amount of duplicates the array contained from the original_length\nend", "def remove_duplicates(nums)\n return nums.length if nums.length < 2\n i = 1\n length = 1\n\n while !nums[i].nil?\n if nums[i-1] == nums[i]\n nums.delete_at(i)\n i -= 1\n else \n length += 1\n end \n i += 1\n end \n length \nend", "def remove_duplicates(nums)\n #提供的array為已經排序過的array\n #將重複的移除,使陣列中每個元素都不重複\n #右邊元素=左邊元素時,全部往左移\n #將左移過後多出來的元素設為nil\n #刪除nil元素用 陣列.delete(nil)\n #回傳新陣列長度\n \n i = 0\n j = 0\n k = 0\n\n numssize = nums.size\n\n while i < (numssize - j)\n nums[i] = nums[ i + j ]\n if nums[i] == nums[i + j +1]\n j += 1\n while nums[i + j] == nums[i + j +1]\n j += 1\n end\n nums[i + j] = nums[ i + j + 1]\n end\n i += 1\n end\n\n for k in (numssize - j)...numssize\n nums[k] = nil \n end\n\n nums.delete(nil)\n\n newsize = nums.size\nend", "def remove_duplicates(nums)\n record_leng = 0\n uniq_arr = nums.uniq\n uniq_arr.each do |i|\n record_leng += 1 if count_great_two?(nums, i)\n end\n return (record_leng + uniq_arr.size)\nend", "def remove_duplicates(nums)\n size, cursor = 0, 0\n while cursor < nums.size # iterating through each number in nums starting from the first number at index 0.\n num = nums[cursor] # as I iterate through each number, I will assign it to a variable called \"num\", i.e \"num\" will be constantly rewritten to the value that I am currently at as I iterate through the numbers.\n cursor += 1 # so that I can iterate.\n while nums[cursor] == num # if the duplicates are next to each other\n cursor += 1 # I iterate to the next number.\n end\n nums[size] = num # use num(which exclude the duplicates) again and assign it to nums[size] (which is the actual number). this step is just a checker so that the next step (size += 1) will be accurate, it is not actually removing the duplicates inline, i.e return nums will not give you the array without duplicates.\n size += 1 # After filtering out the duplicates, increase the counter by 1 every time we move on to another number.\n end\n return size\nend", "def uniq(array)\n counts = Hash.new(0)\n result = []\n array.each do |element|\n counts[element] += 1\n result << element unless counts[element] > 1\n end\n result\nend", "def remove_duplicates(nums)\n prev = nil\n count = 0\n nums.each do |num|\n if num == prev\n next\n else\n nums[count] = num\n prev = num\n count+=1\n end\n end\n\n return count\nend", "def find_unique_elements(arr)\n# Count how many times each element appears in the array, if an element appears\n# more than once, delete that element and any elements that are equal to it.\n \n arr.each do |i|\n\tif arr.count(i) > 1\n\t\tarr.delete(i)\n\tend\n end\n return arr\nend", "def numUnique2(array)\n uniq_length = 0\n for i in 0...array.length\n if array[i+1] != array[i]\n uniq_length += 1\n end\n end\n return uniq_length\nend", "def solution(a)\n # In production environment this will be my solution:\n # a.uniq.size\n #\n # But since this is a coding challenge, my assumption\n # is that you're looking for a by-hand O(N*logN) solution\n\n return 0 if a.empty?\n\n n = a.size\n ary = a.sort\n uniques = 1\n (1...n).each do |i|\n uniques += 1 if ary[i] != ary[i - 1]\n end\n uniques\nend", "def remove_duplicates(nums)\n nums_size, cursor = 0, 0\n\n while cursor < nums.size\n num = nums[cursor]\n cursor += 1\n while nums[cursor] == num\n cursor += 1\n end\n\n nums[nums_size] = num; nums_size += 1\n end\n\n nums_size\nend", "def uniq(arr)\n new_array = []\n arr = arr.sort\n arr.each_with_index do |num, idx|\n new_array << num if num != arr[idx + 1]\n end\n new_array\nend", "def nondupes(array)\n new_array = []\n array.each do |elem| \n if array.count(elem) == 1\n new_array << elem \n end\n end\n new_array\nend", "def remove_duplicates(nums)\n return 0 if nums.length == 0\n write = 0\n read = 1\n\n while read < nums.length\n if nums[write] != nums[read]\n write += 1\n nums[write] = nums[read]\n end\n read += 1\n end\n\n write + 1\nend", "def remove_duplicates(nums)\n return 0 if nums.length === 0\n\n curr_idx = 0\n j = 0\n val = nums[j]\n\n while curr_idx < nums.length\n curr_val = nums[curr_idx]\n if curr_val === val\n curr_idx += 1\n next\n else\n val = curr_val\n j += 1\n nums[j] = curr_val\n end\n end\n\n j + 1\nend", "def DistinctList(arr)\n\n return arr.size - arr.uniq.size\n \nend", "def remove_dup(given_array, duplicate_count)\r\n counter = 0\r\n new_array = []\r\n hold_info = {}\r\n until counter >= given_array.length \r\n if hold_info[given_array[counter]].nil?\r\n hold_info[given_array[counter]] = 1 \r\n else\r\n hold_info[given_array[counter]] += 1\r\n end\r\n counter += 1\r\n end\r\n duplicates_array = hold_info.select{ |key, value| value == duplicate_count}\r\n new_array = given_array.clone\r\n duplicates_array.each {|key,value| new_array.delete(key)} # delete all the duplicate numbers from the array\r\n p new_array.sort\r\nend", "def find_unique_elements(arr)\n \n#Algorithmic Process\n#Create an array that includes elements without the repeats\n#Create a hash that pairs each element of the new array with how many times it appears in the original array\n#Any key-value pair that has 1 for a value is unique and gets placed in the desired array\n \nnew_hash = {}\narr.each do |x|\n new_hash[x] = 0 if new_hash[x].nil?\n new_hash[x] = new_hash[x] + 1\nend\n\nnew_hash.delete_if {|key, value| value != 1}\nnew_hash.each_key {|key| puts key}\n\nend", "def numUnique(array)\n uniq_nums = {}\n if array.length == 0\n uniq_nums = {}\n end\n for i in 0...array.length\n uniq_nums[array[i]] = true\n end\n return uniq_nums.keys.length\nend", "def min_unique(arr)\n arr.sort! #[1,2,2,3,7]\n uniq = []\n dups = []\n (arr.length ).times do |i|\n if arr[i] == arr[i+1]\n dups << arr[i]\n else \n uniq << arr[i]\n end \n end \n\n dups.each do |el|\n while uniq.include?(el)\n el+=1\n end \n uniq << el\n p uniq\n end \n p uniq.reduce(:+)\nend", "def remove_duplicates(array)\nend", "def remove_duplicates_two(nums)\n return 0 if nums.empty?\n i = 0\n j = 1\n while j < nums.length\n if nums[i] != nums[j]\n i += 1\n nums[i] = nums[j]\n end\n j += 1\n end\n print nums\n i+1\nend", "def dupe(array)\n n = array.length - 1\n sum = ((n * n) + n) / 2\n return array.reduce(&:+) - sum\n # array.each_with_object({}) { |i,o| o[i.to_s] ? o[i.to_s] += 1 : o[i.to_s] = 1 }.keep_if { |k,v| v > 1 }.to_a[0][0].to_i\nend", "def remove_duplicates(nums)\n beginning_index = nil\n \n nums.each_with_index do |num, index|\n next if index == 0\n \n if num == nums[index - 1] \n nums[index - 1] = nil\n end\n end\n \n nums.compact!\n \n nums.count\nend", "def no_dupes?(array)\n hash = Hash.new(0)\n array.each do |ele|\n hash[ele] += 1\n end\n new_array = []\n hash.each do |k, v|\n new_array << k if v == 1\n end\n return new_array\nend", "def remove_duplicates(nums)\n\n non_dupe_index = 0\n nums.each do |num|\n if (non_dupe_index == 0 || num > nums[non_dupe_index - 1])\n nums[non_dupe_index] = num\n non_dupe_index += 1\n end\n end\n nums.replace(nums)\n non_dupe_index\n\nend", "def my_uniq(arr)\n counter = Hash.new(0)\n arr.each do |x|\n counter[x] += 1\n end\n counter.keys\nend", "def my_uniq(arr)\n hashed = arr.map {|value| [value, arr.count(value)]}.flatten\n return Hash[*hashed].keys\nend", "def unique_elements(array)\n hash = Hash.new(0)\n array.each { |ele| hash[ele] += 1 }\n\n hash.keys\nend", "def duplicates(array)\n frequency = Hash.new(0)\n array.each do |element|\n frequency[element] += 1\n end\n frequency.each do |k, v|\n return k if v > 1\n end\nend", "def remove_duplicates(nums)\n return 0 if nums.empty?\n cur = nums.first\n primary = 1\n nums.each_with_index do |num, _idx|\n next if num == cur\n nums[primary] = num\n cur = num\n primary += 1\n end\n primary\nend", "def my_uniq(arr)\n hsh = Hash.new(0)\n arr.each do |el|\n hsh[el] += 1\n end\n hsh.keys\nend", "def solution(a)\n a.uniq.count\nend", "def no_dupes?(arr)\n new_hash = Hash.new(0)\n new_arr = []\n\n arr.each do |x|\n new_hash[x] += 1\n end\n\n new_hash.each do |k,v|\n if v == 1\n new_arr << k\n end\n end\n new_arr\nend", "def unique(arr)\n uniq = Hash.new(0)\n arr.each { |x| uniq[x] += 1 }\n uniq.select { |k, v| v == 1 }.keys\nend", "def find_dup(array)\n # 17 - (1 + 2 + 3 + 4 + 5) = 2 --- total in this array minus total if there were no dupes\n array.reduce(&:+) - (1..(array.length - 1)).reduce(&:+)\nend", "def duplicates_subarray3(arr)\n arr.uniq.map { |elm| [elm] * arr.count(elm)}.sort_by {|subarr| subarr[0].ord }\nend", "def remove_dups(arr)\n\treturn arr.uniq()\nend", "def unique_elements(arr)\n hash = Hash.new(0)\n arr.each { |ele| hash[ele] += 1}\n hash.keys\nend", "def numUnique(array)\n\n uniques = {}\n counter = 0\n\n for element in array\n if uniques[element]\n uniques[element] = uniques[element] + 1\n else\n uniques[element] = 1\n end\n end\n\n count_uniques = 0\n\n for element in uniques\n count_uniques += 1\n end\n\n return count_uniques\n\nend", "def my_uniq(arr)\n count = Hash.new(0)\n arr.each {|ele| count[ele]+= 1}\n count.keys\nend", "def num_duplicates\n count = 0\n nums = Hash.new(0)\n @array.each do |num|\n nums[num] += 1\n count += 1 if nums[num] > 1\n end\n count\nend", "def array_unique(array = [])\n raise 'incorrect array' unless array.is_a? Array\n\n uniq_values = []\n array.each do |el|\n unique_counter = 0\n array.each do |e|\n next if el != e\n\n unique_counter += 1\n end\n uniq_values << el if unique_counter == 1\n end\n uniq_values\nend", "def unique_elements(arr)\n hash = Hash.new(0)\n arr.each {|el| hash[el] += 1}\n return hash.keys\n\nend", "def num_unique2(arr)\n count = 0\n new_number = nil\n arr.each do |number|\n if new_number != number\n new_number = number\n count += 1\n end\n end\n return count\n end", "def my_uniq(arr)\n #make hash with each item in teh array as a key, and the value will be its frequency\n new_arr = []\n freqhash = Hash.new(0)\n arr.each do |ele| \n freqhash[ele] += 1\n end\n \n freqhash.each do |k, v| \n new_arr << k\n end\n \n new_arr\nend", "def dupe_indices(arr)\n idxs = Hash.new { |h, k| h[k] = [] }\n \n arr.each_with_index do |ele, i|\n idxs[ele] << i\n end\n\n return idxs.select { |ele, arr| arr.length > 1 }\nend", "def find_duplicate(arr)\n\tarr.select{|e| arr.count(e) > 1}.uniq\nend", "def no_dupes?(arr)\n dupes = Hash.new(0)\n\n arr.each do |ele|\n dupes[ele] += 1\n end\n\n new_arr = []\n dupes.each do |k, v|\n if v == 1\n new_arr << k\n end\n end\n\n new_arr\nend", "def find_unique_elements(arr)\n arr_fin=[]\n arr.each do |x|\n arr.count(x)\n if arr.count(x)==1\n arr_fin << x\n end\n end\n return arr_fin\nend", "def hasDupes(a)\n return a.uniq.length == a.length\nend", "def unique_elements(arr)\n my_hash = Hash.new(0)\n arr.each do |element|\n my_hash[element] += 1\n end\n return my_hash.keys\nend", "def no_dupes?(arr)\n count = Hash.new(0)\n\n arr.each { |ele| count[ele] += 1 }\n\n array = []\n count.each { |k, v| array << k if v == 1 }\n\n array\nend", "def just_once(original_array)\n unique = []\n i = 0\n while i < original_array.length\n unique.push(original_array[i]) unless unique.include?(original_array[i])\n i += 1\n end\n return unique\n end", "def duplicate(array)\n array.uniq!\nend", "def find_duplicate_space(nums)\n # sort nums first (lgn), then check for dups by iterate over (n)\n last_seen = 0\n nums.sort!.each do |num|\n return num if last_seen == num\n last_seen = num\n end\nend", "def nondupes(array)\n array.map do |elem| \n array.count(elem) == 1\n \n end\n \nend", "def no_dupes?(arr)\n solved = Hash.new(0)\n arr.each { |ele| solved[ele] += 1 }\n solved.keys.select { |ele| solved[ele] == 1 }\nend", "def non_duplicated_values(array)\n count = Hash.new(0)\n u_num = []\n array.each {|x| count[x] += 1}\n count.each do |k, v|\n if v == 1\n u_num.push(k)\n end\n end\n\n u_num\nend", "def find_unique_elements(arr)\n arr.reject { |e| arr.count(e) > 1 }\nend", "def no_dupes?(arr)\n count = Hash.new(0)\n arr.each { |el| count[el] += 1 }\n count.keys.select { |el| count[el] == 1 }\nend", "def no_dupes?(arr)\n counts = Hash.new(0)\n arr.each do |e|\n counts[e] += 1\n end\n counts.select {|k,v| v <= 1}.keys\nend", "def unique_items(arr) #O(n)\n hash = Hash.new(0)\n results = []\n arr.each do |el|\n hash[el] += 1\n end\n hash.select { |k, v| k if v == 1 }.keys\nend", "def uniq(array)\n finalArray = []\n array.each do |element|\n if !finalArray.include?(element)\n finalArray.push(element)\n end\n end\n return finalArray\nend", "def remove_duplicates(array)\n uniq_array = []\n array.each {|value| uniq_array << value unless uniq_array.include?(value) }\n return uniq_array\nend", "def unique_elements(arr)\n\n # hash count -> duplicate removed -> return a new array\n new = []\n\n # count = Hash.new(0) # create {} with default value 0\n arr.each do |ele|\n if !new.include?(ele)\n new << ele\n end\n end\n # print count # {\"a\"=>3, \"b\"=>2, \"c\"=>1}\n\n return new \nend", "def uniqify(array)\n encountered = Hash.new { |hash, key| hash[key] = false }\n uniqified_array = []\n array.each do |element|\n uniqified_array.push(element) unless encountered[element]\n encountered[element] = true\n end\n uniqified_array\nend", "def find_dup(arr)\n arr.select { |i| arr.count(i) == 2 }.uniq.join.to_i\nend", "def equalizeArray(arr)\n arr = arr.sort\n count = 0; j = 0\n for i in 0..(arr.length-1)\n if arr[j] != arr[i]\n j += 1\n count+=1\n end\n end\n count\nend", "def no_dupes?(arr)\n counter = Hash.new(0)\n arr.each { |ele| counter[ele] +=1 }\n \n # new_array = []\n # counter.each do |k,v|\n # new_array << k if v == 1\n # end\n # new_array\n counter.keys.select { |el| counter[el] == 1 }\nend", "def remove_dups(arr)\n new_arr = []\n arr.each do |x|\n unless new_arr.include? x\n new_arr.push x\n end\n end\n new_arr\nend", "def move_duplicates(a)\n\n n = a.length\n\n h = Hash.new\n\n if a.length < 1\n return nil\n end\n\n if a.length < 2\n return a\n end\n\n dup_arr = []\n\n (0..n-1).each do |i|\n if h[a[i]]\n h[a[i]] = h[a[i]] + 1\n else\n h[a[i]] = 1\n end\n end\n\n h.each do |key,val|\n\n if h[key] > 1\n dup_arr.push(key)\n end\n end\n\n return dup_arr\n\n\nend", "def unique_number(arr)\n arr.uniq.find { |e| arr.count(e) == 1 }\nend", "def find_unique_elements(arr)\n\tcounts = Hash.new 0\n\tarr.each do |ele|\n\t\tcounts[ele] += 1\n\tend\n\t\n\tcounts.delete_if {|key, value| value > 1 }\n\tresult = counts.keys #Array returned with keys for non-dupe values\n\treturn result\nend", "def duplicates(arr)\n values = Set.new\n copies = Set.new\n\n arr.each do |value|\n if values.include?(value)\n copies << value\n else\n values << value\n end\n end\n\n return copies\nend", "def find_dup(arr)\n arr.select { |num| arr.count(num) == 2 }.uniq.join.to_i\nend", "def unique(array)\n unique_array = []\n\n array.each do |original_element|\n found = false\n\n unique_array.each do |unique_element|\n if original_element == unique_element\n found = true\n break\n end\n end\n\n if !found\n unique_array << original_element\n end\n end\n\n unique_array\nend", "def duplicate_elements?(arr)\n arr.uniq.length != arr.length\nend", "def no_dupes?(arr)\n count_hash = Hash.new(0)\n non_dupes = []\n\n arr.each { |ele| count_hash[ele] += 1 }\n\n count_hash.each do |key, val|\n non_dupes << key if val == 1\n end\n\n non_dupes\nend", "def remove_duplicates(list)\n if list.length < 2\n return list\n else\n i = 0\n list.each do |num|\n if num == list[(i+1)]\n list.delete_at(i)\n end\n i += 1\n end\n return list\n end\nend", "def no_dupes?(arr)\n hash = Hash.new(0)\n arr.each do |ele|\n hash[ele] += 1\n end\n #can use the select method\n # hash.keys.select {|ele| hash[ele] == 1}\n new = []\n hash.each do |k, v|\n new << k if v == 1\n end\n new\n #another way to do it is sort and if there are adjacent pairs\n # we know that it is not a unique pair\nend", "def find_unique_elements(arr)\n arr_unique = []\n arr.each do |elem1|\n var1 = 0\n arr.each do |elem2|\n if elem1 == elem2\n var1 = var1 + 1\n end\n end\n if var1 <= 1\n arr_unique.push(elem1)\n end\n end\nend", "def remove_duplicates(arr)\n (arr.length - 1).times do |i|\n next if arr[i] != arr[i+1]\n arr.delete_at(i)\n end \n p arr \nend", "def ruby_unique(original_array)\n array.uniq\nend", "def using_uniq (array)\n return array.uniq!\nend", "def using_uniq(array)\n \n array.uniq\n \nend", "def solution(array)\n result = Array.new(array.length, 0)\n\n array.each do |element|\n if result[element - 1]\n result[element - 1] += 1\n else\n result[element - 1] = 1\n end\n end\n\n result.uniq.size == 1 ? 1 : 0\nend", "def find_duplicates(array)\n result_hash = {}\n result_array = []\n\n array.each do |num|\n if result_hash[num].nil?\n result_hash[num] = 1\n else\n result_hash[num] += 1\n end\n end\n\n result_hash.each do |k, v|\n result_array.push(k) if v > 1\n end\n\n result_array\nend", "def unique(arr,i=0,j=1)\r\n\r\n unless i + 1 === arr.length #index i has not reached the end of array and has more elements left to check for duplicates\r\n \r\n if i < arr.length - j #there are items in array past index i that could be a duplicate of item at index i\r\n\r\n if arr[i] === arr[-j] #item at index i has a duplicate at index -j\r\n \r\n arr.delete_at(-j) #destroy duplicate of index i at index -j\r\n unique(arr,i,j) #call again with duplicate removed\r\n \r\n else #item at index i does not have a duplicate item at index -j\r\n unique(arr,i,j + 1) # call again incrementing index j by 1 so next item can be check for duplicity\r\n end\r\n\r\n else #there are no more items past i to check\r\n unique(arr,i + 1, 1) # increment index i by 1, reset index j for next round of item at index i for duplicates\r\n end\r\n\r\n else #index i has reached end of array, or array length is 1 or 0\r\n return arr #duplicate checking complete, return filtered array.\r\n end\r\n\r\nend", "def duplicate(array)\n if array.uniq.length == array.length\n return \"array doesn't have any duplicates homey\"\n else\n arycpy = array\n while arycpy != nil do \n y = arycpy.pop\n if arycpy.include? y\n return y\n end\n end\n end\nend", "def duplicates_subarray2(arr)\n arr_srt = arr.sort {|a, b| a.ord <=> b.ord}\n new_arr = [[arr_srt[0]]]\n arr_srt.each_with_index do |elm, idx|\n next if idx == 0\n if new_arr[-1].include? elm\n new_arr[-1] << elm\n else\n new_arr << [elm]\n end\n end\n new_arr\nend", "def my_uniq(arr)\n answer = Hash.new\n arr.each_with_index do |el, i|\n answer[el] = 1\n end\n answer.keys\nend", "def find_dup(array)\n for elem in array\n return elem if array.count(elem) == 2\n end\nend", "def using_uniq(array)\n array.uniq()\nend", "def using_uniq(array)\n array.uniq\nend", "def using_uniq(array)\n array.uniq\nend" ]
[ "0.81445193", "0.8112996", "0.80812114", "0.79461664", "0.79412156", "0.777696", "0.7505186", "0.7496743", "0.748819", "0.7428481", "0.73848355", "0.7253261", "0.7252629", "0.72295797", "0.72220105", "0.71497345", "0.7133866", "0.70874065", "0.7063284", "0.7038074", "0.69907635", "0.6986815", "0.6964113", "0.6959157", "0.69522214", "0.69458795", "0.69405335", "0.69015265", "0.68997955", "0.68927956", "0.68526167", "0.6844522", "0.68417704", "0.68334335", "0.6822723", "0.6813895", "0.6808338", "0.67950934", "0.67915225", "0.67710805", "0.67682004", "0.67625064", "0.67541873", "0.67500573", "0.67477816", "0.6746624", "0.67361206", "0.67356783", "0.6724819", "0.67025405", "0.67002183", "0.6686404", "0.6675246", "0.66726124", "0.6668749", "0.6666762", "0.66649103", "0.66623926", "0.66595894", "0.6643186", "0.66366106", "0.6631319", "0.66263366", "0.6623543", "0.66180533", "0.66177833", "0.6603941", "0.6600959", "0.65969306", "0.6585954", "0.65794086", "0.6571393", "0.65688866", "0.65671164", "0.65655404", "0.6552866", "0.6524938", "0.652133", "0.6514154", "0.6512603", "0.6504217", "0.6475726", "0.64666027", "0.6455061", "0.64443856", "0.6440699", "0.64398533", "0.64381665", "0.6433537", "0.6432182", "0.6417231", "0.64146537", "0.64069235", "0.6397944", "0.6396086", "0.6388359", "0.6385844", "0.6381853", "0.6379944", "0.6379944" ]
0.79134953
5
GET /Usuarios GET /Usuarios.xml
def index #@usuarios = Usuario.all #page = params[:page] || 1 @usuarios = Usuario.paginate(:page => @page) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @usuarios } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @usuarios = Usuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @usuarios }\n end\n end", "def consultar\n @usuario = Usuario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @usuario }\n end\n end", "def show\n @usuario = Usuario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @usuario }\n end\n end", "def show\n @usuario = Usuario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @usuario }\n end\n end", "def show\n @usuario = Usuario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @usuario }\n end\n end", "def show\n @usuario = Usuario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @usuario }\n end\n end", "def show\n @usuario = Usuario.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @usuario }\n end\n end", "def index\n @users = User.all\n render :xml => @users\n end", "def me\n users(request(\"users/authenticate.xml\", :auth => true))\n end", "def index\n @users = LinkedData::Client::Models::User.all\n respond_to do |format|\n format.html\n format.xml { render xml: @users.to_xml }\n end\n end", "def index\n @usuarios = Usuario.all\n \n #I18n.locale = \"pt-BR\"\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @usuarios }\n end\n end", "def index\n @title = \"All users\"\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users.to_xml(:except => [:password_digest, :remember_token])}\n end\n end", "def index\n @unidades = Unidad.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @unidades }\n end\n end", "def index\n\t @allUsuarios = Usuario.all\n end", "def index\n @users = User.find(:all, :order => 'name ASC')\n respond_to do |format|\n format.html \n format.xml { @users.to_xml }\n end\n end", "def show\n @usuarios = Usuario.all\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @users }\n end\n end", "def index\n @usuarios = Usuario.all\n end", "def index\n @usuarios = Usuario.all\n end", "def index\n @usuarios = Usuario.all\n end", "def index\n @users = User.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def list_users\n self.class.get('/users')\n end", "def index\n @users = User.all(:order => \"nick, id ASC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @usuarios = Usuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end", "def index\n @usuarios = Usuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end", "def index\n @usuarios = Usuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end", "def index\n @usuarios = Usuario.all\n # respond_to do |format|\n # format.html\n # format.json { render :json => @usuarios }\n # end\n end", "def index\n @users = User.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n #@usuarios = Usuario.all\n end", "def show\n @utilisateur = Utilisateur.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @utilisateur }\n end\n end", "def index\r\n @users = User.find(:all)\r\n \r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.xml { render :xml => @users.to_xml }\r\n end\r\n end", "def index\n @users = User.all()\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @familiares = @usuario.familiares.all\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @familiares }\n end\n end", "def index\n #Todos os usuários e suas autorizações\n @users = User.find(:all)\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @allow_tests }\n end\n end", "def show\n @idioma_usuario = IdiomaUsuario.find(params[:id]) \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @idioma_usuario }\n end\n end", "def index\n # @usuarios = @topico.perguntas.usuarios\n end", "def index\n @users = User.all(:order=>:name)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users.to_xml(\n :dasherize => false, :only => [:id, :name,\n :created_at, :updated_at]) }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def users\n get('get_users')\n end", "def index\n @cuentas = Cuenta.all\n\n @cadena = getcuentasxml\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @cadena }\n end\n end", "def index\n @users = User.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @usuarios = Usuario.por_colegio(colegio.id).order(\"nombre\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end", "def index\n\t\t@users = User.all\n\t\t\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml\t{ render :xml => @users }\n\t\tend\n\tend", "def index\n @users = User.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @users.to_xml }\n end\n end", "def index\n @users = User.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @users.to_xml }\n end\n end", "def novo\n @usuario = Usuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @usuario }\n end\n end", "def show\n @unidades = Unidade.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @unidades }\n end\n end", "def index\n @namespaces = current_user.namespaces\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @namespaces }\n end\n end", "def show\n @solicitud = Solicitud.find(params[:id])\n @respuestas=SolicitudRespuesta.find(:all,:select=>:usuario_id,:conditions=>{:solicitud_id=>params[:id]}).map(&:usuario_id)\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @solicitud }\n end\n end", "def new\n @usuario = Usuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @usuario }\n end\n end", "def show\n @tipo_usuario = TipoUsuario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tipo_usuario }\n end\n end", "def show\n @usuarios = Usuario.where(tipo: 'usuario')\n end", "def show\n @users = User.find(params[:id])\n @users = parsearUsuario(@users)\n end", "def index3\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n authorize! :read, User\n @users = User.find(:all)\n @users ||= []\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @users.to_xml }\n end\n end", "def index\n @tipo_usuarios = TipoUsuario.all\n @tipo_usuarios = @tipo_usuarios.paginate :page => params[:page], :order => 'created_at DESC', :per_page => 10\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tipo_usuarios }\n end\n end", "def index\n users = get_collection(User) || return\n\n respond_to do |format|\n format.xml { render xml: users.to_xml(only: DEFAULT_FIELDS, root: 'users', skip_types: 'true') }\n format.json { render json: users.to_json(only: DEFAULT_FIELDS) }\n end\n end", "def index\n @tutorias = Tutoria.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tutorias }\n end\n end", "def index\n @users = User.all\n respond_to do |format|\n format.html\n format.xml { render :xml => @users }\n format.json { render :json => @users }\n end\n end", "def index\n @user = current_user\n @title = \"Account\"\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def new\n @usuario = Usuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @Usuario }\n end\n end", "def index\n @users = User.all\n @roles = Role.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def new\n @usuario = Usuario.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @usuario }\n end\n end", "def index\n @users = User.order(:name)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @kudos = Kudo.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @kudos }\n end\n end", "def show\n @user = User.find(params[:id])\n render :xml => @user.to_xml(:except => [ :password ])\n end", "def index\n @deporte_usuarios = DeporteUsuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @deporte_usuarios }\n end\n end", "def list\n get('users')['users']\n end", "def show\n @users = User.find(params[:id])\n if @users\n respond_to do |format|\n format.json { render :json => @users }\n format.xml { render :xml => @users }\n end\n else\n head :not_found\n end\n end", "def list_users(api_object)\r\n puts \"Current Users:\"\r\n doc = Nokogiri::XML.parse api_object.read\r\n names = doc.xpath('users').collect {|e| e.text }\r\n puts names.join(\", \")\r\n puts \"\"\r\nend", "def users(params = {})\n make_get_request('/account/users', params)\n end", "def index\n log_ini\n $log.info(\"log\") { \"Info -- \" \"Entrando en el metodo index del usuario, el dia #{Time.new.day}/#{Time.new.mon}/#{Time.new.year} a las #{Time.new.hour}:#{Time.new.min}:#{Time.new.sec}\"}\n @users = User.all\n if @users.size > 0\n respond_to do |format|\n format.xml { render xml: @users}\n end\n else\n mensajesalida = Mensaje.new\n $log.warn(\"log\") {\"Warn -- \" \"Dia #{Time.new.day}/#{Time.new.mon}/#{Time.new.year} a las #{Time.new.hour}:#{Time.new.min}:#{Time.new.sec}. No existen usuarios --> estoy en el index\" }\n mensajesalida.salida = \"No existen usuarios\"\n respond_to do |format|\n format.xml { render xml: mensajesalida}\n end\n # raise Exceptions::BusinessException.new(\"No existen usuarios\")\n end\n end", "def index\n @usuarios = Usuario.paginate(page: params[:page])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end", "def show\n @usr = Usr.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @usr }\n end\n end", "def list_users\n http_get(:uri=>\"/users\", :fields=>x_cookie)\n end", "def show\n @estagiarios = Estagiario.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @estagiarios }\n end\n end", "def index\n @activos = Activo.all\n @marcas = Marca.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @activos }\n end\n end", "def index\n @catalogo_usuarios = CatalogoUsuario.all\n end", "def users\n \n @users = User.where(:enabled => true)\n @users = @users.where(:role => params[:role].upcase) if params[:role]\n @users = @users.where(:id => params[:id]) if params[:id]\n respond_to do |format|\n format.xml { render :xml => @users.to_xml }\n end\n \n end", "def index\n users = get_collection(visible_users) || return\n\n respond_to do |format|\n format.xml { render xml: users.to_xml(only: DEFAULT_FIELDS, root: :users, skip_types: true) }\n format.json { render json: users.to_json(only: DEFAULT_FIELDS) }\n end\n end", "def show\n @administrativo = Administrativo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @administrativo }\n end\n end" ]
[ "0.73021585", "0.70639926", "0.6735613", "0.6735613", "0.6735613", "0.6735613", "0.6684398", "0.66683435", "0.65899605", "0.65819114", "0.6577307", "0.6529751", "0.6484165", "0.64837134", "0.6454394", "0.64210975", "0.6419777", "0.63922936", "0.63922936", "0.63922936", "0.63884914", "0.6385515", "0.636054", "0.6346059", "0.6321239", "0.6321239", "0.6321239", "0.63120127", "0.631154", "0.631154", "0.631154", "0.6306104", "0.6304626", "0.6303561", "0.6301867", "0.62975097", "0.6295018", "0.6294703", "0.62919724", "0.62846684", "0.6274844", "0.6274844", "0.6274844", "0.6274844", "0.6274844", "0.6274844", "0.6274844", "0.6274844", "0.6274844", "0.6274844", "0.6274844", "0.6274844", "0.6274844", "0.6274844", "0.6274844", "0.6267694", "0.62656575", "0.6252314", "0.6252314", "0.6252314", "0.62516165", "0.6243949", "0.6228314", "0.62279", "0.61942196", "0.61875933", "0.61674505", "0.616629", "0.6165456", "0.61621183", "0.61404765", "0.612793", "0.61215264", "0.6118504", "0.6097554", "0.6090016", "0.6080051", "0.60716957", "0.6070322", "0.60676557", "0.6058022", "0.6051408", "0.6036946", "0.6030316", "0.60091025", "0.6001499", "0.5983678", "0.5979173", "0.5966599", "0.59636414", "0.59574", "0.5953394", "0.5937782", "0.5926652", "0.5924164", "0.5915308", "0.5905674", "0.590335", "0.59007627", "0.5897984" ]
0.65648806
11
GET /Usuarios/1 GET /Usuarios/1.xml
def show @usuario = Usuario.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @usuario } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def consultar\n @usuario = Usuario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @usuario }\n end\n end", "def index\n @usuarios = Usuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @usuarios }\n end\n end", "def show\n @usuario = Usuario.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @usuario }\n end\n end", "def index\n @users = User.all\n render :xml => @users\n end", "def show\n @utilisateur = Utilisateur.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @utilisateur }\n end\n end", "def show\n @idioma_usuario = IdiomaUsuario.find(params[:id]) \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @idioma_usuario }\n end\n end", "def show\n @tipo_usuario = TipoUsuario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tipo_usuario }\n end\n end", "def index\n #@usuarios = Usuario.all\n #page = params[:page] || 1\n @usuarios = Usuario.paginate(:page => @page)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @usuarios }\n end\n end", "def index\n @users = User.find(:all, :order => 'name ASC')\n respond_to do |format|\n format.html \n format.xml { @users.to_xml }\n end\n end", "def index\n @users = LinkedData::Client::Models::User.all\n respond_to do |format|\n format.html\n format.xml { render xml: @users.to_xml }\n end\n end", "def me\n users(request(\"users/authenticate.xml\", :auth => true))\n end", "def index\n @title = \"All users\"\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users.to_xml(:except => [:password_digest, :remember_token])}\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @users }\n end\n end", "def show\n @usr = Usr.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @usr }\n end\n end", "def new\n @usuario = Usuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @usuario }\n end\n end", "def show\n @user = User.find(params[:id])\n render :xml => @user\n rescue\n render :nothing => true, :status => :not_found\n end", "def index\n @cuentas = Cuenta.all\n\n @cadena = getcuentasxml\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @cadena }\n end\n end", "def index\n @unidades = Unidad.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @unidades }\n end\n end", "def index\n @users = User.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all(:order => \"nick, id ASC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all(:order=>:name)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users.to_xml(\n :dasherize => false, :only => [:id, :name,\n :created_at, :updated_at]) }\n end\n end", "def show\n @user = User.find(params[:id])\n render :xml => @user.to_xml(:except => [ :password ])\n end", "def show\n @unidades = Unidade.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @unidades }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def novo\n @usuario = Usuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @usuario }\n end\n end", "def index\n @users = User.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def new\n @usuario = Usuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @Usuario }\n end\n end", "def show\n @solicitud = Solicitud.find(params[:id])\n @respuestas=SolicitudRespuesta.find(:all,:select=>:usuario_id,:conditions=>{:solicitud_id=>params[:id]}).map(&:usuario_id)\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @solicitud }\n end\n end", "def index\r\n @users = User.find(:all)\r\n \r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.xml { render :xml => @users.to_xml }\r\n end\r\n end", "def index\n @users = User.all()\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @familiares = @usuario.familiares.all\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @familiares }\n end\n end", "def index\n @usuarios = Usuario.all\n \n #I18n.locale = \"pt-BR\"\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @usuarios }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def new\n @usuario = Usuario.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @usuario }\n end\n end", "def index3\n @users = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def show\n @administrativo = Administrativo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @administrativo }\n end\n end", "def index\n #Todos os usuários e suas autorizações\n @users = User.find(:all)\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @allow_tests }\n end\n end", "def index\n @users = User.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @users = User.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @users.to_xml }\n end\n end", "def index\n @users = User.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @users.to_xml }\n end\n end", "def show\n @user = User.find(params[:id])\n usr = prepare_user(@user);\n respond_to do |format|\n format.xml { render :xml => usr.to_xml }\n end\n end", "def index\n @user = current_user\n @title = \"Account\"\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def show\n @nossos_servico = NossosServico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @nossos_servico }\n end\n end", "def show\n @unidad = Unidad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @unidad }\n end\n end", "def index\n @namespaces = current_user.namespaces\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @namespaces }\n end\n end", "def show\n @tipo_system_user = TipoSystemUser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tipo_system_user }\n end\n end", "def show\n @user = nil\n id_or_name = params[:id]\n begin\n @user = User.find(id_or_name)\n rescue\n @user = User.find_by_name(id_or_name)\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml {\n xml = Builder::XmlMarkup.new(:indent => 2)\n xml.instruct! directive_tag=:xml, :encoding=> 'utf-8'\n render :xml => xml.user {|u|\n u.id(@user.id)\n u.name(@user.name)\n u.statuses {|ss|\n @user.statuses.each {|stat|\n ss.status {|s|\n s.id(stat.id)\n s.user_id(stat.user_id)\n s.text(stat.text)\n s.geo_tag(stat.geo_tag)\n s.created_at(stat.created_at)\n }\n }\n }\n }\n }\n end\n end", "def show \n @user = User.find(params[:id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @user }\n end\n end", "def show\n @estagiarios = Estagiario.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @estagiarios }\n end\n end", "def show\n\tadd_breadcrumb \"Mostrar usuario\", :usuario_path\n @usuario = Usuario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @usuario }\n end\n end", "def list_users\n self.class.get('/users')\n end", "def show\n @unidade = Unidade.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @unidade }\n end\n end", "def index\n @tipo_usuarios = TipoUsuario.all\n @tipo_usuarios = @tipo_usuarios.paginate :page => params[:page], :order => 'created_at DESC', :per_page => 10\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tipo_usuarios }\n end\n end", "def index\n # @usuarios = @topico.perguntas.usuarios\n end", "def show\n @regiaos = Regiao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @regiaos }\n end\n end", "def show\n @users = User.find(params[:id])\n @users = parsearUsuario(@users)\n end", "def index\n\t @allUsuarios = Usuario.all\n end", "def index\n @kudos = Kudo.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @kudos }\n end\n end", "def index\n\t\t@users = User.all\n\t\t\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml\t{ render :xml => @users }\n\t\tend\n\tend", "def show\n @usuario = Usuario.find(params[:id])\n end", "def show\n @empleadosautorizado = Empleadosautorizado.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @empleadosautorizado }\n end\n end", "def show\n @usuarios = Usuario.all\n end", "def index\n log_ini\n $log.info(\"log\") { \"Info -- \" \"Entrando en el metodo index del usuario, el dia #{Time.new.day}/#{Time.new.mon}/#{Time.new.year} a las #{Time.new.hour}:#{Time.new.min}:#{Time.new.sec}\"}\n @users = User.all\n if @users.size > 0\n respond_to do |format|\n format.xml { render xml: @users}\n end\n else\n mensajesalida = Mensaje.new\n $log.warn(\"log\") {\"Warn -- \" \"Dia #{Time.new.day}/#{Time.new.mon}/#{Time.new.year} a las #{Time.new.hour}:#{Time.new.min}:#{Time.new.sec}. No existen usuarios --> estoy en el index\" }\n mensajesalida.salida = \"No existen usuarios\"\n respond_to do |format|\n format.xml { render xml: mensajesalida}\n end\n # raise Exceptions::BusinessException.new(\"No existen usuarios\")\n end\n end", "def index\n @users = User.order(:name)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @users }\n end\n end", "def index\n @usuarios = Usuario.por_colegio(colegio.id).order(\"nombre\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end", "def show\n respond_to do |format|\n format.html\n format.xml { render :xml => @user }\n end\n end", "def show\n @tipo_controles = TipoControle.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tipo_controles }\n end\n end", "def show\n @users = User.find(params[:id])\n if @users\n respond_to do |format|\n format.json { render :json => @users }\n format.xml { render :xml => @users }\n end\n else\n head :not_found\n end\n end", "def show\n @adminnistrador = Adminnistrador.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @adminnistrador }\n end\n end", "def show\n @direccion = Direccion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @direccion }\n end\n end", "def show\n @user = User.find(params[:id])\n @title = @user.username\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @user.to_xml(:except => [:password_digest, :remember_token])}\n end\n end", "def show\n @valor_sistema = ValorSistema.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @valor_sistema }\n end\n end", "def index\n @usuarios = Usuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end", "def index\n @usuarios = Usuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end", "def index\n @usuarios = Usuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end", "def index\n @usuarios = Usuario.all\n end", "def index\n @usuarios = Usuario.all\n end", "def index\n @usuarios = Usuario.all\n end", "def index\n @tutorias = Tutoria.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tutorias }\n end\n end" ]
[ "0.71564305", "0.7068489", "0.68983924", "0.66170865", "0.65848947", "0.655138", "0.6469004", "0.64490056", "0.64334446", "0.64007115", "0.63813037", "0.6359671", "0.6356015", "0.6328953", "0.63271487", "0.63187784", "0.6317044", "0.6316614", "0.63092715", "0.6301768", "0.63017213", "0.6294278", "0.62637234", "0.62591916", "0.6246383", "0.62393624", "0.62393624", "0.62393624", "0.6231698", "0.6223511", "0.6221696", "0.6214824", "0.6210488", "0.6200115", "0.6194787", "0.6194787", "0.6194787", "0.6194787", "0.6194787", "0.6194787", "0.6194787", "0.6194787", "0.6194787", "0.6194787", "0.6194787", "0.6194787", "0.6194787", "0.6194787", "0.6194787", "0.6187489", "0.617878", "0.6178112", "0.61763453", "0.6166393", "0.6166393", "0.6166393", "0.61585075", "0.6157837", "0.6154518", "0.61539143", "0.612847", "0.60841864", "0.60503566", "0.60404617", "0.6026347", "0.6022258", "0.6017915", "0.6016566", "0.60156125", "0.6011583", "0.60080373", "0.60064834", "0.6001863", "0.59988075", "0.59960747", "0.59874606", "0.5985041", "0.5978569", "0.59667194", "0.5960608", "0.59588844", "0.59586173", "0.5948197", "0.59394366", "0.59339947", "0.59333336", "0.5928323", "0.5927312", "0.5919578", "0.59146494", "0.59106666", "0.59106666", "0.59106666", "0.590944", "0.590944", "0.590944", "0.5908516" ]
0.696614
5
GET /Usuarios/new GET /Usuarios/new.xml
def new @usuario = Usuario.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @Usuario } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @usuario = Usuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @usuario }\n end\n end", "def new\n @usuario = Usuario.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @usuario }\n end\n end", "def novo\n @usuario = Usuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @usuario }\n end\n end", "def new\n @tipo_usuario = TipoUsuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_usuario }\n end\n end", "def new\n @utilisateur = Utilisateur.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @utilisateur }\n end\n end", "def new\n @usr = Usr.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @usr }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nomina }\n end\n end", "def new\n @nossos_servico = NossosServico.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nossos_servico }\n end\n end", "def new\n @administrativo = Administrativo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @administrativo }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.xml { render xml: @user}\n end\n end", "def new\n @nostro = Nostro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nostro }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instituto }\n end\n end", "def new\n @regiaos = Regiao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @regiaos }\n end\n end", "def new\n @unidades = Unidade.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @unidades }\n end\n end", "def new\n @unidade = Unidade.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @unidade }\n end\n end", "def new\n @noticia = Noticia.new \n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @noticia }\n end\n end", "def new\n logger.debug(\"Create a new user\")\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @proceso = Proceso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @proceso }\n end\n end", "def new\n\tputs \"\\n\\t\\t in new\\n\"\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @user }\n end\n end", "def new\n @estatu = Estatu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estatu }\n end\n end", "def new\n @user = User.new\n render :xml => @user\n end", "def new\n @user = User.new\n get_list\n respond_to do |format|\n format.html # new.html.haml\n format.xml { render :xml => @user }\n end\n end", "def new\n\tadd_breadcrumb \"Nuevo usuario\", :new_usuario_path\n @usuario = Usuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @usuario }\n end\n end", "def new\n @aplicacion = Aplicacion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @aplicacion }\n end\n end", "def new\n @aniversario = Aniversario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @aniversario }\n end\n end", "def new\n @recurso = Recurso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @recurso }\n end\n end", "def new\n @tipo_lista = TipoLista.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_lista }\n end\n end", "def new\n @nom = Nom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nom }\n end\n end", "def new\n @solicitud = Solicitud.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @solicitud }\n end\n end", "def new\n @adminnistrador = Adminnistrador.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @adminnistrador }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @tipo_contrato = TipoContrato.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_contrato }\n end\n end", "def new\n @coleccionista = Coleccionista.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @coleccionista }\n end\n end", "def new\n @tservicio = Tservicio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tservicio }\n end\n end", "def new\n @user = User.new()\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @contrato = Contrato.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contrato }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n if params[:tipo]=='traductor' || params[:tipo]=='admin'\n @usuario=Usuario.new\n else\n \t@sitio = Sitio.find(params[:id]) \n \t@usuario = @sitio.usuarios.new\n end\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @usuario }\n end\n end", "def new\n @lien = Lien.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lien }\n end\n end", "def new\n @modulo = Modulo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @modulo }\n end\n end", "def new\n @tipo_controles = TipoControle.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_controles }\n end\n end", "def new\n @tipo_fuente = TipoFuente.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_fuente }\n end\n end", "def new\n @user = User.new \n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end", "def new\n @cuenta = Cuenta.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @cuenta }\n end\n end", "def new\n @cuenta = Cuenta.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @cuenta }\n end\n end", "def new\n @senhas = Senha.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @senhas }\n end\n end", "def new\n @contratosinterventoria = Contratosinterventoria.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @contratosinterventoria }\n end\n end", "def new\n @tipo_system_user = TipoSystemUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_system_user }\n end\n end", "def new\n @tipo_nota = TipoNota.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_nota }\n end\n end", "def new\n @receita = Receita.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @receita }\n end\n end", "def new\n @tcliente = Tcliente.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tcliente }\n end\n end", "def new\n @estagiarios = Estagiario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @estagiarios }\n end\n end", "def new\n @usuario = Usuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usuario }\n end\n end" ]
[ "0.78100944", "0.7808233", "0.7516867", "0.74601316", "0.7353873", "0.7249681", "0.72443676", "0.7241218", "0.7232326", "0.719911", "0.718034", "0.7164125", "0.715564", "0.71519", "0.71356744", "0.711975", "0.71000934", "0.7088865", "0.7082989", "0.7064895", "0.70586395", "0.70558727", "0.70434153", "0.7040824", "0.70353645", "0.70257354", "0.7021616", "0.70062643", "0.69910854", "0.69877857", "0.69872963", "0.69811535", "0.69811535", "0.6972371", "0.6964209", "0.69623613", "0.6955697", "0.6951795", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.6951477", "0.693802", "0.6936131", "0.69360465", "0.69339716", "0.69292873", "0.6928283", "0.6922514", "0.6922514", "0.69195276", "0.6909055", "0.6906693", "0.6904727", "0.6900634", "0.689756", "0.68940496", "0.6891172" ]
0.7743075
2
POST /Usuarios POST /Usuarios.xml
def create @usuario = Usuario.new(params[:usuario]) respond_to do |format| if @usuario.save flash[:notice] = 'El usuario fue creado exitosamente.' format.html { redirect_to(@usuario) } format.xml { render :xml => @usuario, :status => :created, :location => @usuario } else format.html { render :action => "new" } format.xml { render :xml => @usuario.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @usuario = Usuario.new(params[:usuario])\n\n respond_to do |format|\n if @usuario.save\n format.html { redirect_to(@usuario, :notice => 'Usuario was successfully created.') }\n format.xml { render :xml => @usuario, :status => :created, :location => @usuario }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @usuario.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n doc = Nokogiri::XML(request.body.read)\n bNode = doc.xpath('elwak/benutzer')\n\n @benutzer = Benutzer.new(benutzer_params(bNode))\n if @benutzer.save\n if bNode.xpath('objekt_zuordnungs').length > 0\n objekt_ids = bNode.xpath('objekt_zuordnungs/objekt_id').map{|oz| oz.text.to_s.to_i}\n @benutzer.setze_objekt_zuordnungen(objekt_ids)\n end\n success(@benutzer.id)\n else\n error(@benutzer.errors)\n end\n end", "def create\n @tipo_usuario = TipoUsuario.new(params[:tipo_usuario])\n\n respond_to do |format|\n if @tipo_usuario.save\n format.html { redirect_to(@tipo_usuario, :notice => ' - Tipo de usuário cadastrado com sucesso.') }\n format.xml { render :xml => @tipo_usuario, :status => :created, :location => @tipo_usuario }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @tipo_usuario.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n \n \n @usuario = Usuario.create(params[:usuario])\n @[email protected]\n\n #@evento = Evento.new(params[:evento])\n respond_to do |format|\n if @usuario.save\n format.html { redirect_to(@usuario, :notice => t('exito') ) }\n format.xml { render :xml => @usuario, :status => :created, :location => @usuario }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @usuario.errors, :status => :unprocessable_entity }\n end\n end\n end", "def novo\n @usuario = Usuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @usuario }\n end\n end", "def new\n @usuario = Usuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @usuario }\n end\n end", "def create\n @usuario = Usuario.new(params[:usuario])\n flash[:notice] = 'Usuario foi criado com sucesso.' if @usuario.save\n respond_with @usuario, :location => usuarios_path\n end", "def create\n @usuario = Usuario.new(usuario_params)\n\n respond_to do |format|\n if @usuario.save\n format.html { redirect_to \"/usuarios\", notice: 'Usuario was successfully created.' }\n format.json { render :show, status: :created, location: @usuario }\n else\n format.html { render :new }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @usuario = Usuario.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @usuario }\n end\n end", "def new\n @usuario = Usuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @Usuario }\n end\n end", "def create\n @usuario = Usuario.new(usuario_params)\n\n if @usuario.save\n render json: @usuario, status: :created, location: @usuario\n else\n render json: @usuario.errors, status: :unprocessable_entity\n end\n end", "def create\n @usuario = Usuario.new(usuario_params)\n respond_to do |format|\n if @usuario.save\n format.html { redirect_to usuarios_url, notice: 'Usuário criado com sucesso.' }\n format.json { render :show, status: :created, location: @usuario }\n else\n format.html { render :new }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @usu = Usuario.new(usuario_params)\n respond_to do |format|\n if @usu.save\n format.html { redirect_to @usu, notice: 'Usuario was successfully created.' }\n format.json { render :show, status: :created, location: @usu }\n else\n format.html { render :new }\n format.json { render json: @usu.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @usuario = Usuario.new(params[:usuario])\n\n respond_to do |format|\n if @usuario.save\n format.html { redirect_to @usuario, notice: 'Usuario fue creado satisfactoriamente' }\n format.json { render json: @usuario, status: :created, location: @usuario }\n else\n format.html { render action: \"new\" }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @usuarios = Usuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @usuarios }\n end\n end", "def create\n @usuario = Usuario.new(usuario_params)\n\n respond_to do |format|\n if @usuario.save\n record_activity(\"Nuevo Usuario\")\n format.html { redirect_to @usuario, notice: 'Usuario was successfully created.' }\n format.json { render :show, status: :created, location: @usuario }\n else\n format.html { render :new }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @usuario = Usuario.new(usuario_params)\n respond_to do |format|\n if @usuario.save\n format.html { redirect_to @usuario, notice: 'Usuario was successfully created.' }\n format.json { render :show, status: :created, location: @usuario }\n else\n format.html { render :new }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @usuario = Usuario.new(usuario_params)\n respond_to do |format|\n if @usuario.save\n format.html { redirect_to @usuario, notice: 'Usuario was successfully created.' }\n format.json { render :show, status: :created, location: @usuario }\n else\n format.html { render :new }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @usuario = Usuario.new(usuario_params)\n respond_to do |format|\n if @usuario.save\n format.html { redirect_to @usuario, notice: 'Usuario was successfully created.' }\n format.json { render :show, status: :created, location: @usuario }\n else\n format.html { render :new }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @usuario = Usuario.new(usuario_params)\n @usuario.empresa_id = @empresa.id\n @usuario.estado = true\n @usuario.eliminado = false\n respond_to do |format|\n if @usuario.save\n format.html { redirect_to empresa_usuario_path(@usuario.empresa_id,@usuario.id), notice: 'Usuario was successfully created.' }\n format.json { render :show, status: :created, location: @usuario }\n else\n format.html { render :new }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @anamnese = Anamnese.new(anamnese_params)\n @usuarios = Usuario.all\n\n respond_to do |format|\n if @anamnese.save\n format.html { redirect_to @anamnese, notice: 'Anamnese criada com sucesso.' }\n format.json { render :show, status: :created, location: @anamnese }\n else\n format.html { render :new }\n format.json { render json: @anamnese.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @usuario = Usuario.new(usuario_params)\n\n respond_to do |format|\n if @usuario.save\n format.html { redirect_to usuarios_url, notice: \"Se creó correctamente el usuario #{@usuario.nombre}\" }\n else\n format.html { render action: 'new' }\n end\n end\n end", "def create\n @tipo_usuario = TipoUsuario.new(tipo_usuario_params)\n @tipo_usuarios = TipoUsuario.all.paginate(page: params[:page], per_page: 5)\n @action = { title: \"Novo\", button: \"Salvar\"}\n\n respond_to do |format|\n if @tipo_usuario.save\n format.html { redirect_to action: \"new\", notice: 'TIpo Usuário criada com sucesso.' }\n format.json { render :show, status: :created, location: @tipo_usuario }\n else\n format.html { render :new, location: @tipo_usuario}\n format.json { render json: @tipo_usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #Creamos el objeto con los valores a ingresar.\n @usuario = Usuario.new({\n :nombre => params[:usuario][:nombre],\n :apellido => params[:usuario][:apellido],\n :user=> params[:usuario][:user],\n :pass => params[:usuario][:pass],\n });\n #Verificamos si el usuario ha sido creado.\n if @usuario.save()\n redirect_to :controller => \"usuarios\", :action => \"exito\", :notice => \"El usuario ha sido creado\";\n else\n render \"registrar\";\n end\n end", "def create\n @usuario = Usuario.new(usuario_params)\n @usuario.nombres = @usuario.nombres.upcase\n @usuario.apellidos = @usuario.apellidos.upcase\n @usuario.salario = 0\n respond_to do |format|\n if @usuario.save\n format.html { redirect_to @usuario, notice: 'El Usuario se ha creado correctamente.' }\n format.json { render :show, status: :created, location: @usuario }\n else\n @div_edit_admin = true\n format.html { render :new }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n \n end", "def create\n @usuario = Usuario.new(params[:usuario])\n\n respond_to do |format|\n if @usuario.save\n\t\tguardar_log(session[:usuario_id], self.class.name,__method__.to_s, @usuario,nil )\n\t\tformat.html { redirect_to usuarios_url,:notice => \"Usuario #{@usuario.nombre} fue creado exitosamente.\" }\n format.json { render :json => @usuario, :status => :created, :location => @usuario }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @usuario.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @unidades = Unidade.new(params[:unidade])\n respond_to do |format|\n if @unidades.save\n flash[:notice] = 'UNIDADE CADASTRADA COM SUCESSO.'\n format.html { redirect_to(@unidades) }\n format.xml { render :xml => @unidades, :status => :created, :location => @unidades }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @unidades.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @usuario = Usuario.new(params[:usuario])\n\n respond_to do |format|\n if !params[:senha2].nil?\n if @usuario.senha == params[:senha2]\n @usuario.senha = Digest::SHA1.hexdigest(session[:salt] + params[:senha2])\n if @usuario.save\n format.html { redirect_to(consultar_usuario_path(@usuario), :notice => 'O usuário foi criado com sucesso.') }\n format.xml { render :xml => @usuario, :status => :created, :location => @usuario }\n else\n format.html { render :action => \"novo\" }\n format.xml { render :xml => @usuario.errors, :status => :unprocessable_entity }\n end\n else\n flash[:notice] = \"A senha e a confirmação devem ser iguais\"\n redirect_to novo_usuario_path\n end\n end\n end\n end", "def create\n @unidade = Unidade.new(params[:unidade])\n\n respond_to do |format|\n if @unidade.save\n flash[:notice] = 'Unidade cadastrada com sucesso.'\n format.html { redirect_to(@unidade) }\n format.xml { render :xml => @unidade, :status => :created, :location => @unidade }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @unidade.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n User.destroy_all\n @user = params[:user]\n###################\n usuario=@user[:username]\n password=@user[:password]\n\n client = Savon::Client.new (ruta_wdsl)\n client.wsdl.soap_actions\n response = client.request :ser, :validarUsuario do\n soap.namespaces[\"xmlns:ser\"] = \"http://service.wsreserva.qwerty.dsd.upc.edu.pe/\"\n soap.body = \"<usuario>\" + usuario + \"</usuario><password>\" + password + \"</password>\"\n end\n\n if response.success?\n @response=response.to_hash()\n respond_to do |format|\n if @response[:validar_usuario_response][:return][:codigo]==\"0\"\n session[:usr] = usuario\n session[:pwd] = password\n session[:name] = @response[:validar_usuario_response][:return][:username] \n Rails.logger.info session[:usr].inspect\n Rails.logger.info session[:pwd].inspect\n format.html { redirect_to \"/\", notice: @response[:validar_usuario_response][:return][:mensaje] }\n format.json { head :ok }\n else\n session[:usr] = nil\n session[:pwd] = nil\n session[:name] = nil \n #format.html { render action: \"new\" }\n #format.json { render json: @response[:validar_usuario_response][:return][:mensaje], status: :unprocessable_entity }\n format.html { redirect_to \"/users/new\", notice: @response[:validar_usuario_response][:return][:mensaje] }\n #format.json { head :ok }\n end\n end\n end\n\n end", "def create\n\n puts request.body.string\n\n if request.body.string.include? %q[\"id\"]\n render json: %q[{\"error\": \"No se puede crear usuario con id\"}], status: 400\n else\n @usuario = Usuario.new(usuario_params)\n #Tuve que hacerlo asi, pq por alguna razon no me dejaba de la forma tradicional!\n #@usuario = Usuario.new\n #@usuario.usuario = params[:usuario]\n #@usuario.nombre = params[:nombre]\n #@usuario.apellido = params[:apellido]\n #@usuario.twitter = params[:twitter]\n\n\n respond_to do |format|\n if @usuario.save\n #format.html { redirect_to @usuario, notice: 'Usuario was successfully created.' }\n format.json { render :show, status: :created, location: @usuario }\n else\n #format.html { render :new }\n format.json { render json: @usuario.errors, status: 404}# status: :unprocessable_entity }\n end\n end\n end\n end", "def usuario_params\n params.require(:usuario).permit(:title, :name, :lastName, :email, :groupId, :userId,:folio,:conteo)\n end", "def create\n @juntum_usuario = JuntumUsuario.new(juntum_usuario_params)\n\n respond_to do |format|\n if @juntum_usuario.save\n format.html { redirect_to @juntum_usuario, notice: 'Juntum usuario was successfully created.' }\n format.json { render :show, status: :created, location: @juntum_usuario }\n else\n format.html { render :new }\n format.json { render json: @juntum_usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n params.permit(:pseudo_administrateur, :email_administrateur, :motDePasse_administrateur)\n ajout = AdministrateurService.instance.creerNouveauAdmin(params[:pseudo_administrateur], params[:email_administrateur], params[:motDePasse_administrateur])\n (ajout != nil) ? (render json: ajout, status: :ok) : (render json: nil, status: :not_found)\n end", "def registroapi\n @usuario = User.new(:email => params[:email], :password => params[:password], :password_confirmation => params[:password], :nombre => params[:nombre], :username => params[:username], :nacimiento => params[:nacimiento], :genero => params[:genero])\n if @usuario.save\n respond_to do |format|\n format.html { redirect_to '/users/sign_in', notice: 'Registro exitoso, puedes iniciar sesión.', :status => 200 }\n format.json { render json: { :error => 'false', :desc => 'Registro exitoso' } }\n end\n\n else\n respond_to do |format|\n format.html { redirect_to '/registro_api', alert: @usuario.errors.full_messages.to_sentence }\n format.json { render json: { :error => 'true', :desc => @usuario.errors.full_messages} }\n end\n end\n end", "def create(name=\"Default Name\", age=\"50\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <name>#{name}</name>\r\n <age>#{age}</age>\r\n </person>\"\r\n \r\n request = Net::HTTP::Post.new(@url)\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n \r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n response.body \r\n end", "def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end", "def create\n redirect_to root_url, :notice => 'Informacja! Rejestracja zosta&#322;a wy&#322;&#261;czona'\n #@user = User.new(params[:user])\n\n #respond_to do |format|\n #if @user.save\n #format.html { redirect_to( root_url, :notice => 'Informacja! Konto zarejestrowane!') }\n #format.xml { render :xml => @user, :status => :created, :location => @user }\n #else\n #format.html { render :action => \"new\" }\n #format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n #end\n #end\nend", "def usuario_params\n params.require(:usuario).permit(:nome, :email, :senha, :senha_confirmation)\n end", "def create\n @deporte_usuario = DeporteUsuario.new(params[:deporte_usuario])\n\n respond_to do |format|\n if @deporte_usuario.save\n format.html { redirect_to deporte_usuarios_path, notice: 'El Usuario ha sido creado exitosamente.' }\n format.json { render json: @deporte_usuario, status: :created, location: @deporte_usuario }\n else\n format.html { render action: \"new\" }\n format.json { render json: @deporte_usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def usuario_params\n params.require(:usuario).permit(:login, :nome, :email, :perfil, :status)\n end", "def create\r\n @reclamacao = Reclamacao.new(reclamacao_params)\r\n user = Usuario.get_usuario_logado\r\n @reclamacao.write_attribute(:usuario_id, user.id)\r\n respond_to do |format|\r\n if @reclamacao.save\r\n format.html { redirect_to root_path, notice: 'RECLAMAÇÃO EFETUADA COM SUCESSO' }\r\n format.json { render :show, status: :created, location: @reclamacao }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @reclamacao.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def new\n @utilisateur = Utilisateur.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @utilisateur }\n end\n end", "def create\n @tipo_usuario = TipoUsuario.new(params[:tipo_usuario])\n\n respond_to do |format|\n if @tipo_usuario.save\n format.html { redirect_to tipo_usuarios_path, notice: 'Tipo usuario fue creado exitosamente.' }\n format.json { render json: @tipo_usuario, status: :created, location: @tipo_usuario }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tipo_usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @usuario = Usuario.new(params[:usuario])\n if not @usuario.bloqueado or @usuario.admin == 2\n #Usuario esta habilitado\n @usuario.bloqueado = 0\n end\n usuario.transcriptor = true unless usuario.transcriptor or usuario.responsable\n\n respond_to do |format|\n if not @usuario.transcriptor and not @usuario.responsable\n flash.keep\n format.html { render action: \"new\", alert: 'El administrador debe ser transcriptor y/o responsable' }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end \n\n if @usuario.save\n CorreosUsuario.enviar_contrasena(@usuario, flash[:contrasena], 1).deliver\n format.html { redirect_to @usuario, notice: 'Usuario creado exitosamente.'}\n format.json { render json: @usuario, status: :created, location: @usuario }\n else\n flash.keep\n format.html { render action: \"new\", alert: 'Usuario no pudo ser creado.' }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def usuario_params\n params.require(:usuario).permit(:nombre, :apellido, :usuario, :twitter)\n end", "def create\n @usuario = User.new(user_params)\n @usuario.ativo = true\n @usuario.mudar_senha = true\n\n respond_to do |format|\n if @usuario.save\n flash[:notice] = @@msgs\n format.html { redirect_to usuarios_url }\n format.json { render json: @usuario, status: :created, location: @usuario }\n else\n flash[:alert] = @@msge\n format.html { render action: \"new\" }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n \n end\n end\n end", "def usuario_params\n params.require(:usuario).permit(:nombre, :apellido, :user, :pass)\n end", "def usuario_params\n params.require(:usuario).permit(:nome, :password, :email, :matricula, :mac)\n end", "def create\n @utilisateur = Utilisateur.new(params[:utilisateur])\n @utilisateur.account_creation = Time.now\n respond_to do |format|\n if @utilisateur.save\n flash[:notice] = 'Utilisateur was successfully created.'\n format.html { redirect_to(@utilisateur) }\n format.xml { render :xml => @utilisateur, :status => :created, :location => @utilisateur }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @utilisateur.errors, :status => :unprocessable_entity }\n end\n end\n end", "def usuario_params\n params.permit(:usuario, :nombre, :apellido, :twitter)\n end", "def create\r\n #@tipos_usuario = TiposUsuario.new(tipos_usuario_params)\r\n\r\n respond_to do |format|\r\n if @tipos_usuario.save\r\n format.html { redirect_to @tipos_usuario, notice: 'Se añadió un nombre de tipo de usuario correctamente.' }\r\n format.json { render :show, status: :created, location: @tipos_usuario }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @tipos_usuario.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def usuario_params\n params.require(:usuario).permit(:email, :name, :password, :password_confirmation)\n end", "def create\n @unidad = Unidad.new(params[:unidad])\n p params[:unidad]\n \n respond_to do |format|\n if @unidad.save\n flash[:notice] = 'Unidad was successfully created.'\n format.html { redirect_to(@unidad) }\n format.xml { render :xml => @unidad, :status => :created, :location => @unidad }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @unidad.errors, :status => :unprocessable_entity }\n end\n end\n end", "def POST; end", "def usuario_params\n params.require(:usuario).permit(:user, :password, :nombre, :email, :fecha_nacimiento)\n end", "def consultar\n @usuario = Usuario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @usuario }\n end\n end", "def create\n @estagiarios = Estagiario.new(params[:estagiario])\n\n respond_to do |format|\n if @estagiarios.save\n flash[:notice] = 'ESTAGIÁRIO CADASTRADO COM SUCESSO.'\n format.html { redirect_to(@estagiarios) }\n format.xml { render :xml => @estagiarios, :status => :created, :location => @estagiarios }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @estagiarios.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n\t\t@usuario = Usuario.find(params[:seguido_id])\n\t\tusuario_actual.seguir(@usuario)\n\t\t\t# respuesta para AJAX\n\t\trespond_to do |formato|\n\t\t\tformato.html { redirect_to @usuario }\n\t\t\tformato.js\n\t\tend\n\tend", "def create\n @administrativo = Administrativo.new(params[:administrativo])\n\n respond_to do |format|\n if @administrativo.save\n format.html { redirect_to(@administrativo, :notice => 'Administrativo was successfully created.') }\n format.xml { render :xml => @administrativo, :status => :created, :location => @administrativo }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @administrativo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @usuario = Usuario.new\n respond_with @usuario\n end", "def create\n @resultadoconsultum = Resultadoconsultum.new(resultadoconsultum_params)\n\t\n\n\trequire 'nokogiri'\n\t\n\t@doc = Nokogiri::XML(File.open(\"exemplos/emplo.xml\"))\n\n\tcar_tires = @doc.xpath(\"//firstname\")\n\t\n\tdoc = Nokogiri::XML(File.open(\"emplo.xml\"))\n\tdoc.xpath('firstname').each do\n\t\tcar_tires\n\tend\n\n\t \n respond_to do |format|\n if @resultadoconsultum.save\n format.html { redirect_to @resultadoconsultum, notice: car_tires }\n format.json { render :show, status: :created, location: @resultadoconsultum }\n else\n format.html { render :new }\n format.json { render json: @resultadoconsultum.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n \n @selecciones = Seleccion.where(\"cliente_id = ?\",usuario_actual.id)\n respond_to do |format|\n unless @selecciones.empty?\n @peso_total = Seleccion.peso_total(usuario_actual.id)\n @precio_total = Seleccion.precio_total(usuario_actual.id)\n @tarjetas = usuario_actual.tdc\n @orden = Orden.new(:direccion_entrega=>usuario_actual.direccion)\n t = Time.now\n fecha = t.strftime(\"%Y-%m-%d\")\n client = Savon::Client.new(\"http://192.168.1.121/DistribuidorFIF/webservices/servicio.php?wsdl\")\n preorden = \"<solicitud_pedido>\n <num_orden>001</num_orden>\n <nombre_comercio>Tukiosquito</nombre_comercio>\n <fecha_solicitud>\"+fecha.to_s+\"</fecha_solicitud>\n <nombre_cliente>\"+usuario_actual.nombre+\" \"+usuario_actual.apellido+\"</nombre_cliente>\n <direccion_comercio>\n <avenida>Sucre</avenida>\n <calle>-</calle>\n <edificio_casa>CC Millenium</edificio_casa>\n <local_apt>C1-15</local_apt>\n <parroquia>Leoncio Martinez</parroquia>\n <municipio>Sucre</municipio>\n <ciudad>Caracas</ciudad>\n <estado>Miranda</estado>\n <pais>Venezuela</pais>\n </direccion_comercio>\n <direccion_destino>\n <avenida>Santa Rosa</avenida>\n <calle>Tierras Rojas</calle>\n <edificio_casa>Villa Magica</edificio_casa>\n <local_apt>69</local_apt>\n <parroquia> </parroquia>\n <municipio>Zamora</municipio>\n <ciudad>Cua</ciudad>\n <estado>Miranda</estado>\n <pais>Venezuela</pais>\n </direccion_destino>\"\n @selecciones.each do |seleccion|\n p = Producto.find(seleccion.producto_id)\n preorden = preorden+\"\n <articulo>\n <id>\"+p.id.to_s+\"</id>\n <descripcion>\"+p.descripcion+\"</descripcion>\n <peso>\"+p.peso.to_s+\"</peso>\n <cantidad>\"+seleccion.cantidad.to_s+\"</cantidad>\n <precio>\"+p.precio.to_s+\"</precio>\n </articulo>\"\n end\n preorden = preorden+\"</solicitud_pedido>\"\n response = client.request :ejemplo, body: { \"value\" => preorden } \n if response.success? \n respuesta = response.to_hash[:ejemplo_response][:return]\n datos = XmlSimple.xml_in(respuesta)\n end\n\n @precio_envio = datos[\"num_orden\"][0]\n #@arreglo = XmlSimple.xml_in('')\n #@xml = XmlSimple.xml_out(@arreglo, { 'RootName' => 'solicitud_pedido' })\n #url = 'http://192.168.1.101/Antonio/tukyosquito/proyecto/servicio/servicio.php'\n #cotizacion = SOAP::RPC::Driver.new(url)\n #cotizacion.add_method('obtener','asd')\n #tdc = Tarjeta.where(\"id = ? AND cliente_id = ?\",params[:orden][:tarjeta_id],usuario_actual.id)\n #@respuesta = cotizacion.obtener('123')\n format.html # new.html.erb\n else\n format.html { redirect_to carrito_path, notice: 'No tiene productos agregados al carro de compras para generar una orden.' }\n end\n end\n end", "def create\n @unidad = current_user.empresa.unidades.new(unidad_params)\n\n respond_to do |format|\n if @unidad.save\n format.html { redirect_to @unidad, notice: 'Unidad was successfully created.' }\n format.json { render action: 'show', status: :created, location: @unidad }\n else\n format.html { render action: 'new' }\n format.json { render json: @unidad.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @centro_usuario = CentroUsuario.new(centro_usuario_params)\n\n respond_to do |format|\n if @centro_usuario.save\n format.html { redirect_to @centro_usuario, notice: 'Centro usuario was successfully created.' }\n format.json { render :show, status: :created, location: @centro_usuario }\n else\n format.html { render :new }\n format.json { render json: @centro_usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def usuario_params\n params.require(:usuario).permit(:nombre, :password, :password_confirmation)\n end", "def create\n @coleccionista = Coleccionista.new(params[:coleccionista])\n\n respond_to do |format|\n if @coleccionista.save\n \n @coleccionista.users << current_user\n @coleccionista.save\n \n format.html { redirect_to(@coleccionista, :notice => 'Coleccionista was successfully created.') }\n format.xml { render :xml => @coleccionista, :status => :created, :location => @coleccionista }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @coleccionista.errors, :status => :unprocessable_entity }\n end\n end\n end", "def usuario_params\n params.require(:usuarios).permit(:username,:curso_id,:tipoperfil_id,:bloqueio,:administrador)\n end", "def create\n @estatu = Estatu.new(params[:estatu])\n\n respond_to do |format|\n if @estatu.save\n format.html { redirect_to(@estatu, :notice => 'Registro creado correctamente.') }\n format.xml { render :xml => @estatu, :status => :created, :location => @estatu }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @estatu.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @utilisateur = Utilisateur.new(utilisateur_params)\n\n respond_to do |format|\n if @utilisateur.save\n format.html { redirect_to @utilisateur, notice: \"L'utilisateur a bien été créé.\" }\n format.json { render :show, status: :created, location: @utilisateur }\n else\n format.html { render :new }\n format.json { render json: @utilisateur.errors, status: :unprocessable_entity }\n end\n end\n end", "def usuario_params\n params.require(:usuario).permit(:nombre, :rut, :mail, :fechaingreso, :foto, :curso, :rol, :activo, :password, :password_confirmation, estudios_attributes: [:id, :carrera_o_curso, :institucion_id, :done, :_destroy, institucions_attributes: [:id, :nombre, :done, :_destroy]])\n end", "def new\n @tipo_usuario = TipoUsuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tipo_usuario }\n end\n end", "def usuario_params\n params.permit(:id,:nombre, :apellido, :usuario, :twitter)\n end", "def create\n @usuario_seguidor = UsuarioSeguidor.new(usuario_seguidor_params)\n\n respond_to do |format|\n if @usuario_seguidor.save\n format.html { redirect_to @usuario_seguidor, notice: 'Usuario seguidor was successfully created.' }\n format.json { render :show, status: :created, location: @usuario_seguidor }\n else\n format.html { render :new }\n format.json { render json: @usuario_seguidor.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @usuario = Usuario.new\n #Creamos al Rol asociado al Usuario...\n @rols_disp = Rol.find(:all, :order => 'id ASC') #Los roles disponibles...\n @rols_selec = [] #Los roles seleccionados...\n\n #@qbe_key = Rol.new()\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @usuario }\n end\n end", "def create\n @datos_usuario = DatosUsuario.new(datos_usuario_params)\n\n respond_to do |format|\n if @datos_usuario.save\n format.html { redirect_to \"/inicio/success\", success: 'Datos usuario was successfully created.' }\n \n else\n format.html { render action: 'new' }\n format.json { render json: @datos_usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @sucursale = Sucursale.new(sucursale_params)\n @sucursale.usuarios_id = current_usuario.id\n respond_to do |format|\n if @sucursale.save\n format.html { redirect_to @sucursale, notice: 'Sucursal creada con exito!' }\n format.json { render :show, status: :created, location: @sucursale }\n else\n format.html { render :new }\n format.json { render json: @sucursale.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ministerios = Ministerios.new(params[:ministerios])\n @title = \"Cadastro de Ministério\"\n respond_to do |format|\n if @ministerios.save\n Ministerios.update(@ministerios.id, :respcad => self.current_usuarios.login.upcase)\n \tflash[:notice] = 'Ministerios was successfully created.'\n format.html { redirect_to(ministerios_path) }\n format.xml { render :xml => @ministerios, :status => :created, :location => @ministerios }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ministerios.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @usuario = Usuario.new\n @usuario.admin = 0\n @usuario.bloqueado = 0\n @usuario.transcriptor = true\n flash[:accion] = \"Crear Usuario\"\n flash[:contrasena] = SecureRandom.hex(4)\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usuario }\n end\n end", "def create\n @usuario_proyecto = UsuarioProyecto.new(usuario_proyecto_params)\n\n respond_to do |format|\n if @usuario_proyecto.save\n format.html { redirect_to @usuario_proyecto, notice: 'Usuario proyecto was successfully created.' }\n format.json { render :show, status: :created, location: @usuario_proyecto }\n else\n format.html { render :new }\n format.json { render json: @usuario_proyecto.errors, status: :unprocessable_entity }\n end\n end\n end", "def crear_usuario\n require 'keepass/password'\n contacto = Contacto.find_by_id params[:id]\n password = KeePass::Password.generate('uullA{8}')\n respond_to do |format|\n if !Usuario.find_by_email(contacto.email)\n Usuario.create(email: contacto.email, password: password, password_confirmation: password, role: \"Consulta\", contacto_id: contacto.id).send_reset_password_instructions\n format.html { redirect_to contactos_path, notice: 'El usuario ha sido creado exitosamente.' }\n format.json { head :no_content }\n else\n user = Usuario.find_by_email(contacto.email)\n user.contacto_id = contacto.id\n user.save\n user.send_reset_password_instructions\n format.html { redirect_to contactos_path, notice: 'Se han enviado instrucciones al usuario' }\n format.json { head :no_content }\n end\n\n\n end\n end", "def create\n @adminnistrador = Adminnistrador.new(params[:adminnistrador])\n\n respond_to do |format|\n if @adminnistrador.save\n flash[:notice] = 'Adminnistrador was successfully created.'\n format.html { redirect_to(@adminnistrador) }\n format.xml { render :xml => @adminnistrador, :status => :created, :location => @adminnistrador }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @adminnistrador.errors, :status => :unprocessable_entity }\n end\n end\n end", "def utilisateur_params\n params.require(:utilisateur).permit(:idres, :nom_usage, :prenom_usage, :date_naissance, :matricule, :date_entree, :date_sortie, groupe_ids: [])\n end", "def create\n retorno = {erro: \"107\", body: \" \"}\n @usuario = Usuario.new(valid_request?)\n @usuario.status = 1\n if @usuario.mac.blank? \n @usuario.nivel = \"usuario_adm\"\n @usuario.status = 0\n usuario = Usuario.select(:mac).where(\"nivel = 1\").last\n @usuario.mac = (usuario.mac.to_i + 1).to_s\n end\n\n if @usuario.valid?\n if @usuario.save\n retorno = {erro: \"000\", body: {usuario_id: @usuario.id, usuario_nome: @usuario.nome, status: true}}\n end\n end\n #verifica erros na inserção no banco\n if @usuario.errors.any?\n retorno = Usuario.verifica_erro(@usuario.errors.messages)\n end\n render json: retorno.to_json\n end", "def create\n @seguridad_usuario = Seguridad::Usuario.new(params[:seguridad_usuario])\n\n respond_to do |format|\n if @seguridad_usuario.save\n format.html { redirect_to edit_seguridad_usuario_path(@seguridad_usuario), notice: 'Guardado Correctamente.' }\n format.json { render json: @seguridad_usuario, status: :created, location: @seguridad_usuario }\n else\n format.html { render action: \"new\" }\n format.json { render json: @seguridad_usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def info_usuario_params\n params.require(:info_usuario).permit(:nombre, :apellido, :edad, :correo, :telefono, :Localidad_id, :Genero_id, :Usuario_id)\n end", "def create\n params.permit(:email, :adresseIp)\n ajout = UtilisateurService.instance.creerNouveauUtilisateur(params[:email], params[:adresseIp])\n (ajout != nil) ? (render json: ajout, status: :ok) : (render json: nil, status: :not_found)\n end", "def usuario_params\n params.require(:usuario).permit(:ci, :nombres, :apellidos, :rol, :habilitado, :empresa_id, :cuenta_id)\n end", "def new\n @unidades = Unidade.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @unidades }\n end\n end", "def create\n @regiaos = Regiao.new(params[:regiao])\n\n respond_to do |format|\n if @regiaos.save\n flash[:notice] = 'REGIÃO SALVA COM SUCESSO'\n format.html { redirect_to(new_regiao_path)}\n format.xml { render :xml => @regiaos, :status => :created, :location => @regiaos }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @regiaos.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @orden = Orden.new(params[:orden])\n @usuario = Usuario.find(@orden.usuario_id)\n respond_to do |format|\n if @orden.save\n flash[:notice] = 'La Orden de Trabajo fue exitosamente generada.'\n Notificador.deliver_nueva_tarea(@usuario)\n format.html { redirect_to(:action => \"show\", :id => @orden) }\n format.xml { render :xml => @orden, :status => :created, :location => @orden }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @orden.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @usuario = Usuario.new(params[:usuario])\n\n all_saved = false\n respond_to do |format|\n begin \n @usuario.transaction do\n @usuario.save!\n @usuario.create_dias_usuario(params[:data_inicio])\n end\n all_saved = true\n rescue ActiveRecord::StatementInvalid\n all_saved = false\n end\n\n if all_saved\n format.html { redirect_to @usuario, notice: 'Usuario was successfully created.' }\n format.json { render json: @usuario, status: :created, location: @usuario }\n else\n format.html { render action: \"new\" }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def usuarios\n redirect_to :action => \"roles\"\n end", "def create\n @recurso_servidor = RecursoServidor.new(recurso_servidor_params)\n\n respond_to do |format|\n if @recurso_servidor.save\n format.html { redirect_to @recurso_servidor, notice: 'Recurso solicitado com sucesso.' }\n format.json { render :show, status: :created, location: @recurso_servidor }\n else\n format.html { render :new }\n format.json { render json: @recurso_servidor.errors, status: :unprocessable_entity }\n end\n end\n end", "def identificarse(correo = responsables(:obi).correo, clave = '123')\n temp_controller, @controller = @controller, SesionesController.new\n\n post :create, { :correo => correo, :clave => clave }, {}\n assert_redirected_to :controller => :tareas, :action => :index\n assert_not_nil session[:responsable_id]\n\n @controller = temp_controller\n end", "def create\n @selecciones = Seleccion.where(\"cliente_id = ?\",usuario_actual.id)\n @peso_total = Seleccion.peso_total(usuario_actual.id)\n @precio_total = Seleccion.precio_total(usuario_actual.id)\n @tarjetas = usuario_actual.tdc\n \n #Cobro en el banco\n client = Savon::Client.new(\"http://localhost:3001/servicios/wsdl\")\n tdc = Tarjeta.where(\"id = ? AND cliente_id = ?\",params[:orden][:tarjeta_id],usuario_actual.id)\n total_pagar = params[:orden][:total]\n pago = '<Message>\n <Request>\n <numero_tdc>'+tdc.numero+'</numero_tdc>\n <nombre_tarjetahabiente>'+tdc.tarjetahabiente+'</nombre_tarjetahabiente>\n <fecha_vencimiento>'+tdc.mes_vencimiento+'/'+tdc.ano_vencimiento+'</fecha_vencimiento>\n <codigo_seguridad>'+tdc.codigo+'</codigo_seguridad>\n <tipo_tarjeta>'+tdc.tipo+'</tipo_tarjeta>\n <direccion_cobro>'+tdc.direccion+'</direccion_cobro>\n <total_pagar>'+total_pagar+'</total_pagar>\n <cuenta_receptora>'+cuenta_receptora+'</cuenta_receptora>\n </Request>\n </Message>'\n #response = client.request :verificar_pago, body: { \"value\" => pago } \n #if response.success?\n # data = response.to_hash[:verificar_pago_response][:value][:response].first\n # @respuesta = XmlSimple.xml_in(data)\n #end\n\n #NAMESPACE = 'pagotdc'\n #URL = 'http://localhost:8080/'\n #banco = SOAP::RPC::Driver.new(URL, NAMESPACE)\n #banco.add_method('verificar_pago', 'numero_tdc', 'nombre_tarjetahabiente', 'fecha_vencimiento', 'codigo_seguridad', 'tipo_tarjeta', 'direccion_cobro', 'total_pagar', 'cuenta_receptora')\n #\n \n #respuesta = banco.verificar_pago(tdc.numero, tdc.tarjetahabiente, tdc.mes_vencimiento.to_s+'/'+tdc.ano_vencimiento.to_s, tdc.codigo, tdc.tipo, params[:orden][:total], tdc.direccion)\n \n if true #respuesta.ack.eql?(0)\n params[:orden][:cliente_id] = usuario_actual.id\n params[:orden][:total] = Seleccion.precio_total(usuario_actual.id)\n params[:orden][:fecha_entrega] = \"0000-00-00\"\n @orden = Orden.new(params[:orden])\n \n if @orden.save\n @selecciones = Seleccion.where(\"cliente_id = ?\",usuario_actual.id)\n @selecciones.each do |seleccion|\n p = Producto.find(seleccion.producto_id)\n @venta = Venta.new(:producto_id=>p.id, \n :orden_id=>@orden.id,\n :categoria_id=>p.categoria_id, \n :cantidad=>seleccion.cantidad,\n :costo=>p.precio)\n @venta.save\n end\n \n Seleccion.vaciar_carro(usuario_actual.id)\n respond_to do |format|\n format.html { redirect_to ver_ordenes_path, notice: 'Orden generada correctamente.' }\n end\n else\n respond_to do |format|\n format.html { render action: \"new\" }\n end\n end\n else\n respond_to do |format|\n format.html { render action: \"new\", notice: respuesta.mensaje }\n end\n end\n end", "def usuario_params\n params.require(:usuario).permit(:username, :email, :password, :password_confirmation)\n end", "def create\n @respuestum.user = current_user\n\n respond_to do |format|\n if @respuestum.save\n \n format.html { redirect_to(:back, :notice => 'Nueva respuesta creada.') }\n format.xml { render :xml => @respuestum, :status => :created, :location => @respuestum }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @respuestum.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @usuario = User.new(params[:user])\n \n respond_to do |format|\n if @usuario.save\n flash[:success] = \"Usuario criado com sucesso\"\n format.html { redirect_to usuarios_url }\n format.json { render json: @usuario, status: :created, location: @usuario }\n else\n flash[:error] = \"Erro ao criar o usuario\"\n format.html { render action: \"new\" }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n \n end\n end\n end", "def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end" ]
[ "0.6311256", "0.6203309", "0.60940516", "0.60911393", "0.6077686", "0.5884882", "0.58649623", "0.5835982", "0.5816953", "0.5807218", "0.5806025", "0.5801915", "0.5763034", "0.57545894", "0.57542616", "0.56984437", "0.5691789", "0.5691789", "0.5691789", "0.568871", "0.5676997", "0.56721044", "0.5650898", "0.5645041", "0.5635553", "0.5635449", "0.5623738", "0.5612338", "0.5596738", "0.5556471", "0.5536185", "0.5521495", "0.5518228", "0.5516333", "0.5513931", "0.55121773", "0.5505965", "0.54983604", "0.54974574", "0.54953796", "0.5491345", "0.54878676", "0.54860854", "0.5484719", "0.5480568", "0.547767", "0.54704374", "0.5457208", "0.54552704", "0.5450166", "0.5448467", "0.54484576", "0.54400235", "0.54359627", "0.5435624", "0.54348665", "0.5431876", "0.5429132", "0.5424484", "0.54208195", "0.5411134", "0.5407579", "0.5407482", "0.53944033", "0.5394158", "0.53916186", "0.538975", "0.5389544", "0.53878725", "0.53797376", "0.53793144", "0.5376207", "0.53734165", "0.53679156", "0.5357971", "0.5350939", "0.5350746", "0.53435445", "0.53394735", "0.5337624", "0.53301716", "0.53249055", "0.5317144", "0.53108615", "0.5310254", "0.53008395", "0.53003526", "0.5299616", "0.5294433", "0.5291373", "0.5286308", "0.52779734", "0.52628726", "0.52525413", "0.5250647", "0.52505916", "0.5249523", "0.52488554", "0.52483875", "0.52434564" ]
0.629725
1
PUT /Usuarios/1 PUT /Usuarios/1.xml
def update @usuario = Usuario.find(params[:id]) respond_to do |format| if @usuario.update_attributes(params[:usuario]) flash[:notice] = 'El usuario fue correctamente actualizado.' format.html { redirect_to(@usuario) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @usuario.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @usuario = Usuario.find(params[:id])\n\n respond_to do |format|\n if @usuario.update_attributes(params[:usuario])\n format.html { redirect_to(@usuario, :notice => 'Usuario was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @usuario.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @usuario = Usuario.find(params[:id])\n #@[email protected]\n respond_to do |format|\n if @usuario.update_attributes(params[:usuario])\n format.html { redirect_to(@usuario, :notice => t('exitom')) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @usuario.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @usuario = Usuario.find(params[:id])\n @usuario.senha = Digest::SHA1.to_s(@usuario.senha)\n\n respond_to do |format|\n if @usuario.update_attributes(params[:usuario])\n format.html { redirect_to(consultar_usuario_path(@usuario), :notice => 'O usuário foi editado com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"editar\" }\n format.xml { render :xml => @usuario.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n doc = Nokogiri::XML(request.body.read)\n bNode = doc.xpath('elwak/benutzer')\n\n @benutzer = Benutzer.find(params[:id])\n \n #Sicherstellen, dass Benutzer synchronisiert wird auch wenn nur Objekt-Zuordnungen anders sind!\n @benutzer.updated_at = DateTime.now \n\n if bNode.xpath('objekt_zuordnungs').length > 0\n @benutzer.setze_objekt_zuordnungen(bNode.xpath('objekt_zuordnungs/objekt_id').map{|oz| oz.text.to_s.to_i})\n end\n if @benutzer.update(benutzer_params(bNode))\n success(nil)\n else\n error(@benutzer.errors)\n end\n end", "def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def update\n @tipo_usuario = TipoUsuario.find(params[:id])\n\n respond_to do |format|\n if @tipo_usuario.update_attributes(params[:tipo_usuario])\n format.html { redirect_to(@tipo_usuario, :notice => ' - Dados atualizados com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tipo_usuario.errors, :status => :unprocessable_entity }\n end\n end\n end", "def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n doc = strip_class_attributes(yield doc)\n \n request2 = method.new uri\n request2.content_type = 'application/xml'\n auth_admin(request2)\n\n request2.body=doc.to_s\n \n response2 = http.request request2\n response.value\n\n end\n \nend", "def update(id, name=\"Updated Name\", age=\"55\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <id type='integer'>#{id}</id>\r\n <name>#{name}</name>\r\n <age>#{age}</age> \r\n </person>\"\r\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n # no response body will be returned\r\n case response\r\n when Net::HTTPSuccess\r\n return \"#{response.code} OK\"\r\n else\r\n return \"#{response.code} ERROR\"\r\n end\r\n end", "def update(id, name= \"Updated Name\")\n xml_req =\n \"<?xml version='1.0' encoding='UTF-8'?>\n <customer>\n <id type='integer'>#{id}</id>\n <name>#{name}</name>\n </customer>\"\n\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\n request.add_field \"Content-Type\", \"application/xml\"\n request.body = xml_req\n\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end", "def update\n @usuario = Usuario.find(params[:id])\n\n if @usuario.update(usuario_params)\n head :no_content\n else\n render json: @usuario.errors, status: :unprocessable_entity\n end\n end", "def update\n @usuario = Usuario.find(params[:id])\n\n respond_to do |format|\n if @usuario.update_attributes(params[:usuario])\n format.html { redirect_to @usuario, notice: 'Usuario actualizado correctamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to(root_path, :notice => 'Usuario alterado com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def test_put_invoices_1_xml\n @parameters = {:invoice => {:number => 'NewNumber'}}\n \n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/invoices/1.xml',\n {:invoice => {:number => 'NewNumber'}},\n {:success_code => :ok})\n \n assert_no_difference('Invoice.count') do\n put '/invoices/1.xml', @parameters, credentials('admin')\n end\n \n invoice = Invoice.find(1)\n assert_equal \"NewNumber\", invoice.number\n \n end", "def test_should_update_project_via_API_XML\r\n get \"/logout\"\r\n put \"/projects/1.xml\", :project => {:user_id => 1,\r\n :url => 'http://www.apiproject.com',\r\n :name => 'API Project',\r\n :description => 'API Project Desc' }\r\n assert_response 401\r\n end", "def update\n @nossos_servico = NossosServico.find(params[:id])\n\n respond_to do |format|\n if @nossos_servico.update_attributes(params[:nossos_servico])\n format.html { redirect_to(@nossos_servico, :notice => 'Nossos servico was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @nossos_servico.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @utilisateur = Utilisateur.find(params[:id])\n\n respond_to do |format|\n if @utilisateur.update_attributes(params[:utilisateur])\n flash[:notice] = 'Utilisateur was successfully updated.'\n format.html { redirect_to(@utilisateur) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @utilisateur.errors, :status => :unprocessable_entity }\n end\n end\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 @usuario = User.find(params[:id])\n\n respond_to do |format|\n if @usuario.update_attributes(params[:user])\n flash[:success] = \"Usuario atualizado com sucesso\"\n format.html { redirect_to usuarios_url }\n format.json { head :no_content }\n else\n flash[:error] = \"Erro ao atualizar o usuario\"\n format.html { render action: \"edit\" }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\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 => '[email protected]',\r\n :user_id => 1 }\r\n assert_response 401\r\n end", "def update\n @tipo_usuario = TipoUsuario.find(params[:id])\n\n respond_to do |format|\n if @tipo_usuario.update_attributes(params[:tipo_usuario])\n format.html { redirect_to @tipo_usuario, notice: 'Tipo usuario fue actualizado existosamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tipo_usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @estatu = Estatu.find(params[:id])\n\n respond_to do |format|\n if @estatu.update_attributes(params[:estatu])\n format.html { redirect_to(@estatu, :notice => 'Registro actualizado correctamente.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @estatu.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @estudiante = Estudiante.find(params[:id])\n\n respond_to do |format|\n if @estudiante.update_attributes(params[:estudiante])\n flash[:notice] = 'Actualizado.'\n format.html { redirect_to(@estudiante) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @estudiante.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @estagiarios = Estagiario.find(params[:id])\n\n respond_to do |format|\n if @estagiarios.update_attributes(params[:estagiario])\n flash[:notice] = 'ESTAGIÁRIO SALVO COM SUCESSO.'\n format.html { redirect_to(@estagiarios) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @estagiarios.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\r\n respond_to do |format|\r\n if @usuario.update(usuario_params)\r\n format.html { redirect_to usuarios_url, success: 'Editaste un usuario correctamente.' }\r\n format.json { render :show, status: :ok, location: @usuario }\r\n else\r\n format.html { render :edit }\r\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n @sistema = Sistema.find(params[:id])\n\n respond_to do |format|\n if @sistema.update_attributes(params[:sistema])\n format.html { redirect_to @sistema, notice: 'Sistema was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sistema.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n @sucursale.usuarios_id = current_usuario.id\n if @sucursale.update(sucursale_params)\n format.html { redirect_to @sucursale, notice: 'Sucursal actualizada con exito!' }\n format.json { render :show, status: :ok, location: @sucursale }\n else\n format.html { render :edit }\n format.json { render json: @sucursale.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @usuario = Usuario.find(params[:id])\n\t@temp = @usuario.dup\n respond_to do |format|\n if @usuario.update_attributes(params[:usuario])\n\t\tguardar_log(session[:usuario_id], self.class.name,__method__.to_s, @temp,@usuario)\n\t\tformat.html { redirect_to usuarios_url,:notice => 'Usuario #{@usuario.nombre} fue actualizado correctamente.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @usuario.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @tecnico = Tecnico.find(params[:id])\n @tecnico.user = current_user\n\n respond_to do |format|\n if @tecnico.update_attributes(params[:tecnico])\n format.html { redirect_to @tecnico, notice: 'Técnico foi atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tecnico.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tservicio = Tservicio.find(params[:id])\n\n respond_to do |format|\n if @tservicio.update_attributes(params[:tservicio])\n format.html { redirect_to(@tservicio, :notice => 'Tservicio was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tservicio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @seccion = Seccion.find(params[:id])\n\n respond_to do |format|\n if @seccion.update_attributes(params[:seccion])\n format.html { redirect_to(@seccion, :notice => 'Seccion was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @seccion.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @servicio = Servicio.find(params[:id])\n\n respond_to do |format|\n if @servicio.update_attributes(params[:servicio])\n format.html { redirect_to @servicio, :notice => 'Servicio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @servicio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @usuario.update(usuario_params)\n format.html { redirect_to @usuario, notice: 'Usuario was successfully updated.' }\n format.json { render :show, status: :ok, location: @usuario }\n else\n format.html { render :edit }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @usuario.update(usuario_params)\n format.html { redirect_to @usuario, notice: 'Usuario was successfully updated.' }\n format.json { render :show, status: :ok, location: @usuario }\n else\n format.html { render :edit }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @usuario.update(usuario_params)\n format.html { redirect_to @usuario, notice: 'Usuario was successfully updated.' }\n format.json { render :show, status: :ok, location: @usuario }\n else\n format.html { render :edit }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @nombre = params[:usuario][\"nombre\"];\n @dni = params[:usuario][\"dni\"];\n @email = params[:usuario][\"email\"];\n @tarjeta = params[:usuario][\"tarjeta\"];\n @contrasenia = params[:usuario][\"contrasenia\"];\n @usuario = Usuario.find(params[:id]);\n @usuario.nombre = @nombre;\n @usuario.dni = @dni;\n @usuario.email = @email;\n @usuario.tarjeta = @tarjeta;\n @usuario.contrasenia = @contrasenia;\n if @usuario.save()\n redirect_to @usuario\n else\n render \"edit\";\n end\nend", "def update\n respond_to do |format|\n if @usu.update(usuario_params)\n format.html { redirect_to @usu, notice: 'Usuario was successfully updated.' }\n format.json { render :show, status: :ok, location: @usu }\n else\n format.html { render :edit }\n format.json { render json: @usu.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @usuario.update(usuario_params)\n format.html { redirect_to @usuario, notice: 'Usuario was successfully updated.' }\n format.json { render :show, status: :ok, location: @usuario }\n else\n format.html { render :edit }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n\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 update\n @usuario = Usuario.find(params[:id])\n if @usuario.update(usuario_params)\n redirect_to @usuario\n else\n render 'edit'\n end\n end", "def update\n @usuario.nombres = @usuario.nombres.upcase\n @usuario.apellidos = @usuario.apellidos.upcase\n respond_to do |format|\n if @usuario.update(usuario_params)\n format.html { redirect_to @usuario, notice: 'El Usuario se ha editado correctamente.' }\n format.json { render :show, status: :ok, location: @usuario }\n else\n @div_edit_admin = true\n format.html { render :edit }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @administrativo = Administrativo.find(params[:id])\n\n respond_to do |format|\n if @administrativo.update_attributes(params[:administrativo])\n format.html { redirect_to(@administrativo, :notice => 'Administrativo was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @administrativo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @usuario.isAdmin = false unless current_user.isAdmin #bloqueio de atualização de permissão para usuarios que não são admin\n respond_to do |format|\n if @usuario.update(usuario_params)\n format.html { redirect_to (current_user.isAdmin ? usuarios_url : recibos_url), notice: 'Usuário atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @usuario }\n else\n format.html { render :edit }\n format.json { render json: @usuario.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 update\n @ministerio = Ministerio.find(params[:id])\n\n respond_to do |format|\n if @ministerio.update_attributes(params[:ministerio])\n format.html { redirect_to(@ministerio, :notice => 'Ministerio was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ministerio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @solexame.update(solexame_params)\n flash[:notice] = 'Solicitação foi alterada com sucesso.'\n format.html { redirect_to(@solexame) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @solexame.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @usuario.update(usuario_params)\n format.html { redirect_to moviles_url, notice: \"Se actualizó correctamente el usuario #{@usuario.nombre.titleize}\" }\n else\n format.html { render action: 'edit' }\n end\n end\n end", "def update\n @usuario = Usuario.find(params[:id])\n\n respond_to do |format|\n begin\n @usuario.transaction do\n @usuario.update_attributes(params[:usuario])\n @usuario.update_dias_usuario(params[:data_inicio])\n end\n all_saved = true\n rescue ActiveRecord::StatementInvalid\n all_save = false\n end\n\n if all_saved\n format.html { redirect_to @usuario, notice: 'Usuario was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n format.xml { head :method_not_allowed }\n format.json { head :method_not_allowed }\n end\n end", "def update\n @unidades = Unidade.find(params[:id])\n\n respond_to do |format|\n if @unidades.update_attributes(params[:unidade])\n flash[:notice] = 'UNIDADES SALVA COM SUCESSO.'\n format.html { redirect_to(@unidades) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @unidades.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\r\n respond_to do |format|\r\n if @tipos_usuario.update(tipos_usuario_params)\r\n format.html { redirect_to @tipos_usuario, notice: 'La actualización del nombre del tipo de usuario se realizó correctamente.' }\r\n format.json { render :show, status: :ok, location: @tipos_usuario }\r\n else\r\n format.html { render :edit }\r\n format.json { render json: @tipos_usuario.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n @noticia = Noticia.find(params[:id])\n @noticia.user_id = current_user.id\n\n respond_to do |format|\n if @noticia.update_attributes(params[:noticia])\n flash[:notice] = t(:noticia_updated)\n format.html { redirect_to(@noticia) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @noticia.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @user = V1::User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n flash[:notice] = 'V1::User was successfully updated.'\n format.html { redirect_to(@user) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put!\n request! :put\n end", "def update\n @empleadosautorizado = Empleadosautorizado.find(params[:id])\n\n respond_to do |format|\n if @empleadosautorizado.update_attributes(params[:empleadosautorizado])\n format.html { redirect_to(@empleadosautorizado, :notice => 'Empleadosautorizado was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @empleadosautorizado.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @suministro = Suministro.find(params[:id])\n\n respond_to do |format|\n if @suministro.update_attributes(params[:suministro])\n format.html { redirect_to(@suministro, :notice => 'Suministro was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @suministro.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @estudiante = Estudiante.find(params[:id])\n\n respond_to do |format|\n if @estudiante.update_attributes(params[:estudiante])\n format.html { redirect_to(@estudiante, :notice => 'Estudiante was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @estudiante.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @unidade = Unidade.find(params[:id])\n\n respond_to do |format|\n if @unidade.update_attributes(params[:unidade])\n flash[:notice] = 'Unidade atualizada com sucesso.'\n format.html { redirect_to(@unidade) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @unidade.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @ministerios = Ministerios.find(params[:id])\n @title = \"Edição do Ministério: \" + @ministerios.nome\n respond_to do |format|\n if @ministerios.update_attributes(params[:ministerios])\n Ministerios.update(@ministerios.id, :respmod => self.current_usuarios.login.upcase)\n \tflash[:notice] = 'Ministerios was successfully updated.'\n format.html { redirect_to(ministerios_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ministerios.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @regiaos = Regiao.find(params[:id])\n\n respond_to do |format|\n if @regiaos.update_attributes(params[:regiao])\n flash[:notice] = 'REGIÃO SALVA COM SUCESSO'\n format.html { redirect_to(@regiaos) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @regiaos.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @tipo_de_documento = TipoDeDocumento.find(params[:id])\n\n respond_to do |format|\n if @tipo_de_documento.update_attributes(params[:tipo_de_documento])\n format.html { redirect_to(@tipo_de_documento, :notice => 'Tipo de documento atualizado com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tipo_de_documento.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @catalogo_usuario.update(catalogo_usuario_params)\n format.html { redirect_to @catalogo_usuario, notice: 'Catalogo usuario was successfully updated.' }\n format.json { render :show, status: :ok, location: @catalogo_usuario }\n else\n format.html { render :edit }\n format.json { render json: @catalogo_usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @unidad = Unidad.find(params[:id])\n\n respond_to do |format|\n if @unidad.update_attributes(params[:unidad])\n flash[:notice] = 'Unidad was successfully updated.'\n format.html { redirect_to(@unidad) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @unidad.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @valor_sistema = ValorSistema.find(params[:id])\n\n respond_to do |format|\n if @valor_sistema.update_attributes(params[:valor_sistema])\n flash[:notice] = 'ValorSistema was successfully updated.'\n format.html { redirect_to(@valor_sistema) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @valor_sistema.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @cuenta = Cuenta.find(params[:id])\n\n respond_to do |format|\n if @cuenta.update_attributes(params[:cuenta])\n flash[:notice] = 'Cuenta actualizada con exito.'\n format.html { redirect_to(@cuenta) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @cuenta.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @usuario.update(usuario_params)\n\n \n format.html { redirect_to \"/usuarios\", notice: 'Datos guardados satisfactoriamente.' }\n format.json { render :show, status: :ok, location: @usuario }\n\n \n else\n format.html { render :edit }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n\n end", "def update\n @tipo_system_user = TipoSystemUser.find(params[:id])\n\n respond_to do |format|\n if @tipo_system_user.update_attributes(params[:tipo_system_user])\n format.html { redirect_to(@tipo_system_user, :notice => 'Tipo system user was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tipo_system_user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @idioma_usuario = IdiomaUsuario.find(params[:id])\n @usuario = @idioma_usuario.usuario\n respond_to do |format|\n if @idioma_usuario.update_attributes(params[:idioma_usuario])\n format.html {\n flash[:notice] = 'Se edito el idioma correctamente.'\n redirect_to(cuenta(@formacion.usuario)) }\n format.js {actualizar_view}\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @idioma_usuario.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @tipo_fuente = TipoFuente.find(params[:id])\n\n respond_to do |format|\n if @tipo_fuente.update_attributes(params[:tipo_fuente])\n format.html { redirect_to(@tipo_fuente, :notice => 'TipoFuente was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tipo_fuente.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @solicitudrecurso = Solicitudrecurso.find(params[:id])\n \n\n respond_to do |format|\n\n \n if @solicitudrecurso.update_attributes(:motivos => params[:motivos])\n \n @solicitudrecursos = Solicitudrecurso.find_all_by_usuario_id(@usuario_actual.id)\n format.html { redirect_to :action => \"index\" }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @solicitudrecurso.errors, :status => :unprocessable_entity }\n end\n \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\n @nostro = Nostro.find(params[:id])\n\n respond_to do |format|\n if @nostro.update_attributes(params[:nostro])\n flash[:notice] = 'Nostro was successfully updated.'\n format.html { redirect_to(@nostro) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @nostro.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put(*args)\n request :put, *args\n end", "def update\n @serie = Serie.find(params[:id])\n\n respond_to do |format|\n if @serie.update_attributes(params[:serie])\n format.html { redirect_to(niveis_ensino_serie_url(@nivel,@serie), :notice => 'Serie atualizado com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @serie.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n if @tecnico.update_attributes(params[:tecnico])\n format.html { redirect_to @tecnico, notice: 'Tecnico atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tecnico.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @namespace = Namespace.find_by_name(params[:id])\n\n respond_to do |format|\n if @namespace.update_attributes(params[:namespace])\n format.html { redirect_to(@namespace, :notice => 'Namespace was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @namespace.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @aniversario = Aniversario.find(params[:id])\n\n respond_to do |format|\n if @aniversario.update_attributes(params[:aniversario])\n format.html { redirect_to(@aniversario, :notice => 'Aniversario was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @aniversario.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @cuenta = Cuenta.find(params[:id])\n \n respond_to do |format|\n if @cuenta.update_attributes(params[:cuenta])\n flash[:notice] = 'Cuenta actualizado correctamente.'\n format.html { redirect_to(@cuenta) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @cuenta.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_current_logged_in_user(args = {}) \n put(\"/users.json/current\", args)\nend", "def update\n @cuenta = Cuenta.find(params[:id])\n\n respond_to do |format|\n if @cuenta.update_attributes(params[:cuenta])\n format.html { redirect_to(@cuenta, :notice => 'Cuenta was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @cuenta.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n if(params[:usertype] != nil and params[:usertype] != 2)\n params[:sistema] = nil # TODO isso nao funfa\n end\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to root_url, notice: 'Usuario foi atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @contratosinterventoria = Contratosinterventoria.find(params[:id])\n\n respond_to do |format|\n if @contratosinterventoria.update_attributes(params[:contratosinterventoria])\n format.html { redirect_to(@contratosinterventoria, :notice => 'Contratosinterventoria was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @contratosinterventoria.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @title = \"EDITAR WMI NAMESPACE\"\n @wmi_namespace = WmiNamespace.find(params[:id])\n\n respond_to do |format|\n if @wmi_namespace.update_attributes(params[:wmi_namespace])\n flash[:notice] = 'Wmi Namespace fué actualizado correctamente.'\n format.html { redirect_to(@wmi_namespace) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @wmi_namespace.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @tipo_controles = TipoControle.find(params[:id])\n\n respond_to do |format|\n if @tipo_controles.update_attributes(params[:tipo_controle])\n flash[:notice] = 'CADASTRADO COM SUCESSO.'\n format.html { redirect_to(@tipo_controles) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tipo_controles.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @estagio = Estagio.find(params[:id])\n\n respond_to do |format|\n if @estagio.update_attributes(params[:estagio])\n flash[:notice] = 'Estagio was successfully updated.'\n format.html { redirect_to(@estagio) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @estagio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @usuario = User.find(params[:id])\n\n respond_to do |format|\n if @usuario.update_attributes(user_params)\n flash[:notice] = @@msgs\n format.html { redirect_to usuario_url }\n format.json { head :no_content }\n else\n flash[:alert] = @@msge\n format.html { render action: \"edit\" }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @usuario.update(usuario_params)\n @usuario.modificar_role(params[:usuario][:roles])\n format.html { redirect_to empresa_usuarios_path(@usuario.empresa_id), notice: 'Usuario was successfully updated.' }\n format.json { render :show, status: :ok, location: @usuario }\n else\n format.html { render :edit }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @owner = Owner.find(params[:id])\n\n respond_to do |format|\n if @owner.update_attributes(params[:owner])\n format.html { redirect_to owners_path, notice: 'Oferta a fost updatata cu success.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @owner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # respond_to do |format|\n # if @usuario.update(usuario_params)\n @usuario = Usuario.find_by_id(params[:id])\n p \"-----------------------------------\"\n p params[:usuario]\n p \"-----------------------------------\"\n if @usuario.update(usuario_params)\n # format.json { render :show, status: :ok, location: @usuario }\n render :json=> {:success=>true, :usuario=>@usuario, :message=>\"Usuario actualizado correctamente\"},:status=>200\n else\n render :json=> {:success=>false, :message=>\"Error al actualizar\"},:status=>404\n # format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n # end\n end", "def update\n @senhas = Senha.find(params[:id])\n\n respond_to do |format|\n if @senhas.update_attributes(params[:senha])\n flash[:notice] = 'SENHA SALVA COM SUCESSO.'\n format.html { redirect_to(senhas_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @senhas.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @centro_usuario.update(centro_usuario_params)\n format.html { redirect_to @centro_usuario, notice: 'Centro usuario was successfully updated.' }\n format.json { render :show, status: :ok, location: @centro_usuario }\n else\n format.html { render :edit }\n format.json { render json: @centro_usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @remocao = Remocao.find(params[:id])\n respond_to do |format|\n if @remocao.update_attributes(params[:remocao])\n flash[:notice] = 'Remocao efetuada com sucesso.'\n format.html { redirect_to(@remocao) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @remocao.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n\t\t@clinica = Clinica.find(params[:id])\n\t\t id = @clinica.id\n\t\t@usuario = Usuario.find_by_datos_id(id, :conditions => \"datos_type = 'Clinica'\")\n\n # @clinica.sitioWeb = \"http://#{@clinica.sitioWeb}\"\n\n respond_to do |format|\n if @clinica.valid? && @usuario.valid?\n\t\t\t\[email protected]_attributes(params[:clinica])\n\t\t\t\[email protected]_attributes(params[:usuario])\n flash[:notice] = 'La clinica fue actualizada satisfactoriamente'\n format.html { redirect_to :back }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @clinica.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @instituto.update_attributes(params[:instituto])\n format.html { redirect_to(@instituto, :notice => 'Instituto fue modificado exitosamente.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @instituto.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @inventario = Inventario.find(params[:id])\n @foto = @inventario.foto\n \n @service = InventarioService.new(@inventario, @foto)\n respond_to do |format|\n\n if @inventario.update_attributes(params[:inventario],params[:foto_file])\n format.html { redirect_to(@inventario, :notice => 'Inventario was successfully updated.') }\n format.xml { head :ok }\n else\n\t @foto = @service.foto\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @inventario.errors, :status => :unprocessable_entity }\n end\n end\n end", "def edit\n @usuario = Usuario.find(params[:id])\n end", "def update\n @relatorios = Relatorio.find(params[:id])\n\n respond_to do |format|\n if @relatorios.update_attributes(params[:relatorio])\n flash[:notice] = 'RELATORIO SALVO COM SUCESSO.'\n format.html { redirect_to(@relatorios) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @relatorios.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @instituicao = Instituicao.find(params[:id])\n\n respond_to do |format|\n if @instituicao.update_attributes(params[:instituicao])\n format.html { redirect_to(@instituicao, :notice => 'Instituicao was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @instituicao.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @tipo_vinculo = TipoVinculo.find(params[:id])\n\n respond_to do |format|\n if @tipo_vinculo.update_attributes(params[:tipo_vinculo])\n flash[:notice] = 'TipoVinculo was successfully updated.'\n format.html { redirect_to(@tipo_vinculo) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tipo_vinculo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @kudo = Kudo.find(params[:id])\n\n respond_to do |format|\n if @kudo.update_attributes(params[:kudo])\n format.html { redirect_to(@kudo, :notice => 'Kudos was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @kudo.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
[ "0.6400291", "0.6345927", "0.628902", "0.6155422", "0.6151271", "0.6124549", "0.61086804", "0.61059177", "0.6025157", "0.6007945", "0.59239113", "0.59172136", "0.5909498", "0.5881531", "0.58777416", "0.5872825", "0.58191544", "0.5815104", "0.58147043", "0.57693124", "0.57551545", "0.57297486", "0.56591624", "0.5654933", "0.56526184", "0.56453794", "0.56294286", "0.5629388", "0.56122136", "0.5605239", "0.55937755", "0.5583625", "0.5573322", "0.5573322", "0.5573322", "0.55714464", "0.5566715", "0.5552649", "0.5547486", "0.5543823", "0.5541943", "0.55352855", "0.5533042", "0.553213", "0.55285627", "0.55238485", "0.552232", "0.55214065", "0.55192906", "0.5511803", "0.55072135", "0.5501972", "0.550069", "0.5497787", "0.5496353", "0.549097", "0.54891986", "0.5484838", "0.54824173", "0.54708225", "0.54682416", "0.54642683", "0.5459711", "0.5456563", "0.54550314", "0.54522824", "0.5450279", "0.54485005", "0.5446642", "0.5443506", "0.5440683", "0.5439553", "0.5439512", "0.54216707", "0.5412749", "0.54109925", "0.54062784", "0.5405719", "0.5399854", "0.5399531", "0.5398549", "0.53967446", "0.53958285", "0.5395652", "0.5392712", "0.53874177", "0.53810793", "0.53716445", "0.53691196", "0.5368266", "0.53582144", "0.5350911", "0.535024", "0.5349346", "0.5349064", "0.53451085", "0.5338696", "0.53338814", "0.53276247", "0.5325923" ]
0.63276196
2
Edita su propio perfil
def edit_perfil usuario = current_user if usuario @usuario = usuario else redirect_to "/login" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n @profile = current_user.profile\n if @profile.update(profile_params)\n format.html { redirect_to '/home', notice: 'El perfil fue actualizado correctamente.' }\n else\n format.html { render :edit }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @perfil.update(perfil_params)\n format.html { redirect_to perfil_usuario_path, notice: 'Perfil atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @perfil }\n else\n format.html { render :edit }\n format.json { render json: @perfil.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n @profesor = Profesor.find(params[:id])\n end", "def set_usuario_perfil\n @usuario_perfil = UsuarioPerfil.find(params[:id])\n end", "def set_perfil\n @perfil = Perfil.find(params[:id])\n end", "def set_perfil\n @perfil = Perfil.find(params[:id])\n end", "def set_perfil\n @perfil = Perfil.find(params[:id])\n end", "def update\n @perfil = Perfil.find(params[:id])\n\n respond_to do |format|\n if @perfil.update_attributes(params[:perfil])\n flash[:notice] = 'Perfil was successfully updated.'\n format.html { redirect_to(@perfil) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @perfil.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @perfil = Perfil.find(params[:id])\n\n respond_to do |format|\n if @perfil.update_attributes(params[:perfil])\n flash[:notice] = 'Perfil was successfully updated.'\n format.html { redirect_to(@perfil) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @perfil.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @profil.update(profil_params)\n format.html { redirect_to @profil, notice: 'Profil was successfully updated.' }\n format.json { render :show, status: :ok, location: @profil }\n else\n format.html { render :edit }\n format.json { render json: @profil.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @asociacion_perfil = AsociacionPerfil.find(params[:id])\n\n respond_to do |format|\n if @asociacion_perfil.update_attributes(params[:asociacion_perfil])\n flash[:notice] = 'AsociacionPerfil was successfully updated.'\n format.html { redirect_to(@asociacion_perfil) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @asociacion_perfil.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @profil.update(profil_params)\n format.html { redirect_to @profil, notice: 'Profil erfolgreich aktualisiert.' }\n format.json { render :show, status: :ok, location: @profil }\n else\n format.html { render :edit }\n format.json { render json: @profil.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n @profile.slug=nil\n if @profile.update(profile_params)\n @profile.user.cedula = @profile.cedula\n @profile.user.save\n ruta = @profile==current_user.profile ? my_profile_path : @profile\n format.html { redirect_to ruta, notice: 'El perfil fue actualizado exitosamente.' }\n format.json { render :show, status: :ok, location: @profile }\n else\n format.html { render :edit }\n format.json { render json: @profile.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_profil\n @profil = User.find(params[:id])\n end", "def update\n @perfilnegocio = Perfilnegocio.find(params[:id])\n\n respond_to do |format|\n if @perfilnegocio.update_attributes(params[:perfilnegocio])\n format.html { redirect_to @perfilnegocio, notice: 'Perfilnegocio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @perfilnegocio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @usuario_perfil.update(usuario_perfil_params)\n format.html { redirect_to @usuario_perfil, notice: 'Usuario perfil was successfully updated.' }\n format.json { render :show, status: :ok, location: @usuario_perfil }\n else\n format.html { render :edit }\n format.json { render json: @usuario_perfil.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @user.update_attributes(params[:user])\n flash[:notice] = \"Le profil a bien été modifié\"\n redirect_to user_path(@user)\n else\n render :action => 'edit'\n end\n end", "def set_profil\n @profil = Profil.find(params[:id])\n end", "def set_profil\n @profil = Profil.find(params[:id])\n end", "def update\n @funcionario.pessoa = @funcionario.pessoa.specific\n if @funcionario.update(funcionario_params)\n flash[:notice] = \"Funcionario alterado com sucesso\"\n redirect_to @funcionario\n else\n render :edit\n end\n end", "def update\n @perfile = Perfile.find(params[:id])\n @perfile.direccionusuario_attributes.where(:id => current_user.id)\n respond_to do |format|\n if @perfile.perfileusuarios_attributes(params[:perfile]) and @perfile.direccionusuario.direccionusuario_attributes(params[:perfilusuario])\n format.html { redirect_to @perfile, notice: 'Perfile was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @perfile.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # Button press on edit page\n\n # Read the user and update the attributes (don't save at this point)\n @user = User.find(params[:id])\n render_error h \"Der Spezialbenutzer #{@user.username} kann nicht editiert werden.\" and return if @user.special?\n @user.attributes=params[:user] if params[:user]\n\n # Subpages\n select_person and return if params['select_person']\n\n if params['commit']\n # 'Save' button\n render 'edit' and return if [email protected]\n\n flash[:notice] = \"Der Benutzer #{@user.username} wurde gespeichert.\"\n redirect_to_origin(default=@user)\n return\n end\n\n render 'edit'\n end", "def update\n \t@user = User.find(params[:id])\n \tif @user.update_attributes(user_params)\n \t#handle a succesful update\n \tflash[:success] = \"Profil updated\"\n \tredirect_to @user\n \t\n \telse\n \trender 'edit'\n \tend\n end", "def edit_profile\n \t@user = UsersService.findUserById(params[:id])\n \tuser = UsersService.findUserById(params[:id])\n \t@user_profile_form = UserProfileForm.new(UserProfileForm.attributes(user, :edit_profile))\n end", "def edit\n @paciente = Paciente.find(params[:id])\n end", "def edit\n @telefono = @persona.telefonos.find(params[:id])\n end", "def update\n @paciente = Paciente.find(params[:id])\n\n @upersona = @paciente.personas.last\n @paciente_edit = @upersona.perstable\n respond_to do |format|\n if @paciente_edit.update(params[:paciente].permit(:domicilio, :civil, :nss, :edad, :peso, :talla, :imc, :t_sangre, :persona))\n format.html { redirect_to pacientes_path , notice: 'Paciente was successfully updated.' }\n format.json { render :show, status: :ok, location: pacientes_path }\n else\n format.html { render :edit }\n format.json { render json: @paciente.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n @profile = Profile.find(current_user.id)\n end", "def update\n respond_to do |format|\n if @politico.update(politico_params) and @politico.update_attributes(:modificador => current_user.id)\n format.html { redirect_to @politico, notice: 'Politico was successfully updated.' }\n format.json { render :show, status: :ok, location: @politico }\n else\n format.html { render :edit }\n format.json { render json: @politico.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n @user.profile ||= Profile.new\n @profile = @user.profile\n end", "def update\n respond_to do |format|\n if @perfil_egresado.update(perfil_egresado_params)\n format.html { redirect_to @perfil_egresado, notice: 'Perfil egresado was successfully updated.' }\n format.json { render :show, status: :ok, location: @perfil_egresado }\n else\n format.html { render :edit }\n format.json { render json: @perfil_egresado.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_perfil_egresado\n @perfil_egresado = PerfilEgresado.find(params[:id])\n end", "def update\n respond_to do |format|\n if @profile.update(profile_params)\n format.html { redirect_to(@profile, \n :notice => 'Perfil actualizado correctamente.') }\n else\n format.html {render :action => \"edit\"}\n format.json { render :json => @profile.errors, :status => :unprocessable_entity }\n end\n end\n end", "def edit_profile\n end", "def edit\n set_user\n end", "def edit\n\t\t#Find the Particular Profile\n\t\t@surgeon_profile = @profile\n\tend", "def edit\n @usuario = Usuario.find(params[:id])\n end", "def update\n @persona = Persona.find(params[:id])\n if @persona.usuario.nil?\n if @persona.build_usuario(:email=>\"[email protected]\",:password => '123456789', :password_confirmation=>'123456789').save\n redirect_to @persona, notice: 'La Persona fue actualizada correctamente'\n else\n redirect_to crear_usuario_persona_path(@persona), notice: 'Error intente nuevamente.'\n end\n\n else\n if @persona.update_attributes(params[:persona])\n redirect_to @persona, notice: 'La Persona fue actualizada correctamente'\n else\n render action: \"edit\"\n end\n end\n\n end", "def perfil_params\n params.require(:perfil).permit(:nombre)\n end", "def update\n @permiso = Permiso.find(params[:id])\n\n respond_to do |format|\n if @permiso.update_attributes(params[:permiso])\n format.html { redirect_to(@permiso, :notice => 'Permiso fue modificado exitosamente.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @permiso.errors, :status => :unprocessable_entity }\n end\n end\n end", "def edit\n @user ||= User.find(params[:id])\n @quote = Quote.random\n if @user.id != session[:user]\n flash[:error] = 'Só podes alterar o teu próprio perfil'\n redirect_to root_path\n end\n end", "def update\n @campeonato = Campeonato.find(params[:id])\n\n if @campeonato.update_attributes(params[:campeonato])\n redirect_to(@campeonato, :notice => 'Campeonato foi alterado com sucesso.')\n else\n render :action => \"edit\"\n end\n end", "def actualizar\n @puntaje = Puntaje.find(params[:id])\n datos_puntaje = params.require(:puntaje).permit(:tipo)\n @puntaje.tipo = datos_puntaje[:tipo]\n @puntaje.save\n redirect_to puntajes_path\n end", "def edit\n @profile = User.find(params[:id])\n end", "def update\n respond_to do |format|\n if @perfisusuario.update(perfisusuario_params)\n format.html { redirect_to perfisusuarios_url, notice: 'Perfil de Usuário editado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: @perfisusuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n @title = \"Edit basic info\"\n @user=User.find(session[:user_id])\n if param_posted?(:user)\n attribute = params[:attribute]\n case attribute\n when \"email\"\n try_to_update @user, attribute\n when \"password\"\n if @user.correct_password?(params)\n try_to_update @user, attribute\n else\n @user.password_errors(params)\n end\n when \"team_id\"\n try_to_update @user, attribute\n end\n end \n #For security purpose, never fill in password fields automatically.\n @user.clear_password!\n end", "def update\n\n if session[:user]['perfil'] == 'Administrador'\n respond_to do |format|\n @user.nome = params[:user][:nome]\n @user.login = params[:user][:login]\n @user.email = params[:user][:email]\n @user.profile_id = params[:user][:profile_id]\n\n @user.password = User.encripitar_senha(params[:user][:password])\n @user.telefone = params[:user][:telefone]\n\n # Vincula perfis aos usuário\n # vincular_user_profiles\n\n # Vincula os módulos e dominios ao usuário\n vincular_modulos_ao_usuario\n\n if @user.save\n flash[:notice] = 'Usuário atualizado com sucesso.'\n format.html {redirect_to '/users/'}\n format.json {render :show, status: :ok, location: @user}\n else\n format.html {render :edit}\n format.json {render json: @user.errors, status: :unprocessable_entity}\n end\n end\n else\n respond_to do |format|\n flash[:warning] = 'Você não possui permissão para acessar esse recurso.'\n format.html {redirect_to '/'}\n format.json {head :no_content}\n end\n end\n # vincular_user_profiles\n end", "def edit\n @title = \"Edit Profile\"\n @user = current_user\n @user.profile ||= Profile.new\n @profile = @user.profile\n if param_posted?(:profile)\n if @user.profile.update_attributes(params[:profile])\n flash[:notice] = \"Changes saved.\"\n # redirect_to :controller => \"profile\", :action => \"index\"\n end\n end\n end", "def update\n @profesor = Profesor.find(params[:id])\n\n respond_to do |format|\n if @profesor.update_attributes(params[:profesor])\n flash[:notice] = \"Los datos del Profesor #{@profesor.nombre_completo} se han actualizado.\"\n format.html { redirect_to(@profesor) }\n format.xml { head :ok }\n else\n flash[:error] = \"Hubo un error editando el profesor.\"\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @profesor.errors, :status => :unprocessable_entity }\n end\n end\n end", "def edit_profile\n @user = UserService.getUserById(params[:id])\n @profile_form = ProfileForm.new(ProfileForm.initialize(@user, :new_profile))\n end", "def update\n respond_to do |format|\n @profil.sexe = params[:sexe]\n @profil.preference_id = params[:preference]\n @profil.age_preference_id = params[:age_preference]\n if @profil.update(profil_params)\n format.html { redirect_to space_myprofil_path, notice: 'Profil was successfully updated.' }\n format.json { render :show, status: :ok, location: @profil }\n else\n format.html { render :edit }\n format.json { render json: @profil.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @proveedor = Proveedor.find(current_proveedor.perfilable_id)\n \n params[:proveedor][:pais_id] = 1 # Venezuela\n \n @localidad = params[:proveedor][:localidad_id]\n if Genericas::validar_parametros_a_objeto_sin_localidad(@proveedor, params[:proveedor])\n params[:proveedor][:localidad_id] = UbicacionGeografica.buscar_o_crear_id_de_localidad(@localidad,params[:proveedor][:municipio_id])\n end\n\n \n respond_to do |format|\n if @proveedor.update_attributes(params[:proveedor])\n flash[:success] = \"Perfil actualizado.\"\n format.html { redirect_to panel_proveedor_path }\n format.json { head :no_content }\n else\n flash[:error] = \"Ocurrió un error. Revisa el formulario.\"\n format.html { render action: \"edit\" }\n format.json { render json: @proveedor.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n @user = User.find_by_id(params[:id])\n logged_in_user = session[:user_hash][\"username\"]\n if logged_in_user != @user.sunet and not \n User.is_power_user(logged_in_user)\n # permission denied\n flash[:error] = \"Your privileges don't allow you to edit profiles other than your own.\"\n redirect_to \"/users#/users/\"\n end\n @photos = Photo.find_all_by_user_id(params[:id])\n end", "def edit\n @user = User.find_by_id(params[:id])\n logged_in_user = session[:user_hash][\"username\"]\n if logged_in_user != @user.sunet and not \n User.is_power_user(logged_in_user)\n # permission denied\n flash[:error] = \"Your privileges don't allow you to edit profiles other than your own.\"\n redirect_to \"/users#/users/\"\n end\n @photos = Photo.find_all_by_user_id(params[:id])\n end", "def edit\n @user = User.find(params[:user_id])\n @profile = @user.profile\n \n end", "def edit\n @user = User.find (params[:user_id])\n @profile = @user.profile\n end", "def edit\n @user = current_user\n @profile = current_user.profile\n end", "def update\n \tauthorize! :update, @palestrante\n @palestrante = Palestrante.find(params[:id])\n\n respond_to do |format|\n if @palestrante.update_attributes(params[:palestrante])\n format.html { redirect_to @palestrante, notice: 'Palestrante alterado com sucesso!' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @palestrante.errors, status: :unprocessable_entity }\n end\n end\n end", "def profile_edit\n @user = User.find(current_user.id)\n end", "def update\n authorize! :update, Tipo\n respond_to do |format|\n if @tipo.update(tipo_params)\n log(\"Se ha editado la nomina #{@lt}\", 1)\n format.html { redirect_to tipos_path, notice: 'Los datos de la nómina fueron actualizados exitosamente.' }\n format.json { head :no_content }\n end\n end\n end", "def update\n @profile = current_user.profile\n\n respond_to do |format|\n if @profile.update_attributes(params[:profile])\n flash[:notice] = \"Ваш профиль успешно обновлён\"\n format.html { redirect_to(profile_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @profile.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :manage, Pupil\n respond_to do |format|\n if @pupil.update(pupil_attrs)\n format.html { redirect_to @pupil, notice: t('action.update.succeed', entity: Pupil.model_name.human) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @pupil.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @user.update_attributes(params[:user])\n flash[:success] = \"Profil mis à jour\"\n sign_in @user\n redirect_to @user\n else\n render 'edit'\n end\n end", "def edit_profile\n \t@user = current_user\n end", "def update\n @usuario = Usuario.find(params[:id])\n \n if !params[:clave_actual].nil?\n user = Usuario.authenticate(params[:usuario], params[:clave_actual])\n \n if !user\n format.html { render action: \"cambiar_clave\" }\n end\n end\n \n respond_to do |format|\n if @usuario.update_attributes(params[:usuario])\n format.html { redirect_to @usuario, notice: 'Usuario fue actualizado satisfactoriamente' }\n format.json { head :no_content }\n else\n if params[:perfil_id].nil?\n format.html { render action: \"cambiar_clave\" }\n else\n format.html { render action: \"edit\" }\n end\n \n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_profil\n @profil = Profil.find_by user_id: current_user.id\n end", "def update\n @profile = Profile.find_by_user_id(current_user.id)\n\n if @profile.update_attributes(params[:profile])\n flash[:notice] = \"Personal info saved sucessfuly\"\n else\n error_messages(@profile)\n end\n\n redirect_to edit_profile_path\n end", "def update\n @profesor = Profesor.find(params[:id])\n\n respond_to do |format|\n if @profesor.update_attributes(params[:profesor])\n format.html { redirect_to(@profesor, :notice => 'Profesor was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @profesor.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @nombre = params[:usuario][\"nombre\"];\n @dni = params[:usuario][\"dni\"];\n @email = params[:usuario][\"email\"];\n @tarjeta = params[:usuario][\"tarjeta\"];\n @contrasenia = params[:usuario][\"contrasenia\"];\n @usuario = Usuario.find(params[:id]);\n @usuario.nombre = @nombre;\n @usuario.dni = @dni;\n @usuario.email = @email;\n @usuario.tarjeta = @tarjeta;\n @usuario.contrasenia = @contrasenia;\n if @usuario.save()\n redirect_to @usuario\n else\n render \"edit\";\n end\nend", "def update\n respond_to do |format|\n if @profile.update(profile_params)\n format.html { redirect_to @profile, notice: 'Din profil uppdaterades!' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @profile.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n\t\t@user = User.find( params[:user_id] )\n\t\t@profile = @user.profile\n\tend", "def edit\n\t\tadd_breadcrumb \"Editar\"\n\t @service = servicio\n\t if @service.present?\n\t \t\t@experience = servicio.experiences.find(params[:id])\n\t \telse\n\t \t\t@experience = Experience.find(params[:id])\n\t \tend\n\t if current_user != @experience.professor\n\t \tredirect_to root_path, alert: \"Solo el profesor dueño de esta experiencia puede editarla.\"\n\t end\n\tend", "def update\n @pizarra = Pizarra.find(params[:id])\n\n respond_to do |format|\n if @pizarra.update_attributes(params[:pizarra])\n flash[:notice] = 'El nombre de la pizarra se ha actualizado.'\n format.html { redirect_to(admin_pizarras_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @pizarra.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @profilsekolah.update(profilsekolah_params)\n format.html { redirect_to @profilsekolah, notice: 'Profilsekolah was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @profilsekolah.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @punto.update(punto_params) and @punto.update_attributes(:modificador => current_user.id)\n format.html { redirect_to @punto, notice: 'Punto was successfully updated.' }\n format.json { render :show, status: :ok, location: @punto }\n else\n format.html { render :edit }\n format.json { render json: @punto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @permiso.update(permiso_params)\n format.html { redirect_to permisos_path, notice: 'Permiso fue actualizado.' }\n format.json { render :show, status: :ok, location: @permiso }\n else\n format.html { render :edit }\n format.json { render json: @permiso.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n @pizarra = Pizarra.find(params[:id])\n end", "def update\n @persona = Persona.find(params[:id])\n\n respond_to do |format|\n if @persona.update_attributes(params[:persona])\n format.html { redirect_to(admin_path(@persona), :notice => t('adminactualizado')) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @persona.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @company = Company.find(params[:company_id])\n if !can?(:manage, @company)\n raise CanCan::AccessDenied.new(\"Usted no puede administrar otra compañia\", :manage, @company)\n end\n @user = User.find(params[:id])\n @roles = Role.all\n if !params.has_key?(:password_only)\n role_ids = params[:role_ids] if params[:role_ids]\n role_ids ||= []\n @user.role_ids = role_ids\n end\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n if params.has_key?(:password_only)\n format.html { redirect_to show_user_profile_path(@company, @user), notice: 'El perfil fue editado exitosamente.' }\n format.json { head :no_content }\n else \n format.html { redirect_to company_user_path(@company, @user), notice: 'El usuario fue editado exitosamente.' }\n format.json { head :no_content }\n end\n else\n if !params.has_key?(:password_only)\n format.html { render action: \"edit\" }\n else\n format.html { render action: \"edit_password\" }\n end\n \n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n authorize! :edit, @profile\n end", "def update\n respond_to do |format|\n if @pagina_principal.update(pagina_principal_params)\n format.html { redirect_to @pagina_principal, notice: 'Pagina principal was successfully updated.' }\n format.json { render :show, status: :ok, location: @pagina_principal }\n else\n format.html { render :edit }\n format.json { render json: @pagina_principal.errors, status: :unprocessable_entity }\n end\n end\n end", "def agregar_profesor\n @grupo = Grupo.find(params[:id])\n if request.get?\n @profesores = Profesor.search(params[:buscar])\n end\n if request.put?\n @profesor = Profesor.find(params[:profesor_id])\n @grupo.profesor = @profesor\n flash[:notice] = \"Se modificó el profesor al grupo #{@grupo.nombre_completo}\" if @grupo.save\n redirect_to grupo_path(@grupo)\n end\n end", "def user_profile_edit\n\n\n end", "def update\n @persona_tipo = PersonaTipo.find(params[:id])\n\n respond_to do |format|\n if @persona_tipo.update_attributes(params[:persona_tipo])\n format.html { redirect_to @persona_tipo, notice: 'Tipo de participante actualizado correctamente.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @persona_tipo.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n enforce_update_permission(@user)\n end", "def edit_profile(opts = {})\n clear_screen(opts)\n form = View.edit_profile(opts)\n\n case form[:steps].last[:option].to_i\n when 1\n user = User.load\n user = User.new(\n name: form[:name],\n email: form[:email],\n phone: form[:phone],\n password: form[:password],\n gopay: user.gopay\n )\n user.save!\n form[:user] = user\n view_profile(form)\n when 2\n view_profile(form)\n else\n form[:flash_msg] = 'Wrong option entered, please retry'\n edit_profile(form)\n end\n end", "def edit\n @user = User.find(params[:id])\n # @user は編集対象のユーザー\n # current_user はログインしているユーザー \n\n end", "def update\n respond_to do |format|\n if @poto.update(poto_params)\n format.html { redirect_to @poto, notice: 'Poto was successfully updated.' }\n format.json { render :show, status: :ok, location: @poto }\n else\n format.html { render :edit }\n format.json { render json: @poto.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n @person = Person.find(session[:user_id])\n end", "def edit\n user = User.find(params[:user_id])\n @profile = user.profile\n end", "def edit_profile\n @user = User.find params[:id]\n end", "def update\n @profesore = Profesore.find(params[:id])\n\n respond_to do |format|\n if @profesore.update_attributes(params[:profesore])\n format.html { redirect_to @profesore, notice: 'Profesore was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @profesore.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @diretor = Diretor.order('nome')\n @ator = Ator.order('nome')\n\n respond_to do |format|\n if @filme.update_attributes(filme_params)\n format.html { redirect_to @filme, notice: 'O filme foi atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @filme.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n @user = User.find(params[:id])\n @user.update(user_params)\n end", "def update\n @profile = Profile.find(params[:id])\n \n #@profile.email = \n #puts \"ATRIBUTIIIIIIIIIIIIIi\"\n #for @enProfil in @profile.attribute_names\n # puts @enProfil\n #end\n #puts \"PARAMETRIIIIII\"\n \n #puts \"PROFILE = \" + @profile.to_s\n #puts \"USER = \" + @profile.user.to_s\n #@profile.update_attribute(:email, @profile.email)\n #@profile.update_attribute(:im, \"drekkkk\")\n #@profile.save\n #puts 'PRVI PARAMETER = '+ params[:IM]\n\t\n\n respond_to do |format|\n if @profile.update_attributes(params[:profile])\n flash[:notice] = 'Profile was successfully updated.'\n format.html { redirect_to(@profile) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @profile.errors, :status => :unprocessable_entity }\n end\n end\n \n end", "def update\n @usuario.nombres = @usuario.nombres.upcase\n @usuario.apellidos = @usuario.apellidos.upcase\n respond_to do |format|\n if @usuario.update(usuario_params)\n format.html { redirect_to @usuario, notice: 'El Usuario se ha editado correctamente.' }\n format.json { render :show, status: :ok, location: @usuario }\n else\n @div_edit_admin = true\n format.html { render :edit }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tipo_pago = TipoPago.find(params[:id])\n\n respond_to do |format|\n if @tipo_pago.update_attributes(params[:tipo_pago])\n format.html { redirect_to(@tipo_pago, :notice => 'TipoPago was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tipo_pago.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @tipo_pensum = TipoPensum.find(params[:id])\n\n respond_to do |format|\n if @tipo_pensum.update_attributes(params[:tipo_pensum])\n format.html { redirect_to @tipo_pensum, notice: 'Tipo pensum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tipo_pensum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tipo_usuario = TipoUsuario.find(params[:id])\n\n respond_to do |format|\n if @tipo_usuario.update_attributes(params[:tipo_usuario])\n format.html { redirect_to @tipo_usuario, notice: 'Tipo usuario fue actualizado existosamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tipo_usuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\tauthorize! :index, @user\n\n params[:fichario_ficha][:fone].gsub!(/\\-|\\.|\\/|\\(|\\)| /,\"\")\n params[:fichario_ficha][:celular].gsub!(/\\-|\\.|\\/|\\(|\\)| /,\"\")\n params[:fichario_ficha][:cpf].gsub!(/\\-|\\.|\\/|\\(|\\)| /,\"\")\n params[:fichario_ficha][:pja] = params[:fichario_ficha][:pja].to_date\n params[:fichario_ficha][:entrada] = params[:fichario_ficha][:entrada].to_date\n @fichario_ficha = Fichario::Ficha.find(params[:id])\n\n\n respond_to do |format|\n if @fichario_ficha.update_attributes(params[:fichario_ficha])\n format.html { redirect_to(@fichario_ficha, :notice => 'Ficha foi atualizada com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @fichario_ficha.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
[ "0.6871978", "0.6794184", "0.6760972", "0.6755883", "0.6722978", "0.6722978", "0.6722978", "0.6701428", "0.6701428", "0.66975266", "0.6689876", "0.6688541", "0.66482794", "0.66226023", "0.66131467", "0.6591996", "0.6584015", "0.6578821", "0.6578821", "0.6559463", "0.6555132", "0.65099335", "0.65053546", "0.6503879", "0.6486552", "0.64836395", "0.64807874", "0.6469254", "0.6452431", "0.6440429", "0.6439503", "0.64141035", "0.6408043", "0.64015824", "0.63864183", "0.6378164", "0.6371605", "0.63563913", "0.6352377", "0.6340619", "0.6339908", "0.6335736", "0.63347274", "0.6324879", "0.63129526", "0.63097465", "0.6308851", "0.63030154", "0.6283323", "0.6266561", "0.62616384", "0.62501854", "0.6244717", "0.6244717", "0.6238456", "0.62354374", "0.6233153", "0.62326556", "0.6227025", "0.62254155", "0.6222371", "0.62196517", "0.6218128", "0.62172836", "0.6206446", "0.6205716", "0.61973447", "0.61959106", "0.6195555", "0.61898744", "0.61898184", "0.61883575", "0.61864287", "0.61840904", "0.61721027", "0.61708903", "0.6167754", "0.6165032", "0.61538976", "0.61489254", "0.614446", "0.61414254", "0.61344427", "0.6132477", "0.6131009", "0.61265165", "0.61181206", "0.61161625", "0.61131793", "0.61095595", "0.61090845", "0.61060816", "0.6099617", "0.6091968", "0.60918987", "0.6089213", "0.60864645", "0.60836875", "0.60799783", "0.60774726" ]
0.784805
0
DELETE /Usuarios/1 DELETE /Usuarios/1.xml
def destroy @usuario = Usuario.find(params[:id]) @usuario.destroy respond_to do |format| format.html { redirect_to(usuarios_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @usuario = Usuario.find(params[:id])\n @usuario.destroy\n \n respond_to do |format|\n format.html { redirect_to(usuarios_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @usuario = User.find(params[:id])\n @usuario.destroy\n\n respond_to do |format|\n format.html { redirect_to(users_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @tipo_usuario = TipoUsuario.find(params[:id])\n @tipo_usuario.destroy\n\n respond_to do |format|\n format.html { redirect_to(tipo_usuarios_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @administrativo = Administrativo.find(params[:id])\n @administrativo.destroy\n\n respond_to do |format|\n format.html { redirect_to(administrativos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @utilisateur = Utilisateur.find(params[:id])\n @utilisateur.destroy\n\n respond_to do |format|\n format.html { redirect_to(utilisateurs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @direccion = Direccion.find(params[:id])\n @direccion.destroy\n\n respond_to do |format|\n format.html { redirect_to(direccions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @relatestagiario = Relatestagiario.find(params[:id])\n @relatestagiario.destroy\n\n respond_to do |format|\n format.html { redirect_to(relatestagiarios_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @unidad = Unidad.find(params[:id])\n @unidad.destroy\n\n respond_to do |format|\n format.html { redirect_to(unidades_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end", "def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end", "def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end", "def destroy\n @estudiante = Estudiante.find(params[:id])\n @estudiante.destroy\n\n respond_to do |format|\n format.html { redirect_to(estudiantes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @estudiante = Estudiante.find(params[:id])\n @estudiante.destroy\n\n respond_to do |format|\n format.html { redirect_to(estudiantes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @regiaos = Regiao.find(params[:id])\n @regiaos.destroy\n\n respond_to do |format|\n format.html { redirect_to(homes_path) }\n format.xml { head :ok }\n end\n end", "def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end", "def destroy\n @usuario = Usuario.find(params[:id])\n @usuario.destroy\n\n head :no_content\n end", "def destroy\n @adminnistrador = Adminnistrador.find(params[:id])\n @adminnistrador.destroy\n\n respond_to do |format|\n format.html { redirect_to(adminnistradors_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @estagiarios = Estagiario.find(params[:id])\n @estagiarios.destroy\n\n respond_to do |format|\n format.html { redirect_to(homes_path) }\n format.xml { head :ok }\n end\n end", "def destroy\n @recurso = Recurso.find(params[:id])\n @recurso.destroy\n\n respond_to do |format|\n format.html { redirect_to(recursos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @conteudo = Conteudo.find(params[:id])\n @conteudo.destroy\nt=0\n respond_to do |format|\n format.html { redirect_to(exclusao_path) }\n format.xml { head :ok }\n end\n end", "def destroy\n @suministro = Suministro.find(params[:id])\n @suministro.destroy\n\n respond_to do |format|\n format.html { redirect_to(suministros_url) }\n format.xml { head :ok }\n end\n end", "def deleteResource(doc, msg_from)\n \n \n begin\n\n puts \"Deleting\"\n\n path = \"\"\n params = {}\n headers = {}\n \n context, path = findContext(doc, path) \n \n # Deleting member from group\n if context == :user_group_member\n params = {}\n else\n raise Exception.new(\"No context given!\")\n end\n \n httpAndNotify(path, params, msg_from, :delete)\n \n rescue Exception => e\n puts \"Problem in parsing data (CREATE) from xml or sending http request to the VR server: \" + e\n puts \" -- line: #{e.backtrace[0].to_s}\"\n end\n \n end", "def destroy\n @reclamacao = Reclamacao.find(params[:id])\n @reclamacao.destroy\n\n respond_to do |format|\n format.html { redirect_to(reclamacaos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @estatu = Estatu.find(params[:id])\n @estatu.destroy\n\n respond_to do |format|\n format.html { redirect_to(estatus_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @unidade = Unidade.find(params[:id])\n @unidade.destroy\n\n respond_to do |format|\n format.html { redirect_to(unidades_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @dossier = Dossier.find(params[:id])\n @dossier.destroy\n\n respond_to do |format|\n format.html { redirect_to(\"/\") }\n format.xml { head :ok }\n end\n end", "def destroy\n @dato = Dato.find(params[:id])\n @dato.destroy\n\n respond_to do |format|\n format.html { redirect_to(datos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @dato = Dato.find(params[:id])\n @dato.destroy\n\n respond_to do |format|\n format.html { redirect_to(datos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @empleadosautorizado = Empleadosautorizado.find(params[:id])\n @empleadosautorizado.destroy\n\n respond_to do |format|\n format.html { redirect_to(empleadosautorizados_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @iguanasactualizacion = Iguanasactualizacion.find(params[:id])\n @iguanasactualizacion.destroy\n\n respond_to do |format|\n format.html { redirect_to(iguanasactualizaciones_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @remocao = Remocao.find(params[:id])\n @remocao.destroy\n\n respond_to do |format|\n format.html { redirect_to(remocaos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @admin_coleccion = Admin::Coleccion.find(params[:id])\n @admin_coleccion.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_coleccions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @orc_ficha = OrcFicha.find(params[:id])\n @orc_ficha.destroy\n\n respond_to do |format|\n format.html { redirect_to(orc_fichas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @cuenta = Cuenta.find(params[:id])\n @cuenta.destroy\n\n respond_to do |format|\n format.html { redirect_to(cuentas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @cuenta = Cuenta.find(params[:id])\n @cuenta.destroy\n\n respond_to do |format|\n format.html { redirect_to(cuentas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @cuenta = Cuenta.find(params[:id])\n @cuenta.destroy\n\n respond_to do |format|\n format.html { redirect_to(cuentas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @valor_sistema = ValorSistema.find(params[:id])\n @valor_sistema.destroy\n\n respond_to do |format|\n format.html { redirect_to(valores_sistema_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @coleccionista = Coleccionista.find(params[:id])\n @coleccionista.destroy\n\n respond_to do |format|\n format.html { redirect_to(coleccionistas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @contrato = Contrato.find(params[:id])\n @contrato.destroy\n\n respond_to do |format|\n format.html { redirect_to(contratos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @usuario = Usuario.find(params[:id])\n @usuario.destroy\n \n redirect_to usuarios_path\n end", "def destroy\n @nomina.destroy\n\n respond_to do |format|\n format.html { redirect_to(nominas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @seccion = Seccion.find(params[:id])\n @seccion.destroy\n\n respond_to do |format|\n format.html { redirect_to(seccions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @domino = Domino.find(params[:id])\n @domino.destroy\n\n respond_to do |format|\n format.html { redirect_to(dominos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\r\n \r\n #eliminar foto de perfil \r\n r = Photo.where(\"#{:user_id} =?\",params[:id])\r\n #solo eliminar si posee foto de perfil \r\n if r.present?\r\n r.destroy_all\r\n end\r\n\r\n @usuario.destroy\r\n respond_to do |format|\r\n format.html { redirect_to usuarios_url, success: 'Eliminaste un usuario correctamenteed.' }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to(clientes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to(clientes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @usuario = Usuario.find(params[:id])\n @usuario.destroy\n\n respond_to do |format|\n format.html { redirect_to usuarios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @usuario = Usuario.find(params[:id])\n @usuario.destroy\n\n respond_to do |format|\n format.html { redirect_to usuarios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @usuario = Usuario.find(params[:id])\n @usuario.destroy\n\n respond_to do |format|\n format.html { redirect_to usuarios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cuadrante = Cuadrante.find(params[:id])\n @cuadrante.destroy\n\n respond_to do |format|\n format.html { redirect_to(cuadrantes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @instituto.destroy\n\n respond_to do |format|\n format.html { redirect_to(institutos_url) }\n format.xml { head :ok }\n end\n end", "def destroy \n @usuario = Usuario.find(params[:id]).destroy\n flash[:success] = \"Usuario Eliminado\"\n redirect_to usuarios_url\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 @usuario = Usuario.find(params[:id])\n @usuario.destroy\n\n respond_to do |format|\n format.html { redirect_to usuarios_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_conta = TipoConta.find(params[:id])\n @tipo_conta.destroy\n\n respond_to do |format|\n format.html { redirect_to(tipo_contas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @texte_accueil = TexteAccueil.find(params[:id])\n @texte_accueil.destroy\n\n respond_to do |format|\n format.html { redirect_to(texte_accueils_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @tipo_controles = TipoControle.find(params[:id])\n @tipo_controles.destroy\n\n respond_to do |format|\n format.html { redirect_to(tipo_controles_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n administradorId = @concurso.administrador_id\n @concurso.destroy\n respond_to do |format|\n format.html { redirect_to '/administradors/'+administradorId.to_s, notice: 'El concurso fue eliminado' }\n format.json { head :no_content }\n end\n end", "def destroy\n @usuario = Usuario.find(params[:id])\n @usuario.destroy\n\n respond_to do |format|\n format.html { redirect_to usuarios_url, notice: 'Usuario eliminado exitosamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_fuente = TipoFuente.find(params[:id])\n @tipo_fuente.destroy\n\n respond_to do |format|\n format.html { redirect_to(tipo_fuentes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @distribuidora = Distribuidora.find(params[:id])\n @distribuidora.destroy\n\n respond_to do |format|\n format.html { redirect_to(distribuidoras_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @proceso = Proceso.find(params[:id])\n @proceso.destroy\n\n respond_to do |format|\n format.html { redirect_to(procesos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @acre = Acre.find(params[:id])\n @acre.destroy\n\n respond_to do |format|\n format.html { redirect_to(acres_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @estacion = Estacion.find(params[:id])\n @estacion.destroy\n\n respond_to do |format|\n format.html { redirect_to(estaciones_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @reputacao_veiculo = ReputacaoVeiculo.find(params[:id])\n @reputacao_veiculo.destroy\n\n respond_to do |format|\n format.html { redirect_to(reputacao_veiculos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @receita = Receita.find(params[:id])\n @receita.destroy\n\n respond_to do |format|\n format.html { redirect_to(receitas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @tipo_de_documento = TipoDeDocumento.find(params[:id])\n @tipo_de_documento.destroy\n\n respond_to do |format|\n format.html { redirect_to(tipos_de_documento_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @ficha_tematica = FichaTematica.find(params[:id])\n @ficha_tematica.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_ficha_tematicas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @senhas = Senha.find(params[:id])\n @senhas.destroy\n\n respond_to do |format|\n format.html { redirect_to(homes_path) }\n format.xml { head :ok }\n end\n end", "def destroy\n @nom = Nom.find(params[:id])\n @nom.destroy\n\n respond_to do |format|\n format.html { redirect_to(noms_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @rendezvouz = Rendezvouz.find(params[:id])\n @rendezvouz.destroy\n\n respond_to do |format|\n format.html { redirect_to(rendezvouzs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @movimiento = Movimiento.find(params[:id])\n if params[:siguientes]\n principal = @movimiento.principal ? @movimiento.principal : @movimiento.id\n Movimiento.delete_all [\"principal = ? and fecha > ?\", principal, @movimiento.fecha]\n end\n @movimiento.destroy\n\n respond_to do |format|\n format.html { redirect_to(movimientos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @aniversario = Aniversario.find(params[:id])\n @aniversario.destroy\n\n respond_to do |format|\n format.html { redirect_to(aniversarios_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @relatorios = Relatorio.find(params[:id])\n @relatorios.destroy\n\n respond_to do |format|\n format.html { redirect_to(homes_path) }\n format.xml { head :ok }\n end\n end", "def destroy\n @comunidade = Comunidade.find(params[:id])\n @comunidade.destroy\n\n respond_to do |format|\n format.html { redirect_to(comunidades_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @ministerio = Ministerio.find(params[:id])\n @ministerio.destroy\n\n respond_to do |format|\n format.html { redirect_to(ministerios_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 destroy\n @adjunto = Adjunto.find(params[:id])\n @adjunto.destroy\n\n respond_to do |format|\n format.html { redirect_to(adjuntos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @solicitudrecurso = Solicitudrecurso.find(params[:id])\n @solicitudrecurso.destroy\n \n respond_to do |format|\n @solicitudrecursos= Solicitudrecurso.find_all_by_usuario_id(@usuario_actual.id)\n format.html { render :action => \"index\" }\n format.xml { head :ok }\n end\n end", "def destroy\n @noticia = Noticia.find(params[:id])\n @noticia.destroy\n\n respond_to do |format|\n format.html { redirect_to(noticias_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @dossier = Dossier.find(params[:id])\n @dossier.destroy\n\n respond_to do |format|\n format.html { redirect_to(dossiers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @nostro = Nostro.find(params[:id])\n @nostro.destroy\n\n respond_to do |format|\n format.html { redirect_to(nostros_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n\t\t@direccion = Direccion.find(params[:id])\n\t\[email protected]\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to(direccions_url) }\n\t\t\tformat.xml { head :ok }\n\t\tend\n\tend", "def destroy\n @usuario.destroy\n respond_to do |format|\n format.html { redirect_to usuarios_url, notice: 'Usuário eliminado com sucesso.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_contrato = TipoContrato.find(params[:id])\n @tipo_contrato.destroy\n\n respond_to do |format|\n format.html { redirect_to(tipos_contratos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @tipo_system_user = TipoSystemUser.find(params[:id])\n @tipo_system_user.destroy\n\n respond_to do |format|\n format.html { redirect_to(tipo_system_users_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @configuracion = Configuracion.find(params[:id])\n @configuracion.destroy\n\n respond_to do |format|\n format.html { redirect_to(configuracions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @instituicao = Instituicao.find(params[:id])\n @instituicao.destroy\n\n respond_to do |format|\n format.html { redirect_to(instituicoes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @reclamo = Reclamo.find(params[:id])\n @reclamo.destroy\n\n respond_to do |format|\n format.html { redirect_to(reclamos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\r\n @administrateur = Administrateur.find(params[:id])\r\n @administrateur.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to administrateurs_url }\r\n format.json { head :ok }\r\n end\r\n end", "def destroy\n @contratosinterventoria = Contratosinterventoria.find(params[:id])\n @contratosinterventoria.destroy\n\n respond_to do |format|\n format.html { redirect_to(contratosinterventorias_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @asistencia = Asistencia.find(params[:id])\n @asistencia.destroy\n\n respond_to do |format|\n format.html { redirect_to(asistencias_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @tipo_restaurante = TipoRestaurante.find(params[:id])\n @tipo_restaurante.destroy\n\n respond_to do |format|\n format.html { redirect_to(tipo_restaurantes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @grupo = Grupo.find(params[:id])\n @grupo.destroy\n\n respond_to do |format|\n format.html { redirect_to(grupos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n control_usuario\n @usuario.destroy\n respond_to do |format|\n format.html { redirect_to usuarios_url, notice: 'El Usuario se ha eliminado correctamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @aauto = Aauto.find(params[:id])\n @aauto.destroy\n\n respond_to do |format|\n format.html { redirect_to(aautos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @clinica = Clinica.find(params[:id])\n id = @clinica.id\n @usuario = clinicas_todas(id)\n\n @clinica.destroy\n @usuario.destroy\n\n respond_to do |format|\n format.html { redirect_to(clinicas_url) }\n format.xml { head :ok }\n end\n end" ]
[ "0.7009377", "0.6871756", "0.68001074", "0.6761291", "0.675707", "0.6689866", "0.66161466", "0.66031694", "0.65943724", "0.65774703", "0.65436023", "0.65424806", "0.65422106", "0.653701", "0.65227693", "0.64962584", "0.64786017", "0.64782435", "0.6469047", "0.64674574", "0.6458231", "0.64563906", "0.6447303", "0.6444631", "0.64369506", "0.6432487", "0.64209354", "0.64209354", "0.64111936", "0.6401878", "0.6399885", "0.6399244", "0.6397435", "0.63886005", "0.63886005", "0.63886005", "0.638552", "0.63818073", "0.63755316", "0.63752335", "0.63683975", "0.63675964", "0.63577515", "0.63514936", "0.634946", "0.634946", "0.6349371", "0.6349371", "0.6349371", "0.63493264", "0.6341629", "0.6339138", "0.63389987", "0.63372636", "0.6335525", "0.6330912", "0.6330441", "0.6325693", "0.6325423", "0.63227606", "0.63200784", "0.6314725", "0.6314583", "0.6314028", "0.63130003", "0.631113", "0.6308025", "0.63062215", "0.6302174", "0.63012975", "0.6301026", "0.63009137", "0.63005143", "0.6299335", "0.6299093", "0.6293683", "0.62917095", "0.6290204", "0.6287601", "0.62846017", "0.6281195", "0.6279997", "0.6278789", "0.6277974", "0.62721896", "0.626813", "0.62644", "0.6262415", "0.62597805", "0.6254553", "0.6254163", "0.62513244", "0.6250999", "0.6250704", "0.6249695", "0.6248721", "0.624709" ]
0.6994028
4
sum the rating from user, the higher the better
def popularity(movie_id) sum=0 @database.each do |key,info_list| info_list.each do |info| if info[0].to_i==movie_id.to_i sum+=info[1].to_i end end end return sum end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum_ratings\n @sum_ratings ||= @user_ratings.map(&:rating).inject(&:+).to_f\n end", "def rating\n if self.rating_sum > 0 && self.rating_count > 0\n (self.rating_sum / self.rating_count).round(2)\n end\n end", "def user_average_rating(user)\n #av = promedio (avarage), counter = contador(para calcular el total de reviews realizada)\n av, counter = 0.0, 0.0\n \n Review.where(user_id: user.id).each_with_index do |review, i|\n if review.rating\n av = av + review.rating\n counter = counter + 1.0\n end\n end\n\n av / counter\n end", "def rating_calculation\n ratings_collection = Rating.where(user_id: self.id)\n average = -1\n if !ratings_collection.empty?\n sum = 0\n ratings_collection.each do |r|\n sum += r.rating\n end\n average = (sum.to_f / ratings_collection.count).round\n end\n average\n end", "def rating\n rating_calculator.rate(raters)\n end", "def throwing_total\n self.rating_1 +\n self.rating_2 +\n self.rating_3 +\n self.rating_4 +\n self.rating_5\n end", "def baserunning_total\n self.rating_15 + \n self.rating_16 +\n self.rating_17 +\n self.rating_18\n end", "def getAvgUserNumberRating(u)\n @count = 0\n @allR = getUserReviews(u)\n @allR.each do |r|\n @count += r.rating\n end\n return (@allR.count == 0) ? \"None\" : @count/@allR.count \n end", "def rating\n return 0 if total_votes == 0\n (100 * self.yeses) / total_votes\n end", "def average_rating\n self.ratings.reduce(0.0) { |sum, score| sum += score } / self.ratings.length\n end", "def avg_rating u\n \tuser_ratings = @userdata[u.to_s.to_sym]\n \tavg = 0\n \tuser_ratings.each do |id, rating|\n \t\tavg += rating\n \tend\n \tavg = avg / user_ratings.size.to_f\n \treturn avg\n end", "def ratings_sum\nend", "def hitting_total\n self.rating_19 +\n self.rating_20 +\n self.rating_21 +\n self.rating_22 +\n self.rating_23 +\n self.rating_24 +\n self.rating_25 +\n self.rating_26 +\n self.rating_27\n end", "def overall_rating\n\t\ttotal_score = 0\n\t\ttotal_score += self.setting \n\t\ttotal_score += self.hotness\n\t\ttotal_score += self.originality\n\t\ttotal_score += self.style\n\t\ttotal_score += self.attitude\n\t\treturn total_score / 5\n\tend", "def rating\n average = 0.0\n ratings.each { |r|\n average = average + r.rating\n }\n if ratings.size != 0\n average = average / ratings.size\n end\n average\n end", "def rate(rating)\n @nb_ratings += 1\n @sum_ratings += rating\n @average_rating = @sum_ratings / @nb_ratings\n end", "def average_rating\n sum = 0\n self.ratings.each do |rating|\n sum += rating.score\n end\n avg = sum/self.ratings.length\n avg.to_f\n end", "def update_score\n sum = 0.0\n total = 0.0\n ratings.each do |rating|\n vp = User.find(rating.user_id).voting_power \n sum = sum + rating.score * vp\n total = total + vp\n end\n average = sum / total\n variance = ratings.inject(0.0){ |sum, element| sum + \n (element.score - average) ** 2 }\n penalty = Math.log10((variance / ratings.size) + 1) + 1.0;\n update_attribute(:score, average / penalty)\n end", "def rating\n (get_upvotes.size + 2)/(get_downvotes.size + 2)\n end", "def rating\n reviews.any? ? reviews.sum(&:rating) / reviews.count : 0\n end", "def average_ratings\n ratings = 0\n self.ratings.each {|r| ratings += r.score}\n avg = votes == 0 ? 0 : ratings.to_f/votes.to_f\n \"%.1f\" % avg\n end", "def average_ratings\n ratings = 0\n self.ratings.each {|r| ratings += r.score}\n avg = votes == 0 ? 0 : ratings.to_f/votes.to_f\n \"%.1f\" % avg\n end", "def update_rating\n\t\tself.user_rating = self.ratings.sum(\"rating_value\")/self.ratings.count\n\t\tself.save(validate: false) #THIS IS TO PREVENT ALL OF THE USER VALIDATIONS FROM RUNNING\n\tend", "def average_rating\n \ttotal_score = 0\n \tnum_of_ratings = self.ratings.count\n \tself.ratings.each do |rating|\n \t\ttotal_score += rating.overall_rating\n \tend\n \tif num_of_ratings > 0\n \t\treturn total_score / num_of_ratings\n \telse\n \t\treturn 0\n \tend\n end", "def average_rating\n (ratings.sum(:rating).to_f / num_ratings).round(1)\nend", "def num_ratings \n 5\n end", "def rating_by(user)\n user_rating = rating && rating.user_ratings.find_by_user_id(user.id)\n user_rating ? user_rating.score : nil\n end", "def rating\n if reviews.size ==0\n return nil\n end\n rating=0\n reviews.each do |review|\n rating+=review.rating\n end\n return (rating*1.0/reviews.size).round(2)\n end", "def getAvgUserStarRating(u)\n return (getAvgUserNumberRating(u) != \"None\") ? reviewRating(getAvgUserNumberRating(u)) : \"No ratings\".html_safe\n end", "def overall_weighted_rating\n @ratings.group_by(&:evaluation_criteria_id).sum do |criteria_group|\n criteria = EvaluationCriteriaRepository.new.find(criteria_group[0])\n calc = Calculator.new(ratings_for(criteria_group), criteria)\n calc.weighted_avg_all_users\n end\n end", "def rating\n return nil unless ratings.length > 0\n (ratings.average(:value) / 0.25).round * 0.25\n end", "def update_rating!\n # not using count because lates some votes might be something other than +/- 1\n self.positive_vote_count = votes.positive.sum(:value).abs\n self.negative_vote_count = votes.negative.sum(:value).abs\n self.rating = votes.sum(:value)\n save!\n end", "def rating\n 0\n end", "def calculate_rating(user_id,movie_id)\n #user_similarity: {\"user1\"=>{\"user2\"=>similarity, \"user3\" => similarity}, \"user2\"....}\n count = 0;\n rating = 0.0\n user_similarity[user_id.to_i].each do |u,s|\n if (tmp = rating(u.to_i,movie_id.to_i)) != 0\n count += 1\n end\n rating += (tmp * 1.0 * s).round(4)\n end\n return count, rating\n end", "def rating\n\t\tif review.any?\n\t\t\trating = review.map {|review| review.rating}\n\t\t\ttotal = rating.reduce(0) {|total, rating| total += rating}\n\t\t\ttotal = review.reduce(0) {|total, review| total += review.rating}\n\n\t\t#return nil if reviews.empty?\n\t\tend\n\t\t#(reviews.map(&:rating).reduce(&:+).to_f / reviews.length).round(2)\n\t\t#llama a un array de metodo raiting de todos los review; (reduce el array a uno) \n\tend", "def score\n\t\treviews.length > 1 ? 5 + (avg_rating-2.5)*2*rating_factor : -1\n\tend", "def average_rating\n ratings.inject(0.0) {|sum, num| sum +=num} / ratings.length\n end", "def rating\n average_rating = (trips.collect {|trip| trip.rating.to_f}.sum)/trips.length\n ## Code below functions the same as the code in line 28\n ## Was unsure which design was preferred, so left both in\n # total_rating = 0.0\n # trips.each do |trip|\n # total_rating += trip.rating\n # end\n # average_rating = total_rating/trips.length\n return average_rating.round(1)\n end", "def rating_sum(wastes)\n wastes.inject(0) { |sum, v| sum + v.rating }\n end", "def rating(u,m)\n rec=@users[u].rassoc(m)\n if rec==nil\n return 0\n end\n return rec[2]\n end", "def fielding_total\n self.rating_6 +\n self.rating_7 +\n self.rating_8 +\n self.rating_9 +\n self.rating_10 +\n self.rating_11 +\n self.rating_12 +\n self.rating_13 +\n self.rating_14\n end", "def rating (user, movie)\n\t\tif @train_data.has_key?(user) && @train_data[user].return_rating(movie)\n\t\t\treturn @train_data[user].return_rating(movie)\n\t\telse\n\t\t\treturn 0\n\t\tend\n\tend", "def calculate_average_rating\n self.average_rating = ((self.content_rating.to_f + self.recommend_rating.to_f) / 2).round(1)\n end", "def user_rating(user_id)\n if user_rated?(user_id)\n @user_ratings.select { |user_rating| user_rating.user_id == user_id }.first.rating\n else\n 0\n end\n end", "def score\n votes.sum(:vote)\n end", "def rating\n reviews.average(:rating)\n end", "def update_rating\n ratings = reviews.pluck(:rating)\n value = ratings.empty? ? 0 : (ratings.reduce(:+).to_f / ratings.size)\n update(rating: value)\n end", "def average_rating\n return 0 if self.ratings.empty?\n (self.ratings.inject(0){|total, rating| total += rating.score }.to_f / self.ratings.size )\n end", "def set_rating\n food_reviews = self.food_reviews\n if self.has_rating\n totrating = 0\n food_reviews.each do |food_review|\n totrating = totrating + food_review.rating\n end\n avg_rating = totrating.to_f/food_reviews.length\n @food_rating = avg_rating.round(2)\n return\n end\n @food_rating = 0.0\n end", "def ratings\n if self.reviews.any?\n avg_rating = 0\n self.reviews.each do |review|\n avg_rating += review.rating\n end\n avg_rating = (avg_rating/self.reviews.length).ceil\n return avg_rating\n end\n end", "def average_rating()\n total_ratings = 0\n total_trips = 0\n average_rating = 0\n #self.trips = Trip.where(driver_id:self.id)\n self.trips.each do |trip|\n # if trip cost is not nil, the trip is complete\n if trip.cost != nil \n total_ratings += trip.rating\n total_trips += 1\n end\n end\n if total_trips > 0 \n average_rating = total_ratings.to_f / total_trips\n end\n return average_rating\n end", "def feedback_score\n average_rating = self.average_rating\n if average_rating > 0 and average_rating <= 2.5\n average_rating = 1\n elsif average_rating > 2.5 and average_rating <= 5.0\n average_rating = 2\n elsif average_rating > 5.0 and average_rating <= 7.5\n average_rating = 3\n elsif average_rating > 7.5 and average_rating <= 10.0\n average_rating = 4\n end\n end", "def avg_rating\n @avg = self.ratings.average(:rating) \n @avg ? @avg : 0\n end", "def compute_user_rate(user)\n user_rate = Hash.new(0)\n user_movies = @data.select { |item| item[0].to_i == user }.each { |item| user_rate[item[1].to_i] = item[2].to_i }\n user_rate\n end", "def rating_formula\n time = Time.new\n age = ((time - self.created_at)/60/60/24).to_i\n if upvotes != nil\n rating = upvotes + age * (-0.5)\n else \n rating = age * (-0.5)\n end\n rating\n end", "def rating\n return votes.average(:rate) if(votes.size > 0) # example of duck typing here -- very convinient \n \"Not Rated\" \n end", "def rating\n return nil if ratings.empty?\n ratings.reduce(&:+) / ratings.length.to_f\n end", "def vote_score\n votes.sum(:value)\n end", "def average_rating\n rating_sum = 0\n if @trips.length > 0\n @trips.each.map do |trip|\n rating_sum += trip.rating\n end\n total_rating = (rating_sum.to_f / trips.length.to_f)\n total_rating = total_rating.to_f\n puts total_rating\n return total_rating\n elsif @trips == []\n return 0\n end \n end", "def average_ratings\n ratings.average(:int_value)\n end", "def average_rating\n\t\t\t\t\treturn 0 if rates.empty?\n\t\t\t\t\t( rates.inject(0){|total, rate| total += rate.score }.to_f / rates.size )\n\t\t\t\tend", "def corrected_rating\n [(weighted_rating + 2) * 1.6666666666666667, 5.0].min\n end", "def avg_rating\n stars_array = []\n ratings.each do |rating|\n stars_array << rating.stars\n end\n return stars_array.inject{ |sum, el| sum + el }.to_f / stars_array.size\n end", "def average_rating\n total = 0\n self.reviews.each do |review|\n total += review.rating\n end\n average = total.to_f / self.reviews.count\n end", "def set_rating\n all_ratings = []\n self.reviews.each { |review| all_ratings << review.overall_rating }\n self.rating = all_ratings.reduce(:+) / (all_ratings.length * 1.0)\n self.save\n end", "def average_rating\n ratings\n .average(:rating)\n .to_f\n .round(2)\n end", "def rating\r\n\t\t@rating\r\n\tend", "def rate\n votes = answers.inject(0) do |sum, a| \n sum + a.votes.count \n end\n \n # Return a count of votes and answers\n answers.count + votes\n end", "def average_rating\n if ratings != []\n ratings.sum(:stars) / ratings.size\n else\n 0\n end\n end", "def average_rating\n if ratings.where(\"score > 0\").size != 0\n\t\tratings.where(\"score > 0\").sum(:score) / ratings.where(\"score > 0\").size\n\telse\n\t\t0\n\tend\n end", "def average_rating\n average = 0\n count = 0 \n self.trips.each do |trip|\n average += trip.rating.to_i\n count += 1\n end\n return average / count\n end", "def rating\n return @rating\n end", "def rating(u, m)\n @user_list[u].rating(m)\n end", "def rating\n rat = Rating.average(:rating, :conditions => [\"photo_id = ?\", self.id])\n if rat\n rat\n else\n 0\n end\n end", "def average_rating(&block)\n total = 0\n countable_ratings = block ? ratings.select(&block) : ratings\n countable_ratings.each do |rating|\n total += rating.rating\n end\n average_rating = countable_ratings.empty? ? 0 : (0.0 + total) / countable_ratings.size\n # only 1 decimal.\n [(0.0 + (average_rating * 10).round) / 10, countable_ratings.size]\n end", "def rating\n @rating\n end", "def average_rating\n\n all_ratings = self.reviews.to_a.map do |review|\n review.rating\n end\n\n return 0 unless all_ratings.length > 0\n\n all_ratings.sum / all_ratings.length\n end", "def rating(user, movie)\n\t\tscore = @usermovie_rating[\"#{user} #{movie}\"]\n\t\tif score != nil\n\t\t\treturn score\n\t\tend\n\t\treturn 0\n\tend", "def average_rating\n return 'n/a' if reviews.empty?\n #return 0 if reviews.empty?\n (reviews.pluck(:rating).sum / reviews.count.to_f).round(2)\n end", "def calculate_average_rating\n weighted_drinks_ratings.sum.to_f / weighted_drinks_ratings.count\n end", "def current_rating(user)\n rating = ratings.find_by(user_id: user.id)\n rating ? rating.value : 0\n end", "def rating\n if average_rating?\n # Integerize it for now -- no fractional average ratings\n (the_ratings = ratings.average(:rating)) ? the_ratings.round : 0.0\n else\n self.old_rating.nil? ? nil : self.old_rating.rating\n end\n end", "def user_drink_rating(drink_id)\n @user_drink_rating = UserBeerRating.where(user_id: self.id, beer_id: drink_id)\n if !@user_drink_rating.blank?\n @user_average_rating = (@user_drink_rating.average(:user_beer_rating).to_f).round(1)\n if @user_average_rating >= 10.0\n @final_rating = 10\n else\n @final_rating = @user_average_rating\n end\n else\n @final_rating = nil\n end\n @final_rating\n end", "def rate \n @user = User.find_from_param(params[:id])\n if @user.rateable_by?(current_user)\n @user.rate(params[:rate].to_i, current_user)\n render :layout => false, :text => \"#{@user.rating_count} votes\"\n else\n render :nothing => true, :status => :bad_request\n end\n end", "def min_rating\n 0\n end", "def user_rating(book_id)\n user_rating = Rating.where(\"book_id = ? AND user_id = ?\",book_id,current_user.id)\n if user_rating.empty?\n return 0\n end\n return user_rating[0].stars\n end", "def average_rating\n ratings.average(:value).to_f\n end", "def avg_rating(user_id)\n @user_index[user_id].col(:rating).mean\n end", "def average_rating\n if reviews.count > 0\n ratings = reviews.map { |review| review.rating }\n sum = ratings.reduce(:+)\n if sum > 0\n average = sum / ratings.count\n average.round(1)\n else\n return 0\n end\n else\n return 0\n end\n end", "def rating(u, m)\n return @trainingSet.allUsersHash[\"#{u}\"][\"#{m}\"].to_i if @trainingSet.allUsersHash[\"#{u}\"][\"#{m}\"] != nil\n return 0\n end", "def rating(u,m)\n if @usermap[u].has_key?(m)\n @usrmap[u][m]\n else\n 0\n end\n end", "def update_star(review)\n self.average_stars = self.average_stars + review.star_rating\n # self.average_stars = (self.average_stars + review.star_rating)/review.count\n\n self.save\n end", "def average_rating\n return 'N/A' if reviews.none?\n reviews.inject(0) {|memo, review| memo + review.rating} / reviews.length\n end", "def rating #Getter\n @rating\n end", "def average_rating\n ratings.present? ? (ratings.map(&:score).sum.to_f) / ratings.count : nil\n end", "def get_ratings\n return @trips.inject(0) do |sum, trip|\n trip.is_in_progress? ? sum + 0 : sum + trip.rating\n end\n end", "def rating(user,movie)\n\t\tuser= user.to_s\n\t\tmovie = movie.to_s\n\t\tmovie_rating_index = @user_rating_index[user]\n\t\tmovie_rating = movie_rating_index[movie]\n\t\treturn movie_rating.to_f\n\tend", "def avg_score\n reviews.average(:rating).round(2).to_f\n end", "def rating\n position_sum = 0\n games = []\n number_of_teams = 0\n Participation.find_all_by_player_id(self.id).each do |participation|\n position_sum += participation.position\n games.push Game.find(participation.game_id)\n end\n\n games.each do |game|\n number_of_teams += game.number_of_teams\n end\n\n if position_sum == 0\n position_sum = number_of_teams.to_f-0.5\n end\n\n (1 - position_sum.to_f/number_of_teams).round 2\n end", "def show\n @rating = UserRating.where(movie_id: @movie.id).average(:rating)\n if @rating\n @rating = @rating.round(1)\n else\n @rating = 0\n end\n end", "def calculate_average_ratings\n total_reviews = self.reviews.count\n\n quality_total = 0\n study_total = 0\n laptop_total = 0\n hipster_total = 0\n\n self.reviews.each { |review| quality_total += review.qualityRating }\n self.reviews.each { |review| study_total += review.studyRating }\n self.reviews.each { |review| laptop_total += review.laptopRating }\n self.reviews.each { |review| hipster_total += review.hipsterRating }\n\n if total_reviews > 0\n self.average_hipster = hipster_total / total_reviews\n self.average_study = study_total / total_reviews\n self.average_laptop = laptop_total / total_reviews\n self.average_quality = quality_total / total_reviews\n self.overall_average = (average_hipster + average_study + average_laptop + average_quality)/4\n end\n self.save\n end" ]
[ "0.82106996", "0.785109", "0.7656369", "0.7499054", "0.74924666", "0.7483474", "0.74779737", "0.7477552", "0.7429877", "0.74095714", "0.74030876", "0.7397913", "0.73597044", "0.73560184", "0.7336137", "0.7327783", "0.73242056", "0.7309712", "0.73081475", "0.7255266", "0.7245336", "0.7245336", "0.72170717", "0.7216671", "0.7203696", "0.7196897", "0.7164582", "0.7162722", "0.71262807", "0.711562", "0.7113179", "0.70995206", "0.7094623", "0.70869815", "0.70797145", "0.70715576", "0.70703334", "0.7065344", "0.70483446", "0.7046126", "0.70441955", "0.70325774", "0.70218724", "0.7005995", "0.69957584", "0.69888145", "0.6943347", "0.69403815", "0.694027", "0.6933784", "0.6918544", "0.6917316", "0.6887794", "0.6884163", "0.68669426", "0.6857575", "0.6854371", "0.68469197", "0.6841818", "0.6839095", "0.6837801", "0.6833067", "0.68276983", "0.6823473", "0.6822344", "0.68196553", "0.68186253", "0.68100953", "0.6803349", "0.6803308", "0.6801368", "0.6800912", "0.6793685", "0.67915684", "0.67891276", "0.6784577", "0.67739576", "0.6773949", "0.6769915", "0.67687136", "0.6758646", "0.6756516", "0.6753477", "0.6748134", "0.67371744", "0.67360723", "0.6733043", "0.6730485", "0.6724812", "0.67147857", "0.67125237", "0.6708073", "0.6702394", "0.67009544", "0.6695499", "0.6693214", "0.6692812", "0.6683342", "0.66821516", "0.6681413", "0.6672815" ]
0.0
-1
allow account update without specifying your password
def update_resource(resource, params) resource.update_without_password(params) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_with_password(params, *options); end", "def update_without_password(params, *options); end", "def edit_password; end", "def update!(**args)\n @password = args[:password] if args.key?(:password)\n @user = args[:user] if args.key?(:user)\n end", "def change_password\r\n \r\n end", "def change_password!(password)\n json = JSON.generate(:changePassword => { :adminPass => password })\n @compute.connection.req('POST', \"/servers/#{@id}/action\", :data => json)\n @adminPass = password\n end", "def update_password\n # check current password is valid\n if params[:account].present? and [email protected]_password?(params[:account][:current_password])\n redirect_to gns_core.my_account_backend_accounts_path, flash: { error: \"Current password incorrectly.\" }\n return\n end\n\n if params[:account].present?\n params[:account].delete(:password) if params[:account][:password].blank?\n params[:account].delete(:password_confirmation) if params[:account][:password].blank? and params[:account][:password_confirmation].blank?\n\n if @account.update_with_password(account_params)\n bypass_sign_in(@account)\n redirect_to gns_core.my_account_backend_accounts_path, flash: { success: \"The new password has been successfully changed.\" }\n else\n if params[:account][:password].nil? or params[:account][:password].length < 6\n redirect_to gns_core.my_account_backend_accounts_path, flash: { error: \"New password must contain at least 6 characters.\" }\n else\n redirect_to gns_core.my_account_backend_accounts_path, flash: { error: \"Repeat password does not match.\" }\n end\n end\n end\n end", "def password=(new_password); end", "def change_password!(opts = {})\n password!(opts.merge(:verb => :put))\n end", "def update_resource(resource, params)\n # Require current password if user is trying to change password.\n return super if params[\"password\"]&.present?\n # Allows user to update registration information without password.\n resource.update_without_password(params.except(\"current_password\"))\n end", "def update_account(options)\n password = options[:new_password]\n parameters = { :curpass => options[:current_password], :email => options[:email], :newpass => password, :verpass => password, :api_type => :json }\n\n post('api/update', parameters)\n end", "def update_password(newpwd)\n self.password = Utils.sha1(newpwd + 'ad2012spot' + email)\n end", "def update_resource(resource, params)\n return super if params[\"password\"]&.present?\n resource.update_without_password(params.except(\"current_password\"))\n end", "def update_resource(resource, params)\n if params[\"password\"]&.present? or params[\"email\"]&.present?\n return super\n else\n resource.update_without_password(params.except(\"current_password\"))\n end\n end", "def update_current_logged_in_users_password(args = {}) \n put(\"/users.json/current/password\", args)\nend", "def change_password\n #check if user is new or being updated\n if self.encrypted_password.present?\n #verifies password\n if self.password_check\n self.encrypt_password\n else\n raise \"error\"\n end\n else\n raise \"error\"\n end\n end", "def update_password username, password, new_password, account: Conjur.configuration.account\n if Conjur.log\n Conjur.log << \"Updating password for #{username} in account #{account}\\n\"\n end\n url_for(:authn_update_password, account, username, password).put new_password\n end", "def update_resource(resource, params)\n # Require current password if user is trying to change password.\n return super if params['password']&.present?\n\n # Allows user to update registration information without password.\n resource.update_without_password(params.except('current_password'))\n end", "def call\n validate_equality\n user = context.user\n return if user.update(password: context.user_password_params[:password])\n\n context.fail!(message: user.errors.full_messages)\n end", "def update_with_password(params, *options)\n if encrypted_password.blank?\n update_attributes(params, *options)\n else\n super\n end\n end", "def update_with_password(params, *options)\n if encrypted_password.blank?\n update_attributes(params, *options)\n else\n super\n end\n end", "def update_with_password(params, *options)\n if encrypted_password.blank?\n update_attributes(params, *options)\n else\n super\n end\n end", "def update_with_password(params, *options)\n if encrypted_password.blank?\n update_attributes(params, *options)\n else\n super\n end\n end", "def update_with_password(params, *options)\n if encrypted_password.blank?\n update_attributes(params, *options)\n else\n super\n end\n end", "def update_with_password(params, *options)\n if encrypted_password.blank?\n update_attributes(params, *options)\n else\n super\n end\n end", "def update_with_password(params, *options)\n if encrypted_password.blank?\n update_attributes(params, *options)\n else\n super\n end\n end", "def update_with_password(params, *options)\n if encrypted_password.blank?\n update_attributes(params, *options)\n else\n super\n end\n end", "def update_with_password(params, *options)\n if encrypted_password.blank?\n update_attributes(params, *options)\n else\n super\n end\n end", "def update_with_password(params, *options)\n if encrypted_password.blank?\n update_attributes(params, *options)\n else\n super\n end\n end", "def change_password\n @user = User.shod(params[:id])\n authorize! :update, @user\n end", "def update_with_password(params, *options)\n if encrypted_password.blank?\n update_attributes(params.except(:current_password), *options)\n else\n update_with_password_pass(params)\n end\n end", "def update_with_password(params, *options)\n\t\tif encrypted_password.blank?\n\t\t\tupdate_attributes(params, *options)\n\t\telse\n\t\t\tsuper\n\t\tend\n\tend", "def change_password(opts = {})\n password(opts.merge(:verb => :put))\n end", "def change_temp_password\n\tend", "def send_password_change_notification; end", "def update_with_password params, *options\n if encrypted_password.blank?\n update_attributes(params, *options)\n else\n super\n end\n end", "def update_account\n\n @user = User.find(current_user.id)\n\n successfully_updated = @user.update_with_password(user_params)\n\n if successfully_updated\n set_flash_message :notice, :updated\n # Sign in the user bypassing validation in case his password changed\n bypass_sign_in @user\n redirect_to user_path(@user.username)\n else\n render \"edit_account\"\n end\n\n end", "def update_with_password(params={})\n params.delete(:current_password)\n self.update_without_password(params)\n end", "def update_with_password(params={})\n params.delete(:current_password)\n self.update_without_password(params)\n end", "def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend", "def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend", "def password_change_new\n\n end", "def admin_pwd_update\n @user = User.find_by_id(params[:user_id])\n @user.validate_pwd = true\n if @user.update(email: params[:user][:email], password: params[:user][:password], password_confirmation: params[:user][:password_confirmation])\n # if an admin is updating her own password, we need to get around Devise's automatic sign out\n if @user.id == current_user.id\n sign_in(@user, :bypass => true)\n end\n flash.keep[:notice] = 'The password for \"' + params[:user][:email] + '\" was successfully updated.'\n redirect_to '/users'\n else\n render :admin_pwd\n end\n end", "def update_users_account_password( user_uid, password )\n engines_api_system.update_users_account_password( user_uid, password )\n end", "def change_password(username, password)\n perform_request({:action => \"client-updatepassword\", :username => username, :password => password})\n statusmsg.match /success/i\n end", "def update!(**args)\n @enabled = args[:enabled] if args.key?(:enabled)\n @password_required = args[:password_required] if args.key?(:password_required)\n end", "def update_password\n @user.password = @new_e_password\n if GlobalConstant::User.auto_blocked_status == @user.status\n # if we had blocked a user for more than a threshhold failed login attemps we set status to blocked\n # now we should reset it to active\n @user.status = GlobalConstant::User.active_status\n @user.failed_login_attempt_count = 0\n end\n @user.save!\n end", "def send_password_change_notification\n # do not notify the admins for now\n end", "def check_password_changed\n self.temp_password = nil if ( changed.include?('encrypted_password') && !(changed.include?('temp_password')))\n end", "def update\n if params[:commit] == \"Update\"\n super\n elsif params[:commit] == \"Cancel my account\"\n if current_user.valid_password?(params[:user][:current_password])\n kill_user(current_user)\n destroy\n else\n # I don't know how rails is doing that nice effect, so I basically have this dirty hack here...\n clean_up_passwords current_user\n params[:commit] = \"Update\"\n update\n end\n end\n end", "def update_password(passwd = @password)\n validate_before_update\n\n return false if self.errors.any?\n\n cursor = parse \"BEGIN msf.manage_accounts.reset_password_with_answer(:i_username, :i_answer, :i_new_password, :o_status); end;\"\n cursor.bind_param ':i_username', self.username\n cursor.bind_param ':i_answer', @answer, String, 256\n cursor.bind_param ':i_new_password', passwd, String, 32\n exec cursor do\n case cursor[':o_status']\n when 'DONE' : true\n when 'NOT FOUND' : false\n when 'ERROR'\n self.errors.add_to_base 'An error prevented us from resetting your password'\n false\n when 'SAME PASSWORD'\n self.errors.add :password, \"can't be the same as your existing password\"\n false\n end\n end\n end", "def update\n super do |resource|\n # TODO (rspeicher): In Devise master (> 3.4.1), we can set\n # `Devise.sign_in_after_reset_password = false` and avoid this mess.\n if resource.errors.empty? && resource.try(:otp_required_for_login?)\n resource.unlock_access! if unlockable?(resource)\n\n # Since we are not signing this user in, we use the :updated_not_active\n # message which only contains \"Your password was changed successfully.\"\n set_flash_message(:notice, :updated_not_active) if is_flashing_format?\n\n # Redirect to sign in so they can enter 2FA code\n respond_with(resource, location: new_session_path(resource)) and return\n end\n end\n end", "def update_password(db, domain_name, new_pw)\n db.execute(\"UPDATE organizer SET password='#{new_pw}'' WHERE domain_name='#{domain_name}'\")\nend", "def need_change_password!\n return unless password_expiration_enabled?\n\n need_change_password\n save(validate: false)\n end", "def update_with_password(params = {})\n if has_facebook_profile?\n params.delete(:current_password)\n update_without_password(params)\n else\n super\n end\n end", "def update\n puts 'ENTROU NO UPDATE USER'\n return vinculate_user unless params[:vincular].nil?\n\n update_password\n end", "def set_password; nil; end", "def update_credential_password(username, password)\n raise ArgumentError, \"The new password cannot be nil\" unless password\n raise ArgumentError, \"The new username cannot be nil\" unless username\n raise ArgumentError, \"The new password cannot be empty\" if password.empty?\n raise ArgumentError, \"The new username cannot be empty\" if username.empty?\n\n self.service.editCredential(username.to_s, password.to_s)\n\n @credentials = nil\n end", "def skip_password_change_notification!; end", "def newPassword(newPass)\n\t\tDATABASE.edit(\"users\", \"password\", newPass, \"username\", @username)\n\tend", "def password_updation\n user_id = params[:user_id]\n password = params[:password]\n if password.present?\n @password = User.find(params[:user_id]).update(password: params[:password])\n render json: @password, status: :ok\n else\n render json: { error: 'password can not be nil' }, status: :unauthorized\n end \n end", "def change_password(params)\n response = nexus.post(nexus_url(\"service/local/users_changepw\"), :body => create_change_password_json(params), :header => DEFAULT_CONTENT_TYPE_HEADER)\n case response.status\n when 202\n return true\n when 400\n raise InvalidCredentialsException\n else\n raise UnexpectedStatusCodeException.new(response.status)\n end\n end", "def update_password\n if current_user.update_with_password(update_password_params)\n expose current_user\n else\n error! :invalid_resource, current_user.errors\n end\n end", "def update_password\n @employee = current_employee\n if @employee.update_with_password(params_employee)\n redirect_to root_path\n else\n render :action => \"edit_password\"\n end\n end", "def update_resource(resource, params)\n # if params['email'] != current_user.email || params['password'].present?\n # resource.update_with_password(params)\n # else\n resource.update_without_password(params.except('password', 'password_confirmation', 'current_password'))\n # end\n end", "def update_password\n @user = User.find_by_uuid(params[:id])\n if @user.update(user_params_with_password)\n if @user.send_password.present? && @user.send_password.to_i == 1\n @user.send_welcome_email\n end\n flash[:success] = t('messages.default_success')\n redirect_to users_path\n else\n flash[:error] = t('messages.default_error')\n render :edit_password\n end\n end", "def update_with_password(params = {})\n if params[:password].blank?\n params.delete(:password)\n params.delete(:password_confirmation) if params[:password_confirmation].blank?\n end\n update(params)\n end", "def change_password(username, new_password)\n perform_request({:action => \"client-updatepassword\", :username => username, :password => new_password})\n end", "def password_update\n redirect_to lato_core.root_path unless core_getRecoveryPasswordPermission\n user = LatoCore::Superuser.find(params[:id])\n if !user || user.session_code != params[:token]\n flash[:warning] = CORE_LANG['recover_password']['recover_error']\n redirect_to lato_core.login_path and return false\n end\n user.update(password: params[:password], password_confirmation: params[:password])\n if !user.save\n flash[:warning] = CORE_LANG['recover_password']['recover_error']\n redirect_to lato_core.login_path and return false\n end\n\n flash[:success] = CORE_LANG['recover_password']['recover_success']\n redirect_to lato_core.login_path\n end", "def update\n account_update_params = devise_parameter_sanitizer.sanitize(:account_update)\n\n # This is required for the form to submit when the password is left blank.\n if account_update_params[:password].blank?\n account_update_params.delete('password')\n account_update_params.delete('password_confirmation')\n end\n\n @user = User.find(current_user.id)\n if @user.update_attributes(account_update_params)\n set_flash_message ':notice', :updated\n\n # Sign in the user and bypass validation in case the password changed.\n sign_in @user, bypass: true\n redirect_to after_update_path_for(@user)\n else\n render 'edit'\n end\n end", "def update_password\n current_password = params[:current_password]\n correct_password = @account.password\n if current_password == correct_password\n @account.password = params[:account_password]\n flash.now[:message] = \"你的密码已成功修改\" if @account.save\n else\n flash.now[:error_msg] = \"你输入的当前密码不正确, 不能修改密码\"\n end\n \n render :action => \"edit\"\n end", "def need_change_password?\n password_change_requested? || password_too_old?\n end", "def password\n if @user.update_with_password(password_params)\n render_update_success @user\n else\n render_failure @user\n end\n end", "def password_needed?\n resource.authentications.empty? \\\n ? resource.update_with_password(params[resource_name])\\\n : resource.update_attributes(params[resource_name])\n end", "def change_password\n #raise current_user.inspect\n end", "def update\n @user.password = params[:user][:password]\n @user.password_confirmation = params[:user][:password_confirmation]\n if @user.save\n @user.attempts = 0\n @user.save\n flash[:notice] = \"Password succesefully updated\"\n redirect_to account_url\n else\n render :action =>:edit\n end\n end", "def update_users_password_by_e_mail(args = {}) \n put(\"/users.json/backoffice/email/#{args[:email]}/password/#{args[:password]}\", args)\nend", "def update_users_password_by_e_mail(args = {}) \n put(\"/users.json/backoffice/email/#{args[:email]}/password/#{args[:password]}\", args)\nend", "def change_password(username, password, new_pw)\n #errors = validate_password(password, new_pw)\n errors = PasswordConstraints::validate(new_pw, password)\n return errors unless errors.empty?\n\n LdapPassword::change_password(username, password, new_pw)\nend", "def update\n params[:account].delete(:preferred_smtp_password) if params[:account][:preferred_smtp_password].blank?\n respond_to do |format|\n if @account.update_attributes(params[:account])\n format.html { redirect_to dm_core.admin_account_url, notice: \"Account was successfully updated.\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @account.errors, status: :unprocessable_entity }\n end\n end\n end", "def need_change_password\n return unless password_expiration_enabled?\n\n self.password_changed_at = nil\n end", "def change_password\n # https://github.com/site5/lumberg\n server = Lumberg::Whm::Server.new(host: HOST_NAME, hash: `cat #{HASH_FILE_PATH}`)\n cp_email = Lumberg::Cpanel::Email.new(server: server, api_username: @username)\n @password = SecureRandom.urlsafe_base64(12)\n process_options = { domain: @domain, email: @email, password: @password }\n passwd_result = cp_email.change_password(process_options)\n if passwd_result[:params][:data][0][:reason] == ''\n puts \"Successfully changed password of #{@email}\"\n time = Time.new\n logtime = time.strftime('%Y-%m-%d %H:%M')\n File.open(\"#{LOG_FILE_PATH}\", 'a') { |logfile| logfile.puts \"#{logtime}: #{@email}\" }\n else\n # Print c-panel error message if failed to change the password\n puts \"#{passwd_result[:params][:data][0][:reason]}\"\n end\n end", "def update_password\n\t\tparameters=params[:body]\n\t\t @my_accounts=@current_user\n\t\t\tif @my_accounts.valid_password?(parameters[:current_password])\n\t\t\t if @my_accounts.updatePassword(parameters)\n\t\t\t\t render :json=>success1\n\t\t\t\telse\n\t\t\t\t render :json=>failure1(:current_password=>[\"Current password is wrong\"])\n\t\t\t end\n\t\t else\n\t\t render :json=>failure1(@my_accounts.errors)\n\t\t end\n\tend", "def edit_password(user, new_password)\n if @config.restrictions[:password_count_restriction]\n unless new_password >= @config.restrictions[:password_count_restriction].to_i\n return false\n end\n end\n user.password = user.hash_plaintext(new_password)\n user.save_data\n end", "def attempt_set_password(params)\n p = {}\n p[:password] = params[:password]\n p[:password_confirmation] = params[:password_confirmation]\n p[:password_unset] = 0 \n update_attributes(p)\n end", "def update\n auth_password = self.class.klass.auth_password\n self.send(\"current_#{self.class.klass_sym}\")&.update_password(password_params[auth_password])\n render json: { meesage: \"update password successful\"}, status: 200\n rescue UserError => e\n render json: { error: e.message }, status: e.status\n end", "def update_without_password(params, *options)\n result = update_attributes(params, *options)\n clean_up_passwords\n result\n end", "def change_password\n set_breadcrumbs(\"change_password\") \n if request.post? || request.patch? \n admin = Admin.find(current_admin.id)\n @check = params[:admin][:password] == params[:admin][:password_confirmation] && params[:admin][:password].present? && params[:admin][:password_confirmation].present?\n if admin.present? && admin.valid_password?(params[:admin][:old_password])\n if @check \n if admin.update_attribute(:password, params[:admin][:password])\n sign_in admin, :bypass => true\n flash[:notice] = I18n.t('change_password.update.success')\n redirect_to admin_root_path\n else\n flash[:error] = I18n.t('common.error') \n end\n else\n flash[:error] = I18n.t('change_password.failure.password_is_not_match')\n end\n else\n flash[:error] = I18n.t('change_password.failure.invalid_old_password')\n end\n end\n end", "def update \n @account = current_user.account\n if @account.authenticate(params[:account].delete(:current_password))\n if params[:edit] == \"email\" # special treatment for email\n @account.send_confirmation_instructions(params[:account][:email])\n flash[:notice] = I18n.t(:\"confirmations.sent\", \n :email => params[:account][:email]).html_safe\n # do not update current email unless it is not confirmed\n if @account.confirmed? \n redirect_to edit_account_path\n return\n end\n end \n if params[:edit] == \"password\"\n params[:account][:password_set_at] = Time.now\n end\n if @account.update_attributes(params[:account])\n redirect_to edit_account_path\n else\n render 'edit'\n end\n else \n @account.errors.add(:current_password, I18n.t(:'accounts.wrong_password'))\n render 'edit'\n end\n end", "def update_password(user, new_password)\n user.update_password(new_password)\n end", "def update_password(db_connection, new_pass)\n sql = 'UPDATE user_logins SET password=$1 WHERE id=$2;'\n db_connection.exec_params(sql, [ new_pass, id ])\n end", "def update_password\n @user = User.authenticate(params[:login], params[:current_password])\n if @user.nil?\n respond_to do |format|\n format.html { render :action => \"edit\" }\n format.xml { render :text => \"error\" }\n end\n else\n respond_to do |format|\n if @user.update_attributes!(params[:user])\n flash[:notice] = 'Your account was successfully updated.'\n format.html { redirect_to(@user) }\n format.xml { render :text => \"success\"}\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user.errors,\n :status => :unprocessable_entity }\n end\n end\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end", "def update_password(password_params)\n assign_attributes(password_params)\n return false unless valid?(:update_password)\n\n call_ok?(:maintain_user, update_password_request)\n end", "def update\n @user = User.find(params[:id])\n if current_user.admin? && params[:password].present?\n @user.password = params[:password]\n end\n if @user != current_user && !current_user.admin?\n render json: ['Not authorized for that action'], status: :unauthorized\n elsif @user.update(user_params)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update_without_password(params, *options)\n params.delete(:current_password)\n super(params)\n end", "def update_without_password(params, *options)\n params.delete(:current_password)\n super(params)\n end", "def update_with_password(params={}) \n if params[:password].blank? \n params.delete(:password) \n params.delete(:password_confirmation) if params[:password_confirmation].blank? \n end \n update_attributes(params) \n end", "def allow_users_to_change_passwords?\n @policy.allow_users_to_change_password\n end", "def update\n @user = User.find(current_user.id)\n\n # See https://github.com/plataformatec/devise/wiki/How-To%3A-Allow-users-to-edit-their-account-without-providing-a-password\n successfully_updated = if needs_password?(@user, params)\n @user.update_with_password(devise_parameter_sanitizer.sanitize(:account_update))\n else\n params[:user].delete(:current_password)\n \n @user.update_without_password(devise_parameter_sanitizer.sanitize(:account_update))\n end\n\n if successfully_updated\n sign_in @user, :bypass => true\n redirect_to dashboard_path, notice: 'User was successfully updated.'\n else\n render 'edit'\n end\n end", "def password_update?(new_pass)\n return false if current_resource.info['rep:password'].end_with?(\n hash_generator(new_pass)\n )\n true\n end", "def edit_password\n @user = User.find_by_id(current_user.id)\n authorize! :edit_password, User, :id => current_user.id\n end" ]
[ "0.7831725", "0.7497459", "0.72468054", "0.7224611", "0.7194428", "0.7092168", "0.70557415", "0.7048837", "0.70218796", "0.700996", "0.70029974", "0.69978625", "0.69822365", "0.6945035", "0.6937411", "0.6937283", "0.6934329", "0.6925068", "0.6911283", "0.6910967", "0.6910967", "0.6910967", "0.6910967", "0.6910967", "0.6910967", "0.6910967", "0.6910967", "0.6910967", "0.6910967", "0.69038117", "0.6898256", "0.6896135", "0.6882701", "0.6880549", "0.6861581", "0.68355113", "0.68214226", "0.6819034", "0.6819034", "0.6797512", "0.6797512", "0.6788199", "0.67715645", "0.6766365", "0.67471635", "0.6745862", "0.6740519", "0.6722247", "0.6716362", "0.6706496", "0.6699309", "0.66756433", "0.6667855", "0.6664932", "0.6661556", "0.66605824", "0.6656021", "0.66485125", "0.664846", "0.6638346", "0.66185117", "0.65973896", "0.6594928", "0.65877855", "0.6585045", "0.65732425", "0.6569958", "0.6555134", "0.653948", "0.6537704", "0.6536714", "0.65275574", "0.6522309", "0.65172845", "0.651279", "0.6512352", "0.64976895", "0.64976895", "0.64929724", "0.64861614", "0.64825594", "0.64821094", "0.6481727", "0.64791584", "0.6472101", "0.64669675", "0.6465424", "0.64635116", "0.6461235", "0.6453981", "0.6451042", "0.6450826", "0.6448003", "0.64469945", "0.6440016", "0.6440016", "0.6438145", "0.6436209", "0.6435899", "0.64340574", "0.6433376" ]
0.0
-1
Allow for creation of 5 ShortenedUrls per minute max
def no_spamming created_urls = submitter.submitted_urls num_of_recent_urls = created_urls .where('created_at > ?', 1.minute.ago) .count raise "Cannot create more than 5 shortened links in a minute!" if num_of_recent_urls >= 5 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_short_url\n random_chars = ['0'..'9','A'..'Z','a'..'z'].map{|range| range.to_a}.flatten\n self.assign_attributes(short_url: 6.times.map{ random_chars.sample }.join.prepend(\"http://\")) until self.short_url.present? && Link.find_by_short_url(short_url).nil?\n end", "def create_short_url\n rand_url = ('a'..'z').to_a.shuffle[0..5].join\n self.short_url = \"#{rand_url}\"\n end", "def generate_short_url\n url = Process.clock_gettime(Process::CLOCK_REALTIME, :nanosecond).to_s(36)\n old_url = Link.where(short_url: url).last\n if old_url.present? \n self.generate_short_url\n else\n self.short_url = url\n end\n end", "def shorten\n\t\trange = [*'0'..'9',*'A'..'Z',*'a'..'z']\n self.short_url = Array.new(7){range.sample}.join\n self.save\n\tend", "def shortener\n\t\tcharacters = [*\"0\"..\"9\", *\"A\"..\"Z\", *\"a\"..\"z\"]\n\n\t\t@short_url = (0..6).map{characters.sample}.join\n\t\tself.short_url = @short_url\n\tend", "def generate_short_url(clash_count=0)\n raise \"Too many short URL clashes. Please increase the short url length\" if clash_count == 10\n url = self.sanitize_url\n shortened_url = Digest::MD5.hexdigest(url)[(0+clash_count)..(SHORT_URL_LENGTH+clash_count)]\n url_present = Url.find_by_short_url(shortened_url)\n if(url_present)\n generate_short_url(clash_count+1)\n else\n self.short_url = shortened_url\n end\n end", "def nonpremium_max\n return nil if submitter.premium\n created_urls = submitter.submitted_urls\n raise \"Non-premium accounts are limited to 5 Shortened URLs per user\" if created_urls.count >= 5\n end", "def shorten\n self.url_short = SecureRandom.hex(5)\n end", "def shorten\n self.url_short = SecureRandom.hex(5)\n end", "def shorten\n\t\tcharacters = [*\"0\"..\"9\", *\"A\"..\"Z\", *\"a\"..\"z\"]\n\n\t\t@short_url = (0..6).map{characters.sample}.join\n\t\tself.short_url = @short_url\n\tend", "def short_url_algorithm()\n \n unique_id_length = 3\n base64 = Base64.encode64(self.original_url)\n join_url = (base64.split('')).sample(unique_id_length).join()\n safe_url = join_url.gsub(\"+\", \"-\").gsub(\"/\",\"_\")\n \n loop do \n self.short_url = @@URL + safe_url\n \n if Url.find_by_short_url(self.short_url).nil?\n break\n else\n unique_id_length = unique_id_length + 1\n end\n \n end\n \n end", "def generate_short_url\r\n url = rand(36**8).to_s(36)\r\n\r\n # If generated token already exists, execute again\r\n if Shortcut.where(short_url: url).count > 0\r\n generate_short_url\r\n return\r\n end\r\n\r\n # Generated short url\r\n self.short_url = url\r\n end", "def generate_short_url\n url = ([*('a'..'z'),*('0'..'9')]).sample(UNIQUE_ID_LENGTH).join\n old_url = ShortenedUrl.where(short_url: url).last\n if old_url.present?\n self.generate_short_url\n else\n self.short_url = url\n end\n end", "def get_short_url\n\n long_url = params[:long_url]\n\n if long_url.blank? || !long_url.is_valid_url?\n respond_to do |format|\n format.html { redirect_to urls_url, notice: 'Long URL must be in the format http://www.decisiv.com' }\n format.json { render :json => {:error => \"Long URL must be in the format http://www.decisiv.com\"}.to_json, :status => 400 }\n end\n return\n end\n\n short_url = nil\n\n if Url.where(:long_url => long_url).exists?\n\n @url = Url.where(:long_url => long_url).first\n \n respond_to do |format|\n format.html { redirect_to urls_url, notice: 'URL already exists' }\n format.json { render :json => @url.to_json, :status => 400 }\n end\n return\n \n end\n\n\n for i in 0..20 \n\n # generate a random text\n short_url = [*('a'..'z'),*('0'..'9')].shuffle[0,10].join\n\n if RestrictedWord.find_by_fuzzy_word(short_url).count > 0\n next\n end\n\n if Url.find_by_fuzzy_short_url(short_url).count > 0\n next\n end\n\n \n # add it to the database\n @url = Url.new\n @url.long_url = long_url\n @url.short_url = short_url\n \n if @url.save\n\n Url.bulk_update_fuzzy_short_url\n\n respond_to do |format|\n format.html { redirect_to urls_url, notice: 'Short URL created' }\n format.json { render :json => @url.to_json, :status => 200 }\n end\n return\n\n else\n respond_to do |format|\n format.html { render :new }\n format.json { render json: @url.errors, status: :unprocessable_entity }\n end\n return\n\n end\n\n end\n\n respond_to do |format|\n format.html { redirect_to urls_url, notice: 'Error trying to create short URL.' }\n format.json { render :json => {:error => \"Error trying to create short URL.\"}.to_json, :status => 400 }\n end\n\n end", "def generate_short_url\n short_url = unique_url\n\n # check if this is a duplicate\n if ShortenUrl.where(short_url: short_url).exists?\n # try again\n generate_short_url\n else\n self.short_url = short_url\n end\n end", "def shorter_url\n\t\tself.short_url = SecureRandom.base64(10)\n\tend", "def generate_short_url(long_url)\n\t @shortcode = random_string 5\n\t \n\t su = ShortURL.first_or_create(\n\t { :url => long_url }, \n\t {\n\t :short_url => @shortcode,\n\t :created_at => Time.now,\n\t :updated_at => Time.now\n\t })\n\t \n\t @shortenedURL = get_site_url(su.short_url)\n\tend", "def shorten\n\tself.short_url = SecureRandom.hex(3)\n\tend", "def generate_short_url\n new_short = \"/\" + Faker::Lorem.characters(7)\n until short_url_unique?(new_short)\n new_short = \"/\" + Faker::Lorem.characters(7)\n end\n self.short_url = new_short\n end", "def shorten\n\t\t self.short_url = SecureRandom.hex(3)\n\tend", "def shorten\n\t\n\t\tself.short_url = SecureRandom.urlsafe_base64(4)\n\tend", "def shorten_url\n\t\t# generate 7 random numbers from 0-9 and a-z\n\t\tself.short_url = rand(36**7).to_s(36) # [0,6] # use this to ensure 7 characters\n\n\t\t# to include A-Z\n\t\t# require 'base62'\n\t\t# self.short_url = rand(36**7).base62_encode\n\n\t\t# self.short_url = SecureRandom.hex(10)\n\tend", "def generate_short_url(base_url)\n build_shorten_url.update( uniq_id: shorten, expired_at: Time.now.utc + 1.year ) unless shorten_url\n shorten_url.link(base_url)\n end", "def generate_short_url\n short_url = SecureRandom.urlsafe_base64[0..6]\n short_url\n end", "def create_shortened_url\n key = self.id - 1\n\n if key == 0\n shortened = ALPHABET[0]\n else\n shortened = ''\n baseLength = ALPHABET.length\n\n until key < 1\n place = key % baseLength\n shortened += ALPHABET[place]\n\n key /= baseLength\n end\n end\n self.shortened = shortened\n self.save\n end", "def create_short_url(url_params) \n url = Url.new(url_params)\n url.suffix= url.create_suffix(url_params[:longurl],0)\n while url.unique(url.suffix) == false\n url.suffix = url.create_suffix(url_params[:longurl],1)\n end\n domain = Domainatrix.parse(url_params[:longurl]).domain + '.' + Domainatrix.parse(url_params[:longurl]).public_suffix\n short_domain = ShortDomain.where(domain: domain).first[:prefix]\n url.shorturl = \"http://\" + short_domain +'/'+ url.suffix\n if url.save\n return url\n else\n return nil\n end\n end", "def index\n @url = ShortenedUrl.new\n end", "def short_url\n @short_url ||= client.shorten(long_url: url).link\n rescue => e\n Rails.logger.warn(\"Could not shorten bit.ly url #{e.message}\")\n url\n end", "def update_short_url\n uniq_key = Digest::MD5.hexdigest(\"#{self.id()}\").slice(0..6) \n update_column(:short_url, BASE_SHORT_URL + uniq_key)\n true\n end", "def short\n alexa_rank = alexa_rank params[:url]\n host = get_domain params[:url]\n host = host.split \".\"\n domain = host.count >= 3 ? host[host.count - 3] : host[host.count - 2]\n @url = @user.url.create url: params[:url], alexa_rank: alexa_rank, domain: domain\n @url.save!\n render json: {url_short: @url.url_short}\n end", "def generate_8_character_unique_url\n loop do\n random_short_path = SecureRandom.base64(12).gsub('+', '').gsub('/', '').gsub('=', '')[0..7]\n return random_short_path if (random_short_path.length == 8) && Url.where(short_path: random_short_path).count.zero?\n end\n end", "def shorten_urls\n @status = (@status.split(\" \").collect do |word|\n if word =~ URI::regexp and word.length > 30 then\n # using tinyurl\n # NOTE: look into retwt.me, they have a simple api (w/o auth) and provide analysis\n (Net::HTTP.post_form URI.parse('http://tinyurl.com/api-create.php'),{\"url\" => word}).body\n else\n word\n end\n end).join(\" \")\n end", "def generate_short_url\n return if self.short_url.present?\n self.short_url = SecureRandom.hex(2)\n end", "def generate_short_url(url_id)\n # Base62 alphabet to be used\n alphabet_array = [*'a'..'z', *'A'..'Z', *'0'..'9']\n shorturl = []\n while url_id.to_i.positive?\n shorturl.push(alphabet_array[url_id % 62])\n url_id /= 62\n end\n new_url = shorturl.reverse.join\n\n # Check short_url doesn't exist in the database. If short_url exists, we generate a new url\n url_exist = UrlShortener.find_by_short_url(new_url)\n return new_url if url_exist.blank?\n\n generate_short_url(url_id)\n end", "def create\n @url_short = UrlShort.new(url_short_params)\n # if @url_short.short_url.blank?\n # url_shorten = UrlShort.find_by_original_url(@url_short.original_url)\n # render json: {url_short: \"#{request.base_url}/#{url_shorten.short_url}\", error: false} and return if url_shorten\n # end\n begin\n begin\n resp = RestClient.get(@url_short.original_url)\n raise '' if resp.code != 200\n rescue => e\n raise InvalidOriginalUrlExeption, 'Original URL not available'\n end\n if @url_short.short_url.present?\n raise ShortURLAlreadyTaken, 'Such a short URL is already taken' if UrlShort.find_by_short_url(@url_short.short_url)\n else\n count_item = UrlShort.count\n count_item_dec = count_item\n range = 0..7\n arr_alphabet = ('a'..'z').to_a\n loop do\n @url_short.short_url = arr_alphabet.shuffle[range].join()\n break unless UrlShort.find_by_short_url(@url_short.short_url)\n if count_item_dec > 0\n count_item_dec -= 1\n else\n count_item_dec = count_item\n range = Range.new 0, range.end + 1\n end\n end\n end\n rescue InvalidOriginalUrlExeption => exeption\n render json: {description: exeption.message, whose: 'original_url', error: true} and return\n rescue ShortURLAlreadyTaken => exeption\n render json: {description: exeption.message, whose: 'short_url', error: true} and return\n rescue => exeption\n render json: {description: exeption.message, whose: 'common', error: true}\n end\n if @url_short.save\n render json: {url_short: \"#{request.base_url}/#{@url_short.short_url}\", error: false}\n else\n render json: {description: 'Save error', whose: 'common', error: true}\n end\n end", "def create\n url = params[:short_url][:url]\n\n # regex to validate url\n is_url = url.match(/^(http|https):\\/\\/[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5}(:[0-9]{1,5})?(\\/.*)?$/ix).present?\n \n if is_url == true\n surl = Digest::MD5.hexdigest(url+\"in salt we trust\").slice(0..6) \n short_url = \"http://\" + surl\n\n @short_url = ShortUrl.create(title: params[:short_url][:title], url: params[:short_url][:url] , short_url: short_url, jmp_url: \"\", clicks: 0)\n redirect_to @short_url, notice: 'Short url was successfully created.'\n else \n redirect_to short_urls_path, notice: 'Invalid Url.'\n end \n\n \n end", "def index\n @short_urls = ShortUrl.all.order(clicks: :desc).limit(100).paginate(:page => params[:page], :per_page => 10)\n end", "def create\n original_url = params[:short_url][:url]\n sanity_url = get_sanity_url(original_url)[0]\n @short_url = ShortUrl.find_by(sanity_url: sanity_url)\n if !@short_url.present?\n short_url = create_short_url\n while ShortUrl.find_by(short: short_url).present?\n short_url = create_short_url\n end\n @short_url = ShortUrl.new(original: original_url, short: short_url, sanity_url: sanity_url)\n @short_url.save\n end\n redirect_to @short_url, notice: 'Short url was successfully created.'\n end", "def show_short_urls\n\t\turls = Url.all\n\t\t@short_url_list = []\n\t\turls.each do |url|\n\t\t\tshort_url = get_short_url_from_id url.id\n\t\t\t@short_url_list << short_url\n\t\tend\n\t\trender \"url\"\n\tend", "def url_shortener(full_uri)\n mapper = UrlMapper.find_by_original_url(full_uri)\n \n if mapper\n string = mapper.short_url\n else\n string = \"/\"\n 5.times { string << (i = Kernel.rand(62); i += ((i < 10) ? 48 : ((i < 36) ? 55 : 61 ))).chr }\n begin\n UrlMapper.create!({:short_url => string, :original_url => full_uri})\n rescue\n end\n end\n \"#{APP_CONFIG['url_shortener']}#{string}\"\n end", "def loop_threads_and_fetch_url(url_list)\n if @@url_hash.size < @@max_url\n unless url_list.empty?\n if running_thread_count() >= 5\n sleep @@sleep_timer*60\n loop_threads_and_fetch_url(url_list)\n else\n url_list = url_list.map { |url| url if get_host_without_www(url) == 'medium.com' }.compact\n save_data(url_list)\n new_urls_to_scrap = update_url_hash(url_list).compact\n @@retry_counter = 0 #setting the value for every new request\n generate_thread(new_urls_to_scrap)\n end\n end\n end\n end", "def index\n @short_urls = ShortUrl.all\n @short_url = ShortUrl.new\n end", "def create\n @shortened_url = Url.new(:url => params[:url])\n \n \n respond_to do |format|\n if @shortened_url.save\n @num=\"\"\n flash[:shortened_id] = @shortened_url.id\n ( @shortened_url.id..(@shortened_url.id)).each do |i|\n @num=hashing(i)+@num\n end\n @shortened_url.shorturl=url_url(@num) \n @shortened_url.save \n \n format.html {redirect_to new_url_url}\n format.xml { render xml: @urls}\n format.json { render json: @shortened_url, status: :created }\n else\n format.json { render json: @shortened_url.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_short_url(original_url = nil)\n params = {body: {originalURL: original_url, domain: @short_domain}.to_json, headers: {\"Authorization\" => @short_api_key}}\n response = self.class.post(\"/links\", params)\n @short_url = JSON.parse(response.body)[\"shortURL\"]\n response\n end", "def index\n @urlshortners = Urlshortner.all\n end", "def index\n @shorten_urls = ShortenUrl.all\n end", "def no_spamming\n cnt = user\n .submitted_urls\n .where('created_at > ?', 1.minutes.ago)\n .count\n\n errors.add(:no_spamming, \"can't submit more than 5 urls / minute\") if cnt >= 5\n end", "def create\n \n url_match = params[:url][:url] =~ /\\Ahttp(s?):\\/\\//i\n params[:url][:url] = \"http://\" << params[:url][:url] if url_match.nil?\n \n # find existing url\n @existing_url = Url.find_by_url(params[:url][:url])\n \n if @existing_url.nil?\n @url = Url.new(params[:url])\n id = Url.last.id unless Url.last.nil?\n @url.short_url = Shorten::Base62.to_s(id.nil? ? 1 : id+1)\n p @url\n else\n @url = @existing_url\n end\n\n respond_to do |format|\n if !@existing_url.nil? or @url.save\n format.html { redirect_to @url, notice: 'Url was successfully shortened.' }\n format.json { render json: @url, status: :created, location: @url }\n format.js\n else\n format.html { render action: \"new\" }\n format.json { render json: @url.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end", "def new\n @shortened_url = Url.new\n \n end", "def shorten_link\n # http://stackoverflow.com/questions/88311/how-best-to-generate-a-random-string-in-ruby\n o = [('a'..'z'), ('A'..'Z')].map(&:to_a).flatten\n string = (0...6).map { o[rand(o.length)] }.join\n self.short_url = \"http://www.sho.rt/#{string}\"\n end", "def shorten\n request = {\n body: { longUrl: url }.to_json,\n headers: { 'Content-Type' => 'application/json' },\n query: { key: api_key, \n access_token: access_token }\n }\n\n request.merge!({ http_proxyaddr: proxy.host, \n http_proxyport: proxy.port, \n http_proxyuser: proxy.user, \n http_proxypass: proxy.password }) if proxy\n\n Timeout::timeout(timeout) do\n # submit the url to Goo.gl\n result = self.class.post(\"/urlshortener/v1/url\", request)\n # return the response id or the url\n result.parsed_response[\"id\"] || url\n end\n # if a problem occurs\n rescue Timeout::Error, JSON::ParserError => e\n # just return the original url\n url\n end", "def create_short_url\n return if short_url\n # Check if the required parameters are present\n unless upload_image || long_url\n logger.info \"url : #{url_info.inspect} self : #{inspect}\"\n raise 'Missing long_url or upload_image'\n end\n\n self.long_url = url_info.id if long_url.blank?\n\n to_hash = long_url.to_s\n\n # Custom hash if the user is logged in\n to_hash = user.pseudo + 'pw3t' + long_url if user_id\n\n # And we keep only the 10 first characters\n self._id = hash_and_truncate(to_hash)\n end", "def create_unique_key\n begin\n self.unique_key = UrlShort.generate_key\n rescue ActiveRecord::RecordNotUnique\n if (count +=1) < 5\n retry\n else\n raise\n end\n end\n end", "def index\n @url_shortners = UrlShortner.all\n end", "def shorten\n\t\t# range_alpha = [*\"A\"..\"Z\",*\"a\"..\"z\"]\n\t\t# range_int = [*\"0\"..\"9\"]\n\t\t# short_url = (0...3).map{ range_alpha.sample }.join('') \n\t\t# short_url2 = (0...4).map{range_int.sample}.join('')\n\n\t\t# return short_url + short_url2\n\t\treturn SecureRandom.hex(3)\n\tend", "def url\n file.expiring_url(10 * 60)\n end", "def url\n file.expiring_url(10 * 60)\n end", "def RedirectFollower(url, limit=5)\n RedirectFollower.new(url, limit).url\nend", "def thumbnail_urls(n = 4)\n pins.newest_first.not_ids(cover_source_id || 0).limit(n).collect{ |p| p.image.v55.url }\n end", "def index\n redirect_to new_user_session_path and return unless current_user\n @shortened_urls = ShortenedUrl.where(user_id: current_user.id)\n end", "def get_short_url(link)\n client = Bitly.client\n shortened_url = client.shorten(link)\n return shortened_url.short_url \n end", "def create_short_url\n if self.short_url.nil?\n self.short_url = self.id\n self.save\n end\n end", "def test_creates_random_short_name_if_not_given\n num_trials = 1e4\n uniq_names = (1..num_trials).map do\n RequestedShortening.new('http://x.com').short_name\n end.uniq\n assert_equal(num_trials, uniq_names.size,\n 'Generated short names should not collide')\n end", "def short_link\n UrlShort::IsGd.shorten @link\n end", "def get_new_url\n self.update_attributes(url: \"#{(0...50).map{ ('a'..'z').to_a[rand(26)] }.join}\")\n end", "def shorten\n result = url\n \n begin \n if url.size > 18 && !/http:\\/\\/snipr.com.*/.match(url)\n using(rdr = StreamReader.new(request.get_response.get_response_stream)) { \n result = rdr.read_to_end.to_s\n } \n end\n rescue Exception => e\n #catch all errors and just return the regular url\n end\n \n res = ((result.size >= url.size || result.empty?) ? url.ensure_http : result).to_s\n logger.debug(\"*** SniprUrl: Shortened url from: #{url} to #{res}\")\n res\n end", "def index\n @short_urls = ShortUrl.order(id: :desc).all\n end", "def generate_short_url\n self.update_attribute :short_url, self.class.convert_to_base62(self.id)\n end", "def shorten(url)\n bitly_url = \"http://api.bit.ly/shorten?version=2.0.1&login=#{BITLY_LOGIN}&apiKey=#{BITLY_API_KEY}&longUrl=#{CGI::escape(url)}\"\n resp = open(bitly_url).read\n JSON.parse(resp)['results'][url]['shortUrl']\n rescue\n logger.debug(\"Unable to generate Bit.ly url for #{url}\")\n nil\n end", "def set_shorten_url\n @shorten_url = ShortenUrl.find(params[:id])\n end", "def show\n if params[:short_url]\n @url = Url.find_by short_url: params[:short_url]\n if redirect_to \"#{@url.original_url}\"\n @url.clicks += 1\n ip = request.env['HTTP_X_FORWARDED_FOR'] || request.remote_ip\n if [email protected]_addresses.include? ip\n @url.ip_addresses.push(ip)\n end\n @url.save\n end\n else\n @base_url = \"#{request.protocol}#{request.host_with_port}/\"\n @url = Url.find(params[:id])\n end\n end", "def create\n @url = Url.new(url_params)\n\n Url.transaction do\n @url.save\n #write base 62 method\n @url.short_url = generate_base62_short_url(@url.id)\n if @url.save\n render json: @url, status: :created, root: :url\n else\n render json: @url.errors, status: :unprocessable_entity\n end\n end\n end", "def snapshot_every_n_requests; end", "def api_url\n @instant = (1..4).to_a if @instant.empty?\n i = @instant.shift\n return \"http://#{i}-instant.okcupid.com/instantevents?random=#{rand}&server_gmt=#{Time.now.to_i}\"\n end", "def create\n url = ShortURL.url_wrap(params[:url])\n @short_url = ShortURL.find_by_url(url)\n if @short_url\n render :show \n else \n @short_url = ShortURL.new(url: url)\n if @short_url.save\n # short_url.url may be modified depending on the input\n ScraperWorker.perform_async(url, @short_url.id)\n render :show \n else \n render json: @short_url.errors.full_messages, status: 422 \n end\n end\n end", "def shorten(url)\n query = { :'link[url]' => url }\n self.class.post(\"/links\", :query => query)\n end", "def index\n @shorturls = Shorturl.all\n end", "def new\n\t\t@shortened_url = ShortenedUrl.new\n\t\t@url = shorten_urls_path\n\tend", "def create\n url = ShortenedUrl.find_by_long_url(shortened_urls_params[:long_url])\n \n if url\n render json: {shortUrl: url[:short_url]}\n else\n shortened_url = ShortenedUrl.new(shortened_urls_params)\n \n if shortened_url.save\n short_url = shortened_url.generate_short_url\n shortened_url.update_attribute(\"short_url\", short_url)\n \n render json: { shortUrl: shortened_url[:short_url], success: true }\n else\n render json: { error: true }\n end\n end\n end", "def instagram_rate_limit_warning(rate_limit_remaining, url)\n # Key-based expiration\n @rate_limit_remaining = rate_limit_remaining\n @url = url\n cache_key = [\"instagram_rate_limit_warning\", Time.now.hour]\n return nil if Rails.cache.fetch cache_key\n Rails.cache.write cache_key, true\n mail subject: \"[#{AppConfig.app_name}] WARNING: Instagram rate limit low\"\n end", "def get_urls()\n generate_thread(@@source_url)\n end", "def putShortenurl( url)\n params = Hash.new\n params['url'] = url\n return doCurl(\"put\",\"/shortenurl\",params)\n end", "def index\n render_or_error do\n short_codes = ShortUrl.order(click_count: :desc).limit(100).map(&:short_code)\n\n { urls: short_codes }\n end\n end", "def snapshot_every_n_requests=(_arg0); end", "def get_urls_to_retrieve(d1)\n urls = []\n\n if (d1==nil || d1 ==\"\")\n t = DateTime.now\n d = t.strftime(\"%Y/%m/%d\")\n else\n d = d1\n end\n pt1 = \"http://www.bbc.co.uk/\"\n pt2 = \"/programmes/schedules/\"\n\n channel = \"bbcone\"\n url = \"#{pt1}#{channel}#{pt2}london/#{d}.json\"\n urls.push(url)\n\n channel = \"bbctwo\"\n url = \"#{pt1}#{channel}#{pt2}england/#{d}.json\"\n urls.push(url)\n\n channel = \"bbcthree\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"bbcfour\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"bbchd\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"cbeebies\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"cbbc\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"parliament\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"bbcnews\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"radio4\"\n url = \"#{pt1}#{channel}#{pt2}fm/#{d}.json\"\n\n channel = \"radio1\"\n url = \"#{pt1}#{channel}#{pt2}england/#{d}.json\"\n\n channel = \"1extra\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"radio2\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"radio3\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"5live\" \n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"5livesportsextra\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"6music\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"asiannetwork\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"worldservice\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n return urls\n end", "def generate_thumbnails\n self.thumbnails = []\n\n # generate from thumb_moments\n (JSON.parse(profile.thumb_moments) rescue []).each do |time|\n self.thumbnails << Thumbnail.generate(\n newly_converted,\n :width => profile.thumbnail_width,\n :height => profile.thumbnail_height,\n :time => time) if time.to_f <= newly_converted.duration_in_secs\n end\n\n # generate from thumb_way\n thumb_start = profile.thumb_start.to_f > 0.0 ? profile.thumb_start.to_f : 0.0\n thumb_end = profile.thumb_end .to_f > 0.0 ? profile.thumb_end .to_f : newly_converted.duration_in_secs\n thumb_amount = profile.thumb_amount.to_i > 0 ? profile.thumb_amount.to_i : 0\n\n thumb_start = newly_converted.duration_in_secs if thumb_start > newly_converted.duration_in_secs\n thumb_end = newly_converted.duration_in_secs if thumb_end > newly_converted.duration_in_secs\n\n thumb_amount.times do |i|\n time =\n case profile.thumb_way\n when Thumbnail::RAND\n thumb_start + rand*(thumb_end-thumb_start)\n else#Thumbnail::EVEN\n thumb_start + (i+1)*(thumb_end-thumb_start)/(thumb_amount+1)\n end\n self.thumbnails << Thumbnail.generate(\n newly_converted,\n :width => profile.thumbnail_width,\n :height => profile.thumbnail_height,\n :time => time)\n end if thumb_start <= thumb_end\n end", "def pages(time)\n\n response = HTTParty.get(\"https://api.pushshift.io/reddit/search/submission/?subreddit=#{$subreddit}&sort=desc&sort_type=created_utc&size=#{$max_per_page}&search?before=#{time}\")\n json = JSON.parse(response.body)\n\n json[\"data\"].each do |f|\n $urls << [f[\"created_utc\"], f[\"url\"]] if f[\"url\"].match?($img_formats) && f[\"url\"].match?($valid_urls)\n end\n\n if $page < $max_page\n sleep(rand(2..5))\n $page += 1\n pages($urls.last[0])\n else\n write_file\n end\n\nend", "def create\n @url = Url.new(url_params)\n @url.sanitize\n @url.current_ip = request.remote_ip\n if @url.new_url?\n respond_to do |format|\n if @url.save\n format.html { redirect_to shortened_path(@url.short_url), notice: 'Url was successfully created.' }\n format.json { render :show, status: :created, location: @url }\n else\n format.html { render :new }\n format.json { render json: @url.errors, status: :unprocessable_entity }\n end\n end\n else\n flash[:notice] = \"A short link for this URL is already in our database\"\n redirect_to shortened_path(@url.find_duplicate.short_url)\n end\n \n end", "def index\n @short_urls = @user.short_urls.paginate(:page => params[:page][:number], :per_page => params[:page][:size])\n if @short_urls.count > 0\n render json: @short_urls, meta: pagination_details(@short_urls)\n else\n error = {}\n render json: {errors: {message: \"You haven't created Short URLs yet!\"}}\n end\n end", "def create\n @url = ShortenedUrl.new\n @url.original_url = params[:original_url]\n @url_actualy = @url.original_url\n @url_may_exist = ShortenedUrl.find_by_original_url(params[:original_url])\n if @url_may_exist.nil?\n if @url.save\n redirect_to shortened_path(@url.short_url)\n flash[:notice] = \"URL is added to list\"\n else\n flash[:error] = \"URL is not added to list\"\n render 'index'\n end\n else\n flash[:notice] = \"The link is exist already\"\n redirect_to shortened_path(@url_may_exist.short_url)\n end\n end", "def create\n @data = if current_user.present?\n Shortener::ShortenedUrl.generate(params[:url_short][:link], owner: current_user,\n expires_at: 24.hours.since)\n else\n Shortener::ShortenedUrl.generate(params[:url_short][:link], expires_at: 24.hours.since)\n end\n respond_to do |format|\n format.js { render 'url_shorts/status' }\n end\n rescue Exception => e\n @error = true\n @error_data = e\n respond_to do |format|\n format.js { render 'url_shorts/status' }\n end\n\n # redirect_to new_url_short_path\n end", "def set_shortened_url\n @shortened_url = ShortenedUrl.find(params[:id])\n end", "def get_urls\n\n url_array = []\n top_five = 0\n\n while top_five < 5\n url_array << @news_instance[\"response\"][\"docs\"][top_five][\"web_url\"]\n top_five += 1\n end\n\n # returns the array\n return url_array\n\n end", "def create\n # decode url to remove duplicacy in case of same url encoded and decoded\n url = URI.decode(params[:url])\n # check if url already exists in db\n mini_url = MiniUrlHelper.check_existing_url(url, current_user)\n unless mini_url\n mini_url = MiniUrl.new\n mini_url.url = url\n # a check to handle invalid expiry time\n begin\n mini_url.expiry = DateTime.parse(params[:expiry])\n rescue ArgumentError => e\n logger.error \"Invalid expiry time.\"\n end\n mini_url.user = current_user if current_user\n # call method to generate unique code and save into db\n # raise exception in case of some error\n unless mini_url.generate_unique_code\n raise Exceptions::SavingError.new(mini_url.errors)\n end\n end\n short_url = \"#{BASE_URL}/#{mini_url.url_code}\"\n render json: {short_url: short_url}, status: 201\n rescue Exceptions::SavingError => e\n render json: {error: e}, status: 400\n end", "def shorten_with_bitly(long_url)\n # long URL will be sth like:\n # http://springerquotes.heroku.com/article/doi:10.1186/1477-7819-1-29#h[AtmWaa,7,AraRwg,13,IatDaw,1,GcoNwm,4]\n\n # generate the quote URL like this:\n # http://springerquotes.heroku.com/quotes/doi:10.1186/1471-2105-7-126?quotes=h[TmeWta,2,5,6,witFas,2]\n # [\"http\",\n # nil,\n # \"localhost\",\n # \"9292\",\n # nil,\n # \"/article/doi:10.1186/1471-2105-7-126\",\n # nil,\n # nil,\n # \"h[TmeWta,2,5,6,witFas,2]\"]\n uri_elements = URI.split(long_url)\n quote_url = \"http://springerquotes.heroku.com/#{uri_elements[5].gsub(/^\\/article/,\"quotes\")}?quotes=#{uri_elements[8]}\"\n\n puts \"Creating bit.ly URL for #{quote_url}\"\n\n # shorten URL\n yql_query = \"\n SET login = '#{Bitly_username}' ON bit.ly;\n SET apiKey = '#{Bitly_apikey}' ON bit.ly;\n SELECT data FROM bit.ly.shorten WHERE longUrl='#{quote_url}';\n \"\n yql_query = YqlSimple.query(yql_query)\n\n begin\n short_url = yql_query[\"query\"][\"results\"][\"response\"][\"data\"][\"url\"]\n rescue Exception => ex\n short_url = nil\n end\n\n return short_url\n end", "def create\n @short_url = @user.short_urls.new(short_url_params)\n\n if @short_url.save\n short_url = @short_url\n short_url.shorty = \"http://www.my-domain.com/#{@short_url.shorty}\"\n render json: short_url, status: :created\n else\n render json: {errors: @short_url.errors}, status: :unprocessable_entity\n end\n end", "def shorten(long_url, options={})\n response = get(:shorten, { :longUrl => long_url }.merge(options))\n return Bitlyr::Url.new(self, response)\n end", "def crawl_delay(url); end", "def generate_short_url\n # encode base 10 id as base 62 string as seen here https://gist.github.com/zumbojo/1073996\n i = id\n return Constants::ALPHABET[0] if i.zero?\n s = ''\n base = Constants::ALPHABET.length\n while i > 0\n s << Constants::ALPHABET[i.modulo(base)]\n i /= base\n end\n update_attributes(short_url: s.reverse)\n end", "def longen(urls)\n # Make sure it's an array\n urls = [*urls]\n result = {}\n\n # We can pass 10 URLs at once\n urls.each_slice(10) do |the_urls|\n query_string = the_urls.map{|url| \"q=#{url}\"}.join(\"&\")\n response = Net::HTTP.get(URI.parse(\"http://longurlplease.appspot.com/api/v1.1?#{query_string}\"))\n\n result.merge!(JSON.parse(response))\n end\n\n result\n end" ]
[ "0.71524715", "0.6944787", "0.6916518", "0.6914879", "0.6834846", "0.68155485", "0.676827", "0.67620516", "0.67620516", "0.6726566", "0.66728175", "0.66568184", "0.6641456", "0.6625504", "0.66180533", "0.65875334", "0.6507626", "0.6500213", "0.6497644", "0.6475199", "0.6466022", "0.64509636", "0.6415476", "0.6265754", "0.62517464", "0.62304556", "0.61917704", "0.61713684", "0.6139754", "0.6122632", "0.61055076", "0.60949475", "0.6094487", "0.60932684", "0.6074922", "0.60496867", "0.6007369", "0.59911436", "0.5982507", "0.5935904", "0.59308356", "0.59249943", "0.5920096", "0.59193164", "0.5909402", "0.5900309", "0.5900055", "0.5879763", "0.5862886", "0.5859377", "0.5848806", "0.5826425", "0.5822937", "0.5795677", "0.57605124", "0.57522994", "0.57522994", "0.5748219", "0.57327616", "0.5713349", "0.57119787", "0.56802005", "0.56700677", "0.5615781", "0.56007016", "0.5600276", "0.55909103", "0.5554071", "0.55495375", "0.5525703", "0.55225366", "0.55209535", "0.5519085", "0.5513504", "0.54966116", "0.54953384", "0.5492236", "0.5475514", "0.54624134", "0.54623574", "0.544569", "0.54387355", "0.54370475", "0.54216594", "0.5418671", "0.5410013", "0.54022104", "0.53997874", "0.5393079", "0.5387641", "0.53859603", "0.5380426", "0.538033", "0.53776485", "0.5370796", "0.5368099", "0.53649455", "0.5362824", "0.5361879", "0.53537804" ]
0.69650996
1
Limit nonpremium users to creating 5 ShortenedUrls max
def nonpremium_max return nil if submitter.premium created_urls = submitter.submitted_urls raise "Non-premium accounts are limited to 5 Shortened URLs per user" if created_urls.count >= 5 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def no_spamming\n created_urls = submitter.submitted_urls\n num_of_recent_urls = created_urls\n .where('created_at > ?', 1.minute.ago)\n .count\n\n raise \"Cannot create more than 5 shortened links in a minute!\" if num_of_recent_urls >= 5 \n end", "def no_spamming\n cnt = user\n .submitted_urls\n .where('created_at > ?', 1.minutes.ago)\n .count\n\n errors.add(:no_spamming, \"can't submit more than 5 urls / minute\") if cnt >= 5\n end", "def shorten\n\t\trange = [*'0'..'9',*'A'..'Z',*'a'..'z']\n self.short_url = Array.new(7){range.sample}.join\n self.save\n\tend", "def shorten\n self.url_short = SecureRandom.hex(5)\n end", "def shorten\n self.url_short = SecureRandom.hex(5)\n end", "def shortener\n\t\tcharacters = [*\"0\"..\"9\", *\"A\"..\"Z\", *\"a\"..\"z\"]\n\n\t\t@short_url = (0..6).map{characters.sample}.join\n\t\tself.short_url = @short_url\n\tend", "def generate_short_url\n random_chars = ['0'..'9','A'..'Z','a'..'z'].map{|range| range.to_a}.flatten\n self.assign_attributes(short_url: 6.times.map{ random_chars.sample }.join.prepend(\"http://\")) until self.short_url.present? && Link.find_by_short_url(short_url).nil?\n end", "def shorten\n\t\tcharacters = [*\"0\"..\"9\", *\"A\"..\"Z\", *\"a\"..\"z\"]\n\n\t\t@short_url = (0..6).map{characters.sample}.join\n\t\tself.short_url = @short_url\n\tend", "def index\n redirect_to new_user_session_path and return unless current_user\n @shortened_urls = ShortenedUrl.where(user_id: current_user.id)\n end", "def create_short_url\n rand_url = ('a'..'z').to_a.shuffle[0..5].join\n self.short_url = \"#{rand_url}\"\n end", "def shorten\n\t\n\t\tself.short_url = SecureRandom.urlsafe_base64(4)\n\tend", "def generate_short_url\r\n url = rand(36**8).to_s(36)\r\n\r\n # If generated token already exists, execute again\r\n if Shortcut.where(short_url: url).count > 0\r\n generate_short_url\r\n return\r\n end\r\n\r\n # Generated short url\r\n self.short_url = url\r\n end", "def shorten\n\t\t self.short_url = SecureRandom.hex(3)\n\tend", "def generate_short_url(clash_count=0)\n raise \"Too many short URL clashes. Please increase the short url length\" if clash_count == 10\n url = self.sanitize_url\n shortened_url = Digest::MD5.hexdigest(url)[(0+clash_count)..(SHORT_URL_LENGTH+clash_count)]\n url_present = Url.find_by_short_url(shortened_url)\n if(url_present)\n generate_short_url(clash_count+1)\n else\n self.short_url = shortened_url\n end\n end", "def shorten_url\n\t\t# generate 7 random numbers from 0-9 and a-z\n\t\tself.short_url = rand(36**7).to_s(36) # [0,6] # use this to ensure 7 characters\n\n\t\t# to include A-Z\n\t\t# require 'base62'\n\t\t# self.short_url = rand(36**7).base62_encode\n\n\t\t# self.short_url = SecureRandom.hex(10)\n\tend", "def shorten\n\tself.short_url = SecureRandom.hex(3)\n\tend", "def shorter_url\n\t\tself.short_url = SecureRandom.base64(10)\n\tend", "def post_action_rate_limiter\n return unless is_flag? || is_bookmark? || is_like?\n\n return @rate_limiter if @rate_limiter.present?\n\n %w(like flag bookmark).each do |type|\n if public_send(\"is_#{type}?\")\n limit = SiteSetting.get(\"max_#{type}s_per_day\")\n\n if is_like? && user && user.trust_level >= 2\n multiplier = SiteSetting.get(\"tl#{user.trust_level}_additional_likes_per_day_multiplier\").to_f\n multiplier = 1.0 if multiplier < 1.0\n\n limit = (limit * multiplier).to_i\n end\n\n @rate_limiter = RateLimiter.new(user, \"create_#{type}\", limit, 1.day.to_i)\n return @rate_limiter\n end\n end\n end", "def tag_subscription_post_limit\n 200\n end", "def user_website(website)\n unless website.blank?\n if website.size > 20 \n return website.slice(0,18)+\"...\" \nelse\n return website\n end \n\n \n end\nend", "def RedirectFollower(url, limit=5)\n RedirectFollower.new(url, limit).url\nend", "def generate_short_url\n url = ([*('a'..'z'),*('0'..'9')]).sample(UNIQUE_ID_LENGTH).join\n old_url = ShortenedUrl.where(short_url: url).last\n if old_url.present?\n self.generate_short_url\n else\n self.short_url = url\n end\n end", "def generate_short_url\n new_short = \"/\" + Faker::Lorem.characters(7)\n until short_url_unique?(new_short)\n new_short = \"/\" + Faker::Lorem.characters(7)\n end\n self.short_url = new_short\n end", "def limit_posts!; end", "def get_short_url\n\n long_url = params[:long_url]\n\n if long_url.blank? || !long_url.is_valid_url?\n respond_to do |format|\n format.html { redirect_to urls_url, notice: 'Long URL must be in the format http://www.decisiv.com' }\n format.json { render :json => {:error => \"Long URL must be in the format http://www.decisiv.com\"}.to_json, :status => 400 }\n end\n return\n end\n\n short_url = nil\n\n if Url.where(:long_url => long_url).exists?\n\n @url = Url.where(:long_url => long_url).first\n \n respond_to do |format|\n format.html { redirect_to urls_url, notice: 'URL already exists' }\n format.json { render :json => @url.to_json, :status => 400 }\n end\n return\n \n end\n\n\n for i in 0..20 \n\n # generate a random text\n short_url = [*('a'..'z'),*('0'..'9')].shuffle[0,10].join\n\n if RestrictedWord.find_by_fuzzy_word(short_url).count > 0\n next\n end\n\n if Url.find_by_fuzzy_short_url(short_url).count > 0\n next\n end\n\n \n # add it to the database\n @url = Url.new\n @url.long_url = long_url\n @url.short_url = short_url\n \n if @url.save\n\n Url.bulk_update_fuzzy_short_url\n\n respond_to do |format|\n format.html { redirect_to urls_url, notice: 'Short URL created' }\n format.json { render :json => @url.to_json, :status => 200 }\n end\n return\n\n else\n respond_to do |format|\n format.html { render :new }\n format.json { render json: @url.errors, status: :unprocessable_entity }\n end\n return\n\n end\n\n end\n\n respond_to do |format|\n format.html { redirect_to urls_url, notice: 'Error trying to create short URL.' }\n format.json { render :json => {:error => \"Error trying to create short URL.\"}.to_json, :status => 400 }\n end\n\n end", "def slug_limit; end", "def short\n alexa_rank = alexa_rank params[:url]\n host = get_domain params[:url]\n host = host.split \".\"\n domain = host.count >= 3 ? host[host.count - 3] : host[host.count - 2]\n @url = @user.url.create url: params[:url], alexa_rank: alexa_rank, domain: domain\n @url.save!\n render json: {url_short: @url.url_short}\n end", "def generate_short_url\n short_url = SecureRandom.urlsafe_base64[0..6]\n short_url\n end", "def short_url_algorithm()\n \n unique_id_length = 3\n base64 = Base64.encode64(self.original_url)\n join_url = (base64.split('')).sample(unique_id_length).join()\n safe_url = join_url.gsub(\"+\", \"-\").gsub(\"/\",\"_\")\n \n loop do \n self.short_url = @@URL + safe_url\n \n if Url.find_by_short_url(self.short_url).nil?\n break\n else\n unique_id_length = unique_id_length + 1\n end\n \n end\n \n end", "def url_whitelist; end", "def generate_short_url\n short_url = unique_url\n\n # check if this is a duplicate\n if ShortenUrl.where(short_url: short_url).exists?\n # try again\n generate_short_url\n else\n self.short_url = short_url\n end\n end", "def fifteen_minutes_usage\n limit? ? extract_ratelimit!(usage).first : nil\n end", "def shorten\n\t\t# range_alpha = [*\"A\"..\"Z\",*\"a\"..\"z\"]\n\t\t# range_int = [*\"0\"..\"9\"]\n\t\t# short_url = (0...3).map{ range_alpha.sample }.join('') \n\t\t# short_url2 = (0...4).map{range_int.sample}.join('')\n\n\t\t# return short_url + short_url2\n\t\treturn SecureRandom.hex(3)\n\tend", "def generate_short_url(long_url)\n\t @shortcode = random_string 5\n\t \n\t su = ShortURL.first_or_create(\n\t { :url => long_url }, \n\t {\n\t :short_url => @shortcode,\n\t :created_at => Time.now,\n\t :updated_at => Time.now\n\t })\n\t \n\t @shortenedURL = get_site_url(su.short_url)\n\tend", "def index\n if current_user.id == @user.id\n @shorturls = @user.shorturls\n else\n flash[:error] = \"Not authorized!.\"\n redirect_to root_path\n end\n end", "def twitter_api_rate_limit\n # +++ move to app config\n @@_admin_account_access_rate_limit ||= 50 # times per hour\n end", "def generate_short_url\n return if self.short_url.present?\n self.short_url = SecureRandom.hex(2)\n end", "def url_allowlist; end", "def generate_short_url(base_url)\n build_shorten_url.update( uniq_id: shorten, expired_at: Time.now.utc + 1.year ) unless shorten_url\n shorten_url.link(base_url)\n end", "def sanitize\n \tself.original_url.strip!\n \tself.sanitize_url = self.original_url.downcase.gsub(/(https?:\\/\\/)|(www\\.)/, \"\")\n \tself.sanitize_url = \"http://#{self.sanitize_url}\"\n\n \n start = 8\n final = self.sanitize_url.length\n\n while start <= final do\n sanitize_url[start] == ' ' ? sanitize_url[start] = '-' : sanitize_url[start] = sanitize_url[start] #change spaces for '-'\n break if sanitize_url[start] == '/' #break if '/' is found\n start +=1\n end\n\n self.sanitize_url = sanitize_url[0..start] #cut the string for creating the shortened_url\n self.short_url = sanitize_url + short_url #save the final shortened_url on the short_url's field\n end", "def update_short_url\n uniq_key = Digest::MD5.hexdigest(\"#{self.id()}\").slice(0..6) \n update_column(:short_url, BASE_SHORT_URL + uniq_key)\n true\n end", "def generate_short_url\n url = Process.clock_gettime(Process::CLOCK_REALTIME, :nanosecond).to_s(36)\n old_url = Link.where(short_url: url).last\n if old_url.present? \n self.generate_short_url\n else\n self.short_url = url\n end\n end", "def redirection_limit=(limit); end", "def limit_posts; end", "def shorten_urls\n @status = (@status.split(\" \").collect do |word|\n if word =~ URI::regexp and word.length > 30 then\n # using tinyurl\n # NOTE: look into retwt.me, they have a simple api (w/o auth) and provide analysis\n (Net::HTTP.post_form URI.parse('http://tinyurl.com/api-create.php'),{\"url\" => word}).body\n else\n word\n end\n end).join(\" \")\n end", "def index\n @url = ShortenedUrl.new\n end", "def index\n @short_urls = ShortUrl.all.order(clicks: :desc).limit(100).paginate(:page => params[:page], :per_page => 10)\n end", "def instagram_rate_limit_warning(rate_limit_remaining, url)\n # Key-based expiration\n @rate_limit_remaining = rate_limit_remaining\n @url = url\n cache_key = [\"instagram_rate_limit_warning\", Time.now.hour]\n return nil if Rails.cache.fetch cache_key\n Rails.cache.write cache_key, true\n mail subject: \"[#{AppConfig.app_name}] WARNING: Instagram rate limit low\"\n end", "def index\n @short_urls = @user.short_urls.paginate(:page => params[:page][:number], :per_page => params[:page][:size])\n if @short_urls.count > 0\n render json: @short_urls, meta: pagination_details(@short_urls)\n else\n error = {}\n render json: {errors: {message: \"You haven't created Short URLs yet!\"}}\n end\n end", "def shorten_link\n # http://stackoverflow.com/questions/88311/how-best-to-generate-a-random-string-in-ruby\n o = [('a'..'z'), ('A'..'Z')].map(&:to_a).flatten\n string = (0...6).map { o[rand(o.length)] }.join\n self.short_url = \"http://www.sho.rt/#{string}\"\n end", "def maximum_requests\n super\n end", "def default_limit\n 10\n end", "def apply_slug_limit(candidate, uuid); end", "def candidate_limit(uuid); end", "def check_for_rate_limits\n rate_limit_remaining < 10\n end", "def generate_8_character_unique_url\n loop do\n random_short_path = SecureRandom.base64(12).gsub('+', '').gsub('/', '').gsub('=', '')[0..7]\n return random_short_path if (random_short_path.length == 8) && Url.where(short_path: random_short_path).count.zero?\n end\n end", "def index\n @url_shortners = UrlShortner.all\n end", "def selective_tweet_shortener(tweet)\n if tweet.length > 140\n bulk_tweet_shortener(tweets)\n else\n tweet\n end\nend", "def create\n url = params[:short_url][:url]\n\n # regex to validate url\n is_url = url.match(/^(http|https):\\/\\/[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5}(:[0-9]{1,5})?(\\/.*)?$/ix).present?\n \n if is_url == true\n surl = Digest::MD5.hexdigest(url+\"in salt we trust\").slice(0..6) \n short_url = \"http://\" + surl\n\n @short_url = ShortUrl.create(title: params[:short_url][:title], url: params[:short_url][:url] , short_url: short_url, jmp_url: \"\", clicks: 0)\n redirect_to @short_url, notice: 'Short url was successfully created.'\n else \n redirect_to short_urls_path, notice: 'Invalid Url.'\n end \n\n \n end", "def url_set\n @randomstring = SecureRandom.hex(5)\n if User.where('unique_url = ?', @randomstring).blank?\n params[:user][:unique_url] = @randomstring\n else\n url_set\n end\n end", "def resource_limits; end", "def resource_limits; end", "def rate_limited?\n tries = redis.get(key=\"tries:#{@env['REMOTE_ADDR']}\").to_i\n\n if tries > 10\n true\n else\n # give the key a new value and tell it to expire in 30 seconds\n redis.set(key, tries+1)\n redis.expire(key, 30)\n false\n end\n end", "def create_shortened_url\n key = self.id - 1\n\n if key == 0\n shortened = ALPHABET[0]\n else\n shortened = ''\n baseLength = ALPHABET.length\n\n until key < 1\n place = key % baseLength\n shortened += ALPHABET[place]\n\n key /= baseLength\n end\n end\n self.shortened = shortened\n self.save\n end", "def redirection_limit; end", "def redirection_limit; end", "def url_whitelist=(_arg0); end", "def index\n @shorten_urls = ShortenUrl.all\n end", "def slug_limit=(_arg0); end", "def limited_users_count\n @limited_users_count ||= users.limit(count_limit).count\n end", "def index\n @urlshortners = Urlshortner.all\n end", "def set_limit\n @limit = 250\n end", "def create_short_url(original_url = nil)\n params = {body: {originalURL: original_url, domain: @short_domain}.to_json, headers: {\"Authorization\" => @short_api_key}}\n response = self.class.post(\"/links\", params)\n @short_url = JSON.parse(response.body)[\"shortURL\"]\n response\n end", "def limit; end", "def limit; end", "def limit; end", "def limit\n 7\n end", "def short_url\n @short_url ||= client.shorten(long_url: url).link\n rescue => e\n Rails.logger.warn(\"Could not shorten bit.ly url #{e.message}\")\n url\n end", "def max_tag_subscriptions\n 5\n end", "def rate_limit\n new_request=RequestLimit.new({ip:request.remote_ip.to_s})\n\n # create a new record of RequestLimit to keep count of the incomming requests\n new_request.save\n\n # Check if current request exceeds max limit specified\n\n if RequestLimit.all.size > RequestLimit::MAX_LIMIT\n\n # Calculate the Time till the count will get reset\n time_left=(Time.now.end_of_hour).to_i-(Time.now).to_i\n render status: 429, json: { message: \"Rate limit exceeded. Try again in #{time_left} seconds\" } ## response when limit is exceeded\n end\n end", "def generate_short_url(url_id)\n # Base62 alphabet to be used\n alphabet_array = [*'a'..'z', *'A'..'Z', *'0'..'9']\n shorturl = []\n while url_id.to_i.positive?\n shorturl.push(alphabet_array[url_id % 62])\n url_id /= 62\n end\n new_url = shorturl.reverse.join\n\n # Check short_url doesn't exist in the database. If short_url exists, we generate a new url\n url_exist = UrlShortener.find_by_short_url(new_url)\n return new_url if url_exist.blank?\n\n generate_short_url(url_id)\n end", "def rate_limit_calls\n calls = ENV['RATE_LIMIT_CALLS'].to_i\n calls > 0 ? calls : 5\n end", "def shorten\n result = url\n \n begin \n if url.size > 18 && !/http:\\/\\/snipr.com.*/.match(url)\n using(rdr = StreamReader.new(request.get_response.get_response_stream)) { \n result = rdr.read_to_end.to_s\n } \n end\n rescue Exception => e\n #catch all errors and just return the regular url\n end\n \n res = ((result.size >= url.size || result.empty?) ? url.ensure_http : result).to_s\n logger.debug(\"*** SniprUrl: Shortened url from: #{url} to #{res}\")\n res\n end", "def helpers_allowed\n (participants.coming.accepted.size / 5).to_i\n end", "def create\n @short_url = @user.short_urls.new(short_url_params)\n\n if @short_url.save\n short_url = @short_url\n short_url.shorty = \"http://www.my-domain.com/#{@short_url.shorty}\"\n render json: short_url, status: :created\n else\n render json: {errors: @short_url.errors}, status: :unprocessable_entity\n end\n end", "def show_short_urls\n\t\turls = Url.all\n\t\t@short_url_list = []\n\t\turls.each do |url|\n\t\t\tshort_url = get_short_url_from_id url.id\n\t\t\t@short_url_list << short_url\n\t\tend\n\t\trender \"url\"\n\tend", "def set_rate_usage(resp)\n rate_limit = resp[\"x-ratelimit-limit\"]\n usage_limit = resp[\"x-ratelimit-usage\"]\n return if rate_limit.nil? or usage_limit.nil?\n short_limit = rate_limit.split(\",\")[0].to_i\n long_limit = rate_limit.split(\",\")[1].to_i\n short_usage = usage_limit.split(\",\")[0].to_i\n long_usage = usage_limit.split(\",\")[1].to_i\n quarter_hours_left = [(DateTime.now.utc.end_of_day.to_i - DateTime.now.utc.to_i) / 900, 1].max\n short_max = [ ( (long_limit - long_usage) / quarter_hours_left.to_f).to_i, short_limit].min\n $redis.set(\"strava_short_limit\", short_limit)\n $redis.set(\"strava_long_limit\", long_limit)\n $redis.set(\"strava_short_usage\", short_usage)\n $redis.set(\"strava_long_usage\", long_usage)\n $redis.set(\"strava_last_time\", DateTime.now.to_i)\n $redis.set(\"strava_short_max\", short_max)\n end", "def test_creates_random_short_name_if_not_given\n num_trials = 1e4\n uniq_names = (1..num_trials).map do\n RequestedShortening.new('http://x.com').short_name\n end.uniq\n assert_equal(num_trials, uniq_names.size,\n 'Generated short names should not collide')\n end", "def create\n if current_user.id == @user.id\n @shorturl = @user.shorturls.build(shorturl_params)\n respond_to do |format|\n if @shorturl.save\n format.html { redirect_to user_shorturl_path(@user, @shorturl), notice: 'Shorturl was successfully created.' }\n format.json { render :show, status: :created, location: @shorturl }\n else\n format.html { render :new }\n format.json { render json: @shorturl.errors, status: :unprocessable_entity }\n end\n end\n else\n flash[:error] = \"Not authorized!.\"\n redirect_to root_path\n end\n end", "def set_shorten_url\n @shorten_url = ShortenUrl.find(params[:id])\n end", "def item_limit\n 100\n end", "def below_user_limit?(user, additional_items)\n if purchase_limit == 0\n true\n else\n current_count = current_count(user, additional_items)\n current_count < purchase_limit\n end\n end", "def create\n @short_url = ShortUrl.new(params[:short_url])\n @short_url.user_id = current_user.id if signed_in?\n if @short_url.save\n redirect_to @short_url\n else\n render 'new'\n end\n end", "def for_web_urls\n self.fixed_length\n end", "def short_link\n UrlShort::IsGd.shorten @link\n end", "def limit\n super\n end", "def check_max_allowed_admin_count\n total = Admin.not_deleted.where(default_client_id: @client_id).count\n\n return error_with_data(\n 'am_au_i_cmaac_1',\n 'total no of admins added has reached max limit',\n \"You can add only upto #{MAX_ADMINS} admins\",\n GlobalConstant::ErrorAction.default,\n {}\n ) if total.to_i >= MAX_ADMINS\n\n success\n end", "def create\n original_url = params[:short_url][:url]\n sanity_url = get_sanity_url(original_url)[0]\n @short_url = ShortUrl.find_by(sanity_url: sanity_url)\n if !@short_url.present?\n short_url = create_short_url\n while ShortUrl.find_by(short: short_url).present?\n short_url = create_short_url\n end\n @short_url = ShortUrl.new(original: original_url, short: short_url, sanity_url: sanity_url)\n @short_url.save\n end\n redirect_to @short_url, notice: 'Short url was successfully created.'\n end", "def spamcheck(url, max_score=5.0)\n filters(spamcheck: {settings: {enable: 1, maxscore: max_score, url: url}})\n end", "def thumbnail_urls(n = 4)\n pins.newest_first.not_ids(cover_source_id || 0).limit(n).collect{ |p| p.image.v55.url }\n end" ]
[ "0.6934241", "0.6458169", "0.6436229", "0.63092214", "0.63092214", "0.627229", "0.6268417", "0.62402046", "0.6187315", "0.6138328", "0.6096861", "0.6069791", "0.6068162", "0.60563904", "0.60221416", "0.6015275", "0.5949638", "0.58199316", "0.5803775", "0.57888997", "0.5775395", "0.57486665", "0.57339996", "0.57204276", "0.57140946", "0.5627711", "0.56200933", "0.5617816", "0.561296", "0.5606347", "0.5604657", "0.55376166", "0.5527054", "0.5519358", "0.55145776", "0.5479086", "0.54742056", "0.5462882", "0.54567885", "0.54548734", "0.54536825", "0.5449066", "0.54395366", "0.54274124", "0.5410049", "0.53939146", "0.5374571", "0.5372503", "0.5370047", "0.5367997", "0.53654015", "0.5365147", "0.53624177", "0.5362074", "0.5354838", "0.53389114", "0.5326292", "0.5322829", "0.5321433", "0.530657", "0.53064513", "0.53064513", "0.52997535", "0.5298764", "0.528774", "0.528774", "0.52756864", "0.52534497", "0.52461606", "0.5245108", "0.5241178", "0.5238673", "0.52373403", "0.5198143", "0.5198143", "0.5198143", "0.51951975", "0.5190306", "0.518525", "0.51776266", "0.51424545", "0.5139886", "0.5135969", "0.51312834", "0.5112845", "0.51022255", "0.5099167", "0.5085269", "0.5085068", "0.5084716", "0.50535524", "0.5052545", "0.50431955", "0.50412863", "0.5023624", "0.50222623", "0.5021344", "0.5012019", "0.50090665", "0.5004873" ]
0.8482006
0
Are notes in the same graph?
def notes_in_the_same_graph? if self.source_note.nil? return false end if self.target_note.nil? return false end return self.source_note.graph == self.target_note.graph end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def different_notes?\n if self.source_note.nil?\n return false\n end\n if self.target_note.nil?\n return false\n end\n return self.source_note != self.target_note\n end", "def equivalent?(other_chord)\n other_notes = other_chord.notes.map(&:unbind)\n notes.uniq.sort == other_notes.uniq.sort\n end", "def ==(other_note)\n self.tone == other_note.tone\n end", "def different_tag?\n note_tags = @note.tags || []\n tag = @tag.get || []\n (note_tags - tag).size != 0 || (tag - note_tags).size != 0\n end", "def appropriate\n notes.map(&:class).uniq.size >= @chord.notes.size\n end", "def eql?(other_note)\n other_note.instance_of?(self.class) and self == other_note\n end", "def note?\n first_element_child.text =~ /\\A\\s*Note:\\s/\n end", "def notes_within(ivp_x, ivp_y, ivp_width, ivp_height)\n vp_x = ivp_x.to_i\n vp_y = ivp_y.to_i\n vp_width = ivp_width.to_i\n vp_height = ivp_height.to_i\n\n # Get appropriate notes:\n vp_notes_strict = self.notes.find(:all, :readonly => true, :conditions => \n [\"(x+width) >= ? AND x <= ? AND (y+height) >= ? AND y <= ?\",\n vp_x, vp_x+vp_width, vp_y, vp_y+vp_height\n ]\n )\n\n # Add notes with direct links to viewport notes\n vp_notes = vp_notes_strict.clone\n vp_notes_strict.each do |n|\n\n # See if the note has any unadded sources\n n.edges_to.each do |e|\n # .. by checking the original\n testnote = Note.find(e.source_note.id)\n if !vp_notes_strict.include?(testnote)\n # Add the source note\n vp_notes.push(testnote)\n end\n end\n\n # Same for outgoing edges\n n.edges_from.each do |e|\n testnote = Note.find(e.target_note.id)\n if !vp_notes_strict.include?(testnote)\n vp_notes.push(testnote)\n end\n end\n end\n\n return vp_notes\n end", "def notes; end", "def notes; end", "def notes; end", "def bidirectionally_unique?\n if self.source_note.nil?\n return false\n end\n if self.target_note.nil?\n return false\n end\n return Edge.first(:conditions => {:source_id => self.target_note.id, :target_id => self.source_note.id}).nil?\n end", "def inferred_notes\n if scrubbed_notes?\n Rails.logger.debug \"not replacing scrubbed notes\"\n head_notes\n notes\n elsif head_notes.present?\n head_notes\n elsif notes.present? && ff?\n Rails.logger.debug \"not deleting old ff notes\"\n head_notes\n notes\n else\n head_notes\n end\n end", "def notes_from_training\n end", "def get_same_comment(nodes, metadata)\n record_call(:get_same_comment, nodes, metadata)\n nodes.map { |node| [node, \"Comment for #{node}\"] }.to_h\n end", "def note_nodes\n nodes = Nokogiri::HTML.fragment(self.notes).children\n if nodes.size == 1\n content = Scrub.remove_surrounding(notes)\n Nokogiri::HTML.fragment(content).children\n else\n return nodes\n end\n end", "def all_notes\n self.has_notes? ? self.annotations.map {|n| n.body }.join(' ') : '' \n end", "def same_tracks_as?(other_pattern)\n @tracks.keys.each do |track_name|\n other_pattern_track = other_pattern.tracks[track_name]\n if other_pattern_track == nil || @tracks[track_name].rhythm != other_pattern_track.rhythm\n return false\n end\n end\n \n return @tracks.length == other_pattern.tracks.length\n end", "def notes( params={} )\n notes = get_connections(\"notes\", params)\n return map_connections notes, :to => Facebook::Graph::Note\n end", "def may_note?\n false\n end", "def old_combine_notes\n notes = self.notes\n full_text = \"\"\n\n for note in notes\n full_text << \" //- \"\n full_text << note.body.strip\n # if @note != @notes[-1]\n # @full_text << \" //- \"\n # end\n end\n\n self.combined_notes = full_text\n puts self.combined_notes\n self.save \n end", "def _Notes\n while true\n\n _save1 = self.pos\n while true # choice\n _tmp = apply(:_Note)\n break if _tmp\n self.pos = _save1\n _tmp = apply(:_SkipBlock)\n break if _tmp\n self.pos = _save1\n break\n end # end choice\n\n break unless _tmp\n end\n _tmp = true\n set_failed_rule :_Notes unless _tmp\n return _tmp\n end", "def note\n qry = ActiveRDF::Query.new(Note).select(:note).distinct\n qry.where(:note, N::DCT.isPartOf, self)\n qry.execute\n end", "def notes\n @notes\n end", "def same_tracks_as?(other_pattern)\n @tracks.keys.each do |track_name|\n other_pattern_track = other_pattern.tracks[track_name]\n if other_pattern_track.nil? || @tracks[track_name].rhythm != other_pattern_track.rhythm\n return false\n end\n end\n\n @tracks.length == other_pattern.tracks.length\n end", "def graph?\n true\n end", "def note?\n entry_type == :note\n end", "def note_state\n state if note\n end", "def test_notes_parts_values\n obs = observations(:template_and_orphaned_notes_scrambled_obs)\n assert_equal(\"red\", obs.notes_part_value(\"Cap\"))\n assert_equal(\"pine\", obs.notes_part_value(\"Nearby trees\"))\n end", "def graph?\n false\n end", "def test_can_accept_multiple_notes\n p = players(:manny)\n assert_equal [], p.notes\n note1 = Note.create!(:body => \"note 1\")\n note2 = Note.create!(:body => \"note 2\")\n p.notes << note1\n p.notes << note2\n assert_equal [note1, note2], p.notes\n end", "def notes(wspace=workspace)\n\t\twspace.notes\n\tend", "def notes\n\t\tall.map do |tone|\n\t\t\tKey.from_index(tone.tone, tone.letter_index).name\n\t\tend.extend(NoteSequence)\n\tend", "def creates_circular_reference(subject_to_embed, graph, subject_stack)\n subject_stack[0..-2].any? do |subject|\n subject[:graph] == graph && subject[:subject]['@id'] == subject_to_embed['@id']\n end\n end", "def notes_chronologically\n notes.in_order\n end", "def directed?() false; end", "def play(notes)\n\n md = /(\\w):(.+)/.match(notes)\n \n notetype = @notes[md[1]]\n d = @seq.note_to_delta(notetype)\n\n # n.b channel is inverse of string - chn 0 is str 6 \n md[2].split('|').each_with_index do |fret, channel| \n if fret.to_i.to_s == fret\n fret = fret.to_i\n oldfret = @prev[channel]\n @prev[channel] = fret \n\n if oldfret\n oldnote = @tuning[channel] + oldfret\n @track.events << MIDI::NoteOffEvent.new(channel,oldnote,0,d)\n d = 0\n end\n \n noteval = @tuning[channel] + fret\n @track.events << MIDI::NoteOnEvent.new(channel,noteval,80 + rand(38),d)\n d = 0\n end\n end\n end", "def notes\n Notes.new(self)\n end", "def merged_notes\n Commit.new(merged_base, git).notes?\n end", "def empty?\n notes.empty?\n end", "def condition_note\r\n self.notes\r\n end", "def _notes\n @_notes ||= Hash.new do |h, k|\n h[k] = {}\n end\n end", "def directed?\n true\n end", "def notes\n return @notes\n end", "def notes\n return @notes\n end", "def notes\n return @notes\n end", "def notes\n return @notes\n end", "def note_contents\n self.notes.map(&:content)\n end", "def note_contents\n self.notes.map(&:content)\n end", "def starred_notes\n fetch_notes_for nil, true\n end", "def orphan?\n !target_type || !notes.match?(/\\A\\d{14}/)\n end", "def verify_note(test_data)\n verify_values_match(test_data[CoreUseOfCollectionsData::NOTE.name], element_value(note_text_area))\n end", "def show_notes\n info \"showing notes\"\n res = run(\"git notes --ref #{refname} show\")\n if res[:val] == 0\n info \"existing note: #{res[:out].strip}\"\n else\n info \"no existing note\"\n end\n end", "def equal_by_trans?(g1, g2)\n check_pre((\n (graph_obj?(g1)) and\n (graph_obj?(g2))\n ))\n\n # pick two points\n # sub p1 from p2\n # translate p2 by diff\n # check equal_by_tree\n\n if not equal_by_dim?(g1, g2)\n return false\n end\n\n p1 = shape_lowest_left_point(g1)\n p2 = shape_lowest_left_point(g2)\n\n tp1 = p1 - p2\n tg1 = g2.translate(tp1)\n\n return equal_by_tree?(g1, tg1)\nend", "def graph?\n show?\n end", "def graph?\n show?\n end", "def verify_note(test_data)\n verify_values_match(test_data[UseOfCollections::NOTE.name], element_value(note_text_area))\n end", "def notes\n @attributes[:notes]\n end", "def notes\n @attributes[:notes]\n end", "def notes=(value)\n @notes = value\n end", "def notes=(value)\n @notes = value\n end", "def notes=(value)\n @notes = value\n end", "def notes=(value)\n @notes = value\n end", "def notes\n notes_range.to_a.map(&:to_s)\n end", "def set_notes_parts\n values = @@chord_possibilities[@type]\n @core_notes.each do |note|\n poss_int = @core_notes.map { |n| (note.pitch - n.pitch) % 12 }\n if @type == :diminished\n if !poss_int.include?(3)\n poss_int = [3]\n elsif !poss_int.include?(6)\n poss_int = [6]\n else\n poss_int = [9]\n end\n end \n if values == :unknown\n note.part = :unknown\n elsif poss_int.include?(values[0])\n note.part = :root\n elsif poss_int.include?(values[1])\n note.part = :third\n elsif poss_int.include?(values[2])\n note.part = :fifth\n elsif poss_int.include?(values[3])\n note.part = :seventh\n else\n note.part = :error\n end \n end\n self.fill_non_chord_parts\n end", "def node_and_parent_same_text?(node)\n node.parent.text.strip == node.text.strip\n end", "def note_contents\n self.notes.each.map{|note| note.content}\n end", "def next_note\r\n end", "def notes\n return Note.find(:all, :conditions => [\"type_id = ? AND owner = ?\", self.id, :property ])\n end", "def intersection(note_a, note_b)\n\n return (note_a[0] <= note_b[1] and note_a[1] >= note_b[0])\n\n end", "def get_different_comment(nodes, metadata)\n record_call(:get_different_comment, nodes, metadata)\n nodes.map { |node| [node, 'Comment from test_cmdb_2'] }.to_h\n end", "def note?\n return true unless Settings.note.blank?\n return false\n end", "def directed_only?\n true\n end", "def items_have_notes?(items)\n return false if items.nil? || items.empty?\n items.any? { |i| !i.fetch('notes', '').empty? }\n end", "def similar?(other)\n other && other.to == @to && other.from == @from && other.label == @label\n end", "def note(*note_names)\n midi_values = note_names.map { |name| Midishark::Notes.note(name) }\n @notes << midi_values\n\n midi_values\n end", "def note\n @scale.note(degree)\n end", "def answers\n pseudo_graph_pattern.all_answers.map(&:to_answer).uniq\n end", "def notes_orphaned_parts(user)\n return [] if notes.blank?\n\n # Change spaces to underscores in order to subtract template parts from\n # stringified keys because keys have underscores instead of spaces\n template_parts_underscored = user.notes_template_parts.each do |part|\n part.tr!(\" \", \"_\")\n end\n notes.keys.map(&:to_s) - template_parts_underscored - [other_notes_part]\n end", "def has_same_identity_as?(other)\n @label == other.label && [email protected]?\n end", "def notes?\n result = false\n self.class.all_note_fields.each do |field|\n result = send(field).to_s.match(/\\S/)\n break if result\n end\n result\n end", "def note_strings\n ::Set.new(@notes.collect(&:note_string))\n end", "def notes_generated(notes)\n puts green(\"Release notes generated: #{notes}\")\n end", "def notes\n\t\tNote.find(:all)\n\tend", "def notes\n @data[:notes]\n end", "def sequence?\n kmer_length = @parent_graph.hash_length\n if kmer_length -1 > @ends_of_kmers_of_node.length\n return false\n else\n return true\n end\n end", "def update_note(update_octave=true) # Update_octave=false used in generative parsing\n if self[:pc]\n self.merge!(get_ziff(self[:pc], self[:key], self[:scale],(update_octave ? (self[:octave] || 0) : false),(self[:add] || 0)))\n elsif self[:hpcs]\n notes = []\n self[:hpcs].each do |d|\n pc = d[:pc]\n notes.push(get_note_from_dgr(pc, d[:key], d[:scale], (d[:octave] || 0)) + (self[:add] || 0))\n end\n self[:pcs] = self[:hpcs].map {|h| h[:pc] }\n self[:notes] = notes\n end\n end", "def add_note(note)\n self.notes = notes.present? ? \"\\n\\n#{note}\" : note\n save\n end", "def detect_cycle_in_graph(edges)\nend", "def equal_by_trans?(graph_obj1, graph_obj2)\n check_pre((graph_obj?(graph_obj1) and graph_obj?(graph_obj2)))\n bounds_obj1 = bounds(graph_obj1)\n bounds_obj2 = bounds(graph_obj2)\n if (not (bounds_obj1.size == bounds_obj2.size)) #or (not equal_by_dim?(graph_obj1, graph_obj2))\n false\n elsif one_dim?(graph_obj1) and one_dim?(graph_obj2)\n translate(graph_obj1, -(bounds_obj1.first - bounds_obj2.first)) == graph_obj2\n #equal_by_tree?(translate(graph_obj1, -(bounds_obj1.first - bounds_obj2.first)), graph_obj2)\n elsif two_dim?(graph_obj1) and two_dim?(graph_obj2)\n translate(graph_obj1, Point2d[-(bounds_obj1.x_range.first - bounds_obj2.x_range.first),\n -(bounds_obj1.y_range.first - bounds_obj2.y_range.first)]) == graph_obj2\n #equal_by_tree?(translate(graph_obj1, Point2d[-(bounds_obj1.x_range.first - bounds_obj2.x_range.first), \n #-(bounds(graph_obj1).y_range.first - bounds(graph_obj2).y_range.first)]), graph_obj2)\n else false\n end\nend", "def merge_description_notes\n src_notes = @src.all_notes\n dest_notes = @dest.all_notes\n src_notes.each_key do |f|\n if dest_notes[f].blank?\n dest_notes[f] = src_notes[f]\n elsif src_notes[f].present?\n dest_notes[f] += \"\\n\\n--------------------------------------\\n\\n\"\n dest_notes[f] += src_notes[f].to_s\n end\n end\n @dest.all_notes = dest_notes\n end", "def notes_show_formatted\n Observation.show_formatted(notes)\n end", "def note_for_main_target?(note)\n !@mixed_targets || @main_target_type == note.noteable_type\n end", "def growEqualityGraph(s_vertices, t_vertices, s_neighbors, s_neighbors_not_in_t) #weights, s_vertices, t_vertices, s_neighbors_not_in_t, s_neighbors)\n\t\t\n\t\t#update labels\n\t\t\n\t\t\n\t\tlabelUpdateVal = nil\n\t\t\n\t\t#We want to grow T in order to up the chance we can have a match\n\t\t\n\t\tunconnected_y_vertices = @y_vertices - t_vertices\n\t\t\n\t\tputs \"Update labels, matching some thing in S #{s_vertices.to_a} and not T #{unconnected_y_vertices.to_a}\" if DEBUG_OUTPUT\n\t\t\t\t\t\t\t\n\t\ts_vertices.each do |xIdx|\n\t\t\tunconnected_y_vertices.each do |y|\n\t\t\t\t\t\n\t\t\t\tyIdx = yIdx(y)\n\t\t#\t\t\t\t\t\t\n\t\t\t\tnext if @weights[xIdx][yIdx] == nil\n\t\t\t\t#puts \"looking at #{x} #{xIdx} #{y} #{yIdx} ..label vals #{labelX[xIdx]} + #{labelY[yIdx]} - weights[xIdx][yIdx]\" if DEBUG_OUTPUT\n\t\t\t\tcandidate = @labelX[xIdx] + @labelY[yIdx] - @weights[xIdx][yIdx]\n\t\t\t\tlabelUpdateVal = candidate if labelUpdateVal == nil || candidate < labelUpdateVal\n\t\t\tend\n\t\tend\n\t\t\t\n\t\t#Todo probably the cells matching candidate and exactly\n\t\t#the ones that are the new lines in the equality subgraph\n\t\t\n\t\tputs \"Label Updating Value #{labelUpdateVal}\" if DEBUG_OUTPUT\n\t\t\t\n\t\t\t#Now adjust the label values accordingly\n\t\t#\t\t\t\t#This adjustment will keep the equality graph the same but add an edge\n\t\ts_vertices.each do |xIdx|\n\t\t\t@labelX[xIdx] -= labelUpdateVal\n\t\tend\n\t\t\t\n\t\tt_vertices.each do |y|\t\t\n\t\t\t@labelY[yIdx(y)] += labelUpdateVal\n\t\tend\n\t\t\t\t\t\n\t\t#@edges = Set.new\n\t\t#puts \"Arg: #{@edges.to_a}\" if DEBUG_OUTPUT\n\t\t\n\t\t#New eq graph has same edges if x is part of s && y is part of t or\n\t\t#if x,y not part s,t respectively\n\t\t#so we just have to blow away stuff in s, but not t and t but not s\n\t\t\n\t\tclearEdges\t\t\n#\t\tnot_s_vertices = x_vertices - s_vertices\n#\t\t\n#\t\[email protected]! { |e| s_vertices.member?(e[0]) != t_vertices.member?(e[1]) }\n#\t\t\n\t\ts_vertices.each do |x|\n\t\t\tunconnected_y_vertices.each do |y|\n\t\t\t\t#puts \"genEqGraph x=[#{x}] y=[#{y}] weight=#{weights[xIdx][yIdx]} labelX=#{labelX[xIdx]} labelY=#{labelY[yIdx]}\" if DEBUG_OUTPUT\n\t\t\t\tif isEdge(x, y) == true\n\t\t\t\t\tputs \"Adding #{y} to s_neighbors #{s_neighbors.to_a}\" if DEBUG_OUTPUT\n\t\t\t\t\ts_neighbors.add(y)\n\t\t\t\t\ts_neighbors_not_in_t.push(y)\t\t\t\t\t\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t\n\t\tputs \"LabelX #{@labelX}\" if DEBUG_OUTPUT\n\t\tputs \"LabelY #{@labelY}\" if DEBUG_OUTPUT\t\t\n\t\tputs \"New Equality graph\\n#{to_s}\" if DEBUG_OUTPUT\t\t\t\n\t\t\t\t\t\n\tend", "def new_notes=(note)\n\t\tif !note.blank? then\n\t\t\ttime = Time.now.strftime(\"%m-%d-%y %I:%M %p\")\n\t\t\tnew_note = \"<p>#{note}<br/>\"\n\t\t\tnew_note << \"<span class=\\\"info\\\">\"\n\t\t\tnew_note << \"[#{time}]\"\n\t\t\tnew_note << \"</span></p>\"\n\t\t\tif self.notes.blank? then\n\t\t\t\tself.notes = new_note\n\t\t\telse\n\t\t\t\tself.notes << new_note\n\t\t\tend\n\t\tend\n\tend", "def form_notes_parts(user)\n return user.notes_template_parts + [other_notes_part] if notes.blank?\n\n user.notes_template_parts + notes_orphaned_parts(user) +\n [other_notes_part]\n end", "def create_notes\n end", "def notations; end", "def siblings?(node_id, other_node_id)\n node_id ^ other_node_id == 1\n end", "def note(note)\n\t\t@note = note\n\tend" ]
[ "0.6654293", "0.61116856", "0.59113777", "0.58173233", "0.58132035", "0.5663675", "0.563164", "0.5607588", "0.5603544", "0.5603544", "0.5603544", "0.56011367", "0.56010455", "0.55668646", "0.55227923", "0.5516326", "0.55051094", "0.54770356", "0.5458376", "0.54555386", "0.54467654", "0.54163563", "0.5401671", "0.5382427", "0.53667706", "0.5351928", "0.5322888", "0.53166103", "0.5264563", "0.524129", "0.52287805", "0.5222287", "0.52177423", "0.5198803", "0.5190196", "0.5174934", "0.5167364", "0.5150327", "0.5140914", "0.50931424", "0.5078051", "0.5047915", "0.50369966", "0.50290525", "0.50290525", "0.50290525", "0.50290525", "0.50190735", "0.50190735", "0.50129986", "0.5012632", "0.4995277", "0.4994439", "0.49896973", "0.49881458", "0.49881458", "0.49871746", "0.4985411", "0.4985411", "0.49829933", "0.49829933", "0.49829933", "0.49829933", "0.49768507", "0.49731207", "0.49572462", "0.49490133", "0.49475735", "0.49424726", "0.4938252", "0.49338803", "0.49334753", "0.49327862", "0.4926911", "0.49224916", "0.4920901", "0.49178702", "0.4915616", "0.49142382", "0.49073234", "0.4895853", "0.4893914", "0.48914135", "0.48759672", "0.48715228", "0.48688424", "0.48585337", "0.48571846", "0.485695", "0.48525733", "0.48490536", "0.48472652", "0.484473", "0.4842942", "0.48390797", "0.4838723", "0.48242998", "0.48239788", "0.48195863", "0.48148242" ]
0.7899092
0
Are notes different? As in, not the same note. (Properties besides ID can be the same, of course)
def different_notes? if self.source_note.nil? return false end if self.target_note.nil? return false end return self.source_note != self.target_note end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def eql?(other_note)\n other_note.instance_of?(self.class) and self == other_note\n end", "def ==(other_note)\n self.tone == other_note.tone\n end", "def notes_in_the_same_graph?\n if self.source_note.nil? \n return false\n end\n if self.target_note.nil? \n return false\n end\n return self.source_note.graph == self.target_note.graph\n end", "def test_can_accept_multiple_notes\n p = players(:manny)\n assert_equal [], p.notes\n note1 = Note.create!(:body => \"note 1\")\n note2 = Note.create!(:body => \"note 2\")\n p.notes << note1\n p.notes << note2\n assert_equal [note1, note2], p.notes\n end", "def docmp(itemA, itemB)\n itemA[:alias] != itemB[:alias] or itemA[:format] != itemB[:format]\n end", "def verify_note(test_data)\n verify_values_match(test_data[CoreUseOfCollectionsData::NOTE.name], element_value(note_text_area))\n end", "def different_tag?\n note_tags = @note.tags || []\n tag = @tag.get || []\n (note_tags - tag).size != 0 || (tag - note_tags).size != 0\n end", "def verify_note(test_data)\n verify_values_match(test_data[UseOfCollections::NOTE.name], element_value(note_text_area))\n end", "def equivalent?(other_chord)\n other_notes = other_chord.notes.map(&:unbind)\n notes.uniq.sort == other_notes.uniq.sort\n end", "def test_notes_parts_values\n obs = observations(:template_and_orphaned_notes_scrambled_obs)\n assert_equal(\"red\", obs.notes_part_value(\"Cap\"))\n assert_equal(\"pine\", obs.notes_part_value(\"Nearby trees\"))\n end", "def may_note?\n false\n end", "def old_combine_notes\n notes = self.notes\n full_text = \"\"\n\n for note in notes\n full_text << \" //- \"\n full_text << note.body.strip\n # if @note != @notes[-1]\n # @full_text << \" //- \"\n # end\n end\n\n self.combined_notes = full_text\n puts self.combined_notes\n self.save \n end", "def appropriate\n notes.map(&:class).uniq.size >= @chord.notes.size\n end", "def inferred_notes\n if scrubbed_notes?\n Rails.logger.debug \"not replacing scrubbed notes\"\n head_notes\n notes\n elsif head_notes.present?\n head_notes\n elsif notes.present? && ff?\n Rails.logger.debug \"not deleting old ff notes\"\n head_notes\n notes\n else\n head_notes\n end\n end", "def notes?\n result = false\n self.class.all_note_fields.each do |field|\n result = send(field).to_s.match(/\\S/)\n break if result\n end\n result\n end", "def note\n qry = ActiveRDF::Query.new(Note).select(:note).distinct\n qry.where(:note, N::DCT.isPartOf, self)\n qry.execute\n end", "def note?\n entry_type == :note\n end", "def other_notes_key\n Observation.other_notes_key\n end", "def _Notes\n while true\n\n _save1 = self.pos\n while true # choice\n _tmp = apply(:_Note)\n break if _tmp\n self.pos = _save1\n _tmp = apply(:_SkipBlock)\n break if _tmp\n self.pos = _save1\n break\n end # end choice\n\n break unless _tmp\n end\n _tmp = true\n set_failed_rule :_Notes unless _tmp\n return _tmp\n end", "def test_form_notes_parts\n # no template and no notes\n obs = observations(:minimal_unknown_obs)\n parts = [\"Other\"]\n assert_equal(parts, obs.form_notes_parts(obs.user))\n\n # no template and Other notes\n obs = observations(:detailed_unknown_obs)\n parts = [\"Other\"]\n assert_equal(parts, obs.form_notes_parts(obs.user))\n\n # no template and orphaned notes\n obs = observations(:substrate_notes_obs)\n parts = %w[substrate Other]\n assert_equal(parts, obs.form_notes_parts(obs.user))\n\n # no template, and orphaned notes and Other notes\n obs = observations(:substrate_and_other_notes_obs)\n parts = %w[substrate Other]\n assert_equal(parts, obs.form_notes_parts(obs.user))\n\n # template and no notes\n obs = observations(:templater_noteless_obs)\n parts = [\"Cap\", \"Nearby trees\", \"odor\", \"Other\"]\n assert_equal(parts, obs.form_notes_parts(obs.user))\n\n # template and other notes\n obs = observations(:templater_other_notes_obs)\n parts = [\"Cap\", \"Nearby trees\", \"odor\", \"Other\"]\n assert_equal(parts, obs.form_notes_parts(obs.user))\n\n # template and orphaned notes\n obs = observations(:templater_orphaned_notes_obs)\n parts = [\"Cap\", \"Nearby trees\", \"odor\", \"orphaned_caption\", \"Other\"]\n assert_equal(parts, obs.form_notes_parts(obs.user))\n\n # template and notes for a template part\n obs = observations(:template_only_obs)\n parts = [\"Cap\", \"Nearby trees\", \"odor\", \"Other\"]\n assert_equal(parts, obs.form_notes_parts(obs.user))\n\n # template and notes for a template part and Other notes\n obs = observations(:template_and_other_notes_obs)\n parts = [\"Cap\", \"Nearby trees\", \"odor\", \"Other\"]\n assert_equal(parts, obs.form_notes_parts(obs.user))\n\n # template and notes for a template part and orphaned part\n obs = observations(:template_and_orphaned_notes_obs)\n parts = [\"Cap\", \"Nearby trees\", \"odor\", \"orphaned_caption\", \"Other\"]\n assert_equal(parts, obs.form_notes_parts(obs.user))\n\n # template and notes for a template part, orphaned part, Other,\n # with order scrambled in the Observation\n obs = observations(:template_and_orphaned_notes_scrambled_obs)\n parts = [\"Cap\", \"Nearby trees\", \"odor\", \"orphaned_caption_1\",\n \"orphaned_caption_2\", \"Other\"]\n assert_equal(parts, obs.form_notes_parts(obs.user))\n end", "def orphan?\n !target_type || !notes.match?(/\\A\\d{14}/)\n end", "def notes\n return Note.find(:all, :conditions => [\"type_id = ? AND owner = ?\", self.id, :property ])\n end", "def items_have_notes?(items)\n return false if items.nil? || items.empty?\n items.any? { |i| !i.fetch('notes', '').empty? }\n end", "def to_up_notes(raw_notes)\n raw_notes.present? ? { other: raw_notes } : Observation.no_notes\n end", "def note?\n first_element_child.text =~ /\\A\\s*Note:\\s/\n end", "def test_update_note\n notes = @database.get_not_deleted_notes\n assert_not_nil notes\n \n note = notes.first\n assert_not_nil note\n \n note.content = \"A new content\"\n note.modifydate = Time.new.to_f.to_s\n version = note.version\n syncnumber = note.syncnumber\n \n tags = [\"important\", \"todo\"]\n note.tags = tags\n note.version += 1\n note.syncnumber += 1\n \n note.save\n \n updated_note = @database.get_note_with_key note.key\n\n # Check if changes were forwared to the database correctly\n assert_equal updated_note.content, note.content\n assert_equal updated_note.modifydate, note.modifydate\n assert_equal updated_note.tags, note.tags\n end", "def verify_note(note)\n logger.debug \"Verifying visible data for note ID #{note.id}\"\n\n # Verify data visible when note is collapsed\n collapsed_note_el(note).when_present Utils.medium_wait\n collapse_note note\n visible_data = visible_collapsed_note_data note\n expected_short_updated_date = \"Last updated on #{expected_note_short_date_format note.updated_date}\"\n wait_until(1, \"Expected '#{note.subject}', got #{visible_data[:subject]}\") { visible_data[:subject] == note.subject }\n wait_until(1, \"Expected '#{expected_short_updated_date}', got #{visible_data[:date]}\") { visible_data[:date] == expected_short_updated_date }\n\n # Verify data visible when note is expanded\n expand_note note\n visible_data.merge!(visible_expanded_note_data note)\n wait_until(1, \"Expected '#{note.body}', got '#{visible_data[:body]}'\") { visible_data[:body] == \"#{note.body}\" }\n wait_until(1, 'Expected non-blank advisor name') { !visible_data[:advisor].empty? }\n wait_until(1, 'Expected non-blank advisor role') { !visible_data[:advisor_role].empty? }\n wait_until(1, \"Expected '#{note.advisor.depts}', got #{visible_data[:advisor_depts]}\") { visible_data[:advisor_depts] == note.advisor.depts }\n\n # Topics\n note_topics = (note.topics.map { |t| t.name.upcase }).sort\n wait_until(1, \"Expected '#{note_topics}', got #{visible_data[:topics]}\") { visible_data[:topics] == note_topics }\n wait_until(1, \"Expected no remove-topic buttons, got #{visible_data[:remove_topics_btns].length}\") { visible_data[:remove_topics_btns].length.zero? }\n\n # Attachments\n non_deleted_attachments = note.attachments.reject &:deleted_at\n expected_file_names = non_deleted_attachments.map &:file_name\n wait_until(1, \"Expected '#{expected_file_names.sort}', got #{visible_data[:attachments].sort}\") { visible_data[:attachments].sort == expected_file_names.sort }\n\n # Check visible timestamps within 1 minute to avoid failures caused by a 1 second diff\n expected_long_created_date = \"Created on #{expected_note_long_date_format note.created_date}\"\n wait_until(1, \"Expected '#{expected_long_created_date}', got #{visible_data[:created_date]}\") do\n Time.parse(visible_data[:created_date]) <= Time.parse(expected_long_created_date) + 60\n Time.parse(visible_data[:created_date]) >= Time.parse(expected_long_created_date) - 60\n end\n expected_long_updated_date = \"Last updated on #{expected_note_long_date_format note.updated_date}\"\n wait_until(1, \"Expected '#{expected_long_updated_date}', got #{visible_data[:updated_date]}\") do\n Time.parse(visible_data[:updated_date]) <= Time.parse(expected_long_updated_date) + 60\n Time.parse(visible_data[:updated_date]) >= Time.parse(expected_long_updated_date) - 60\n end\n end", "def diff?(model = self.class.find(id))\n self.class.diffable_attributes.each do |attribute|\n return true if send(attribute) != model.send(attribute)\n end\n return false\n end", "def bidirectionally_unique?\n if self.source_note.nil?\n return false\n end\n if self.target_note.nil?\n return false\n end\n return Edge.first(:conditions => {:source_id => self.target_note.id, :target_id => self.source_note.id}).nil?\n end", "def notes_orphaned_parts(user)\n return [] if notes.blank?\n\n # Change spaces to underscores in order to subtract template parts from\n # stringified keys because keys have underscores instead of spaces\n template_parts_underscored = user.notes_template_parts.each do |part|\n part.tr!(\" \", \"_\")\n end\n notes.keys.map(&:to_s) - template_parts_underscored - [other_notes_part]\n end", "def dirty?\n orig_repr.properties != repr.properties ||\n sans_anon(orig_repr.all_links) != sans_anon(repr.all_links) ||\n raw_anons(orig_repr.all_links) != raw_anons(repr.all_links)\n end", "def test_notes_export_format\n assert_equal(\n \"\",\n observations(:minimal_unknown_obs).notes_export_formatted\n )\n\n assert_equal(\n \"Found in a strange place... & with śtrangè characters™\",\n observations(:detailed_unknown_obs).notes_export_formatted\n )\n assert_equal(\n \"substrate: soil\",\n observations(:substrate_notes_obs).notes_export_formatted\n )\n assert_equal(\n \"substrate: soil\\nOther: slimy\",\n observations(:substrate_and_other_notes_obs).notes_export_formatted\n )\n end", "def note_strings\n ::Set.new(@notes.collect(&:note_string))\n end", "def discrepancy?(local, remote)\n local.status != remote['status'] ||\n local.ad_description != remote['description']\n end", "def note_state\n state if note\n end", "def changed?(olds, news) ; olds != news ; end", "def _same_contents?(p1, p2)\n contents1 = p1.read.split(\"\\n\").map { |line| line.chomp }\n contents2 = p2.read.split(\"\\n\").map { |line| line.chomp }\n contents1 == contents2\n end", "def notes\n @notes\n end", "def merged_notes\n Commit.new(merged_base, git).notes?\n end", "def serialize_did_notes(data, xml, fragments)\n data.notes.each do |note|\n next if note[\"publish\"] === false && !@include_unpublished\n next unless data.did_note_types.include?(note['type']) # and note[\"publish\"] == true)\n\n audatt = note[\"publish\"] === false ? {:audience => 'internal'} : {}\n content = ASpaceExport::Utils.extract_note_text(note, @include_unpublished)\n\n att = { :id => prefix_id(note['persistent_id']) }.reject {|k,v| v.nil? || v.empty? || v == \"null\" }\n att ||= {}\n\n case note['type']\n when 'dimensions', 'physfacet'\n xml.physdesc(audatt) {\n #xml.physdesc {\n xml.send(note['type'], att) {\n sanitize_mixed_content( content, xml, fragments, ASpaceExport::Utils.include_p?(note['type']) )\n }\n }\n else\n xml.send(note['type'], att) {\n sanitize_mixed_content(content, xml, fragments,ASpaceExport::Utils.include_p?(note['type']))\n }\n end\n end\n end", "def test_update_name_merge_both_notes\n old_name = names(:mergeable_description_notes)\n new_name = names(:mergeable_second_description_notes)\n old_notes = old_name.description.notes\n new_notes = new_name.description.notes\n params = {\n id: old_name.id,\n name: {\n text_name: new_name.text_name,\n author: new_name.author,\n rank: new_name.rank,\n deprecated: (new_name.deprecated ? \"true\" : \"false\"),\n citation: \"\"\n }\n }\n login(\"rolf\")\n put(:update, params: params)\n\n assert_flash_success\n assert_redirected_to(name_path(new_name.id))\n assert_no_emails\n assert(new_name.reload)\n assert_not(Name.exists?(old_name.id))\n assert_equal(new_notes, new_name.description.notes)\n # Make sure old notes are still around.\n other_desc = (new_name.descriptions - [new_name.description]).first\n assert_equal(old_notes, other_desc.notes)\n end", "def notes\n @attributes[:notes]\n end", "def notes\n @attributes[:notes]\n end", "def equal?(other)\n return false unless other.is_a?(self.class)\n are_identical = false\n if self.title == other.title\n begin\n obj_id = self.object_id.to_s\n self.title += obj_id\n are_identical = (self.title == other.title)\n ensure\n self.title.sub(/#{obj_id}$/,'')\n end\n are_identical\n else\n false\n end\n end", "def serialize_did_notes(data, xml, fragments)\n data.notes.each do |note|\n next if note[\"publish\"] === false && !@include_unpublished\n next unless (data.did_note_types.include?(note['type']) and note[\"publish\"] == true)\n\n #audatt = note[\"publish\"] === false ? {:audience => 'internal'} : {}\n content = ASpaceExport::Utils.extract_note_text(note, @include_unpublished)\n\n att = { :id => prefix_id(note['persistent_id']) }.reject {|k,v| v.nil? || v.empty? || v == \"null\" }\n att ||= {}\n\n case note['type']\n when 'dimensions', 'physfacet'\n #xml.physdesc(audatt) {\n xml.physdesc {\n xml.send(note['type'], att) {\n sanitize_mixed_content( content, xml, fragments, ASpaceExport::Utils.include_p?(note['type']) )\n }\n }\n else\n xml.send(note['type'], att) {\n sanitize_mixed_content(content, xml, fragments,ASpaceExport::Utils.include_p?(note['type']))\n }\n end\n end\n end", "def documents_equal?(a, b)\n normalize_document(a) == normalize_document(b)\n end", "def same; end", "def invoice_or_delivery_note\n self.is_invoice = extract_invoice_id && extract_reference\n self.is_delivery_note = extract_order_confirmation_id && extract_delivery_note_id\n end", "def _notes\n @_notes ||= Hash.new do |h, k|\n h[k] = {}\n end\n end", "def starred_notes\n fetch_notes_for nil, true\n end", "def note?\n return true unless Settings.note.blank?\n return false\n end", "def note(id)\n @contacts.each do |contact|\n if contact.id == id\n contact.notes.clear\n contact.notes << @note.input\n contact.notes.flatten!\n end\n end\n end", "def expected_duplicate?(id)\n EXPECTED_DUPLICATES.include? id\n end", "def duplicate?\n\t\tother = Ng2::WordDetail.find(@word).last\n\t\t!other.nil? &&\n\t\tother.file_path == self.file_path &&\n\t\tother.line_no == self.line_no &&\n\t\tother.word_no == self.word_no\n\tend", "def issue_has_changelog_note(issue)\n issue.custom_values.each do |custom_value|\n false unless custom_value.custom_field_id == changelog_notes_id\n end\n end", "def merge_description_notes\n src_notes = @src.all_notes\n dest_notes = @dest.all_notes\n src_notes.each_key do |f|\n if dest_notes[f].blank?\n dest_notes[f] = src_notes[f]\n elsif src_notes[f].present?\n dest_notes[f] += \"\\n\\n--------------------------------------\\n\\n\"\n dest_notes[f] += src_notes[f].to_s\n end\n end\n @dest.all_notes = dest_notes\n end", "def to_down_notes(notes)\n # notes.is_a?(Hash) ? (notes)[:Other] : \"\"\n notes.empty? ? \"\" : (notes)[:Other]\n end", "def to_up_notes(raw_notes)\n raw_notes.present? ? { Other: raw_notes } : {}\n end", "def expected_note_id_sort_order(notes)\n (notes.sort_by {|n| [n.updated_date, n.created_date, n.id] }).reverse.map &:id\n end", "def note\n @attributes[:note]\n end", "def note_contents=(notes)\n notes.each do |content|\n if content.strip != '' # => ignores blank notes\n self.notes.build(content: content) \n end\n end\n end", "def test_truth\n assert_kind_of InvoiceNote, invoice_notes(:first)\n end", "def record_unchanged?(record_new, record_old)\n # NOTE: Using the dirty state would be great here, but it doesn't keep track of\n # in-place changes.\n\n allow_indexing?(record_old) == allow_indexing?(record_new) &&\n [email protected] { |field| record_old.send(field) == record_new.send(field) }.include?(false)\n end", "def verify_history_notes(test_data)\n test_histories = test_data[Org::HISTORY_NOTES.name]\n errors = []\n test_histories = [{ Org::HISTORY_NOTE.name => ''}] unless test_histories\n test_histories.each_with_index do |test_history, index|\n text_values_match?(test_history[Org::HISTORY_NOTE.name], element_value(history_input(index)), errors)\n end\n errors\n end", "def identical?\n #Song.first.attributes.each { |v,k| Song.find(:all, :conditions => [\" #{v} like ?\", \"%blah%\"])}\n Song.find(:all, :conditions => [\"name = ? or length = ?\", \"#{self.name}\", self.length]) do |x| \n x.hash == self.hash\n end\n end", "def favorite_note?(note_id)\n !favorite_notes.where(note_id: note_id).first.nil?\n end", "def diffable?\n true\n end", "def test_ut_diff_warning_02\n assert_equal 2,@diff_warning.diff_status_id\n assert_equal 1,@diff_warning.diff_file_id\n assert_equal 1,@diff_warning.rule_set\n assert_equal 1,@diff_warning.warning_id\n assert_equal 1,@diff_warning.original_file_id\n end", "def to_down_notes(notes)\n notes.empty? ? \"\" : notes[:other]\n end", "def eql? other\n id == other.id &&\n path == other.path &&\n line == other.line\n end", "def id_changed?\n to_id != @attributes[self.class.id_method]\n end", "def destruction?\n self.diff['attributes']['old'] && !self.diff['attributes']['new']\n end", "def valid_notes?\n return true if @version >= IOS_LEGACY_VERSION # Easy out if we've already identified the version\n\n # Just because my fingerprinting isn't great yet, adding in a more manual check for the key tables we need\n expected_tables = [\"ZICCLOUDSYNCINGOBJECT\",\n \"ZICNOTEDATA\"]\n @database.execute(\"SELECT name FROM sqlite_master WHERE type='table'\") do |row|\n expected_tables.delete(row[\"name\"])\n end\n\n return (expected_tables.length == 0)\n end", "def notes(options = {})\n # Create a default 2 item hash and update if options is supplied\n options = {\n id: nil,\n type: nil\n }.update(options)\n return nil if @_notes.nil?\n return nil if @_notes.empty?\n\n # Empty 2-D Hash to be used for notes found based on id and type\n notes_found = Hash.new do |h, k|\n # h is the id portion of the hash\n # k is the type portion of the hash\n h[k] = {}\n end\n # Filter @notes based off of the id\n filter_hash(@_notes, options[:id]).each do |id, hash|\n # Filter hash based off of the type\n filter_hash(hash, options[:type]).each do |type, note|\n # Store the note into note_found\n notes_found[id][type] = note\n end\n end\n if notes_found.empty?\n nil\n elsif notes_found.size == 1\n notes_found.values.first.values.first\n else\n notes_found\n end\n end", "def equal_list(expected)\n message = \"#{Helpers.inspect_records(@object)} has the same records as #{Helpers.inspect_records(expected)}\"\n \n left = @object.map(&:id)\n right = expected.map(&:id)\n \n test_case.assert(left != right, message)\n end", "def notes\n return @notes\n end", "def notes\n return @notes\n end", "def notes\n return @notes\n end", "def notes\n return @notes\n end", "def get_note(obj, id)\n obj['notes'].find {|n| n['persistent_id'] == id}\nend", "def datacite_metadata_changed? metadata=nil\n return true if datacite_document.nil?\n metadata||=doi_metadata\n metadata=JSON.parse(metadata.to_json) if metadata.key? :title\n old_metadata=JSON.parse(datacite_document)\n return metadata!=old_metadata\n end", "def changed_content?(doc)\n return true if title != doc[:title] || content != doc[:content] || m[:tag_list] != doc[:metadata][:tag_list]\n false\n end", "def test_no_duplicate_id\n dup = {\"_id\" => \"foo\", :_id => \"foo\"}\n one = {\"_id\" => \"foo\"}\n\n assert_equal @encoder.serialize(one, false, true).to_a, @encoder.serialize(dup, false, true).to_a\n end", "def equal_set(expected)\n message = \"#{Helpers.inspect_records(@object)} has the same records as #{Helpers.inspect_records(expected)}\"\n \n left = @object.map(&:id).sort\n right = expected.map(&:id).sort\n \n test_case.assert(left != right, message)\n end", "def note\n DBC.require( bu?, \"Vin non bu: La note n'est pas definie\" )\n\n @note\n end", "def show_notes\n info \"showing notes\"\n res = run(\"git notes --ref #{refname} show\")\n if res[:val] == 0\n info \"existing note: #{res[:out].strip}\"\n else\n info \"no existing note\"\n end\n end", "def note_given?\n params.has_key?(:note)\n end", "def test_update_name_merge_no_notes_into_description_notes\n old_name = names(:mergeable_no_notes)\n new_name = names(:mergeable_description_notes)\n notes = new_name.description.notes\n params = {\n id: old_name.id,\n name: {\n text_name: new_name.text_name,\n author: new_name.author,\n rank: new_name.rank,\n citation: \"\",\n deprecated: (old_name.deprecated ? \"true\" : \"false\")\n }\n }\n login(\"rolf\")\n put(:update, params: params)\n\n assert_flash_success\n assert_redirected_to(name_path(new_name.id))\n assert_no_emails\n assert(new_name.reload)\n assert_not(Name.exists?(old_name.id))\n assert_equal(notes, new_name.description.notes)\n end", "def creation?\n self.diff['attributes']['new'] && !self.diff['attributes']['old']\n end", "def author_worthy?\n notes?\n end", "def valid_notes?\n return true if @version >= 8 # Easy out if we've already identified the version\n\n # Just because my fingerprinting isn't great yet, adding in a more manual check for the key tables we need\n expected_tables = [\"ZICCLOUDSYNCINGOBJECT\",\n \"ZICNOTEDATA\"]\n @database.execute(\"SELECT name FROM sqlite_master WHERE type='table'\") do |row|\n expected_tables.delete(row[\"name\"])\n end\n\n return (expected_tables.length == 0)\n end", "def read_notes_without_serializing(obs)\n Observation.connection.exec_query(\"\n SELECT notes FROM observations WHERE id = #{obs.id}\n \").rows.first.first\n end", "def notes=(value)\n @notes = value\n end", "def notes=(value)\n @notes = value\n end", "def notes=(value)\n @notes = value\n end", "def notes=(value)\n @notes = value\n end", "def notes\n @data[:notes]\n end", "def modified?( original )\n DATA_ATTRIBUTES.any? { |e| send( e ) != original.send( e )}\n end", "def ==(other)\n return false unless other.is_a?(Document)\n @attributes.except(:modified_at).except(:created_at) ==\n other.attributes.except(:modified_at).except(:created_at)\n end", "def ==(other)\n BSON::ObjectId === other && data == other.data\n end" ]
[ "0.63706565", "0.63424486", "0.62246", "0.619334", "0.6150781", "0.6105678", "0.6098882", "0.60767806", "0.6075602", "0.6073008", "0.5900267", "0.5883932", "0.5877974", "0.5853289", "0.5794233", "0.57785225", "0.57640356", "0.57606083", "0.5746181", "0.57453763", "0.5742036", "0.5723324", "0.5721206", "0.57135594", "0.5685268", "0.5600768", "0.5590386", "0.5580489", "0.55596906", "0.5554912", "0.54644483", "0.54522717", "0.5423715", "0.5359894", "0.53584135", "0.53509456", "0.5347926", "0.53474253", "0.53470653", "0.5341454", "0.5332961", "0.5329725", "0.5329725", "0.5327743", "0.53190315", "0.5313494", "0.5300771", "0.5299205", "0.5286644", "0.52700806", "0.5268459", "0.5264902", "0.52592623", "0.5258957", "0.5257356", "0.5241472", "0.52230936", "0.5218404", "0.52052516", "0.52037007", "0.5197501", "0.5197112", "0.51934737", "0.51819587", "0.51783234", "0.5167207", "0.5164885", "0.51644385", "0.51628995", "0.51579195", "0.51570094", "0.5148034", "0.51446295", "0.5141077", "0.51380825", "0.5137588", "0.5137588", "0.5137588", "0.5137588", "0.51357144", "0.5131679", "0.5130608", "0.5126317", "0.51262987", "0.5112967", "0.51081115", "0.51055104", "0.5100576", "0.51004744", "0.51001704", "0.50983596", "0.5096916", "0.5091149", "0.5091149", "0.5091149", "0.5091149", "0.50896275", "0.50877774", "0.50744116", "0.50715685" ]
0.7353027
0
Is there already a note from target to source?
def bidirectionally_unique? if self.source_note.nil? return false end if self.target_note.nil? return false end return Edge.first(:conditions => {:source_id => self.target_note.id, :target_id => self.source_note.id}).nil? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def different_notes?\n if self.source_note.nil?\n return false\n end\n if self.target_note.nil?\n return false\n end\n return self.source_note != self.target_note\n end", "def orphan?\n !target_type || !notes.match?(/\\A\\d{14}/)\n end", "def notes_in_the_same_graph?\n if self.source_note.nil? \n return false\n end\n if self.target_note.nil? \n return false\n end\n return self.source_note.graph == self.target_note.graph\n end", "def note_for_main_target?(note)\n !@mixed_targets || @main_target_type == note.noteable_type\n end", "def is_source?\n @before.nil?\n end", "def target; true; end", "def journal?\n copies.any?(&:journal?)\n end", "def may_note?\n false\n end", "def is_target?\n not is_source? and @next.nil? and @chain.size > 1\n end", "def is_target? \n return false\n end", "def source_modified_or_dest_missing?(source_path, dest_path); end", "def mentioning?\n # Skip send notification if Doc not in publishing\n if instance_of?(Doc)\n publishing?\n else\n true\n end\n end", "def note?\n entry_type == :note\n end", "def has_changes?\r\n @source_files.size > 0\r\n end", "def isSourceStale?(sourcefile, targetext)\n\t\ttargetfile = toBuildDirFile(changeExt(sourcefile, targetext))\n\t\treturn (isStale?(targetfile, [sourcefile]))\n\tend", "def qualifiable?\n !source.nil?\n end", "def manually_added?\n if credit_note_items.size == 1\n return true if credit_note_items.first.source_type == 'User'\n end\n false\n end", "def has_target?(rop, target)\n rop.elements.each('compatibility/target') { |t|\n return true if t.text =~ /#{target}/i\n }\n return false\n end", "def source?\n false\n end", "def should_copy?(source, target)\n return true\n return true if !File.exists?(target)\n\n source_sha = Digest::SHA1.hexdigest(File.read(source))\n target_sha = Digest::SHA1.hexdigest(File.read(target))\n \n debugger if source_sha != target_sha\n \n return true if source_sha == target_sha\n \n return false\n end", "def is_known\n TargetsXML.has_target(@name)\n end", "def simple?\n !! ( origins && target || sequence? )\n end", "def is_ref? ; !!metadata[:ref] ; end", "def ___source_marker?(spec)\n end", "def check_exist_link_tp\n check('link source/target tp ref check') do |messages|\n all_links do |link, _nw|\n src_refs = link.source.refs\n dst_refs = link.destination.refs\n check_tp_ref(messages, 'source', src_refs, link)\n check_tp_ref(messages, 'destination', dst_refs, link)\n end\n end\n end", "def note?\n first_element_child.text =~ /\\A\\s*Note:\\s/\n end", "def source_modified_or_dest_missing?(source_path, dest_path)\n modified?(source_path) || (dest_path && !File.exist?(dest_path))\n end", "def one_target?\n return OneTarget.include?(target)\n end", "def amended?\n @doc.at_xpath('/a:akomaNtoso/a:act', a: NS)['contains'] != 'originalVersion'\n end", "def tracked?(path); end", "def tracked?(path); end", "def exist?()\n return File.exist?(@r_note_filepath)\n end", "def irrelevant_line?(source_line); end", "def external_target?\n return false if target_symbol == :inline\n target_file_path != callback_file_path\n end", "def has_no_source?\n sources.count == 0\n end", "def create_target?\n !(project.initialize_with_readme && target_branch == project.default_branch) && target_new_branch\n end", "def replied_to?\n !replied_at.nil?\n end", "def following? subject\n has_event? 'follow', subject\n end", "def mirror?\n source_type == 'url'\n end", "def oneway?\n [email protected]_key?([@dest, @src])\n end", "def has_notes?\n notes&.match(/\\S/)\n end", "def note?\n return true unless Settings.note.blank?\n return false\n end", "def copyfrom_known?\n ( self[:copyfrom_rev] >= 0 )\n end", "def perform_merge\n src_notes = @src.all_notes\n dest_notes = @dest.all_notes\n result = false\n\n # Mergeable if there are no fields which are non-blank in\n # both descriptions.\n if @src.class.all_note_fields.none? \\\n { |f| src_notes[f].present? && dest_notes[f].present? }\n result = true\n\n # Copy over all non-blank descriptive fields.\n src_notes.each do |f, val|\n @dest.send(\"#{f}=\", val) if val.present?\n end\n\n # Save changes to destination.\n @dest.save\n\n # Copy over authors and editors.\n @src.authors.each { |user| @dest.add_author(user) }\n @src.editors.each { |user| @dest.add_editor(user) }\n\n # Delete old description if requested.\n delete_src_description_and_update_parent if @delete_after\n end\n\n result\n end", "def added_by_user?(user)\n @sources.length == 1 && @sources[0].id == user.agent.id\n end", "def matching_source?(metadata)\n if metadata.has_key?('metadata_version') && metadata['metadata_version'] == '2.0'\n metadata['source_type'] == 'git' &&\n metadata['location'] == @location &&\n metadata['commitish_type'] == commitish_type.to_s &&\n (metadata['commitish_type'] == 'ref' ? true : metadata['commitish'] == commitish.to_s)\n else\n metadata['source_type'] == 'git' &&\n metadata['commitish_type'] == commitish_type.to_s &&\n (metadata['commitish_type'] == 'ref' ? true : metadata['commitish'] == commitish.to_s)\n end\n end", "def conforms_to_inline_attachment\n return true if @uti.start_with?(\"com.apple.notes.inlinetextattachment\")\n return false\n end", "def needs_updating?(change_set)\n # Always mint/update the ARK unless the resource already has an identifier\n return true unless change_set.resource.try(:identifier)\n # Only update under the following conditions:\n # - The resource has been published with a new identifier\n # - The source metadata identifier has changed\n published?(change_set) || published_with_new_title?(change_set) || change_set.changed?(:source_metadata_identifier)\n end", "def target_is_upstream_source\n return if source&.upstream == target\n\n errors.add :source, I18n.t('openwebslides.validations.pull_request.target_is_upstream_source')\n end", "def changelog_may_contain_anchor?( file_name )\n %w( .md .rdoc .textile ).include?( File.extname( file_name ) )\n end", "def attachment_reference_changed?\n !!@attachment_changed\n end", "def attachment_reference_changed?\n !!@attachment_changed\n end", "def author_worthy?\n notes?\n end", "def source_dest_check\n data[:source_dest_check]\n end", "def motivatedBy?(uri=nil)\n motivatedBy(uri).length > 0\n end", "def note_state\n state if note\n end", "def linked_to?(actor)\n Thread.current[:actor].links.include? actor\n end", "def abs_target?\n !note[TSBS::AbsoluteTarget].nil? && for_random?\n end", "def abs_target?\n !note[TSBS::AbsoluteTarget].nil? && for_random?\n end", "def has_source_info?\n self.any_present?(:source_title, :publisher, :start_page)\n end", "def include?(msg)\n @changes.include? msg\n end", "def target_name?( proposal )\n extensions[:Middlemac].options.Target == proposal.to_sym\n end", "def contains_journal_entry?\n note_contents.match(heading_pattern) != nil\n end", "def already_there(target, full_target)\n File.exists?(full_target) and (!CHECKSUMS.key?(target) or Digest::MD5.file(full_target).hexdigest == CHECKSUMS[target])\n end", "def rerun_needed?\n\t\t\[email protected](\"log\", true).rerun_needed?\n\t\tend", "def is_about\n downcased_noteable_type = self.noteable_type.downcase\n if downcased_noteable_type == \"comment\" \n if Comment.find(self.noteable_id).sentence == nil\n self.destroy\n \"Notification Removed\"\n elsif Comment.find(self.noteable_id).sentence.paragraph.story\n Comment.find(self.noteable_id).sentence.paragraph.story.title\n else\n \"Notification Removed\"\n end\n else\n Course.find(Enrollment.find(self.noteable_id).course_id).name\n end\n end", "def append_story_note(message,story_id=nil)\n if (story_id ||= :infer) == :infer\n story_id = extract_story_id_from(message)\n end\n return false unless story_id\n send_story_note!(\"[#{prepend_text}] #{message}\",story_id)\n true\n end", "def comment_line?(line_source); end", "def comment_line?(line_source); end", "def spec?(source,target)\n @cyc.genls?(target,source)\n end", "def show_notes\n info \"showing notes\"\n res = run(\"git notes --ref #{refname} show\")\n if res[:val] == 0\n info \"existing note: #{res[:out].strip}\"\n else\n info \"no existing note\"\n end\n end", "def pinned?(ctx)\n source.pinned?(ctx)\n end", "def backedge_target?(source)\n return false unless loopheader?\n # if the loopnest of the source is smaller than ours, it is certainly not in the same loop\n return false unless source.loopnest >= loopnest\n # if the source is in the same loop, our loops are a suffix of theirs\n # as loop nests form a tree, the suffices are equal if there first element is\n source_loop_index = source.loopnest - loopnest\n source.loops[source_loop_index] == self.loop\n end", "def published?\n self.targets.map { |tgt| File.exist?(File.join(\n self.publish_path, self.to_s, tgt)) }.all?\n end", "def reminded?\n !!reminded_at\n end", "def inferred_notes\n if scrubbed_notes?\n Rails.logger.debug \"not replacing scrubbed notes\"\n head_notes\n notes\n elsif head_notes.present?\n head_notes\n elsif notes.present? && ff?\n Rails.logger.debug \"not deleting old ff notes\"\n head_notes\n notes\n else\n head_notes\n end\n end", "def symlink_outside_site_source?(entry); end", "def has_description?\n description_history.length > 0\n end", "def note_given?\n params.has_key?(:note)\n end", "def different_target?(record)\n record.id != owner._read_attribute(reflection.foreign_key)\n end", "def genls?(source,target)\n @cyc.genls?(source,target)\n end", "def check_if_reply_and_not_already_read(tweet)\n\n puts tweet.text\n if tweet.text.match(/^@partyprinter.*/) && tweet.user.id != 1678701920 && Tweet.exists?(tweet.id.to_i) == nil\n puts \"new\"\n return true\n end\n\n end", "def appropriate\n notes.map(&:class).uniq.size >= @chord.notes.size\n end", "def to?( state )\n target_names.include?( state.to_sym )\n end", "def needs_followup?\n followup_note_count && followup_note_count > 0\n end", "def revealed? ; false ; end", "def should_generate_new_friendly_id?\n datetime_from_exif_changed? ||\n datetime_from_file_changed? ||\n datetime_from_manual_entry_year_changed? ||\n datetime_from_manual_entry_month_changed? ||\n datetime_from_manual_entry_day_changed? ||\n datetime_from_manual_entry_hour_changed? ||\n datetime_from_manual_entry_minute_changed? ||\n datetime_from_manual_entry_second_changed? ||\n source_attachment.changed? ||\n source_catalog_file_path_changed? ||\n source_type_changed? ||\n super\n end", "def peer_auditor_issue?\n self.auditor_result == 'Comment'\n end", "def changed?\n head.nil? or head.id != read_head_id\n end", "def source_noteworthy?\n source.present? && source != \"mo_website\"\n end", "def target_type\n scan_ses_notes if @target_type.nil?\n @target_type\n end", "def include? m\n self.destination == m[:destination]\n end", "def modified?\n ((self.created_at != self.updated_at) ||\n (segments.collect { |e| e.audio_asset.authored? && e.audio_asset.delivered? }.include?(true))) \n end", "def teleportable?\n !grabbed?\n end", "def stream?(ref)\n obj, stream = @xref.object(ref)\n stream ? true : false\n end", "def trackable?\n true\n end", "def issue_includes_changelog_note(issue)\n return false if issue.custom_values.length == 0\n issue_has_changelog_note(issue)\n end", "def changelog_has_been_modified\n\n modified = git.modified_files.include?(\"CHANGELOG.md\")\n return modified\n\nend", "def duplicate?\n\t\tother = Ng2::WordDetail.find(@word).last\n\t\t!other.nil? &&\n\t\tother.file_path == self.file_path &&\n\t\tother.line_no == self.line_no &&\n\t\tother.word_no == self.word_no\n\tend", "def can_be_replied_to?\n !locked?\n end" ]
[ "0.6855658", "0.6619958", "0.6479083", "0.642819", "0.6127064", "0.6036958", "0.6023684", "0.5915764", "0.5810275", "0.5795451", "0.57939565", "0.5782486", "0.5741669", "0.57402575", "0.5712923", "0.5705824", "0.56656635", "0.5661356", "0.5636952", "0.56108403", "0.5606577", "0.5598608", "0.55951023", "0.55884564", "0.55712014", "0.55589676", "0.55181646", "0.55172855", "0.5475432", "0.5473102", "0.5473102", "0.54580986", "0.54547393", "0.5433014", "0.5425924", "0.5420865", "0.54175913", "0.5378908", "0.5375737", "0.53670716", "0.53603244", "0.5348676", "0.53438854", "0.5333177", "0.53252345", "0.532414", "0.5318764", "0.53151447", "0.53116477", "0.5310732", "0.5303203", "0.5303203", "0.530264", "0.5302105", "0.52989495", "0.52828443", "0.5277493", "0.52755046", "0.52755046", "0.52747285", "0.5264782", "0.5263959", "0.52614015", "0.52555686", "0.5252768", "0.52453536", "0.5240756", "0.52390623", "0.52390623", "0.5232382", "0.5229167", "0.5226006", "0.52252126", "0.5223805", "0.52158034", "0.5208189", "0.52020895", "0.5197953", "0.51924884", "0.5189471", "0.51850426", "0.51632184", "0.5160864", "0.5155561", "0.5154988", "0.5146449", "0.51389384", "0.5137912", "0.51296157", "0.5127962", "0.5126852", "0.51222324", "0.5119396", "0.5119037", "0.5116579", "0.5103944", "0.5103274", "0.5102444", "0.5098837", "0.50984704" ]
0.6392804
4
Run on guide and returns report
def run report = "Seriously::#{params[:id].to_s.classify}Guide::Base".constantize.run(verbose: false) render json: report end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def report; end", "def report; end", "def report; end", "def report; end", "def report; end", "def report\n \n end", "def report\n\t\tend", "def execute\n puts @robot.report\n end", "def report(output)\n end", "def run\n @report = Report.new\n @report.plugin = self\n build_report\n rescue Exception => e\n @report.error e\n ensure\n return @report\n end", "def report\n require File.join File.expand_path(File.dirname(__FILE__)), \"report\"\n Brakeman::Report.new(self)\n end", "def report\n\t\t dir = \"./report/\"\n File.open(dir + \"method.mmd\", \"w\") do |f|\n f.puts \"# Methods #\"\n Dir[\"./experiments/*/*.rb\"].each do |desc|\n if File.basename(desc) == File.basename(File.dirname(desc)) + \".rb\"\n File.read(desc).split(\"\\n\").each do |line|\n if m = line.match(/^\\# (.+)/)\n f.puts m[1]\n else\n break\n end\n end\n f.puts\n f.puts\n end\n end\n end\n require 'csv'\n require \"yaml\"\n require File.dirname(__FILE__) + \"/stats\"\n CSV.open(dir + \"/data.csv\", \"w\") do |csv|\n data = {}\n Dir[\"./results/*/results.yaml\"].each do |res|\n d = YAML::load_file(res)\n da = {}\n d.each do |k, vals|\n da[k.to_s + \" mean\"], da[k.to_s + \" sd\"] = Stats::mean(vals), Stats::standard_deviation(vals)\n vals.each_with_index do |v, i|\n da[k.to_s + \" cv:\" + i.to_s] = v\n end\n end\n array_merge(data, da)\n end\n data.keys.map do |key| \n \t\t # calculate stats\n \t\t a = data[key]\n \t\t [key] + a\n \t\t end.transpose.each do |row|\n \t\t csv << row\n \t\t end\n end\n\t\t\n\t\tend", "def reporting\n # STUB\n end", "def write_report\n\n end", "def set_report\n end", "def output_report\n\t\toutput_start\n\t\toutput_head\n\t\toutput_body_start\n\t\toutput_body\n\t\toutput_body_end\n\t\toutput_end\n\tend", "def start\n setup_files\n create_report\nend", "def mreport\r\n\t\tsystem (\"clear\")\r\n\t\tputs \"#@name\" + \" the \" + \"#@type \" + \"approaches!!\"\r\n\t\tputs \" \"\r\n\t\tputs \"#@name\" + \" has \" + \"#@health \" + \"health\"\r\n\t\tputs \" \"\r\n\t\tsleep 1\r\n\t\treturn\r\n\tend", "def generate_report\n self.consume_stdin\n self.data_sorter\n\n @drivers.each do |driver|\n driver.total_duration\n driver.distance_calculator\n driver.average_speed\n end\n\n self.compile_report\n end", "def report_learner\n # I'm using the ! here so we can track down errors faster if there is an issue making\n # the report_learner\n super || create_report_learner!\n end", "def mreport\r\n\t\tsystem (\"clear\")\r\n\t\tputs \"#@name\" + \" the \" + \"#@type \" + \"approaches!!\"\r\n\t\tputs \" \"\r\n\t\tputs \"#@name\" + \" has \" + \"#@health \" + \"health\"\r\n\t\tputs \" \"\r\n\t\tsleep 2\r\n\tend", "def run\n\t\tmy_credentials = {\"user\" => \"test.api\", 'password' => '5DRX-AF-gc4', 'client_id' => 'Test', 'client_secret' => 'xIpXeyMID9WC55en6Nuv0HOO5GNncHjeYW0t5yI5wpPIqEHV'}\n\t\taccess_token = self.class.post('http://testcost.platform161.com/api/v2/access_tokens/', { query: my_credentials })['token']\n\t\theaders = {:headers => {'PFM161-API-AccessToken' => access_token}}\n\t\tadvertiser_reports = self.class.post('https://testcost.platform161.com/api/v2/advertiser_reports/', headers )\n\t\tcreate_local_report advertiser_reports['id']\n\t\tcampaign = self.class.get('https://testcost.platform161.com/api/v2/campaigns/' + campaign_id.to_s, headers )\n\t\tif advertiser_reports['results'] && advertiser_reports['results'].select { |campaign| campaign['campaign_id'] == campaign_id }.present?\n\t\t\tadvertiser_report = advertiser_reports['results'].select { |campaign| campaign['campaign_id'] == campaign_id }\n\t\t\tReportGeneratorCsvBuilder.new({advertiser_report: advertiser_report, campaign: campaign}).build\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend", "def generate_report()\n system(\"java -cp emma.jar emma report -r html -in coverage.em,coverage.ec\")\nend", "def output_report\n report = \"\"\n report << '<html>'\n report << ' <head>'\n report << \" <title>#{@title}</title>\"\n report << ' </head>'\n report << ' <body>'\n @text.each { |line| report << \" <p>#{line}</p>\" }\n report << ' </body>'\n report << '</html>'\n end", "def reporters; end", "def reporters; end", "def reporters; end", "def reporters; end", "def reporters; end", "def report_body; end", "def report_body; end", "def report\n if @coverage_level > 0 then\n extend RDoc::Text\n end\n\n if @coverage_level.zero? then\n calculate\n\n return great_job if @num_items == @doc_items\n end\n\n ucm = @store.unique_classes_and_modules\n\n report = RDoc::Markup::Document.new\n report << RDoc::Markup::Paragraph.new('The following items are not documented:')\n report << RDoc::Markup::BlankLine.new\n\n ucm.sort.each do |cm|\n body = report_class_module(cm) {\n [\n report_constants(cm),\n report_attributes(cm),\n report_methods(cm),\n ].compact\n }\n\n report << body if body\n end\n\n if @coverage_level > 0 then\n calculate\n\n return great_job if @num_items == @doc_items\n end\n\n report\n end", "def great_job\n report = RDoc::Markup::Document.new\n\n report << RDoc::Markup::Paragraph.new('100% documentation!')\n report << RDoc::Markup::Paragraph.new('Great Job!')\n\n report\n end", "def make_reports(opts)\n # Get the gcovr version number.\n gcovr_version_info = get_gcovr_version()\n\n # Build the common gcovr arguments.\n args_common = args_builder_common(opts)\n\n if ((gcovr_version_info[0] == 4) && (gcovr_version_info[1] >= 2)) || (gcovr_version_info[0] > 4)\n # gcovr version 4.2 and later supports generating multiple reports with a single call.\n args = args_common\n args += args_builder_cobertura(opts, false)\n args += args_builder_sonarqube(opts, false)\n args += args_builder_json(opts, true)\n # As of gcovr version 4.2, the --html argument must appear last.\n args += args_builder_html(opts, false)\n\n print \"Creating gcov results report(s) in '#{GCOV_ARTIFACTS_PATH}'... \"\n STDOUT.flush\n\n # Generate the report(s).\n run(args)\n else\n # gcovr version 4.1 and earlier supports HTML and Cobertura XML reports.\n # It does not support SonarQube and JSON reports.\n # Reports must also be generated separately.\n args_cobertura = args_builder_cobertura(opts, true)\n args_html = args_builder_html(opts, true)\n\n if args_html.length > 0\n print \"Creating a gcov HTML report in '#{GCOV_ARTIFACTS_PATH}'... \"\n STDOUT.flush\n\n # Generate the HTML report.\n run(args_common + args_html)\n end\n\n if args_cobertura.length > 0\n print \"Creating a gcov XML report in '#{GCOV_ARTIFACTS_PATH}'... \"\n STDOUT.flush\n\n # Generate the Cobertura XML report.\n run(args_common + args_cobertura)\n end\n end\n\n # Determine if the gcovr text report is enabled. Defaults to disabled.\n if is_report_enabled(opts, ReportTypes::TEXT)\n make_text_report(opts, args_common)\n end\n end", "def report\n # Iterate over each qotd record and check if it is present verbatim\n # in the corresponding content AT file.\n discrepancies = []\n @qotd_records.each { |qotd_record|\n date_code = qotd_record[:title].downcase\n puts \" - processing #{ date_code }\"\n sanitized_qotd_content = sanitize_qotd_content(qotd_record[:contents])\n corresponding_content_at_file = RFile::ContentAt.find_by_date_code(\n date_code,\n \"at\",\n @content_type\n )\n\n if corresponding_content_at_file.nil?\n raise ArgumentError.new(\"Could not find content AT file for #{ date_code }\")\n end\n\n sanitized_content_at_plain_text = sanitize_content_at_plain_text(\n corresponding_content_at_file.plain_text_with_subtitles_contents({})\n )\n\n find_diffs_between_qotd_and_content_at(\n date_code,\n qotd_record[:publishdate],\n sanitized_qotd_content,\n sanitized_content_at_plain_text,\n discrepancies\n )\n }\n assign_discrepancy_types(discrepancies)\n discrepancies\n end", "def interpret_report(command)\n ensure_placed\n @ui.write_text @robot.report\n end", "def report\n puts \"Hello! My name is #{@name}, I've delivered #{@experience} papers\n today and I've earned $#{@earnings} so far!\"\n end", "def report\n raise \"Calling Abstract method report on class Heuristic.\"\n end", "def perform(report)\n generate_excel_file(report)\n end", "def report_startup\n @time = Time.now\n #dir = File.basename(source) #File.basename(File.dirname(source))\n report \"Generating #{job} in #{File.basename(output)}:\\n\\n\"\n end", "def run\n build_report if self.class.needs.all? { |l| library_available?(l) }\n data_for_server\n end", "def report_load\n self.report('load_report')\n end", "def report\n @output.puts \"#{posx},#{posy},#{dir.to_s.upcase}\"\n activate\n end", "def generate_scan_report\n freshclam_stderr = IO.read($config[\"freshclam_stderr\"])\n freshclam_stdout = @freshclam_stdout\n template = IO.read(\"views/clamav.html.erb\")\n output = ERB.new(template).result(binding)\n File.open(\"clamav.html\", \"w\") {|file| file.write(output)}\nend", "def report\n return @report\n end", "def report_run(command)\n result = nil\n @run_report = Report.new(name: nil, target: command)\n begin\n result = yield @run_report\n ensure\n @run_report = nil\n end\n\n result\n end", "def report\n @logger\n end", "def report\n report_metrics\n report_resources\n if run_status.failed?\n report_backtrace\n end\n end", "def create_report_for(command)\n checker.create_report_for(command, self.title, self.variant)\n end", "def report(context, repo, dir)\n raise \"No report(context, repo, dir) function defined by report subclass\"\n end", "def create_new_report!; end", "def create_new_report!; end", "def emp_report\n \n end", "def create_report\n dir = Dir.pwd\n file_name = \"#{@name}.log\"\n reports_dir = dir + \"/spec/reports\"\n if File.directory? reports_dir\n @spec_report_file = File.open(reports_dir + \"/\" + file_name, 'w')\n @spec_report_file.puts \"WatirmarkLog: \" + @name\n else\n #spec/Reports directory does not exits\n @spec_report_file = nil\n end\n end", "def report\n @scan = find_scan( params.require( :id ) )\n\n format = URI( request.url ).path.split( '.' ).last\n render layout: false,\n content_type: FrameworkHelper.content_type_for_report( format ),\n text: FrameworkHelper.framework { |f| f.report_as format, @scan.report.object }\n end", "def report\n sprintf \"Number of paragraphs %d \\n\" <<\n \"Number of sentences %d \\n\" <<\n \"Number of words %d \\n\" <<\n \"Number of characters %d \\n\\n\" <<\n \"Average words per sentence %.2f \\n\" <<\n \"Average syllables per word %.2f \\n\\n\" <<\n \"Flesch score %2.2f \\n\" <<\n \"Flesh-Kincaid grade level %2.2f \\n\" <<\n \"Fog Index %2.2f \\n\",\n num_paragraphs, num_sentences, num_words, num_characters,\n words_per_sentence, syllables_per_word,\n flesch, kincaid, fog\n end", "def report\n @scan = find_scan( params.require( :id ) )\n\n format = URI( request.url ).path.split( '.' ).last\n render layout: false,\n text: FrameworkHelper.\n framework { |f| f.report_as format, @scan.report.object }\n end", "def produce_report(*args)\n # Check xcov availability, install it if needed\n `gem install xcov` unless xcov_available?\n unless xcov_available?\n puts \"xcov is not available on this machine\"\n return\n end\n\n require \"xcov\"\n require \"fastlane_core\"\n\n # Init Xcov\n config = FastlaneCore::Configuration.create(Xcov::Options.available_options, convert_options(args.first))\n Xcov.config = config\n Xcov.ignore_handler = Xcov::IgnoreHandler.new\n\n # Init project\n report_json = nil\n manager = Xcov::Manager.new(config)\n\n if Xcov.config[:html_report] || Xcov.config[:markdown_report] || Xcov.config[:json_report]\n # Parse .xccoverage and create local report\n report_json = manager.run\n else\n # Parse .xccoverage\n report_json = manager.parse_xccoverage\n end\n\n # Map and process report\n process_report(Xcov::Report.map(report_json))\n end", "def begin_report_command(command, report)\n @report = report\n end", "def reports(wspace=workspace)\n\t\twspace.reports\n\tend", "def begin_report_app(app, report)\n shell.info \"Checking cached dependency records for #{app[\"name\"]}\"\n end", "def report\n ktlint_report_file_complete = \"#{Dir.pwd}/#{ktlint_report_file}\"\n detekt_report_file_complete= \"#{Dir.pwd}/#{detekt_report_file}\"\n\n check_file_integrity(ktlint_report_file_complete)\n check_file_integrity(detekt_report_file_complete)\n\n ktlint_issues = read_issues_from_report(ktlint_report_file)\n detekt_issues = read_issues_from_report(detekt_report_file)\n\n report_issues(ktlint_issues)\n report_issues(detekt_issues)\n end", "def end_report_app(app, report)\n all_reports = report.all_reports\n\n warning_reports = all_reports.select { |r| r.warnings.any? }.to_a\n if warning_reports.any?\n shell.newline\n shell.warn \"Warnings:\"\n warning_reports.each do |r|\n display_metadata = r.map { |k, v| \"#{k}: #{v}\" }.join(\", \")\n\n shell.warn \"* #{r.name}\"\n shell.warn \" #{display_metadata}\" unless display_metadata.empty?\n r.warnings.each do |warning|\n shell.warn \" - #{warning}\"\n end\n shell.newline\n end\n end\n\n errored_reports = all_reports.select { |r| r.errors.any? }.to_a\n\n dependency_count = all_reports.count { |r| r.target.is_a?(Licensed::Dependency) }\n error_count = errored_reports.reduce(0) { |count, r| count + r.errors.size }\n\n if error_count > 0\n shell.newline\n shell.error \"Errors:\"\n errored_reports.each do |r|\n display_metadata = r.map { |k, v| \"#{k}: #{v}\" }.join(\", \")\n\n shell.error \"* #{r.name}\"\n shell.error \" #{display_metadata}\" unless display_metadata.empty?\n r.errors.each do |error|\n shell.error \" - #{error}\"\n end\n shell.newline\n end\n end\n\n shell.newline\n shell.info \"#{dependency_count} dependencies checked, #{error_count} errors found.\"\n end", "def send_report(report)\n headers = {\n \"Content-Type\" => \"application/json\",\n \"x-data-collector-auth\" => \"version=1.0\",\n \"x-data-collector-token\" => @token,\n }\n\n all_report_shas = report[:profiles].map { |p| p[:sha256] }\n missing_report_shas = missing_automate_profiles(headers, all_report_shas)\n\n full_report = truncate_controls_results(enriched_report(report), @control_results_limit)\n full_report = strip_profiles_meta(full_report, missing_report_shas, @run_time_limit)\n json_report = Chef::JSONCompat.to_json(full_report, validate_utf8: false)\n\n # Automate GRPC currently has a message limit of ~4MB\n # https://github.com/chef/automate/issues/1417#issuecomment-541908157\n if json_report.bytesize > 4 * 1024 * 1024\n Chef::Log.warn \"Generated report size is #{(json_report.bytesize / (1024 * 1024.0)).round(2)} MB. #{ChefUtils::Dist::Automate::PRODUCT} has an internal 4MB limit that is not currently configurable.\"\n end\n\n unless json_report\n Chef::Log.warn \"Something went wrong, report can't be nil\"\n return false\n end\n\n begin\n Chef::Log.info \"Report to #{ChefUtils::Dist::Automate::PRODUCT}: #{@url}\"\n Chef::Log.debug \"Compliance Phase report: #{json_report}\"\n http_client.post(nil, json_report, headers)\n true\n rescue => e\n Chef::Log.error \"send_report: POST to #{@url} returned: #{e.message}\"\n false\n end\n end", "def run\n Salesforce.set_http(session[:accesstoken], session[:accessurl])\n \t@response = Salesforce.run_report(params)\n @describe = Salesforce.describe_report(params)\n \trespond_to do |format|\n format.json { render :json => {:data => @response, :meta => @describe}.to_json}\n \tend\n end", "def build_report\n puts \"building performance test comparison report...\"\n puts\n\n # load template\n report = File.read(@template_path)\n\n # metrics result\n result_comparison_table = extract_table_from_csv2html_output(@result_comparison_path)\n\n # atop summary\n atop_summary_comparison_table = extract_table_from_csv2html_output(@atop_summary_comparison_path)\n\n # atop detail\n # TODO: enable\n # atop_detail_comparison_table = extract_table(@atop_detail_comparison_path)\n\n # replace tables (do this first since table data may include parameters)\n report = report.gsub(\"$RESULT_COMPARISON_TABLE\", result_comparison_table)\n report = report.gsub(\"$ATOP_SUMMARY_COMPARISON_TABLE\", atop_summary_comparison_table)\n\n # TODO: enable\n # report = report.gsub(\"$ATOP_DETAIL_TABLE\", atop_detail_table)\n\n # replace parameters\n report = replace_parameters(report)\n\n # write report\n puts \"writing report to #{@output_path}\"\n\n File.write(@output_path, report)\nend", "def complaintsreport\n\t\t@complaints = Complaint.find(:all)\t\t\n html = render :layout => false \n\tkit = PDFKit.new(html)\n\n\tkit.stylesheets << RAILS_ROOT + '/public/stylesheets/styles.css' \n\n\tsend_data(kit.to_pdf, :filename => \"complaintsreport.pdf\", :type => 'application/pdf')\n\tend", "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 run(runner, user_arguments)\n super(runner, user_arguments)\n \n #make the runner a class variable\n @runner = runner\n \n #use the built-in error checking \n if not runner.validateUserArguments(arguments(), user_arguments)\n return false\n end\n\n runner.registerInitialCondition(\"Starting QAQC report generation\")\n\n # get the last model and sql file \n @model = runner.lastOpenStudioModel\n if @model.is_initialized\n @model = @model.get\n else\n runner.registerError(\"Cannot find last model.\")\n return false\n end\n \n @sql = runner.lastEnergyPlusSqlFile\n if @sql.is_initialized\n @sql = @sql.get\n else\n runner.registerError(\"Cannot find last sql file.\")\n return false\n end\n \n resource_path = \"#{File.dirname(__FILE__)}/resources/\"\n if not File.exists?(\"#{resource_path}/CreateResults.rb\")\n # support pre 1.2.0 OpenStudio\n resource_path = \"#{File.dirname(__FILE__)}/\"\n end\n\n\n \n #require the files that create results and qaqc checks\n # use different code for 2.0 and higher\n if @model.version < OpenStudio::VersionString.new('1.11')\n runner.registerInfo(\"Using the pre-2.0 code\")\n require \"#{resource_path}/CreateResults.rb\"\n require \"#{resource_path}/EndUseBreakdown\"\n require \"#{resource_path}/EUI\"\n require \"#{resource_path}/FuelSwap\"\n require \"#{resource_path}/PeakHeatCoolMonth\"\n require \"#{resource_path}/UnmetHrs\"\n\n #vector to store the results and checks\n report_elems = OpenStudio::AttributeVector.new\n report_elems << create_results\n \n #create an attribute vector to hold the checks\n check_elems = OpenStudio::AttributeVector.new\n\n #unmet hours check\n check_elems << unmet_hrs_check\n \n #energy use for cooling and heating as percentage of total energy check\n check_elems << enduse_pcts_check\n\n #peak heating and cooling months check\n check_elems << peak_heat_cool_mo_check\n\n #EUI check\n check_elems << eui_check\n \n #end checks\n report_elems << OpenStudio::Attribute.new(\"checks\", check_elems)\n \n #create an extra layer of report. the first level gets thrown away.\n top_level_elems = OpenStudio::AttributeVector.new\n top_level_elems << OpenStudio::Attribute.new(\"report\", report_elems) \n \n #create the report\n result = OpenStudio::Attribute.new(\"summary_report\", top_level_elems)\n result.saveToXml(OpenStudio::Path.new(\"report.xml\"))\n\n else\n runner.registerInfo(\"Using the post-2.0 code\")\n require \"#{resource_path}/CreateResults_2.rb\"\n require \"#{resource_path}/EndUseBreakdown_2\"\n require \"#{resource_path}/EUI_2\"\n require \"#{resource_path}/FuelSwap_2\"\n require \"#{resource_path}/PeakHeatCoolMonth_2\"\n require \"#{resource_path}/UnmetHrs_2\" \n \n # store the results\n create_results\n \n # QAQC checks\n runner.registerValue(\"test_reg_value\", 9989, \"ft^2\")\n \n \n end\n \n #closing the sql file\n @sql.close()\n\n #reporting final condition\n runner.registerFinalCondition(\"Finished generating report.xml.\")\n \n return true\n \n end", "def run_report(options = {})\n options = argument_cleaner(required_params: %i( reportid entityid ), optional_params: %i( format content_disposition nodata AsOf), options: options )\n authenticated_get cmd: \"runreport\", **options\n end", "def report_run(command)\n super do |report|\n @report = report\n yield report\n end\n end", "def create_report\n print_sales_report_ASCII\n print_date\n print_products_ASCII\n print_brands_ASCII\n end", "def generate_report(school_year=$config.school_year, reprint = false)\r\n reprints = reprint ? \"/WITH_INTACT_TAGS\" : \"\"\r\n puts \"ENTERED 'generate_report'\"\r\n session_school_year=(school_year)\r\n puts \"1\"\r\n student_first_name = first_name.value\r\n puts \"2\"\r\n student_last_name = self.last_name.value\r\n puts \"3\"\r\n file_path = $config.init_path(\"#{$paths.reports_path}Progress_Reports/School_Year_#{session_school_year}/#{term}_K6_Students#{reprints}\")\r\n puts \"4\"\r\n word_doc_path = \"#{file_path}STUDENT_#{student_id}.docx\"\r\n puts \"5\"\r\n pdf_doc_path = \"#{file_path}#{term}_#{student_last_name}_#{student_first_name}_#{student_id}.pdf\"\r\n puts \"6\"\r\n if File.exists?(pdf_doc_path)\r\n puts \"REPORT PREVIOUSLY GENERATED\"\r\n record = progress_record\r\n record.fields[\"reported_datetime\"].value = $idatetime\r\n record.save\r\n return pdf_doc_path\r\n else\r\n puts \"#{student.student_id} #{DateTime.now.strftime(\"%H:%M\")}\"\r\n teacher = self.teacher.value\r\n #each of these need to be set up to handle different school years\r\n puts \"GETTING PROGRESS DETAILS\"\r\n replace = Hash.new\r\n replace[\"[grade_level]\" ] = grade_level.value \r\n replace[\"[school_year]\" ] = session_school_year\r\n replace[\"[first_name]\" ] = student_first_name\r\n replace[\"[last_name]\" ] = student_last_name\r\n replace[\"[student_id]\" ] = student.student_id\r\n replace[\"[today]\" ] = $iuser\r\n replace[\"[school_enroll_date]\" ] = student.school_enroll_date.value\r\n replace[\"[teacher]\" ] = teacher\r\n replace[\"[a_p_1]\" ] = days_present(\"Q1\" ) || \"\"\r\n replace[\"[a_p_2]\" ] = days_present(\"Q2\" ) || \"\"\r\n replace[\"[a_p_3]\" ] = days_present(\"Q3\" ) || \"\"\r\n replace[\"[a_p_4]\" ] = days_present(\"Q4\" ) || \"\"\r\n replace[\"[a_e_1]\" ] = absences_excused(\"Q1\" ) || \"\"\r\n replace[\"[a_e_2]\" ] = absences_excused(\"Q2\" ) || \"\"\r\n replace[\"[a_e_3]\" ] = absences_excused(\"Q3\" ) || \"\"\r\n replace[\"[a_e_4]\" ] = absences_excused(\"Q4\" ) || \"\"\r\n replace[\"[a_u_1]\" ] = absences_unexcused(\"Q1\" ) || \"\"\r\n replace[\"[a_u_2]\" ] = absences_unexcused(\"Q2\" ) || \"\"\r\n replace[\"[a_u_3]\" ] = absences_unexcused(\"Q3\" ) || \"\"\r\n replace[\"[a_u_4]\" ] = absences_unexcused(\"Q4\" ) || \"\"\r\n replace[\"[math_goals_1]\" ] = math_goals(\"Q1\" ) || \"\"\r\n replace[\"[math_goals_2]\" ] = math_goals(\"Q2\" ) || \"\"\r\n replace[\"[math_goals_3]\" ] = math_goals(\"Q3\" ) || \"\"\r\n replace[\"[math_goals_4]\" ] = math_goals(\"Q4\" ) || \"\"\r\n replace[\"[reading_goals_1]\" ] = reading_goals(\"Q1\" ) || \"\"\r\n replace[\"[reading_goals_2]\" ] = reading_goals(\"Q2\" ) || \"\"\r\n replace[\"[reading_goals_3]\" ] = reading_goals(\"Q3\" ) || \"\"\r\n replace[\"[adequate_1]\" ] = adequate_progress(\"Q1\" ) || \"\"\r\n replace[\"[adequate_2]\" ] = adequate_progress(\"Q2\" ) || \"\"\r\n replace[\"[adequate_3]\" ] = adequate_progress(\"Q3\" ) || \"\"\r\n replace[\"[adequate_4]\" ] = adequate_progress(\"Q4\" ) || \"\"\r\n replace[\"[assessment_1]\" ] = assessment_completion(\"Q1\" ) || \"\"\r\n replace[\"[assessment_2]\" ] = assessment_completion(\"Q2\" ) || \"\"\r\n replace[\"[assessment_3]\" ] = assessment_completion(\"Q3\" ) || \"\"\r\n replace[\"[assessment_4]\" ] = assessment_completion(\"Q4\" ) || \"\"\r\n replace[\"[submission_1]\" ] = work_submission(\"Q1\" ) || \"\"\r\n replace[\"[submission_2]\" ] = work_submission(\"Q2\" ) || \"\"\r\n replace[\"[submission_3]\" ] = work_submission(\"Q3\" ) || \"\"\r\n replace[\"[submission_4]\" ] = work_submission(\"Q4\" ) || \"\"\r\n replace[\"[comments]\" ] = comments || \"\"\r\n \r\n puts \"GETTING COURSE PROGRESS\"\r\n #progress###############################################################\r\n p_h = Hash.new\r\n terms = [\"Q1\",\"Q2\",\"Q3\",\"Q4\"]\r\n i_terms = 0\r\n terms.each{|term|\r\n progress = progress(term)\r\n if progress\r\n progress.each{|p|\r\n #if term_active?(term) && !p.fields[\"course_subject_school\"].value.nil?\r\n subject = p.fields[\"course_subject_school\" ].value\r\n p_h[subject] = {\"Q1\"=>nil,\"Q2\"=>nil,\"Q3\"=>nil,\"Q4\"=>nil} if !p_h.has_key?(subject)\r\n p_h[subject][term] = p.fields[\"progress\"].to_user\r\n #end\r\n }\r\n end\r\n i_terms+=1\r\n }\r\n i=1\r\n p_h.each_pair{|subject,progress|\r\n replace[\"[p#{i}]\"] = subject\r\n terms.each{|term|\r\n replace[\"[p#{i}_#{term}]\"] = progress[term]\r\n }\r\n i+=1\r\n }\r\n i = 1\r\n while i <= 10\r\n replace[\"[p#{i}]\"] = \" \" if !replace.has_key?(\"[p#{i}]\")\r\n terms.each{|term|\r\n replace[\"[p#{i}_#{term}]\"] = \" \" if !replace.has_key?(\"[p#{i}_#{term}]\")\r\n }\r\n i+=1\r\n end\r\n ########################################################################\r\n \r\n #masteries##############################################################\r\n m_hash = {\r\n \"Reading\" => \"rm\",\r\n \"Mathematics\" => \"mm\",\r\n \"Writing\" => \"wm\",\r\n \"History\" => \"hm\",\r\n \"Science\" => \"sm\",\r\n \"Physical Education\" => \"pm\" \r\n }\r\n # mastery_records = masteries_snapshot\r\n ########################################################################\r\n \r\n #reading masteries######################################################\r\n rm_h = Hash.new\r\n terms = [\"Q2\",\"Q4\"]\r\n i_terms = 0\r\n placeholder_term = term\r\n terms.each{|this_term|\r\n term = this_term\r\n results = masteries\r\n if results\r\n results.each{|r|\r\n if term_open? #&& !r.fields[\"mastery_level\"].value.nil?\r\n mastery_id = r.fields[\"mastery_id\" ].value\r\n mastery_section = $tables.attach(\"K6_Mastery_Sections\").by_primary_id(mastery_id)\r\n content_area = mastery_section.fields[\"content_area\"].value\r\n if content_area == \"Reading\"\r\n desc = mastery_section.fields[\"description\" ].value\r\n rm_h[desc] = {\"Q2\"=>nil,\"Q4\"=>nil} if !rm_h.has_key?(desc)\r\n rm_h[desc][term] = r.fields[\"mastery_level\"].value\r\n end\r\n end\r\n }\r\n end\r\n i_terms+=1\r\n }\r\n \r\n i=1\r\n rm_h.each_pair{|k,v|\r\n replace[\"[rm#{i}_d]\"] = k\r\n terms.each{|term|\r\n replace[\"[rm#{i}_#{term}]\"] = v[term]\r\n }\r\n i+=1\r\n }\r\n i = 1\r\n while i <= 15\r\n replace[\"[rm#{i}_d]\"] = \" \" if !replace.has_key?(\"[rm#{i}_d]\")\r\n terms.each{|term|\r\n replace[\"[rm#{i}_#{term}]\"] = \" \" if !replace.has_key?(\"[rm#{i}_#{term}]\")\r\n }\r\n i+=1\r\n end\r\n ########################################################################\r\n \r\n #mathematics masteries######################################################\r\n mm_h = Hash.new\r\n i_terms = 0\r\n placeholder_term = term\r\n terms.each{|this_term|\r\n term = this_term\r\n results = masteries\r\n if results\r\n results.each{|r|\r\n if term_open? #&& !r.fields[\"mastery_level\"].value.nil?\r\n mastery_id = r.fields[\"mastery_id\" ].value\r\n mastery_section = $tables.attach(\"K6_Mastery_Sections\").by_primary_id(mastery_id)\r\n content_area = mastery_section.fields[\"content_area\"].value\r\n if content_area == \"Mathematics\"\r\n desc = mastery_section.fields[\"description\" ].value\r\n mm_h[desc] = {\"Q2\"=>nil,\"Q4\"=>nil} if !mm_h.has_key?(desc)\r\n mm_h[desc][term] = r.fields[\"mastery_level\"].value\r\n end\r\n end\r\n }\r\n end\r\n i_terms+=1\r\n }\r\n i=1\r\n mm_h.each_pair{|k,v|\r\n replace[\"[mm#{i}_d]\"] = k\r\n terms.each{|term|\r\n replace[\"[mm#{i}_#{term}]\"] = v[term]\r\n }\r\n i+=1\r\n }\r\n i = 1\r\n while i <= 20\r\n replace[\"[mm#{i}_d]\"] = \" \" if !replace.has_key?(\"[mm#{i}_d]\")\r\n terms.each{|term|\r\n replace[\"[mm#{i}_#{term}]\"] = \" \" if !replace.has_key?(\"[mm#{i}_#{term}]\")\r\n }\r\n i+=1\r\n end\r\n ########################################################################\r\n \r\n #writing masteries######################################################\r\n wm_h = Hash.new\r\n terms = [\"Q2\",\"Q4\"]\r\n i_terms = 0\r\n placeholder_term = term\r\n terms.each{|this_term|\r\n term = this_term\r\n results = masteries\r\n if results\r\n results.each{|r|\r\n if term_open? #&& !r.fields[\"mastery_level\"].value.nil?\r\n mastery_id = r.fields[\"mastery_id\" ].value\r\n mastery_section = $tables.attach(\"K6_Mastery_Sections\").by_primary_id(mastery_id)\r\n content_area = mastery_section.fields[\"content_area\"].value\r\n if content_area == \"Writing\"\r\n desc = mastery_section.fields[\"description\" ].value\r\n wm_h[desc] = {\"Q2\"=>nil,\"Q4\"=>nil} if !wm_h.has_key?(desc)\r\n wm_h[desc][term] = r.fields[\"mastery_level\"].value\r\n end\r\n end\r\n }\r\n end\r\n i_terms+=1\r\n }\r\n i=1\r\n wm_h.each_pair{|k,v|\r\n replace[\"[wm#{i}_d]\"] = k\r\n terms.each{|term|\r\n replace[\"[wm#{i}_#{term}]\"] = v[term]\r\n }\r\n i+=1\r\n }\r\n i = 1\r\n while i <= 8\r\n replace[\"[wm#{i}_d]\"] = \" \" if !replace.has_key?(\"[wm#{i}_d]\")\r\n terms.each{|term|\r\n replace[\"[wm#{i}_#{term}]\"] = \" \" if !replace.has_key?(\"[wm#{i}_#{term}]\")\r\n }\r\n i+=1\r\n end\r\n ########################################################################\r\n \r\n #history masteries######################################################\r\n hm_h = Hash.new\r\n terms = [\"Q2\",\"Q4\"]\r\n i_terms = 0\r\n placeholder_term = term\r\n terms.each{|this_term|\r\n term = this_term\r\n results = masteries\r\n if results\r\n results.each{|r|\r\n if term_open? #&& !r.fields[\"mastery_level\"].value.nil?\r\n mastery_id = r.fields[\"mastery_id\" ].value\r\n mastery_section = $tables.attach(\"K6_Mastery_Sections\").by_primary_id(mastery_id)\r\n content_area = mastery_section.fields[\"content_area\"].value\r\n if content_area == \"History\"\r\n desc = mastery_section.fields[\"description\" ].value\r\n hm_h[desc] = {\"Q2\"=>nil,\"Q4\"=>nil} if !hm_h.has_key?(desc)\r\n hm_h[desc][term] = r.fields[\"mastery_level\"].value\r\n end\r\n end\r\n }\r\n end\r\n i_terms+=1\r\n }\r\n i=1\r\n hm_h.each_pair{|k,v|\r\n replace[\"[hm#{i}_d]\"] = k\r\n terms.each{|term|\r\n replace[\"[hm#{i}_#{term}]\"] = v[term]\r\n }\r\n i+=1\r\n }\r\n i = 1\r\n while i <= 5\r\n replace[\"[hm#{i}_d]\"] = \" \" if !replace.has_key?(\"[hm#{i}_d]\")\r\n terms.each{|term|\r\n replace[\"[hm#{i}_#{term}]\"] = \" \" if !replace.has_key?(\"[hm#{i}_#{term}]\")\r\n }\r\n i+=1\r\n end\r\n ########################################################################\r\n \r\n #science masteries######################################################\r\n sm_h = Hash.new\r\n terms = [\"Q2\",\"Q4\"]\r\n i_terms = 0\r\n placeholder_term = term\r\n terms.each{|this_term|\r\n term = this_term\r\n results = masteries\r\n if results\r\n results.each{|r|\r\n if term_open? #&& !r.fields[\"mastery_level\"].value.nil?\r\n mastery_id = r.fields[\"mastery_id\" ].value\r\n mastery_section = $tables.attach(\"K6_Mastery_Sections\").by_primary_id(mastery_id)\r\n content_area = mastery_section.fields[\"content_area\"].value\r\n if content_area == \"History\"\r\n desc = mastery_section.fields[\"description\" ].value\r\n sm_h[desc] = {\"Q2\"=>nil,\"Q4\"=>nil} if !sm_h.has_key?(desc)\r\n sm_h[desc][term] = r.fields[\"mastery_level\"].value\r\n end\r\n end\r\n }\r\n end\r\n i_terms+=1\r\n }\r\n i=1\r\n sm_h.each_pair{|k,v|\r\n replace[\"[sm#{i}_d]\"] = k\r\n terms.each{|term|\r\n replace[\"[sm#{i}_#{term}]\"] = v[term]\r\n }\r\n i+=1\r\n }\r\n i = 1\r\n while i <= 1\r\n replace[\"[sm#{i}_d]\"] = \" \" if !replace.has_key?(\"[sm#{i}_d]\")\r\n terms.each{|term|\r\n replace[\"[sm#{i}_#{term}]\"] = \" \" if !replace.has_key?(\"[sm#{i}_#{term}]\")\r\n }\r\n i+=1\r\n end\r\n ########################################################################\r\n \r\n #PE masteries######################################################\r\n pm_h = Hash.new\r\n terms = [\"Q2\",\"Q4\"]\r\n i_terms = 0\r\n placeholder_term = term\r\n terms.each{|this_term|\r\n term = this_term\r\n results = masteries\r\n if results\r\n results.each{|r|\r\n if term_open? #&& !r.fields[\"mastery_level\"].value.nil?\r\n mastery_id = r.fields[\"mastery_id\" ].value\r\n mastery_section = $tables.attach(\"K6_Mastery_Sections\").by_primary_id(mastery_id)\r\n content_area = mastery_section.fields[\"content_area\"].value\r\n if content_area == \"Physical Education\"\r\n desc = mastery_section.fields[\"description\" ].value\r\n pm_h[desc] = {\"Q2\"=>nil,\"Q4\"=>nil} if !pm_h.has_key?(desc)\r\n pm_h[desc][term] = r.fields[\"mastery_level\"].value\r\n end\r\n end\r\n }\r\n end\r\n i_terms+=1\r\n }\r\n i=1\r\n pm_h.each_pair{|k,v|\r\n replace[\"[pm#{i}_d]\"] = k\r\n terms.each{|term|\r\n replace[\"[pm#{i}_#{term}]\"] = v[term]\r\n }\r\n i+=1\r\n }\r\n i = 1\r\n while i <= 1\r\n replace[\"[pm#{i}_d]\"] = \" \" if !replace.has_key?(\"[pm#{i}_d]\")\r\n terms.each{|term|\r\n replace[\"[pm#{i}_#{term}]\"] = \" \" if !replace.has_key?(\"[pm#{i}_#{term}]\")\r\n }\r\n i+=1\r\n end\r\n ##########################################################################\r\n grade_ = Integer(student.grade.value.split(\" \")[0].split(\"th\")[0].split(\"rd\")[0].split(\"nd\")[0])\r\n \r\n eoy = end_of_year_placement.value\r\n if eoy == \"Promoted\"\r\n replace[\"[end_of_year_placement]\"] = \"#{student.first_name.value} will be promoted to grade #{grade_ + 1} for the 2012-2013 school year.\"\r\n elsif eoy == \"Retained\"\r\n replace[\"[end_of_year_placement]\"] = \"#{student.first_name.value} will be retained in grade #{grade_} for the 2012-2013 school year.\"\r\n elsif eoy == \"Placed\"\r\n replace[\"[end_of_year_placement]\"] = \"#{student.first_name.value} will be placed in #{grade_ + 1} grade for the 2012-2013 school year.\"\r\n elsif eoy == \"Promoted Pending Summer School\"\r\n replace[\"[end_of_year_placement]\"] = \"If student attends Summer School at Agora and masters grade level standanrds, he/she will be promoted to the #{grade_ + 1} grade for the 2012-2013 school year.\"\r\n end\r\n \r\n term = placeholder_term\r\n puts \"CREATING DOCUMENT\"\r\n failed = 0\r\n document_created = false\r\n until document_created || failed == 3\r\n begin\r\n puts \"CONNECTING TO WORD\"\r\n word = $base.word\r\n puts \"OPENING WORD TEMPLATE\"\r\n doc = word.Documents.Open(\"#{$paths.templates_path}student_progress_report_k6__with_masteries.docx\")\r\n puts \"BEGINNING FIND AND REPLACE\"\r\n replace.each_pair{|f,r|\r\n #footer\r\n word.ActiveWindow.View.Type = 3\r\n word.ActiveWindow.ActivePane.View.SeekView = 10\r\n word.Selection.HomeKey(unit=6)\r\n find = word.Selection.Find\r\n find.Text = f\r\n while word.Selection.Find.Execute\r\n if r.nil? || r == \"\"\r\n rvalue = \" \"\r\n elsif r.class == Field\r\n rvalue = r.to_user.nil? || r.to_user.to_s.empty? ? \" \" : r.to_user.to_s\r\n else\r\n rvalue = r.to_s\r\n end\r\n word.Selection.TypeText(text=rvalue.gsub(\"’\",\"'\"))\r\n end\r\n \r\n #main body\r\n word.ActiveWindow.ActivePane.View.SeekView = 0\r\n word.Selection.HomeKey(unit=6)\r\n find = word.Selection.Find\r\n find.Text = f\r\n while word.Selection.Find.Execute\r\n if r.nil? || r == \"\"\r\n rvalue = \" \"\r\n elsif r.class == Field\r\n rvalue = r.to_user.nil? || r.to_user.to_s.empty? ? \" \" : r.to_user.to_s\r\n else\r\n rvalue = r.to_s\r\n end\r\n word.Selection.TypeText(text=rvalue.gsub(\"’\",\"'\"))\r\n end\r\n }\r\n puts \"SAVING WORD DOC\"\r\n doc.SaveAs(word_doc_path.gsub(\"/\",\"\\\\\"))\r\n puts \"CONVERTING TO PDF\"\r\n doc.SaveAs(pdf_doc_path.gsub(\"/\",\"\\\\\"),17)\r\n doc.close\r\n document_created = true\r\n word.quit\r\n puts \"REMOVING WORD DOC\"\r\n FileUtils.rm(word_doc_path) if File.exists?(word_doc_path)\r\n puts \"WORD DOC REMOVED\"\r\n \r\n record = progress_record\r\n record.fields[\"reported_datetime\"].value = $idatetime\r\n record.save\r\n rescue => e\r\n puts e\r\n failed+=1\r\n puts \"Failed Attempt #{failed}.\"\r\n $base.system_notification(\r\n subject = \"K6 Progress Report Failed - SID: #{student_id}\",\r\n content = \"#{__FILE__} #{__LINE__}\",\r\n caller[0],\r\n e\r\n ) if failed == 3\r\n end\r\n end\r\n \r\n \r\n #MARK AS REPORTED - FNORD\r\n \r\n puts \"RETURNING PDF PATH\"\r\n return pdf_doc_path\r\n end\r\n end", "def report\n # generate_report()\n ReportWorker.perform_async(\"07-01-2018\", \"08-01-2018\")\n render \\\n json: {status: 'SUCCESS', message:'REQUEST TO GENERATE A REPORT ADDED TO THE QUEUE'},\n status: :ok\n end", "def run_report\n comparison_values.tap do |results|\n display_report(results)\n end\n end", "def report(option)\n @report_type = option\n self\n end", "def parse_output(_report, _result, _targets); end", "def html_report\n begin\n require 'ruport'\n rescue LoadError\n abort(\"Couldn't load ruport, suggest that gem install ruport should help\")\n end\n\n unless @options.report_file\n html_report_file_name = 'Kismet-Wireless-Report-' + Time.now.to_s + '.html'\n end\n\n unless @options.report_file =~ /html$/\n html_report_file_name = @options.report_file + '.html'\n end\n\n @report = File.new(html_report_file_name,'w+')\n html_report_header\n html_report_stats\n \n if @options.create_map\n @report << '<hr /><br /><br />'\n html_report_map_body\n end\n @report << '<hr /><br /><br />'\n html_report_inf\n @report << '<hr /><br /><br />'\n html_report_adhoc\n @report << '<hr /><br /><br />'\n html_report_probe\n @report << \"</body>\"\n @report << \"</html>\"\n end", "def wardreport\n\t\t@wards = Ward.find(:all)\n\n\n html = render :layout => false \n\tkit = PDFKit.new(html)\n\n\tkit.stylesheets << RAILS_ROOT + '/public/stylesheets/styles.css' \n\n\tsend_data(kit.to_pdf, :filename => \"wardreport.pdf\", :type => 'application/pdf')\n\tend", "def print_final_report\n puts; puts; puts \"=== FINAL DATABASE COUNTS ===\"\n puts; puts end_of_task_report\n puts; puts; puts \"=== BY SCHOOL ===\"\n puts by_school_report\n puts; AssessmentsReport.new.print_report\n end", "def run\n schedule_data_reports\n end", "def report(args)\n return if !@is_robot_availabe\n puts \"Report: The current location of Robot is #{@pos_x}, #{@pos_y} and facing towards #{@direction}\"\n # return \"REPORT\" #for test\n end", "def runAnalyzer(num_samples,inhash)\n # select profile for run\n show do \n title \"Select #{QIAXCEL_TEMPLATE[inhash[:sampleTypes]]}\" # this is just a profile name, should be ok for other polymerases\n note \"Click <b>Back to Wizard</b> if previous data is displayed.\"\n check \"Under <b>Process -> Process Profile</b>, make sure <b>#{QIAXCEL_TEMPLATE[inhash[:sampleTypes]]}</b> is selected.\"\n end\n \n # select alignment marker\n ref_marker = (inhash[:sampleTypes] == 'DNA') ? REF_MARKERS[inhash[:type_ind]][inhash[:cutoff_ind]] : REF_MARKERS[inhash[:type_ind] ]\n show do \n title \"Select alignment marker\"\n check \"Under <b>Marker</b>, in the <b>Reference Marker </b> drop-down, select <b>#{ref_marker}</b>. A green dot should appear to the right of the drop-down.\"\n end\n \n # empty rows\n if inhash[:sampleTypes] == 'RNA'\n num_samples = num_samples + 1 # Include the ladder in the first well of the first stripwell\n nonempty_rows = (num_samples/WELLS_PER_STRIPWELL.to_f).ceil\n (num_samples % WELLS_PER_STRIPWELL) > 0 ? nonempty_rows + 1 : nonempty_rows\n else\n nonempty_rows = (num_samples/WELLS_PER_STRIPWELL.to_f).ceil\n end\n show do \n title \"Deselect empty rows\"\n check \"Under <b>Sample selection</b>, deselect all rows but the first #{nonempty_rows}.\"\n end\n \n # check \n show do \n title \"Perform final check before running analysis\"\n note \"Under <b>Run Check</b>, manually confirm the following:\"\n check \"Selected rows contain samples.\"\n check \"Alignment marker is loaded (changed every few weeks).\"\n end\n \n # run and ask tech for remaining number of runs\n run_data = show do \n title \"Run analysis\"\n note \"If you can't click <b>Run</b>, and there is an error that reads <b>The pressure is too low. Replace the nitrogen cylinder or check the external nitrogen source</b>, close the software, and reopen it. Then restart at title - <b>Select #{QIAXCEL_TEMPLATE[inhash[:sampleTypes]]} </b>\"\n check \"Otherwise, click <b>Run</b>\"\n note \"Estimated time of experiment is given at the bottom of the screen\"\n get \"number\", var: \"runs_left\", label: \"Enter the number of <b>Remaining Runs</b> left in this cartridge\", default: 0\n #image \"frag_an_run\"\n end\n \n # return\n run_data[:runs_left]\n \n end", "def analyze\n format_results\n end", "def report\n @report_file || \"kacl_report.json\"\n end", "def write_report!\n notify.critical_error(\"Must run `test!` before writing a report\") if test.status.nil?\n in_test_dir do\n self.writer = GitTest::Writer.new(:path => report_path,\n :name => report_name,\n :report => test.report )\n in_report_branch do\n writer.save!\n commit_to_test_proj!\n end\n end\n end", "def run_report(report)\n report.update! status: 'running'\n\n klass = report.name.constantize\n\n r = klass.new(report.parameters)\n if r.parameters_valid?\n record_set = r.query\n report_template = klass.template\n\n output = ApplicationController.new\n .render_to_string(template: report_template, formats: report.format,\n locals: { klass: klass, record_set: record_set,\n created_at: report.created_at })\n report.update! status: 'completed', output: output\n else\n report.update status: 'error'\n report.update status_message: r.error_message\n end\n end", "def reports_path; end", "def reports_path; end", "def run(runner, user_arguments)\n super(runner, user_arguments)\n\n # make the runner a class variable\n @runner = runner\n\n # if true errors on QAQC sections will show full backtrace. Use for diagnostics\n @error_backtrace = true\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments, user_arguments)\n return false\n end\n\n run_qaqc = runner.getBoolArgumentValue('run_qaqc', user_arguments)\n unless run_qaqc\n return true\n end\n\n runner.registerInitialCondition('Starting QAQC report generation')\n\n # get sql, model, and web assets\n setup = OsLib_Reporting.setup(runner)\n unless setup\n return false\n end\n @model = setup[:model]\n # workspace = setup[:workspace]\n @sql = setup[:sqlFile]\n web_asset_path = setup[:web_asset_path]\n\n # vector to store the results and checks\n time_a = Time.new\n report_elems = OpenStudio::AttributeVector.new\n report_elems << create_results(skip_weekends = false,\n skip_holidays = false,\n start_mo = 'January',\n start_day = 1,\n start_hr = 1,\n end_mo = 'December',\n end_day = 31,\n end_hr = 24)\n time_b = Time.new\n delta_time = time_b.to_f - time_a.to_f\n runner.registerInfo(\"Gathering results: elapsed time #{delta_time.round(1)} seconds.\")\n\n # utility name to to used by some qaqc checks\n @utility_name = 'LADWP'\n\n # get building type, different standards path if multifamily\n building_type = ''\n if @model.getBuilding.standardsBuildingType.is_initialized\n building_type = @model.getBuilding.standardsBuildingType.get\n end\n\n # get building template features\n runner.registerInfo(\"Getting building features.\")\n hvac_system_type = get_bldg_feature_string(@model, 'hvac_system_type')\n target_envelope_standard = get_bldg_feature_string(@model, 'envelope_template')\n if target_envelope_standard.nil?\n runner.registerInfo(\"'set_envelope_template measure' did not have argument 'template' set; using DEER 2003\")\n target_envelope_standard = 'DEER 2003'\n end\n\n # using lighting as the internal loads standard for comparison\n # @todo separate internal loads into lighting, equipment, and occupancy\n target_internal_loads_standard = get_bldg_feature_string(@model, 'interior_lighting_template')\n if target_internal_loads_standard.nil?\n runner.registerInfo(\"'set_interior_lighting_template measure' did not have argument 'template' set; using DEER 2003\")\n target_internal_loads_standard = 'DEER 2003'\n end\n\n target_hvac_standard = get_bldg_feature_string(@model, 'hvac_template')\n if target_hvac_standard.nil?\n runner.registerInfo(\"'set_hvac_template measure' did not have argument 'template' set; using DEER 2003\")\n target_hvac_standard = 'DEER 2003'\n end\n\n # create an attribute vector to hold the checks\n check_elems = OpenStudio::AttributeVector.new\n\n # call individual checks and add to vector\n\n # envelope checks\n runner.registerInfo(\"Comparing model envelope to defaults from #{target_envelope_standard}.\")\n check_elems << check_envelope_conductance('Baseline', target_envelope_standard)\n\n # internal load checks\n runner.registerInfo(\"Comparing model internal loads to defaults from #{target_internal_loads_standard}.\")\n check_elems << check_internal_loads('Baseline', target_internal_loads_standard)\n check_elems << check_internal_loads_schedules('Baseline', target_internal_loads_standard)\n check_elems << check_plenum_loads('General', target_internal_loads_standard)\n check_elems << check_occ_zones_conditioned('General', target_internal_loads_standard)\n check_elems << check_sch_coord('General', target_internal_loads_standard)\n\n # hvac system checks\n runner.registerInfo(\"Comparing model hvac to defaults from #{target_hvac_standard}.\")\n check_elems << check_mech_sys_capacity('General', target_hvac_standard)\n check_elems << check_plant_cap('General', target_hvac_standard)\n check_elems << check_fan_power('General', target_hvac_standard)\n check_elems << check_pump_power('General', target_hvac_standard)\n check_elems << check_mech_sys_efficiency('Baseline', target_hvac_standard)\n check_elems << check_mech_sys_part_load_eff('General', target_hvac_standard)\n check_elems << check_supply_air_and_thermostat_temp_difference('Baseline', target_hvac_standard)\n check_elems << check_air_loop_temps('General')\n check_elems << check_plant_temps('General')\n check_elems << check_part_loads('General')\n check_elems << check_simultaneous_heating_and_cooling('General')\n\n # unmet hours by system type\n case hvac_system_type\n when 'No HVAC (Unconditioned)'\n runner.registerInfo(\"HVAC system type is '#{hvac_system_type}. Unmet hours expected.\")\n check_elems << check_unmet_hours('General', target_hvac_standard, expect_clg_unmet_hrs: true, expect_htg_unmet_hrs: true)\n when 'Baseboard district hot water heat',\n 'Baseboard electric heat',\n 'Baseboard hot water heat',\n 'Unit heaters',\n 'Heat pump heat with no cooling',\n 'Residential forced air',\n 'Forced air furnace',\n 'No Cooling with Electric Heat',\n 'No Cooling with Gas Furnace'\n runner.registerInfo(\"HVAC system type is '#{hvac_system_type}. Checking for only heating unmet hours.\")\n check_elems << check_unmet_hours('General', target_hvac_standard, expect_clg_unmet_hrs: true, expect_htg_unmet_hrs: false)\n when 'PTAC with no heat',\n 'PSZ-AC with no heat',\n 'Fan coil district chilled water with no heat',\n 'Fan coil chiller with no heat',\n 'Window AC with no heat',\n 'Direct evap coolers',\n 'Residential AC with no heat'\n runner.registerInfo(\"HVAC system type is '#{hvac_system_type}. Checking for only cooling unmet hours.\")\n check_elems << check_unmet_hours('General', target_hvac_standard, expect_clg_unmet_hrs: false, expect_htg_unmet_hrs: true)\n else\n runner.registerInfo(\"HVAC system type is '#{hvac_system_type}. Checking for heating and cooling unmet hours.\")\n check_elems << check_unmet_hours('General', target_hvac_standard, expect_clg_unmet_hrs: false, expect_htg_unmet_hrs: false)\n end\n\n # diagnostic scripts to implement\n # check_elems << check_geometry()\n # check_elems << check_coil_controllers()\n # check_elems << check_zone_outdoor_air()\n\n # diagnostic scripts unused\n # check_elems << check_la_weather_files()\n # check_elems << check_calibration()\n\n # add checks to report_elems\n report_elems << OpenStudio::Attribute.new('checks', check_elems)\n\n # create an extra layer of report. the first level gets thrown away.\n top_level_elems = OpenStudio::AttributeVector.new\n top_level_elems << OpenStudio::Attribute.new('report', report_elems)\n\n # create the report\n result = OpenStudio::Attribute.new('summary_report', top_level_elems)\n result.saveToXml(OpenStudio::Path.new('report.xml'))\n\n # closing the sql file\n @sql.close\n\n # reporting final condition\n runner.registerFinalCondition('Finished generating report.xml.')\n\n # populate sections using attributes\n sections = OsLib_Reporting.sections_from_check_attributes(check_elems, runner)\n\n # generate html output\n OsLib_Reporting.gen_html(\"#{File.dirname(__FILE__)}report.html.erb\", web_asset_path, sections, name)\n\n return true\n end", "def report_title; end", "def report_title; end", "def report\n raise \"#{self.class} should implement #report\"\n end", "def report\n raise \"#{self.class} should implement #report\"\n end", "def report!\n simplecov\n Coveralls.push!\n\n nil\n end", "def report\n super\n\n begin\n puts \"Writing HTML reports to #{@reports_path}\"\n erb_str = File.read(@erb_template)\n renderer = ERB.new(erb_str)\n\n tests_by_suites = tests.group_by { |test| test_class(test) } # taken from the JUnit reporter\n\n suites = tests_by_suites.map do |suite, tests|\n suite_summary = summarize_suite(suite, tests)\n suite_summary[:tests] = tests.sort { |a, b| compare_tests(a, b) }\n suite_summary\n end\n\n suites.sort! { |a, b| compare_suites(a, b) }\n\n result = renderer.result(binding)\n File.open(html_file, 'w') do |f|\n f.write(result)\n end\n\n # rubocop:disable Lint/RescueException\n rescue Exception => e\n puts 'There was an error writing the HTML report'\n puts 'This may have been caused by cancelling the test run'\n puts 'Use mode => :verbose in the HTML reporters constructor to see more detail' if @mode == :terse\n puts 'Use mode => :terse in the HTML reporters constructor to see less detail' if @mode != :terse\n raise e if @mode != :terse\n end\n # rubocop:enable Lint/RescueException\n end", "def report(file, result)\n Fast.report(result,\n file: file,\n show_link: @show_link,\n show_permalink: @show_permalink,\n show_sexp: @show_sexp,\n headless: @headless,\n bodyless: @bodyless,\n colorize: @colorize)\n end", "def data_report(options={})\n puts \"\\n\\n\"\n puts \"**********************************\\n\"\n puts \"**********************************\"\n puts @last_log\nend", "def find_or_create_report(opts)\n\t\treport_report(opts.merge({:wait => true}))\n\tend", "def reports\n backend.reports\n end" ]
[ "0.7354263", "0.7354263", "0.7354263", "0.7354263", "0.7354263", "0.72990054", "0.70978945", "0.6788482", "0.67505884", "0.65277207", "0.65267944", "0.6518355", "0.6516559", "0.65113986", "0.6448719", "0.64310515", "0.63754135", "0.6364535", "0.6303359", "0.62592494", "0.6221651", "0.62208796", "0.6219872", "0.61564696", "0.6131072", "0.6131072", "0.6131072", "0.6131072", "0.6131072", "0.6080153", "0.6080153", "0.6061015", "0.60490686", "0.596576", "0.5953284", "0.5951043", "0.59508455", "0.5940912", "0.5933862", "0.592683", "0.5916949", "0.59111154", "0.59079474", "0.5907755", "0.5899704", "0.5897642", "0.5896542", "0.5891003", "0.5889245", "0.58856565", "0.58776325", "0.58776325", "0.5860387", "0.5851194", "0.58510303", "0.58485186", "0.5845642", "0.58403957", "0.58335054", "0.58149254", "0.5800362", "0.5792184", "0.5791414", "0.57871044", "0.57841784", "0.5761852", "0.5742003", "0.5738146", "0.5736841", "0.57352686", "0.57256126", "0.572348", "0.5722211", "0.57221174", "0.57149357", "0.57109106", "0.5709108", "0.57076335", "0.56839406", "0.56825125", "0.5679041", "0.5665379", "0.56615365", "0.5656401", "0.5655667", "0.5654755", "0.5651749", "0.5650517", "0.5650517", "0.5648597", "0.56423485", "0.56423485", "0.56312925", "0.56312925", "0.5614302", "0.5610515", "0.55999464", "0.5590293", "0.55888265", "0.5573296" ]
0.62160885
23
TODO: lots of this stuff is specific to a decision tree.
def initialize(relation_name, attributes, data, class_attribute) @relation_name = relation_name @attributes = attributes @data = data @class_attribute = class_attribute end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def decision_tree_class\n C100App::CompletionDecisionTree\n end", "def parsed_tree; end", "def decision\n return @decision\n end", "def render_decision args\n decision = current_decision args\n # text is either the value of decision's description key or warning that no description exists\n args.labels << [640, 360, decision[:description] || \"No definition found for #{args.state.decision_id}. Please update decision.rb.\", 0, 1] # uses string interpolation\n\n # All decisions are stored in a hash\n # The descriptions output onto the screen are the values for the description keys of the hash.\n if decision[:option_one]\n args.labels << [10, 360, decision[:option_one][:description], 0, 0] # option one's description label\n args.labels << [10, 335, \"(Press 'left' on the keyboard to select this decision)\", -5, 0] # label of what key to press to select the decision\n end\n\n if decision[:option_two]\n args.labels << [1270, 360, decision[:option_two][:description], 0, 2] # option two's description\n args.labels << [1270, 335, \"(Press 'right' on the keyboard to select this decision)\", -5, 2]\n end\n\n if decision[:option_three]\n args.labels << [640, 45, decision[:option_three][:description], 0, 1] # option three's description\n args.labels << [640, 20, \"(Press 'down' on the keyboard to select this decision)\", -5, 1]\n end\n\n if decision[:option_four]\n args.labels << [640, 700, decision[:option_four][:description], 0, 1] # option four's description\n args.labels << [640, 675, \"(Press 'up' on the keyboard to select this decision)\", -5, 1]\n end\nend", "def decision_tree_evaluate(i,j)\n rules = IO.read(Constant.new(@c,\"decision_rules\").filename(i))\n data = CSV.read(Constant.new(@c,\"csv_test\").filename(j))\n data.shift\n correct, count, unmatched = 0,0,[]\n data.each do |d|\n puts d[0..-2].inspect\n puts d[-1].inspect\n indegree_ratio, outdegree_ratio, outindegree_ratio = d[0], d[1], d[2]\n inmsg_ratio, outmsg_ratio, mutualin_nbrs_ratio = d[3], d[4], d[5]\n reciprocated = nil\n eval(rules)\n begin\n correct += 1 if reciprocated == d[-1]\n rescue\n unmatched << d\n end\n count += 1\n end\n \n File.open(Constant.new(@c,\"decision_results_basedon\",[i]).filename(j),\"w\") do |f|\n f.puts \"Using rules of %d on %j\" % [i,j]\n f.puts \"XAccuracy: %d %d %.4f\" % [correct, count, (correct-0.0)/count]\n f.puts \"Unmatched: \"\n unmatched.each { |u| f.puts u.inspect }\n end\n end", "def leaf?; false end", "def for_node; end", "def child_condition; end", "def leaf?; @leaf; end", "def is_leaf\n true\n end", "def is_leaf\n true\n end", "def goalNode?(node)\n node.name == 'Goal'\nend", "def classify_edge(x,y)\n if y.parent == x\n return :tree\n elsif y.discovered? and !y.processed?\n return :back\n elsif y.processed? and y.pre < x.pre\n return :cross\n elsif y.processed? and x.pre < y.pre\n return :forward\n end\nend", "def branch; end", "def decide!\n return if not (consider = self.current_state.decisions)\n consider.each {|decision| break if process_decision!(decision) }\n self.current_state.name\n end", "def is_valid_tree(tree)\n\nend", "def heuristics\n raise NotImplementedError, \"not implemented in #{self}\"\n end", "def decision_tree_generate(i, prefix)\n csv_training = \"csv_training_\" + prefix\n csv_test = \"csv_test_\" + prefix\n decision_rules = \"decision_rules_\" + prefix\n decision_results = \"decision_results_\" + prefix\n \n #Generate\n puts \"Generating rules based on training data...\"\n @dt = DecisionTree.new(Constant.new(@c,csv_training).filename(i))\n File.open(Constant.new(@c,decision_rules).filename(i),\"w\") do |f|\n f.puts @dt.get_rules\n end\n \n # Test\n puts \"Testing data on generated rules...\"\n data = CSV.read(Constant.new(@c,csv_test).filename(i))\n data.shift\n correct, count, unmatched = 0, 0, []\n data.each do |d|\n puts d[0..-2].inspect\n puts d[-1].inspect\n begin\n correct += 1 if @dt.eval(d[0..-2]) == d[-1]\n rescue NameError\n unmatched << d\n end\n count += 1\n end\n File.open(Constant.new(@c,decision_results).filename(i),\"w\") do |f|\n f.puts \"Accuracy: %d %d %.4f\" % [correct, count, (correct-0.0)/count]\n f.puts \"Unmatched: \"\n unmatched.each { |u| f.puts u.inspect }\n end\n end", "def decision=(value)\n @decision = value\n end", "def label() @positive end", "def walk_tree(sample_entry)\n index = 0\n\n predicted_class = nil\n #puts sample_entry\n split_entry = sample_entry.split(', ')\n # label is name here\n set = false\n sample_entry.split(', ').each do |attribute_label|\n\n current_node = @ignore_list[index]\n #puts current_node\n label_index = @p.attr_array.index(current_node)\n #puts \"Lable index: #{label_index}\"\n sample_value = split_entry[label_index]\n #puts \"Sample Value: #{sample_value}\"\n node = @tree[sample_value]\n #puts \"Node: #{node}\"\n\n if node['result'] != nil then\n predicted_class = \"#{node['result'].upcase}.\"\n #puts \"---- CLASSIFICATION: #{node['result'].upcase}\"\n set = true\n break\n end\n\n if node['child'] == nil then\n predicted_class = '>50K.'\n #puts \"---- CLASSIFICATION: >50K.\"\n break\n end\n index += 1\n end\n\n return predicted_class\n\n end", "def nodes; end", "def nodes; end", "def nodes; end", "def business_decision_support \n end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def node; end", "def pre_execute_boolean_attribute\n\n return unless children.size == 1\n\n t = @node['tree'] = Flor.dup(tree)\n t[1] << [ '_boo', true, @node['tree'][2] ]\n end", "def current_decision args\n args.state.game_definition[:decisions][args.state.decision_id] || {} # either has value or is empty\nend", "def check(node); 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 test(data)\n if @nominal\n @children.each_with_index do |child, ind|\n child.test(data) if data.vals[@att] == @@nom_choices[@att][ind]\n end\n else # continuous\n if data.vals[@att].to_f < @thresh # > on one side, <= on oter\n @children.first.test(data)\n else\n @children[1].test(data)\n end\n end\n end", "def most_specific_subdivision; end", "def checked; end", "def child_node; end", "def display_parent_child_test_cases\n \n end", "def branch\n raise NotImplementedError\n end", "def getKnowledge\n\t\t\n\tend", "def label; end", "def label; end", "def traverse; end", "def getDecision(output, data_source)\r\n key = data_source.to_sym\r\n\r\n # Last sold check\r\n idx = output[key][:metricsNames].index(\"Last Sold History\")\r\n output[:reason][0] = \"Sold too recently\" if !output[key][:metricsPass][idx]\r\n\r\n # Rurality Checks\r\n rs_idx = output[:Census][:metricsNames].index(\"Rurality Score\")\r\n vol_idx = output[key][:metricsNames].index(\"St. Dev. of Historical Home Price\")\r\n\r\n if output[:region] == \"East\"\r\n output[:reason][1] = \"Too rural\" if (!output[:Census][:metricsPass][rs_idx] || !output[key][:metricsPass][vol_idx]) \r\n end\r\n\r\n if output[:region] == \"West\"\r\n output[:reason][1] = \"Too rural\" if !output[:Census][:metricsPass][rs_idx]\r\n end\r\n\r\n # Typicality\r\n typ_idx = output[key][:metricsUsage].each_index.select { |i| output[key][:metricsUsage][i] == \"Typicality\" }\r\n typ_fail_cnt = typ_idx.inject([]) { |tot, a| tot << output[key][:metricsPass][a] }.count(false)\r\n\r\n if data_source == \"Zillow\"\r\n neigh_idx = output[key][:metricsNames].index(\"Neighbors Available\")\r\n sqft_idx = output[key][:metricsNames].index(\"SqFt Typicality - Comps\")\r\n est_idx = output[key][:metricsNames].index(\"Estimate Typicality - Comps\")\r\n\r\n if output[key][:metrics][neigh_idx] >= 4\r\n sqfi_nb_idx = output[key][:metricsNames].index(\"SqFt Typicality - Neighbors\")\r\n est_nb_idx = output[key][:metricsNames].index(\"Estimate Typicality - Neighbors\")\r\n\r\n output[:reason][2] = \"Atypical property\" if typ_fail_cnt >= 3\r\n output[:reason][2] = \"Atypical property\" if typ_fail_cnt >= 1 && (output[key][:metrics][sqft_idx] > 65.0 || output[key][:metrics][est_idx] > 65.0)\r\n output[:reason][2] = \"Atypical property\" if !output[key][:metricsPass][sqft_idx] && !output[key][:metricsPass][sqfi_nb_idx]\r\n output[:reason][2] = \"Atypical property\" if !output[key][:metricsPass][est_idx] && !output[key][:metricsPass][est_nb_idx]\r\n else\r\n output[:reason][2] = \"Atypical property\" if typ_fail_cnt >= 2\r\n output[:reason][2] = \"Atypical property\" if typ_fail_cnt >= 1 && (output[key][:metrics][sqft_idx] > 60.0 || output[key][:metrics][est_idx] > 60.0)\r\n end\r\n else\r\n output[:reason][2] = \"Atypical property\" if typ_fail_cnt >= 2\r\n output[:reason][2] = \"Atypical property\" if typ_fail_cnt >= 1 && (output[key][:metrics][sqft_idx] > 60.0 || output[key][:metrics][est_idx] > 60.0)\r\n end\r\n\r\n # Liquidity (allow one false)\r\n liq_idx = output[key][:metricsUsage].each_index.select { |i| output[key][:metricsUsage][i] == \"Liquidity\" }\r\n liq_fail_cnt = liq_idx.inject([]) { |tot, a| tot << output[key][:metricsPass][a] }.count(false)\r\n output[:reason][3] = \"Illiquidity\" if liq_fail_cnt >= 2\r\n\r\n # Investment Guidelines\r\n est_idx = output[key][:metricsNames].index(\"Estimated Value\")\r\n type_idx = output[key][:metricsNames].index(\"Property Use\")\r\n build_idx = output[key][:metricsNames].index(\"Build Date\")\r\n msa_idx = output[key][:metricsNames].index(\"Pre-approval\")\r\n\r\n output[:reason][4] = \"Out of $ Range\" if !output[key][:metricsPass][est_idx]\r\n output[:reason][5] = \"Not Prop Type\" if !output[key][:metricsPass][type_idx]\r\n output[:reason][6] = \"New Construction\" if !output[key][:metricsPass][build_idx]\r\n output[:reason][7] = \"Not in MSAs\" if !output[key][:metricsPass][msa_idx]\r\n\r\n # Volatility (allow one false)\r\n vol_idx = output[key][:metricsUsage].each_index.select { |i| output[key][:metricsUsage][i] == \"Volatility\" }\r\n vol_fail_cnt = vol_idx.inject([]) { |tot, a| tot << output[key][:metricsPass][a] }.count(false)\r\n output[:reason][8] = \"Price Vol\" if vol_fail_cnt >= 2\r\n\r\n # Combo Rural (if applicable)\r\n cr_idx = output[:Census][:metricsNames].index(\"Combo Rural\")\r\n output[:reason][9] = \"Combo Rural\" if !output[:Census][:metricsPass][cr_idx]\r\n\r\n # Distance\r\n output[:reason][10] = \"MSA Distance\" if !output[:Google][:metricsPass].any?\r\n\r\n # Approve if not issues\r\n output[:reason][11] = \"Approved\" if output[:reason].compact.size == 0\r\n end", "def branches; end", "def decision_context\n FlowFiber.current[:decision_context]\n end", "def node_type; end", "def node_type; end", "def apply_children\n \n end", "def show_tree\n\tend", "def leaf?\n true\n end", "def process_node(node, this, nxt)\n if node.value == \"ALT\"\n node_alt(node, this, nxt)\n elsif node.value == \"SEQ\"\n node_seq(node, this, nxt)\n elsif node.value == \"*\"\n node_kleene(node, this, nxt)\n elsif node.value == \"lambda\"\n leaf_lambda(node, this, nxt)\n else\n leaf_child(node, this, nxt)\n end\n end", "def labels; end", "def visit_node(n); end", "def initialize to_check, expected, label=nil, solution=nil, father_cat=nil\n @to_check=to_check\n @expected = expected\n @label = label\n @solution=solution\n @id = NumerationFactory.create father_cat\n @status= -1\n\n @father_cat = father_cat\n if father_cat != nil\n @display_offset=father_cat.display_offset+1\n else\n @display_offset=0\n end\n\n end", "def else_branch\n node.else\n end", "def feature\n child_node.feature\n end", "def feature\n child_node.feature\n end", "def operation\n results = []\n @children.each { |child| results.append(child.operation) }\n \"Branch(#{results.join('+')})\"\n end", "def tree(capa = 1)\n R3::Tree.new(capa)\nend", "def operation\n results = []\n @children.each { |child| results.push(child.operation) }\n \"Branch(#{results.join('+')})\"\n end", "def evaluate\n\n end", "def decide!(input)\n decision( input: input, symbolize_keys: false)\n end", "def valid_tree?\n true\n end", "def valid_tree?\n true\n end", "def winning_node?(evaluator)\n end", "def confidence; end", "def transform(tree); end", "def decision_tree_generate_rev(i, prefix)\n csv_training = \"csv_training_\" + prefix\n csv_test = \"csv_test_\" + prefix\n decision_rules = \"decision_rules_rev_\" + prefix\n decision_results = \"decision_results_rev_\" + prefix\n \n #Generate\n puts \"Reverse Generating rules based on training data...\"\n @dt = DecisionTree.new(Constant.new(@c,csv_test).filename(i))\n File.open(Constant.new(@c,decision_rules).filename(i),\"w\") do |f|\n f.puts @dt.get_rules\n end\n \n # Test\n puts \"Reverse Testing data on generated rules...\"\n data = CSV.read(Constant.new(@c,csv_training).filename(i))\n data.shift\n correct, count, unmatched = 0, 0, []\n data.each do |d|\n puts d[0..-2].inspect\n puts d[-1].inspect\n begin\n correct += 1 if @dt.eval(d[0..-2]) == d[-1]\n rescue NameError\n unmatched << d\n end\n count += 1\n end\n File.open(Constant.new(@c,decision_results).filename(i),\"w\") do |f|\n f.puts \"Accuracy: %d %d %.4f\" % [correct, count, (correct-0.0)/count]\n f.puts \"Unmatched: \"\n unmatched.each { |u| f.puts u.inspect }\n end\n end", "def formation; end", "def evaluate(mode = [:nodes])\n case @type\n when :comparison\n left = @children[0].evaluate(mode)\n right = @children[1].evaluate(mode)\n if mode.last == :subquery\n left = left[0] if left.length == 1\n comparison(left, right)\n elsif mode.last == :resources\n if left[0] == 'tag'\n comparison(left[0], right)\n else\n comparison(['parameter', left[0]], right)\n end\n else\n subquery(mode.last,\n :fact_contents,\n ['and', left, comparison('value', right)])\n end\n when :boolean\n value\n when :string\n value\n when :number\n value\n when :date\n require 'chronic'\n ret = Chronic.parse(value, :guess => false).first.utc.iso8601\n fail \"Failed to parse datetime: #{value}\" if ret.nil?\n ret\n when :booleanop\n [value.to_s, *evaluate_children(mode)]\n when :subquery\n mode.push :subquery\n ret = subquery(mode[-2], value + 's', children[0].evaluate(mode))\n mode.pop\n ret\n when :regexp_node_match\n mode.push :regexp\n ret = ['~', 'certname', Regexp.escape(value.evaluate(mode))]\n mode.pop\n ret\n when :identifier_path\n if mode.last == :subquery || mode.last == :resources\n evaluate_children(mode)\n elsif mode.last == :regexp\n evaluate_children(mode).join '.'\n else\n # Check if any of the children are of regexp type\n # in that case we need to escape the others and use the ~> operator\n if children.any? { |c| c.type == :regexp_identifier }\n mode.push :regexp\n ret = ['~>', 'path', evaluate_children(mode)]\n mode.pop\n ret\n else\n ['=', 'path', evaluate_children(mode)]\n end\n end\n when :regexp_identifier\n value\n when :identifier\n mode.last == :regexp ? Regexp.escape(value) : value\n when :resource\n mode.push :resources\n regexp = value[:title].type == :regexp_identifier\n if !regexp && value[:type].capitalize == 'Class'\n title = capitalize_class(value[:title].evaluate)\n else\n title = value[:title].evaluate\n end\n ret = subquery(mode[-2], :resources,\n ['and',\n ['=', 'type', capitalize_class(value[:type])],\n [regexp ? '~' : '=', 'title', title],\n ['=', 'exported', value[:exported]],\n *evaluate_children(mode)])\n mode.pop\n ret\n end\n end", "def fetch_pre_decision_status\n if pending_schedule_hearing_task?\n :pending_hearing_scheduling\n elsif hearing_pending?\n :scheduled_hearing\n elsif evidence_submission_hold_pending?\n :evidentiary_period\n elsif at_vso?\n :at_vso\n elsif distributed_to_a_judge?\n :decision_in_progress\n else\n :on_docket\n end\n end", "def node; changeset.node; end", "def word_classification_detail(word)\n\n p \"word_probability\"\n result=self.categories.inject({}) do |h, cat|\n h[cat]=self.word_probability(word, cat); h\n end\n p result\n\n p \"word_weighted_average\"\n result=categories.inject({}) do |h, cat|\n h[cat]=word_weighted_average(word, cat); h\n end\n p result\n\n p \"doc_probability\"\n result=categories.inject({}) do |h, cat|\n h[cat]=doc_probability(word, cat); h\n end\n p result\n\n p \"text_probability\"\n result=categories.inject({}) do |h, cat|\n h[cat]=event_probability(word, cat); h\n end\n p result\n\n end", "def tree\n @flow_expression.tree\n end", "def scanned_node?(node); end", "def generate_nodes(parent = nil, vectors = nil)\n #puts \"generate_nodes(#{[parent.name, parent.content].inspect}, [#{vectors.size} vectors])\" unless parent.nil?\n vectors ||= @set.vectors\n remaining_attributes = parent.nil? ? @set.non_decision_attributes.map(&:name) : (@set.non_decision_attributes.map(&:name) - ancestor_attributes(parent))\n unless parent.nil?\n \n #puts \"parent: #{parent.content} at depth #{depth(parent)}\"\n # if all examples associated with parent leaf have same target attribute value\n decision_values = vectors.map {|v| @set.decision_value_of_vector(v)}\n unique_decision_values = decision_values.uniq\n \n if unique_decision_values.size == 1\n #puts \" all examples associated with parent leaf have same target attribute value\"\n parent.content = @set.decision_attribute\n return unique_decision_values.first\n end\n \n # if each attribute has been used along this path\n # if remaining_attributes.empty?\n # #puts \" each attribute has been used along this path\"\n # return decision_values.first\n # end\n end\n evaulate_real_attributes(vectors, remaining_attributes)\n attribute = @set.max_gain_attribute(vectors, remaining_attributes)\n if attribute.nil?\n @root.printTree\n y vectors\n y remaining_attributes\n end\n #puts \" max gain attribute: #{attribute}\"\n if parent.nil?\n @root = TreeNode.new(\"ROOT\", attribute)\n generate_nodes(@root, vectors)\n else\n # if parent.content.nil?\n # @root.printTree\n # p parent\n # p attribute\n # end\n if parent.content == \"standby-pay\"\n p @set.values_of_attribute(parent.content)\n end\n @set.values_of_attribute(parent.content).each do |value|\n value_set = @set.subset(parent.content, value, vectors)\n # puts \"value_set = @set.subset(#{parent.content.inspect}, #{value.inspect}, [#{vectors.size} vectors])\"\n # puts \"value_set.size: #{value_set.size}\"\n node = TreeNode.new(value, attribute)\n parent << node\n if value_set.empty? || remaining_attributes.size == 1\n #p 'value_set is empty or remaining_attributes will be'\n end_value = @set.best_value(@set.decision_attribute, vectors)\n node.content = @set.decision_attribute\n node << TreeNode.new(end_value, nil)\n elsif end_value = generate_nodes(node, value_set)\n #p 'leaf children'\n node << TreeNode.new(end_value, nil)\n end\n #p end_value\n end\n end\n return false\n end", "def order_attributes(xfold = false)\n\n @ignore_list = Array.new\n @max_result_array = Array.new\n @max_class_count_array = Array.new\n @tree = Hash.new\n\n\n attr_results_array = Array.new\n attr_length = @p.attributes.size\n gain_ratio_array = Array.new\n class_count_array = Array.new\n\n puts \"Reading in attributes\"\n # read in all attributes counts and store the results\n (0..13).each do |x|\n puts \"On #{x} out of 13\"\n if xfold then\n result = @p.alternate_read_attribute_values(x, 'decision_tree_model', true)\n attr_results_array.push(result)\n\n class_count = @p.class_count\n class_count_array.push(class_count)\n\n gain_ratio = @e.gain_ratio(result, class_count).abs\n gain_ratio_array.push(gain_ratio)\n else\n result = @p.alternate_read_attribute_values(x, 'descrete', true)\n attr_results_array.push(result)\n\n class_count = @p.class_count\n class_count_array.push(class_count)\n\n gain_ratio = @e.gain_ratio(result, class_count).abs\n gain_ratio_array.push(gain_ratio)\n\n end\n end\n puts \"Done reading\"\n\n (0..13).each do |x| \n max = -10000000\n max_class = nil \n max_result = nil\n max_class_count = nil\n (0..13).each do |i| \n class_label = @p.attributes[i]['name'].chomp\n if @ignore_list.include?(class_label) then next end\n #puts class_label\n# if xfold then\n# result = @p.alternate_read_attribute_values(i, 'decision_tree_model', true)\n# else\n# result = @p.alternate_read_attribute_values(i, 'descrete', true)\n# end\n #puts result\n# class_count = @p.class_count\n #puts class_count\n #puts '-'*100\n# gain_ratio = @e.gain_ratio(result, class_count).abs\n# if gain_ratio > max then \n if gain_ratio_array[i] > max then \n# max = gain_ratio \n# max_class = class_label\n# max_result = result\n# max_class_count = class_count\n\n max = gain_ratio_array[i]\n max_class = class_label\n max_result = attr_results_array[i]\n max_class_count = class_count_array[i]\n\n end\n #puts '-'*100\n end\n #puts max\n #puts max_class\n #puts max_result\n #puts max_class_count\n @max_result_array.push(max_result)\n @max_class_count_array.push(max_class_count)\n @ignore_list.push(max_class)\n end\n\n return @ignore_list\n end" ]
[ "0.597345", "0.5909468", "0.5878644", "0.5855606", "0.5774286", "0.5757316", "0.56772333", "0.5663579", "0.563308", "0.56110203", "0.56110203", "0.5577041", "0.5576192", "0.55466545", "0.5500676", "0.54962397", "0.5473831", "0.5467606", "0.54351884", "0.542709", "0.53875214", "0.53856015", "0.53856015", "0.53856015", "0.5383301", "0.53771657", "0.53771657", "0.53771657", "0.53771657", "0.53771657", "0.53771657", "0.53771657", "0.53771657", "0.53771657", "0.53771657", "0.53771657", "0.53771657", "0.53771657", "0.53771657", "0.53771657", "0.53771657", "0.53771657", "0.53771657", "0.53771657", "0.53771657", "0.53771657", "0.53771657", "0.53771657", "0.53771657", "0.53771657", "0.53771657", "0.53771657", "0.5367718", "0.5365638", "0.5357146", "0.534026", "0.533737", "0.5319207", "0.5317472", "0.5312202", "0.53113765", "0.5267221", "0.52586067", "0.5258063", "0.5258063", "0.5257535", "0.52504253", "0.5240584", "0.5236107", "0.5226757", "0.5226757", "0.5218061", "0.52136177", "0.52086383", "0.52018785", "0.5200968", "0.5191115", "0.51868975", "0.51865816", "0.5157179", "0.5157179", "0.5154051", "0.51336724", "0.51093215", "0.51064926", "0.5091912", "0.50823414", "0.50823414", "0.5072867", "0.50683624", "0.50647056", "0.50520945", "0.50502956", "0.5042272", "0.50399023", "0.5035075", "0.50349426", "0.50330263", "0.502951", "0.50271297", "0.50252837" ]
0.0
-1
Make all continuous attributes discrete
def continuize! @data.each_index do |data_index| @data[data_index].each do |attribute_name, attribute| att_type = @attributes.find { |attr| attr[:name] == attribute_name } #class is a special case. Store original value if att_type[:name] == "class" or att_type[:name] == @class_attribute @old_class_nominal_attributes = att_type[:nominal_attributes] end if att_type[:type] == "string" or att_type[:type] == "nominal" @data[data_index][attribute_name] = att_type[:nominal_attributes].find_index(attribute) end end end #change attribute types @attributes.each do |attribute| if attribute[:type] == "string" or attribute[:type] == "nominal" attribute[:type] = "numeric" attribute[:old_nominal_attributes] = attribute[:nominal_attributes] attribute[:nominal_attributes] = nil end end self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def discrete_set(v)\n sig_val = sigmoid(v)\n ret = if sig_val <= 0.25\n -1\n elsif sig_val >= 0.75\n 1\n else\n 0\n end\n end", "def discrete\n\n height = @options[:height].to_f\n upper = normalize(@options[:upper].to_f)\n background_color = @options[:background_color]\n step = @options[:step].to_f\n\n width = @norm_data.size * step - 1\n\n create_canvas(@norm_data.size * step - 1, height, background_color)\n\n below_color = @options[:below_color]\n above_color = @options[:above_color]\n std_dev_color = @options[:std_dev_color]\n\n drawstddevbox(width,height,std_dev_color) if @options[:has_std_dev] == true\n\n i = 0\n @norm_data.each do |r|\n if !r.nil?\n color = (r >= upper) ? above_color : below_color\n @draw.stroke(color)\n @draw.line(i, (@canvas.rows - r/(101.0/(height-4))-4).to_f,\n i, (@canvas.rows - r/(101.0/(height-4))).to_f)\n end\n i += step\n end\n\n @draw.draw(@canvas)\n @canvas\n end", "def normalize(set, attributes)\n\t\tnew_set = []\n\t\ti = 0\n\t\twhile i < set.count\n\t\t\texample_aux = set[i]\n\t\t\tattributes.each do |a|\n\t\t\t\t# only if the attribute is continuous\n\t\t\t\tif a.type == \"continuous\"\n #puts \"example_aux.attributes[a.name] = \"+((set[i].attributes[a.name]).to_f / (a.max.to_f - a.min.to_f).to_f).to_s\n example_aux.attributes[a.name] = (set[i].attributes[a.name]).to_f / (a.max.to_f - a.min.to_f).to_f # normalization: (attribute.value)/(attribute max - attribute.min)\n end\n\t\t\tend\n\t\t\tnew_set << example_aux\n\t\t\ti += 1\n\t\tend\n\t\treturn new_set\n\tend", "def continuous\n extend Continuous\n end", "def unnormalized; end", "def normal\n attributes.normal\n end", "def normalized; end", "def initial_cut_values\n end", "def calculate_based_attributes\n attributes_groups_by(type: 'based').each do |group|\n next unless group.character_attributes\n\n # TODO: remember to check if the attribute that is going to serve as\n # the base does not have a base too, or it can go down to a deadlock\n # this security check can be made on the controller, when the attributes\n # are saved\n group.character_attributes.each do |attribute|\n attribute.base_attribute = find_character_attribute(\n attribute.base_attribute_group,\n attribute.base_attribute_name\n )\n end\n end\n end", "def make_dimensionless\n self.physical_quantity = 'dimensionless'\n @base_quantity_hash = { }\n end", "def initialize(_attribtues_ = {})\n @attributes = {}\n \n # Ensure that start and end positions are in the correct order.\n if _attribtues_[:start] && (_attribtues_[:end] || _attribtues_[:stop])\n seq_start, seq_end = [_attribtues_.delete(:start).to_i, (_attribtues_.delete(:end) || _attribtues_.delete(:stop)).to_i].sort\n _attribtues_[:start] = seq_start\n _attribtues_[:end] = seq_end\n end\n \n _attribtues_.each do |name, value|\n send(\"#{name}=\", value)\n end\n end", "def use_default_attributes\n self.name = \"element#{column}\"\n self.units = ''\n self.default_min = nil\n self.default_max = nil\n self.scale_factor = 1.0\n self.offset = 0.0\n self.display_type = 'continuous'\n end", "def set_string_attributes_to_nominal(column_indices = nil)\n nominals = {}\n # Frustratingly, we have to traverse this 2D array with the\n # wrong dimension first. Oh well.\n @instances.each_with_index do |row, row_index|\n row.each_with_index do |string, col_index|\n next unless @attributes[col_index].type == ATTRIBUTE_STRING\n next unless column_indices.nil? or column_indices.include?(col_index)\n\n nominals[col_index] ||= {}\n nominals[col_index][string] ||= true\n end\n end\n\n nominals.each do |index, strings|\n @attributes[index].type = \"{#{strings.keys.join(',')}}\"\n end\n end", "def draw_attributes\n draw_header\n \n change_color(system_color)\n #draw_text(5, 32, self.width, 24, \"Categoria:\")\n draw_text(5, 32, self.width, 24, \"Atributos:\")\n change_color(normal_color)\n \n 8.times do |i|\n draw_text(5, 56 + i * 24, 131, 24, Vocab.param(i))\n end\n\n 8.times do |i|\n change_color(normal_color)\n draw_text(self.width - 108, 54 + i * 24, 64, 24, \"#{@item.params[i].to_i}\")\n draw_text(self.width - 75, 54 + i * 24, 64, 24, \"→\")\n change_color(@enchant[:effects][i] > 0 ? power_up_color : normal_color)\n draw_text(self.width - 54, 54 + i * 24, 64, 24, \"#{(@item.params[i] + @enchant[:effects][i]).to_i}\")\n end\n end", "def upsample_discrete upsample_factor, filter_order\n return self.clone.upsample_discrete!(upsample_factor, filter_order)\n end", "def entropy(attr,labels)\n # check binary attributes\n mapped = parse_attr(attr)\n if mapped.keys.size == 2\n #Binary attributes\n return gain([mapped.values[0],mapped.values[1]])\n end\n end", "def scales\n \n end", "def initialize(attributes)\n\t\t\tsuper\n\n\t\t\t# The wrapper to the API does not judge original values, so I initialize them here\n\t\t\t@max_weight ||= 100000000000\n\t\t\t@min_weight ||= 0\n\t\t\t@max_depth ||= 100000000000\n\t\t\t@min_depth \t||= 0\n\t\t\t@max_height ||= 100000000000\n\t\t\t@min_height ||= 0\n\t\t\t@max_width \t||= 100000000000\n\t\t\t@min_width \t||= 0\n\t\t\t@max_value \t||= 100000000000\n\t\t\t@min_value \t||= 0\n\n\t\tend", "def domain_attrs\n attributes.symbolize_keys.select {|_k, v| !v.nil? }\n end", "def generate_attr(desired_value)\n min = desired_value - 2\n min = 0 if min < 0\n max = desired_value + 2\n max = 0 if max < 0\n rand(min..max)\n end", "def resample_discrete! upsample_factor, downsample_factor, filter_order\n @data = DiscreteResampling.resample @data, @sample_rate, upsample_factor, downsample_factor, filter_order\n @sample_rate *= upsample_factor\n @sample_rate /= downsample_factor\n return self\n end", "def attr(attrib)\n\t\t\tcp = Curses::COLORS[attrib]\n\t\t\t#raise \"Invalid Attribute: #{attrib}\" if cp.nil?\n\t\t\tcp = Curses::COLORS[:plain] if cp.nil?\n\n\t\t\tpair = Curses.color_pair cp\n\t\t\[email protected](pair)\n\t\t\tyield\n\t\t\[email protected](pair)\n\t\tend", "def tributes *attrs\n if attrs.empty? \n @tributes ||= []\n else \n @tributes = attrs\n super *attrs\n end \n end", "def data y_values\n super(Array.new(y_values.to_a.size) { |i| i }, y_values.to_a)\n end", "def setup_attributes\n fill_opacity 0\n stroke 'gold3'\n stroke_width 2\n stroke_linecap 'round'\n stroke_linejoin 'round'\n end", "def resample_discrete upsample_factor, downsample_factor, filter_order\n return self.clone.resample_discrete!(upsample_factor, downsample_factor, filter_order)\n end", "def get_fill_properties(fill) # :nodoc:\n return { :_defined => 0 } unless fill\n\n fill[:_defined] = 1\n\n fill\n end", "def default_derived_characteristics\n chrs = specimen_characteristics || return\n pas = chrs.class.nondomain_attributes.reject { |pa| pa == :identifier }\n chrs.copy(pas)\n end", "def initialize_attributes(attributes, *) # :nodoc:\n attributes = super\n enums.each do |name, reflection|\n if (value = attributes.delete(reflection.name.to_s))\n attributes[reflection.id_name.to_s] ||= reflection.id(value)\n end\n end\n attributes\n end", "def normalize\n x_alize(true)\n end", "def derived_attributes\n @derive_attribute ||= {}\n end", "def initialize( values )\n @name = nil\n @values = values\n @scale = nil \n @color = [ 128,128,128 ]\n end", "def prepare_attributes(data_set, meta_data, options)\n # create meta data and data set for the scaled output\n sc = DatasetScaling.new(meta_data, data_set)\n @meta_data = sc.scaled_meta\n @scaled_dataset = sc.scaled_data_set\n set_attributes(@scaled_dataset, options[:extreme_values])\n end", "def set_normal\n self.critical = false\n end", "def xy\n @attributes.fetch('xy', [0.0, 0.0])\n end", "def xmlAttr()\r\n a = super()\r\n a << ['width', @width]\r\n a << ['height', @height]\r\n a << ['depth', @depth]\r\n @fillColor.xmlAttr.each { |ac|\r\n a << ac\r\n }\r\n a\r\n end", "def downsample_discrete downsample_factor, filter_order\n return self.clone.downsample_discrete!(downsample_factor, filter_order)\n end", "def copy_attribute(entity)\n dicts = entity.attribute_dictionaries\n tmp = []\n #Schleife läuft über alle Dictionarys, sollten üblicherweise die Dictionarys\n # \"StandardAttributes\" und \"GenericAttributes sein\"\n dicts.each do |d|\n #Jedes Key/Value Paar wird kopiert\n d.each_pair { | key, value |\n #puts \"#{key}, #{value}\"\n #im Array speichern, erster Wert ist Name des Dictionary, zweiter Wert ist Key\n #dritter Wert ist value\n tmp << [d.name.to_s, key.to_s, value.to_s]\n }\n end\n #Es soll nur möglich sein, Attribute von Gruppen auch wieder auf Gruppen zu kopieren\n #Das Gleiche gilt für Faces. Deshalb wird zusätzlich zum Array aller Attribute\n #gespeichert, ob es von einem Face oder Group kopiert wurde\n if(entity.class == Sketchup::Face)\n @@clipboard << [tmp,\"Face\"]\n else\n @@clipboard << [tmp,\"Group\"]\n end\n end", "def clean_attributes(attributes)\n # attributes[:rights_license] = Array(attributes[:rights_license]) if attributes.key? :rights_license\n super( attributes )\n end", "def setfillcolorind(*)\n super\n end", "def coerce_attribute_definition(defn)\n defn = coerce_symbolized_hash(defn)\n defn[:domain] = coerce_domain(defn[:domain])\n if defn.key?(:default)\n defn[:default] = coerce_default_value(defn[:default], defn[:domain])\n end\n defn[:mandatory] = coerce_mandatory(defn[:mandatory])\n defn\n end", "def intensifier; end", "def attributes\n self.class.attributes + numeric_attrs\n end", "def quantity_discount_attributes=(quantity_discount_attributes)\n quantity_discount_attributes.each do |attributes|\n if attributes[:id].blank?\n quantity_discounts.build(attributes)\n else\n quantity_discount = quantity_discounts.detect { |q| q.id == attributes[:id].to_i }\n quantity_discount.attributes = attributes\n end\n end\n end", "def stadium; end", "def generate_non_singular!\n @colt_property.generateNonSingular(@colt_matrix)\n end", "def unset_denormalized_value_for_all(attribute_name, conditions = \"1\")\n unset_denormalized_values_for_all(attribute_name, conditions)\n end", "def attribute_values \n @attribute_values = Hash.new\n @attribute_values[:influencers] = \"Influencers: \" + self.influencers.to_s\n @attribute_values[:specialties] = \"Specialities: \" + self.specialties.to_s\n @attribute_values[:compensation] = \"Compensation: \" + self.compensation.to_s\n @attribute_values[:experience] = \"Experience: \" + self.experience.to_s\n \n @attribute_values[:genre] = \"Genre(s): \"\n if self.genre != nil\n self.genre.split(\",\").each do |genre|\n @attribute_values[:genre] += genre + \", \"\n end\n @attribute_values[:genre] = @attribute_values[:genre][0, @attribute_values[:genre].length-2]\n end\n \n @attribute_values\n end", "def attribute_values \n @attribute_values = Hash.new\n @attribute_values[:influencers] = \"Influencers: \" + self.influencers.to_s\n @attribute_values[:specialties] = \"Specialities: \" + self.specialties.to_s\n @attribute_values[:compensation] = \"Compensation: \" + self.compensation.to_s\n @attribute_values[:experience] = \"Experience: \" + self.experience.to_s\n \n @attribute_values[:genre] = \"Genre(s): \"\n if self.genre != nil\n self.genre.split(\",\").each do |genre|\n @attribute_values[:genre] += genre + \", \"\n end\n @attribute_values[:genre] = @attribute_values[:genre][0, @attribute_values[:genre].length-2]\n end\n \n @attribute_values\n end", "def attribute_values \n @attribute_values = Hash.new\n @attribute_values[:influencers] = \"Influencers: \" + self.influencers.to_s\n @attribute_values[:specialties] = \"Specialities: \" + self.specialties.to_s\n @attribute_values[:compensation] = \"Compensation: \" + self.compensation.to_s\n @attribute_values[:experience] = \"Experience: \" + self.experience.to_s\n \n @attribute_values[:genre] = \"Genre(s): \"\n if self.genre != nil\n self.genre.split(\",\").each do |genre|\n @attribute_values[:genre] += genre + \", \"\n end\n @attribute_values[:genre] = @attribute_values[:genre][0, @attribute_values[:genre].length-2]\n end\n \n @attribute_values\n end", "def characteristics=(value)\n unless value.nil?\n self[:characteristics] = value.map{|characteristic| Calculated::Models::Characteristic.new(characteristic)}\n end\n end", "def set_double(attr, val); end", "def set_double(attr, val); end", "def collect_attribute_labels(original_data)\n original_data.keys\nend", "def custom_constrained_attributes\n collect_attributes { |element_name, attrdef| attrdef.custom == \"true\" && attrdef.constrained == \"true\" }\n end", "def all_no=(val)\n BOOL_ATTRIBUTES.each do |attr|\n self.instance_variable_set(\"@#{attr}\",val)\n end\n end", "def upsample_discrete! upsample_factor, filter_order\n @data = DiscreteResampling.upsample @data, @sample_rate, upsample_factor, filter_order\n @sample_rate *= upsample_factor\n return self\n end", "def collegiate_rivals\n end", "def cellarray(xmin, xmax, ymin, ymax, dimx, dimy, color)\n super(xmin, xmax, ymin, ymax, dimx, dimy, 1, 1, dimx, dimy, int(color))\n end", "def cellarray(xmin, xmax, ymin, ymax, dimx, dimy, color)\n super(xmin, xmax, ymin, ymax, dimx, dimy, 1, 1, dimx, dimy, int(color))\n end", "def normalize_blank_values\n attributes.each do |column, value|\n self[column].present? || self[column] = nil\n end\n end", "def initialize(hypos, alpha=1.0)\n super\n hypos.each {|hypo| set(hypo, hypo**(-alpha)) }\n normalize\n end", "def run_values_to_ranges\n GRADES.each do |grade|\n classifier[grade].each_pair do |metric, value|\n classifier[grade][metric] = {\n threshold: value,\n range: ThresholdToRange.new(\n metric, value, grade, reversed: ->(m) { reversed_metrics.include?(m) }\n ).range\n }\n end\n end\n end", "def normalize!\n constant = @terms.select{ |t| t.is_a? Numeric }.inject(:+)\n hterms = @terms.select{ |t| t.is_a? Ilp::Term }.group_by(&:var)\n @terms = []\n constant ||= 0\n @terms << constant\n hterms.each do |v, ts| \n t = ts.inject(Ilp::Term.new(v, 0)) { |v1, v2| v1.mult += v2.mult; v1 }\n terms << t if t.mult != 0\n end\n self\n end", "def nonuniformcellarray(x, y, dimx, dimy, color)\n raise ArgumentError unless x.length == dimx + 1 && y.length == dimy + 1\n\n super(x, y, dimx, dimy, 1, 1, dimx, dimy, int(color))\n end", "def default_set(v)\n (sigmoid(v) * 2) - 1\n end", "def downsample_discrete! downsample_factor, filter_order\n @data = DiscreteResampling.downsample @data, @sample_rate, downsample_factor, filter_order\n @sample_rate /= downsample_factor\n return self\n end", "def get_rain_range_colors\n { 0..0.10 => :blue,\n 0.11..0.20 => :purple,\n 0.21..0.30 => :teal,\n 0.31..0.40 => :green,\n 0.41..0.50 => :lime,\n 0.51..0.60 => :aqua,\n 0.61..0.70 => :yellow,\n 0.71..0.80 => :orange,\n 0.81..0.90 => :red,\n 0.91..1 => :pink\n }\n end", "def determine_values\n { :inter_x => calculated_dimension_delta(@scaled_meta.domain_x),\n :delta_x => @scaled_meta.domain_x.step,\n :inter_y => calculated_dimension_delta(@scaled_meta.domain_y),\n :delta_y => @scaled_meta.domain_y.step }\n end", "def normalized_attributes\n Buildable.normalize_attributes(@attributes ||= {})\n end", "def create_smart_attribute_methods\n denormalized_attribute_names.each do |denormalized_attribute_name|\n base_method_name = denormalized_attribute_base_name(denormalized_attribute_name)\n define_method(base_method_name) do\n if may_use_denormalized_value?(denormalized_attribute_name)\n self.send(denormalized_attribute_name)\n else\n self.send(self.class.denormalized_compute_method_name(denormalized_attribute_name))\n end\n end\n end\n end", "def initialize(attributes={})\n super\n attributes[:type] ||= T_REGULAR\n end", "def normalize!\n end", "def numeric_attrs\n int_attrs + float_attrs\n end", "def normalized(attribute)\n @normalized ||= csf\n (@normalized.respond_to?(attribute)) ? @normalized.send(attribute) : []\n end", "def normalize; end", "def categorize_on_attr(send_name)\n categories = Hash.new { |h,k| h[k] = [] }\n self.each do |elt|\n if !elt.respond_to?(send_name)\n raise \"elt #{elt} doesn't respond to #{send_name}\"\n else\n categories[elt.send(send_name)] << elt\n end\n end\n categories\n end", "def initialize(attributes = {})\n self.class.set_attrb_accessors\n\n #cheeto = Student.new(name: \"cheeto\", grade: 6)\n attributes.each do |property, value|\n #interpolation converts symbol to string\n self.send(\"#{property}=\", value)\n end\n end", "def attribute *array\n return self if guard *array\n r = self.clone\n a = array.flatten\n n_full_pairs, n_unpaired = a.length.divmod 2\n (1..n_full_pairs + n_unpaired).each do |i|\n r << '[' + a.shift\n r << '=' + a.shift unless i > n_full_pairs\n r << ']'\n end\n CssString.new r\n end", "def labeled\r\n attrs.fetch(:labeled, {})\r\n end", "def semi_bandwidth\n @colt_property.semiBandwidth(@colt_matrix)\n end", "def chomsky_normal_form\n raise NotImplementedError \n end", "def calculate_irreducibles\n @irreducibles = make_default_set(@lattice.index_lex)\n for x in @lattice do\n if @lattice.upper_covers[x].count() == 1 then\n @irreducibles.add(x)\n end\n end\n end", "def attribute_values\n @attribute_values ||= {}\n end", "def all=(val)\n self.red = val\n self.green = val\n self.blue = val\n end", "def blue=(num)\n @blue = constrain num, 0..255\n end", "def setscale(*)\n super\n end", "def transform_attr(key, value); end", "def denormalize attributes\n return object_class.new if attributes.nil?\n\n object = object_class.new\n\n attribute_names.each do |attr_name|\n attr_value = attributes[attr_name] || attributes[attr_name.to_s]\n\n object.send(:\"#{attr_name}=\", attr_value)\n end # each\n\n object\n end", "def attrs_authoritative\n @authority = :attributes\n self\n end", "def apply_attributes_relationship!\n return unless attributes_groups\n\n self.calculator = ::Sheet::Calculator.new\n save_attributes_as_variables\n\n calculate_equipment_modifiers\n calculate_group_points\n calculate_based_attributes\n calculate_attributes_formula\n\n # TODO: remember to never modify the points of any attribute. Save\n # in separated fields and use the method `value` to sum them up\n\n # TODO: never let an attribute be based on another based attribute\n # Can it be based on a type=table group? To do that I need to parse the table\n # groups before everything, but the points will not be ready yet\n self\n end", "def model_crucial_params(new_model)\n logger.error \"CRUCIAL_ATTRS undefined for model #{new_model.class}\" unless defined? new_model.class::CRUCIAL_ATTRS\n Hash[new_model.class::CRUCIAL_ATTRS.map { |a| [a, new_model[a]] }]\n end", "def update_attr_with_ial(attr, ial); end", "def normalize(domain); end", "def svg\n values = self[0..2].map do |v|\n v = Range.O.trim( v )\n (255.0 * v).to_i \n end\n return \"rgb(#{values.join(\",\")})\"\n end", "def available_cis_attributes=(attributes)\n # puts \"available_cis_attributes: #{attributes.inspect}\"\n # logger.debug \"Changed: #{changed?} OUTAGE: #{inspect}\"\n assign_attributes(cis_outages_attributes: attributes)\n # logger.debug \"Changed: #{changed?} OUTAGE: #{inspect}\"\n end", "def every=(val)\r\n\r\n self.every__index_was = self.every__index\r\n res = Array(val).compact.map{|i|\r\n case i\r\n when nil\r\n nil\r\n when 1..14 # index\r\n i\r\n when *EVERIES\r\n EVERIES.index(i) + 1\r\n when \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"11\", \"12\", \"13\", \"14\" # index as string\r\n i.to_i\r\n end\r\n }.compact.join(',')\r\n write_attribute(:every, res)\r\nend", "def normalize\n end", "def nonuniformcellarray(x, y, dimx, dimy, color)\n raise ArgumentError unless x.length == dimx + 1 && y.length == dimy + 1\n\n nx = dimx == x.length ? -dimx : dimx\n ny = dimy == y.length ? -dimy : dimy\n super(x, y, nx, ny, 1, 1, dimx, dimy, int(color))\n end", "def define_attribute_methods\n if super\n define_nilify_blank_methods\n end\n end" ]
[ "0.5701719", "0.5652055", "0.53836375", "0.5226976", "0.48273346", "0.4741695", "0.46655294", "0.4654857", "0.46285343", "0.46129662", "0.45786908", "0.45717704", "0.44770524", "0.44707528", "0.44695765", "0.44608656", "0.4457269", "0.44568703", "0.4446897", "0.4440583", "0.44321316", "0.44112933", "0.4406798", "0.43651238", "0.43641302", "0.43606862", "0.43550473", "0.43475914", "0.4344016", "0.43383205", "0.43376166", "0.43339545", "0.43238747", "0.43163207", "0.43156195", "0.4313702", "0.4308785", "0.43049625", "0.4281081", "0.42786038", "0.42717287", "0.42611337", "0.42593893", "0.42429537", "0.42408228", "0.4237226", "0.42368588", "0.4236766", "0.4236766", "0.4236766", "0.42344356", "0.42296252", "0.42296252", "0.42239934", "0.42219225", "0.421414", "0.42113516", "0.4207566", "0.42069885", "0.42069885", "0.41951883", "0.41938", "0.4191456", "0.41781121", "0.41767365", "0.41756734", "0.41743606", "0.41738144", "0.41734657", "0.41729236", "0.41703582", "0.4170141", "0.41684905", "0.41648793", "0.41620484", "0.41536552", "0.41522327", "0.4140028", "0.41393068", "0.41392392", "0.4137263", "0.41237327", "0.41207957", "0.4115794", "0.41039032", "0.41010907", "0.41009387", "0.40972376", "0.40908924", "0.40902272", "0.40830848", "0.40782142", "0.40775448", "0.40735134", "0.40702274", "0.4070054", "0.4069256", "0.40662622", "0.40654972", "0.40635008" ]
0.49085897
4
Return an array of new ArffFile objects split on the given attribute
def split_on_attribute(attribute) index = find_index_of_attribute(attribute) splitted_stuff = {} @attributes[index][:nominal_attributes].each do |attribute_value| splitted_stuff[attribute_value] = [] end #then remove that attribute? @data.each do |data| splitted_stuff[data[attribute]] << data.clone end ret = {} splitted_stuff.each do |key, value| ret[key] = ArffFile.new(@relation_name.clone, @attributes.clone, value.clone, @class_attribute.clone).remove_attribute(attribute) end ret end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def retrieve(attribute)\n attributes = []\n @files.each do |file|\n attributes.push(file[attribute.to_s]) if file[attribute.to_s].present?\n end\n attributes\n end", "def split() File.split(@path).map {|f| self.class.new(f) } end", "def get\n arr = []\n\n process(csv_file).each do |record|\n arr << SOA_CSV_RECORD.new(*record.fields)\n end\n\n arr\n end", "def split_attr(at)\n if @data.nil?\n return []\n end\n \n y = @data[at]\n if !y.nil?\n if y.is_a? Array\n return y\n else\n return y.split(\" \")\n end\n end\n return []\n end", "def arraycreate(filename)\n\tarray = IO.readlines(filename)\n\tselector(array, filename)\nend", "def arraycreate(filename)\n\tarray = IO.readlines(filename)\n\tselector(array, filename)\nend", "def parse(output) #:nodoc:\n volumes = []\n\n output.split(\"\\n\").each do |line|\n args = process_line(attributes, line)\n\n # now we force some types to ints since we've requested them as bytes\n # without a suffix\n args[:size] = args[:size].to_i\n\n # we resolve the attributes line to nicer symbols\n args.merge!(parse_vg_attr(args[:attr]))\n\n # finally build our object\n volume = VolumeGroup.new(args)\n\n if block_given?\n yield volume\n else\n volumes << volume\n end\n end\n\n return volumes\n end", "def constructListFromFile(input)\n\t\t\tresult = Array.new()\n\t\t\tsize = input.size/6\n\t\t\tfor i in 0..size-1\n\t\t\t\talimento = Alimento.new(input[6*i], input[6*i+1].to_f, input[6*i+2].to_f, input[6*i+3].to_f, input[6*i+4].to_f, input[6*i+5].to_f)\n\t\t\t\tresult.append( alimento )\n\t\t\tend\n\t\t\treturn result\n\t\tend", "def to_array\n return [@filename,\n @timestamp,\n @source,\n @rmr_number,\n @series_description,\n @gender,\n @slice_thickness,\n @slice_spacing,\n @reconstruction_diameter, \n @acquisition_matrix_x,\n @acquisition_matrix_y]\n end", "def split() File.split(path).map {|f| Path::Name.new(f) } end", "def record_to_array(marc_field)\n record_values = []\n marc_field, sub_field = marc_field.split('.')\n to_marc.find_all {|f| marc_field == f.tag}.each do |entry|\n unless entry[sub_field].nil?\n record_values.push(entry[sub_field])\n # or clean the record first\n # record_values.push(clean_record(entry[sub_field])\n end\n end\n record_values\n end", "def as_array\n @fm.dup\n end", "def read_binary_array(fname,fd,length)\n ary = []\n\n # first: read object refs\n if(length != 0) then\n buff = fd.read(length * @object_ref_size)\n objects = buff.unpack(@object_ref_size == 1 ? \"C*\" : \"n*\")\n\n # now: read objects\n 0.upto(length-1) do |i|\n object = read_binary_object_at(fname,fd,objects[i])\n ary.push object\n end\n end\n\n return CFArray.new(ary)\n end", "def build_cls_list(file_name, arr)\n file = File.open(file_name, \"r\")\n while !file.eof?\n line = file.readline.chomp\n arr.push(line)\n end\n file.close\nend", "def parse_file\n parsed_result_blocks = get_record_blocks\n\n gff_array = []\n if !parsed_result_blocks.empty?\n parsed_result_blocks.each do |b|\n gff_array << line_to_gff(b)\n end\n end\n return gff_array\n end", "def parse(output)\n volumes = []\n\n output.split(\"\\n\").each do |line|\n\n args = parse_attributes(line)\n\n\n # finally build our object\n volume = Disk.new(args)\n\n\n if block_given?\n yield volume\n else\n volumes << volume\n end\n end\n\n return volumes\n end", "def path_array\n a = []\n each_filename { |ea| a << ea }\n a\n end", "def generate_cards\n # no need to assign or return @cards here.\n # switching from .each to .map implictly returns the updated array\n # call the generate_cards during initialize to assign to instance variable\n File.open(@filename).map do |line|\n question = line.split(',')[0]\n answer = line.split(',')[1]\n category = line.split(',')[2].delete(\"\\n\")\n card = Card.new(question, answer, category)\n end\n end", "def get_exif_by_entry(*entry)\n ary = []\n if entry.length.zero?\n exif_data = self['EXIF:*']\n exif_data.split(\"\\n\").each { |exif| ary.push(exif.split('=')) } if exif_data\n else\n get_exif_by_entry # ensure properties is populated with exif data\n entry.each do |name|\n rval = self[\"EXIF:#{name}\"]\n ary.push([name, rval])\n end\n end\n ary\n end", "def load\n arr = []\n begin\n while([email protected]?)\n line = @file.readline.chomp\n arr.concat(line.split)\n end\n ensure\n @file.close\n end\n arr\n end", "def import\n @@files_array.collect { |filename| Song.create_from_filename(filename) } \n end", "def convert_to_array(attr)\n attr = attr.split(',')\n return attr\nend", "def card_on_file(card)\n all_cards = cards.map(&:card)\n end", "def files\n array = []\n @list.each do |k,v|\n array += v.filename\n end\n array\n end", "def to_a\n @file_list.map{ |file| Pathname.new(file) }\n end", "def parse_csv_file(delim, file_name) \n \n temp_array = Array.new #Create an array\n file = File.open(file_name, \"r\") #Open a file for reading\n \n \n #Iterate file, parse strings and store\n file.each_line do |line|\n temp_array.push(parse_line(delim, line))\n end\n\n #Close resource\n file.close\n \n return temp_array\nend", "def make_team_array(file_name)\n\n array_of_hashes=get_data(file_name)\n\n @teams=[]\n array_of_hashes.each do |hashes|\n @teams.push(hashes[:Team])\n end\n @teams.uniq\nend", "def make_team_array(file_name)\n\n array_of_hashes=get_data(file_name)\n\n @teams=[]\n array_of_hashes.each do |hashes|\n @teams.push(hashes[:Team])\n end\n @teams.uniq\nend", "def flistf\n return $fframes.to_a\nend", "def getAnts(groupName)\n\n result = `/home/obs/ruby/bin/fxconf.rb sals`\n\n list = [];\n\n # Get the antennas in the \"groupName\" group\n result.each do |line| \n line = line.chomp.strip; \n if(line.include?(groupName) == true) \n parts = line.chomp.split(/\\s+/);\n parts[1..-1].each do |a|\n list << Ant.new(a);\n end\n end\n end \n return list; \nend", "def parse_attribute_as_array_of(name, data, klass)\n value = data.class != Array || data.empty? ? [] : data.collect { |i| klass.new(i) }\n instance_variable_set(\"@#{name.to_s.underscore}\", value)\n end", "def createFileNameArr\n # Build Mirror Array of Filenames\n @fileNameArr.each do |filename|\n filename.gsub!(\" \", \"-\")\n end\n\n end", "def gen_array_attribute_filters(object, attributes)\n attributes.map { |filter_name| gen_object_filter(object, filter_name, filter_name) }\n end", "def extract_files(an_array)\n files = []\n an_array.reverse.each do |a_file|\n next if a_file.empty?\n next if a_file.start_with?(' ')\n break if a_file.start_with?('Date:')\n files << a_file # .split(\"\\t\").last\n end\n return files.sort\nend", "def create_upload_files(record)\n return unless record.mapper.respond_to?(:files)\n files_to_attach = record.mapper.files\n return [] if files_to_attach.nil? || files_to_attach.empty?\n\n uploaded_file_ids = []\n files_to_attach.each do |filename|\n file = File.open(find_file_path(filename))\n uploaded_file = Hyrax::UploadedFile.create(user: depositor, file: file)\n uploaded_file_ids << uploaded_file.id\n file.close\n end\n uploaded_file_ids\n end", "def to_a\n ::Dir.glob(path + '/*').collect {|pth| UFS::FS::File.new(pth)}\n # Uncomment the following to return File & Dir objects instead of Strings.\n # ::Dir.glob(path + '/*').collect {|pth| UFS::FS.new pth}\n end", "def process_readable(source, attributes)\n if attributes['filename']\n name = attributes['filename']\n elsif source.respond_to?(:filename)\n name = source.filename\n else\n begin\n name = File.basename(source)\n rescue TypeError\n raise ArgumentError, \"Error: Could not determine filename from source, try: `Sablon.content(readable_obj, filename: '...')`\"\n end\n end\n #\n [File.basename(name), source.read]\n end", "def acquire_element_array_list\n element_array_list = []\n (0..7).each do |number|\n element_file_name = ELEMENT_FILE_PREFIX + number.to_s + TEXT_FILE_SUFFIX\n element_array = File.read(element_file_name)\n element_array_list[number] = element_array.split(EXPORT_LIST_SEPARATOR)\n end\n element_array_list\n end", "def iterate_over_file_paths\n parsed_file.each do |hit|\n file_path_array << hit[0]\n end\n file_path_array\n end", "def files\n ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']\n end", "def create_band_array\n band = (0...BandDisplay::FILES.size).to_a.shuffle\n return band + band[0, 3]\n end", "def csv_to_array(file)\n @recipes = []\n CSV.foreach(file){|row| @recipes << Recipe.new(row[0], row[1].to_i, row[2].to_i, row[3].to_i)}\n end", "def import_attributes(array)\n index = 0\n map_values = Array.new \n\n while index < array.length\n current_line = array[index].strip\n #puts current_line\n if assert_tag(\"map\", current_line)\n map_values = Map.extract_tag(\"map\", current_line)\n index = array.length\n end\n index = index.next\n end\n\n if map_values.length >= 7\n self.name = map_values[0]\n self.container_width = map_values[1]\n self.container_height = map_values[2]\n self.width = map_values[3]\n self.height = map_values[4]\n self.tile_width = map_values[5]\n self.tile_height = map_values[6]\n end\n end", "def files\n entries.map{ |f| FileObject[path, f] }\n end", "def attr_split\n expr.attr_split.each_pair.each_with_object({}) do |(k,v),h|\n h[k] = Predicate.new(v)\n end\n end", "def to_a()\n array = @basenameList.map{|basename|\n @analyzerTable[basename] ;\n }\n return array ;\n end", "def make_sliced_file(flist)\n flist_sliced = []\n flist.each_with_index do |v, i|\n # 開始時のファイルはスライスしない\n if i == 0\n flist_sliced << v\n else\n tmp_file = \"/tmp/sound_#{i}.mp3\"\n silent_files = (Sound::SILENT_FILE_PATH + \" \") * i\n cmd = \"sox #{silent_files} #{v} #{tmp_file}\"\n result = `#{cmd}`\n flist_sliced << tmp_file\n end\n end\n return flist_sliced\n end", "def get_file_array(path)\n array = []\n File.open(path) do |f|\n f.each_line do |line|\n array.push(line)\n end\n end\n return array\nend", "def import\n#song_by_filename\n files.each{|f| Song.new_by_filename(f)}\n\nend", "def load_file(f)\n\t\tdata = []\n f.each do |line| \n user_id, movie_id, rating, timestamp = line.split(\"\\t\")\n data.push({\"user_id\"=> user_id.to_i, \"movie_id\"=>movie_id.to_i,\"rating\"=> rating.to_i,\"timestamp\"=>timestamp.to_i})\n\t\tend\n\t\treturn data\n\tend", "def by_file\n @by_file ||= notes.group_by(&:file)\n end", "def list\n ret = get()\n return [] if ret.is_a? Hash and ret.has_key? :error\n ret.map{|i| FileItem.new(i)}\n end", "def get_file(row, obj_identifier)\n gf_pid = row['id']\n gf_identifier = row['identifier']\n obj_id = @new_id_for[row['intellectual_object_id']]\n gf = {}\n gf['file_format'] = row['file_format']\n gf['uri'] = row['uri']\n gf['size'] = row['size']\n gf['intellectual_object_id'] = obj_id\n gf['identifier'] = gf_identifier\n gf['state'] = row['state']\n gf['created_at'] = row['created_at']\n gf['updated_at'] = row['updated_at']\n gf['checksums_attributes'] = get_checksums(gf_pid, gf_identifier)\n gf['premis_events_attributes'] = get_file_events(gf_pid, obj_identifier)\n gf\n end", "def create_rides(arr_file, arr_id)\n drivers = create_drivers(arr_id)\n\n arr_file.each do |item|\n arr_input = item.split(\",\")\n h_ride = {date:arr_input[1], cost:arr_input[2].to_f, ride:arr_input[3], rate:arr_input[4].to_i}\n id = arr_input[0]\n idx = arr_id.index(id)\n drivers[idx][:rides].push(h_ride)\n end\n\n return drivers\nend", "def file_attributes\n get_attributes_set(:FILE_ATT_LOOKUPS)\n end", "def file_attributes\n get_attributes_set(:FILE_ATT_LOOKUPS)\n end", "def parse_file(file_class)\n lines = []\n while line = @file_desc.gets\n lines << file_class.parse_line(line)\n end\n lines\n end", "def readfile\n features=[]\n feature=''\n data_range=''\n price=''\n \n File.open(\"./public/test.txt\", \"r\").each_line do |line|\n feature = line.scan(/([a-zA-z ]+ \\– [0-9]+)/).to_s.strip()\n date_range= line.scan(/([0-9\\/]+ \\– [0-9]+\\/[0-9]+)/).to_s\n price = line.scan(/( [0-9]+\\.[0-9]+)/).to_s.strip()\n this_feature={\n \"feature\" => feature,\n \"date_range\" => date_range,\n \"price\" => price\n \n }\n features << this_feature\n \n \n end\n\n return features\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 file_record(attrs)\n file_set = FileSet.new\n file_attributes = Hash.new\n\n # Singularize non-enumerable attributes and make sure enumerable attributes are arrays\n attrs.each do |k, v|\n if file_set.attributes.keys.member?(k.to_s)\n file_attributes[k] = if !file_set.attributes[k.to_s].respond_to?(:each) && file_attributes[k].respond_to?(:each)\n v.first\n elsif file_set.attributes[k.to_s].respond_to?(:each) && !file_attributes[k].respond_to?(:each)\n Array(v)\n else\n v\n end\n end\n end\n\n file_attributes['date_created'] = attrs['date_created']\n file_attributes['visibility'] = attrs['visibility']\n unless attrs['embargo_release_date'].blank?\n file_attributes['embargo_release_date'] = attrs['embargo_release_date']\n file_attributes['visibility_during_embargo'] = attrs['visibility_during_embargo']\n file_attributes['visibility_after_embargo'] = attrs['visibility_after_embargo']\n end\n\n file_attributes\n end", "def files\n @files_array ||= Dir.glob(\"#{@path}/*.mp3\").collect do |filename|\n filename.rpartition(\"/\").last \n end \n end", "def to_ary\n lines.take(1000).map { |l| { :number => l.filtered_number, :file => l.filtered_file, :method => l.filtered_method, :source => l.source } }\n end", "def load_attributes!\n self.flexi_fields.map { |f| self.send(f.name.to_sym) }\n end", "def file_fields\n @file_fields ||= []\nend", "def test_arff_parse\n in_file = './test_arff.arff'\n rel = Rarff::Relation.new\n rel.parse(File.open(in_file).read)\n\n assert_equal(rel.instances[2][1], 3.2)\n assert_equal(rel.instances[7][4], 'Iris-setosa')\n end", "def map_activestorage_files_as_file_objects\n files.map do |file|\n path = file_path_for(file)\n original_filename = file.filename.to_s\n File.open(path) do |f|\n # We're exploiting the fact that Hydra-Works calls original_filename on objects passed to it, if they\n # respond to that method, in preference to looking at the final portion of the file path, which,\n # because we fished this out of ActiveStorage, is just a hash. In this way we present Fedora with the original\n # file name of the object and not a hashed or otherwise modified version temporarily created during ingest\n f.send(:define_singleton_method, :original_filename, -> { original_filename })\n yield f\n end\n end\n end", "def my_array_splitting_method(source)\nend", "def map_activestorage_files_as_file_objects\n files.map do |file|\n path = file_path_for(file)\n original_filename = file.filename.to_s\n File.open(path) do |f|\n # We're exploiting the fact that Hydra-Works calls original_filename on objects passed to it, if they\n # respond to that method, in preference to looking at the final portion of the file path, which,\n # because we fished this out of ActiveStorage, is just a hash. In this way we present Fedora with the original\n # file name of the object and not a hashed or otherwise modified version temporarily created during ingest\n f.send(:define_singleton_method, :original_filename, ->() { original_filename })\n yield f\n end\n end\n end", "def parse_files(files_a)\n\t\tfiles_a.each do |file_p|\n\t\t\tparse_file(file_p) do |cons|\n\t\t\t\tyield(cons)\n\t\t\tend\n\t\tend\n\tend", "def get_all_values_for_attribute( attribute )\n xml = self.xml( nil, attribute.to_a, nil )\n #puts \"----\\n#{xml}\\n----\"\n tsvdata = self.post_query( xml )\n #puts \"----\\n#{tsvdata}\\n----\"\n \n values = []\n data_by_line = tsvdata.split(\"\\n\")\n data_by_line.each do |d|\n values.push( d )\n end\n \n return values\n end", "def build_data_array\n table = helper_class.new(@file_upload.file.path).to_table # # load data to array of hashes\n errors = []\n data = table.map do |item_hash|\n process_item(attributes(item_hash), errors)\n end\n [data, errors]\n end", "def read_object_array(cls, io_offset, length)\n @io.seek io_offset\n array = []\n length.times do\n # All object arrays only contain java object refs\n id = @io.read_id\n array << @snapshot.resolve_object_ref(id)\n end\n array\n end", "def strip(attribute, struct = @structure)\n if struct.instance_of? Array\n data = []\n struct.each { |item| data << strip(attribute, item) }\n return data\n else\n struct.method(attribute).call\n end\n end", "def read_members\n @@member_array = []\n lines = File.readlines('members.txt')\n lines.each do| line |\n line_parts = line.split('/')\n\n member_id = line_parts[0].to_i\n member_name = line_parts[1]\n book_id_1 = line_parts[2].to_i\n book_id_2 = line_parts[3].to_i\n book_id_3 = line_parts[4].to_i\n\n @@member_array << Member.new(member_id, member_name, book_id_1, book_id_2, book_id_3) #class implementation\n end #do\n write_array_to_file\n # pp @@member_array #test\n puts \"\\n\\n\"\n end", "def extract_files(lines)\n lines.drop_while { |line| !line.match?(FILE_MARKER) }\n .slice_before(FILE_MARKER).map do |slice|\n # The first element of the slice is a file marker. Therefore it's\n # removed from the slice and parsed separately.\n file_marker = slice.shift.match(FILE_MARKER)\n File.new(name: file_marker[:filename],\n data: slice.join)\n end\n end", "def cards\n # Read the text file by line removing newline characters. Each line is an element in the card_data array.\n card_data = IO.readlines(@filename, chomp: true)\n\n # Split each element by comma. The comma delineates all attributes of each Card attribute. This makes it so each Card object attributes is an array, with each element being a different attribute.\n # Card = [:question, :answer, :category]\n card_data.map! { |card| card.split(',') }\n\n # Take each Card element and set each element into a new Card object to return.\n card_data.map { |card| Card.new(card[0], card[1], card[2].to_sym) }\n end", "def each_property\n IO.readlines(path).each do |l|\n begin\n stripped = l.strip.encode(\"UTF-8\")\n if stripped.match(/^\\-\\-\\s+sem\\.attribute\\./)\n stripped.sub!(/^\\-\\-\\s+sem\\.attribute\\./, '')\n name, value = stripped.split(/\\=/, 2).map(&:strip)\n yield name, value\n end\n rescue Encoding::InvalidByteSequenceError\n # Ignore - attributes must be in ascii\n end\n end\n rescue Encoding::InvalidByteSequenceError\n # Ignore - file must be in ascii in order to parse attributes\n end", "def find_apf( path_and_file = self.file_name_and_contents.path_and_file)\n match_apf = []\n regexp = /^t([^ \\#]+)( *$| )/\n File_name_and_contents.new( path_and_file ).contents.each do |line|\n if line.match(regexp) != nil\n if line.match(regexp)[1] != nil \n match_apf << ( self.file_name_and_contents.path_and_file.sub(/\\/.+/, '') + '/' + line.match(regexp)[1].chomp + '.apf' ) \n end\n end\n end\n match_apf\n end", "def splitByFile\n outfile = nil\n stream = open(@filename)\n until (stream.eof?)\n line = stream.readline\n\n # we need to create a new file\n if (line =~ /--- .*/) == 0\n if (outfile) \n outfile.close_write\n end\n #find filename\n tokens = line.split(\" \")\n tokens = tokens[1].split(\":\")\n tokens = tokens[0].split(\"/\")\n filename = tokens[-1]\n filename << \".patch\"\n if File.exists?(filename)\n puts \"File #{filename} already exists. Renaming patch.\"\n appendix = 0\n while File.exists?(\"#{filename}.#{appendix}\")\n appendix += 1\n end\n filename << \".#{appendix}\"\n end\n outfile = open(filename, \"w\")\n outfile.write(line)\n else\n if outfile\n outfile.write(line)\n end\n end\n end\n end", "def flistr fname\n flist = []\n if fexistr fname\n eval \"$#{fname}.each\" do |i|\n sname,ftype = i.split \",\"\n if ftype.eq \"ref\"\n flist.push sname\n end \n end\n end\n return flist\nend", "def split_input filename, pieces\n input = {}\n name = nil\n seq=\"\"\n sequences=0\n output_files=[]\n if pieces > 1\n File.open(filename).each_line do |line|\n if line =~ /^>(.*)$/\n sequences+=1\n if name\n input[name]=seq\n seq=\"\"\n end\n name = $1\n else\n seq << line.chomp\n end\n end\n input[name]=seq\n # construct list of output file handles\n outputs=[]\n pieces = [pieces, sequences].min\n pieces.times do |n|\n outfile = \"#{filename}_chunk_#{n}.fasta\"\n outfile = File.expand_path(outfile)\n outputs[n] = File.open(\"#{outfile}\", \"w\")\n output_files[n] = \"#{outfile}\"\n end\n # write sequences\n count=0\n input.each_pair do |name, seq|\n outputs[count].write(\">#{name}\\n\")\n outputs[count].write(\"#{seq}\\n\")\n count += 1\n count %= pieces\n end\n outputs.each do |out|\n out.close\n end\n else\n output_files << filename\n end\n output_files\n end", "def ret_array(_array, _ret, _id)\n if !_ret.nil?\n _ret.each do |_r|\n _array = _array << _r.read_attribute(_id) unless _array.include? _r.read_attribute(_id)\n end\n end\n end", "def ret_array(_array, _ret, _id)\n if !_ret.nil?\n _ret.each do |_r|\n _array = _array << _r.read_attribute(_id) unless _array.include? _r.read_attribute(_id)\n end\n end\n end", "def ret_array(_array, _ret, _id)\n if !_ret.nil?\n _ret.each do |_r|\n _array = _array << _r.read_attribute(_id) unless _array.include? _r.read_attribute(_id)\n end\n end\n end", "def ret_array(_array, _ret, _id)\n if !_ret.nil?\n _ret.each do |_r|\n _array = _array << _r.read_attribute(_id) unless _array.include? _r.read_attribute(_id)\n end\n end\n end", "def fetch(group, id_or_name, attribute_name)\n return [] if attribute_name.empty?\n attribute_name = normalize_attribute_name(attribute_name)\n value = entry(group, id_or_name)[attribute_name]\n value ? value.dup : []\n end", "def nf_parse_files(files_a)\n\t\tfiles_a.each do |file_p|\n\t\t\tnf_parse_file(file_p) do |cons|\n\t\t\t\tyield(cons)\n\t\t\tend\n\t\tend\n\tend", "def parse_attributes! #:nodoc:\n self.attributes = (attributes || []).map do |attr|\n Barbecue::Generators::GeneratedAttribute.parse(attr)\n end\n end", "def split(file)\n if m = file.match(/^(.*\\/)?([^\\.]+)\\.?(\\w+)?\\.?(\\w+)?\\.?(\\w+)?$/)\n if m[5] # Multipart formats\n [m[1], m[2], \"#{m[3]}.#{m[4]}\", m[5]]\n elsif m[4] # Single format\n [m[1], m[2], m[3], m[4]]\n else\n if valid_extension?(m[3]) # No format\n [m[1], m[2], nil, m[3]]\n else # No extension\n [m[1], m[2], m[3], nil]\n end\n end\n end\n end", "def array_by_40_characters \n recieve_and_read_file.scan(/.{1,40}/)\n end", "def adjacent_files\n files = []\n files << file_names[x - 1] unless file == :a\n files << file_names[x + 1] unless file == :h \n files\n end", "def initialize(array_to_split)\n @array_to_split = array_to_split\n end", "def separateInArrays params \r\n\tvalidCoupons = Array.new\r\n\torders \t\t = Array.new\r\n\torderItems = Array.new\r\n\tproducts = Array.new\r\n\toutputFile = nil\r\n\r\n\tparams.each do |param|\r\n\t\tcase param\r\n\t\t\twhen 'coupons.csv'\r\n\t\t\t\tverifyIfValidDiscount param, validCoupons\r\n\t\t\twhen 'order_items.csv'\r\n\t\t\t\tpushToArray param, orderItems\r\n\t\t\twhen 'orders.csv'\r\n\t\t\t\tpushToArray param, orders\r\n\t\t\twhen 'products.csv'\r\n\t\t\t\tpushToArray param, products\r\n\t\t\twhen 'output.csv'\r\n\t\t\t\toutputFile = param\r\n\t\t\t\tpushToArray param, orderItems\r\n\t\t\telse\r\n\t\t\t\t# stop program if invalid file is passed\r\n\t\t\t\tputs 'arquivo \"' + param + '\" é inválido! passe arquivos válidos para o programa e tente novamente!'\r\n\t\t\t\tabort\r\n\t\tend\r\n\tend\r\n\t\r\n\treturn validCoupons, orders, orderItems, products, outputFile\r\nend", "def get_variable(variable)\n\n survey_name = Survey.find(variable.survey_id).original_filename\n values_array = Array.new\n #open the dataset\n csvfile = FCSV.open( 'filestore/datasets/' + survey_name, :headers => true, :return_headers => true,:col_sep => \"\\t\")\n #skip past first line with the headers\n csvfile.gets\n #add the header as the first value of the array\n values_array.push(variable.name)\n #read each line of values\n while (line = csvfile.gets!=nil)\n #current value for this particular variable\n values_array.push(line.field[variable.name])\n end\n csvfile.close\n return values_array\n\n end", "def loadAttributes(attribType)\n result = []\n\n # ad is an attribute descriptor.\n @list.each do |ad|\n next unless ad['attrib_type'] == attribType\n\n # Load referenced attribute and add it to parent.\n result += @boot_sector.mftEntry(ad['mft']).loadAttributes(attribType)\n end\n\n result\n end", "def analyze_file()\n arrayLinAnaly=[]\n linenum=0\n File.foreach('test.txt') do |line|\n arrayLinAnaly << LineAnalyzer.new(line, linenum)\n linenum+=linenum\n end\n return arrayLinAnaly\n end", "def le_arquivoL (arq)\n l = Array.new\n text = File.open(arq).read\n text.gsub!(/\\r\\n?/, \"\\n\")\n text.each_line do |line|\n l = l << line\n end\n return l\n end", "def fetch_scenarios\n scenarios = []\n text = file_raw\n while match = FeatureElement::Scenario::PATTERN.match(text)\n FeatureElement::Scenario.new(self, match[0]).tap do |scenario|\n# scenarios.push(scenario) if cfm.filter.pass?(scenario.tags)\n scenarios.push(scenario)\n end\n text = match.post_match\n end\n scenarios\n end", "def file_field_sets\n @file_field_sets ||= begin\n # Select only file and instantiation fields.\n file_and_instantiation_fields = fields.select { |field| file_header?(field.header) || instantiation_header?(field.header) }\n\n # Slice the selected fields into field sets for each file.\n file_and_instantiation_fields.slice_when do |prev_field, field|\n initial_file_header?(field.header) && !initial_file_header?(prev_field.header)\n end\n end\n end", "def initialize(file, cat)\n @file = import(file)\n @cards_array = @file.map{|row| FlashCard.new(row) if row[:category] == cat }\n @cards_array.compact!\n end" ]
[ "0.61262554", "0.6109307", "0.5442131", "0.52961385", "0.5243283", "0.5243283", "0.5139335", "0.51194966", "0.5090329", "0.50429493", "0.5019851", "0.49869454", "0.4959345", "0.49237558", "0.49090505", "0.48791775", "0.486143", "0.48350227", "0.48311663", "0.48238683", "0.48171216", "0.4814312", "0.47844854", "0.4778719", "0.4774258", "0.47607988", "0.4729399", "0.4729399", "0.4696165", "0.46954685", "0.46901816", "0.46818754", "0.46814147", "0.46729165", "0.46555164", "0.46510115", "0.4643756", "0.4642889", "0.46404874", "0.46392572", "0.46362782", "0.46316063", "0.46178195", "0.46128127", "0.46100223", "0.46093276", "0.46086007", "0.46021584", "0.45977843", "0.45914584", "0.4590472", "0.45831192", "0.4577791", "0.45694494", "0.4567118", "0.4567118", "0.4554241", "0.45533347", "0.4546146", "0.4543747", "0.45406225", "0.45398402", "0.45340404", "0.4531287", "0.45305714", "0.45261076", "0.4525674", "0.45241612", "0.4519685", "0.45123458", "0.45096153", "0.45053908", "0.4503587", "0.4502866", "0.4496605", "0.44935924", "0.44922385", "0.4483737", "0.4477342", "0.4475689", "0.4466284", "0.44612437", "0.44612437", "0.44612437", "0.44612437", "0.44598514", "0.44536647", "0.44514745", "0.44495183", "0.4443072", "0.44418815", "0.4441529", "0.44401813", "0.4433705", "0.44216788", "0.44187802", "0.4418354", "0.4417358", "0.44171566", "0.4411534" ]
0.70536923
0
Removes an attribute from a dataset. to_remove can be an index or a String or symbol for the attribute name.
def remove_attribute(to_remove) index = 0 if not to_remove.kind_of? Fixnum index = find_index_of_attribute(to_remove) else index = to_remove end # binding.pry if not index.nil? @attributes.delete_at index @data.each do |d| d.delete to_remove end end self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_attribute(name); end", "def remove_attribute(name); end", "def remove_attribute(name); end", "def remove_attribute(name); end", "def - (name) remove_attribute name end", "def remove_attr(name); end", "def remove_attr(name); end", "def remove_attribute(attr)\n C.LLVMRemoveFunctionAttr(self, attr)\n end", "def remove_attribute(name)\n attr = attributes[name].remove if key? name\n clear_xpath_context if Nokogiri.jruby?\n attr\n end", "def del_attribute(opts = {})\n data, _status_code, _headers = del_attribute_with_http_info(opts)\n return data\n end", "def remove_attribute(node_id:, name:)\n {\n method: \"DOM.removeAttribute\",\n params: { nodeId: node_id, name: name }.compact\n }\n end", "def delete(attribute)\n `c$Element.prototype.m$remove_property.call(#{@element},attribute)`\n end", "def removeAttribute(name)\n ret = getAttributeNode(name)\n removeAttributeNode(ret) if ret\n end", "def remove_attribute(name)\n `#{@element}.removeAttribute(#{name})`\n end", "def remove_attr name\n each do |el|\n next unless el.respond_to? :remove_attribute\n el.remove_attribute(name)\n end\n self \n end", "def delete(attribute); end", "def delete_attribute(attr_name)\n debug(\"Model#delete_attribute(#{attr_name.inspect})\")\n set_attribute(attr_name, nil)\n end", "def removed(attribute_name)\n changed(attribute_name)\n end", "def removed(attribute_name)\n changed(attribute_name)\n end", "def kwattr_remove(attribute_name, keywords); end", "def trim_attributes(attributes, to_remove)\n to_remove.each { |a| attributes.delete(a) }\n attributes\n end", "def delete_attribute(key); end", "def remove_attribute(locator, attribute)\n execute_script(%(\n var element = arguments[0];\n var attributeName = arguments[1];\n if (element.hasAttribute(attributeName)) {\n element.removeAttribute(attributeName);\n }\n ), find_element(locator), attribute)\n end", "def remove_attribute(name)\n `#@native.removeAttribute(name)`\n end", "def erase(attr)\n erased << attr.to_s\n end", "def removeAttribute(name)\n `#{@el}.removeAttribute(#{name})`\n end", "def delete(attribute)\n attribute = (\"@\"+attribute).to_sym if attribute.to_s !~ /^@/\n instance_variable_set(attribute.to_sym, nil)\n end", "def delete attrib\n if attrib.is_a? String and attrib.include? \".\"\n syms = attrib.split(\".\")\n first = syms[0]\n rest = syms[1..-1].join(\".\")\n self.send(first).delete(rest)\n else\n self.delete_field(attrib)\n end\n end", "def delete(attribute)\n `c$Element.prototype.m$remove_style.call(#{@element},attribute)`\n end", "def clear_attribute( attribute )\n send(\"#{attribute}=\", nil)\n end", "def reset(attribute)\n @attributes.delete attribute.to_sym\n end", "def delete_attribute(*args)\n end", "def delete_custom_attribute(product_id, attribute_name)\n response, status = BeyondApi::Request.delete(@session, \"/products/#{product_id}/attributes/#{attribute_name}\")\n\n handle_response(response, status, respond_with_true: true)\n end", "def delete(key)\n removeAttribute(key.to_s)\n end", "def delete(key)\n removeAttribute(key.to_s)\n end", "def delete(key)\n removeAttribute(key.to_s)\n end", "def delete_attr!(key)\n copy_on_write if @attrs.shared\n key = key.intern \n old_attrs = @attrs\n @attrs = AttrArray.new\n @attrs_hash = {}\n old_attrs.each do |a|\n put_attr(a) if a.key_symbol != key\n end\n end", "def remove_property(attribute)\n `var el=this.__native__,attr=attribute.__value__,bool=c$Element.__boolean_attributes__[attr],key=c$Element.__boolean_attributes__[attr]||bool`\n `key ? el[key]=bool?false:'' : el.removeAttribute(attr)`\n return self\n end", "def kwattr_remove(attribute_name, keywords)\n if keywords.nil?\n remove_attribute(attribute_name)\n return self\n end\n\n keywords = keywordify(keywords)\n current_kws = kwattr_values(attribute_name)\n new_kws = current_kws - keywords\n if new_kws.empty?\n remove_attribute(attribute_name)\n else\n set_attribute(attribute_name, new_kws.join(\" \"))\n end\n self\n end", "def delete_user_attribute(email_address, attribute)\n found_user = read_user(email_address)\n if found_user\n dn = get_DN(found_user[:cn])\n Net::LDAP.open(@ldap_conf) do |ldap|\n ldap.delete_attribute(dn, ENTITY_ATTR_MAPPING[attribute])\n end\n end\n end", "def destroy\n row.delete_attribute(attr_name)\n row.save\n end", "def remove(*args)\n do_op(:remove, column_family, *args)\n end", "def remove(*args)\n do_op(:remove, column_family, *args)\n end", "def remove_content(attribute_path)\n create_and_execute_edit('REMOVE', attribute_path)\n end", "def remove_catalog_attribute 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_remove_catalog_attribute_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::Retail::V2::AttributesConfig.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def remove_filter(*attributes)\n\n config.remove_filter(*attributes)\n\n end", "def toggle!(attribute)\n toggle(attribute).update_attribute(attribute, self[attribute])\n end", "def delete(attr)\n attr = attr.intern\n if @parameters.has_key?(attr)\n @parameters.delete(attr)\n else\n raise Puppet::DevError.new(\"Undefined attribute '#{attr}' in #{self}\")\n end\n end", "def removeAttributeNode(oldAttr)\n ret = getAttributeNode(oldAttr.nodeName)\n if ret.nil? || ret != oldAttr\n raise DOMException.new(DOMException::NOT_FOUND_ERR)\n end\n @attr.removeNamedItem(oldAttr.nodeName)\n ret.ownerElement = nil\n ret\n end", "def unlink_attribute(asset,attribute_name)\r\n\t\tgraph_element = asset.el\r\n\t\tif master?(asset) && attribute_linked?(asset,attribute_name)\r\n\t\t\tmaster_value = get_attribute( asset, attribute_name, 0 )\r\n\t\t\tslides_for( asset ).to_ary[1..-1].each do |slide|\r\n\t\t\t\taddset = slide.el.at_xpath( \".//*[@ref='##{graph_element['id']}']\" ) || slide.el.add_child(\"<Set ref='##{graph_element['id']}'/>\").first\r\n\t\t\t\taddset[attribute_name] = master_value\r\n\t\t\tend\r\n\t\t\trebuild_caches_from_document\r\n\t\t\ttrue\r\n\t\telse\r\n\t\t\tfalse\r\n\t\tend\r\n\tend", "def remove_tag(artist, tag)\n post(:session, {:method => \"artist.removeTag\", :artist => artist, :tag => tag})\n end", "def attr_unsearchable(*args)\n if table_exists?\n opts = args.extract_options!\n args.flatten.each do |attr|\n attr = attr.to_s\n raise(ArgumentError, \"No persisted attribute (column) named #{attr} in #{self}\") unless self.columns_hash.has_key?(attr)\n self._metasearch_exclude_attributes = self._metasearch_exclude_attributes.merge(\n attr => {\n :if => opts[:if]\n }\n )\n end\n end\n end", "def remove(attributes)\n project(header - attributes)\n end", "def delete_attribute(attribute_id, opts = {})\n delete_attribute_with_http_info(attribute_id, opts)\n return nil\n end", "def op_del(attrname = nil)\n attrname ||= pop\n push pop.dup\n peek.delete(attrname)\n end", "def delete( attribute )\n \n deleted_reader_writer_accessor_setting = super( attribute )\n \n unless @without_hooks\n update_for_subtraction( attribute, :accessor )\n end\n \n return deleted_reader_writer_accessor_setting\n \n end", "def delete_from_array(attribute_path, value)\n create_and_execute_edit('DELETE', attribute_path, value)\n end", "def delete_attribute_with_http_info(attribute_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: AttributesApi.delete_attribute ...\"\n end\n \n \n # verify the required parameter 'attribute_id' is set\n fail ArgumentError, \"Missing the required parameter 'attribute_id' when calling AttributesApi.delete_attribute\" if attribute_id.nil?\n \n \n \n \n \n # resource path\n local_var_path = \"/api/v2/attributes/{attributeId}\".sub('{format}','json').sub('{' + 'attributeId' + '}', attribute_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud Auth']\n data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AttributesApi#delete_attribute\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def delete_team_attribute_definition(name, headers=default_headers)\n @logger.info(\"Deleting the \\\"#{name}\\\" Team Attribute Definition\")\n delete(\"#{@api_url}/teamAttributeDefinitions/#{encode(name)}\", headers)\n end", "def del_attribute_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DefaultApi.del_attribute ...\"\n end\n # resource path\n local_var_path = \"/{uuid}/attribute/{key}\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:DELETE, 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 => 'InlineResponse2004')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#del_attribute\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def attr_without_feed_prefix (attr_sym)\n self[attr_sym].slice feed.prefix if self.gtfs_cols_with_prefix.include? (attr_sym)\n end", "def remove_column(table, name, **extra_args)\n current_instructions << Instructions::RemoveColumn.new(\n **extra_args,\n table: table,\n name: name,\n )\n end", "def remove_style(attribute)\n `var attr=attribute.__value__.replace(/[_-]\\\\D/g, function(match){return match.charAt(1).toUpperCase();})`\n `this.__native__.style[attr]=null`\n return self\n end", "def remove(el)\n n = word_number(el)\n if (n >= @bits.attr_length)\n grow_to_include(el)\n end\n @bits[n] &= ~bit_mask(el)\n end", "def remove_method\n :\"remove_#{self[:name].to_s.singularize}\"\n end", "def delete_attribute(ents, handle, name = nil)\n ents.each { |e|\n name ? e.delete_attribute(handle, name) : e.delete_attribute(handle)\n }\n end", "def rm(dataset)\n \"remove dataset name=#{dataset}\"\n end", "def remove_column(name)\n @columns_hash.delete name.to_s\n end", "def removed_attributes\n operand.header - header\n end", "def remove(meth)\n return nil unless valid_meth?(meth)\n @excluded -= [meth.to_s]\n end", "def remove_method\n :\"remove_#{singularize(self[:name])}\"\n end", "def delete_user_custom_attribute(key, user_id)\n delete(\"/users/#{user_id}/custom_attributes/#{key}\")\n end", "def remove_tag (tag)\n `rs_tag --remove \"#{tag}\"`\n end", "def remove!(name)\n remove_instance_variable to_ivar(name)\n end", "def remove_unique_attrs( char )\n ResourcePool.unique_attrs.each do |attr|\n if (self.is_storing_picked?(attr[0]))\n atr = attr[0]\n attr.slice(1, (attr.length - 1)).each do |attr|\n if (attr.is_a?(Array))\n self.add_to_picked(atr, char.send(attr[1]))\n self.delete_from_pool(attr[0], char.send(attr[1]))\n else\n self.add_to_picked(atr, char.send(attr))\n self.delete_from_pool(atr, char.send(attr))\n end\n end\n end\n end\n end", "def remove(value)\n @client.execute_udf(@key, @PACKAGE_NAME, 'remove', [@bin_name, value], @policy)\n end", "def rem_title_feature(symbol)\n symbol = symbol.to_sym\n $data_actors[self.id].remove_feature(*RVKD::Passives::FEATURES[symbol])\n end", "def attribute\n if to.is_a?(Symbol)\n to\n else\n name\n end\n end", "def []=(name, value)\n name = name.to_s\n value.nil? ? remove_attribute(name) : attr_set(name, value.to_s)\n end", "def remove_whitespace\n attribute_names.each do |name|\n if send(name).respond_to?(:strip)\n send(\"#{name}=\", send(name).strip)\n end\n end\n end", "def delete_user_attribute_definition(name, headers=default_headers)\n @logger.info(\"Deleting the \\\"#{name}\\\" User Attribute Definition\")\n delete(\"#{@api_url}/userAttributeDefinitions/#{encode(name)}\", headers)\n end", "def remove_column(column_id)\n request(method: 'removeColumn', params: { column_id: column_id })\n end", "def _remove_method\n :\"_remove_#{self[:name].to_s.singularize}\"\n end", "def delete(attribute)\n @errors.delete_if do |error|\n error.attribute == attribute\n end\n end", "def strip(attribute, struct = @structure)\n if struct.instance_of? Array\n data = []\n struct.each { |item| data << strip(attribute, item) }\n return data\n else\n struct.method(attribute).call\n end\n end", "def tags_to_remove=(value)\n @tags_to_remove = value\n end", "def remove(column_family, key, column = nil, sub_column = nil, consistency = Consistency::WEAK, timestamp = Time.stamp)\n column_family = column_family.to_s\n assert_column_name_classes(column_family, column, sub_column)\n\n column = column.to_s if column\n sub_column = sub_column.to_s if sub_column\n args = [column_family, key, column, sub_column, consistency, timestamp]\n @batch ? @batch << args : _remove(*args)\n end", "def strip_attributes\n attribute_names().each do |name|\n if self.send(name.to_sym).respond_to?(:strip)\n self.send(\"#{name}=\".to_sym, self.send(name).strip)\n end\n end\n end", "def toggle!(attribute)\n toggle(attribute) && save\n end", "def remove(value)\n connection.zrem(key_label, value)\n end", "def remove_column(table_name, column_name, type = nil, options = {})\n super\n clear_cache!\n end", "def strip_attributes(doc)\n attrs = %w[data-tralics-id data-label data-number data-chapter\n role aria-readonly target]\n doc.tap do\n attrs.each do |attr|\n doc.xpath(\"//@#{attr}\").remove\n end\n end\n end", "def remove(remove_me)\n @index_driver.remove(remove_me)\n end", "def remove(datatype_property)\n return @datatype_properties.delete(datatype_property)\n end", "def filter_attributes(attributes, to_filter)\n return nil if attributes.nil? || to_filter.nil?\n\n attributes.select { |key, _| to_filter.include? key.to_sym }\n end", "def del(name)\n data.delete(name)\n end", "def clear_original_attributes(options = {})\n if !(options[:only] or options[:except]) || !@original_attributes\n return @original_attributes = nil\n end\n \n attributes_to_clear = if options[:only]\n Array(options[:only]).map(&:to_s)\n elsif options[:except]\n except = Array(options[:except]).map(&:to_s)\n self.class.column_names.reject { |c| except.include?(c) }\n end\n \n attributes_to_clear.each do |attribute|\n @original_attributes[attribute] = @attributes[attribute]\n end\n end", "def destroy\n @user_attribute = UserAttribute.find(params[:id])\n @user_attribute.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_attributes_url) }\n format.xml { head :ok }\n end\n end", "def _remove_method\n :\"_remove_#{singularize(self[:name])}\"\n end", "def scrub_attributes(node)\n node.attribute_nodes.each do |attr_node|\n attr_name = if attr_node.namespace\n \"#{attr_node.namespace.prefix}:#{attr_node.node_name}\"\n else\n attr_node.node_name\n end\n\n if DATA_ATTRIBUTE_NAME.match?(attr_name)\n next\n end\n\n unless SafeList::ALLOWED_ATTRIBUTES.include?(attr_name)\n attr_node.remove\n next\n end\n\n if SafeList::ATTR_VAL_IS_URI.include?(attr_name)\n next if scrub_uri_attribute(attr_node)\n end\n\n if SafeList::SVG_ATTR_VAL_ALLOWS_REF.include?(attr_name)\n scrub_attribute_that_allows_local_ref(attr_node)\n end\n\n next unless SafeList::SVG_ALLOW_LOCAL_HREF.include?(node.name) &&\n attr_name == \"xlink:href\" &&\n attr_node.value =~ /^\\s*[^#\\s].*/m\n\n attr_node.remove\n next\n end\n\n scrub_css_attribute(node)\n\n node.attribute_nodes.each do |attr_node|\n if attr_node.value !~ /[^[:space:]]/ && attr_node.name !~ DATA_ATTRIBUTE_NAME\n node.remove_attribute(attr_node.name)\n end\n end\n\n force_correct_attribute_escaping!(node)\n end" ]
[ "0.6693441", "0.6693441", "0.6693441", "0.6693441", "0.65489346", "0.6396487", "0.6396487", "0.6213663", "0.6179488", "0.6122835", "0.60458183", "0.59947646", "0.596605", "0.5939172", "0.592752", "0.5918795", "0.58605015", "0.585825", "0.585825", "0.58464295", "0.5841614", "0.58338296", "0.5833225", "0.57890445", "0.5779996", "0.5724477", "0.568534", "0.5586666", "0.55734587", "0.5571813", "0.5549473", "0.5538347", "0.5456561", "0.5425036", "0.5425036", "0.5425036", "0.5363022", "0.5337403", "0.5317493", "0.53056836", "0.53005356", "0.52750677", "0.52750677", "0.51971126", "0.5173602", "0.5172088", "0.5113801", "0.5077534", "0.5052627", "0.50207144", "0.5001626", "0.49269724", "0.4923939", "0.4914426", "0.49123877", "0.4884835", "0.48460025", "0.48457944", "0.48278245", "0.48167354", "0.48089594", "0.48068398", "0.48000976", "0.4781941", "0.47662148", "0.47658315", "0.47434798", "0.47327566", "0.4727002", "0.4724671", "0.4718938", "0.47133586", "0.4712241", "0.47019374", "0.46896702", "0.46876538", "0.4687269", "0.46766275", "0.4670339", "0.46595976", "0.46500024", "0.46431375", "0.46161172", "0.45985675", "0.45791963", "0.4572127", "0.45652813", "0.4557703", "0.4548175", "0.454271", "0.45324644", "0.452698", "0.45261282", "0.45260066", "0.45249352", "0.45180625", "0.45138615", "0.45092085", "0.45072326", "0.44924337" ]
0.7978585
0
default logger format, removes prompt of: +d, [20200620 14:02:2917329] INFO MONGODB:+
def format!(logger) logger.formatter = proc { |severity, datetime, progname, msg| "#{msg}" } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default_logger\n logger = Logger.new(STDERR)\n logger.level = Mongoid::Config.log_level\n logger\n end", "def log(level, msg)\n return unless @logger\n case level\n when :fatal then\n @logger.fatal \"MONGODB [FATAL] #{msg}\"\n when :error then\n @logger.error \"MONGODB [ERROR] #{msg}\"\n when :warn then\n @logger.warn \"MONGODB [WARNING] #{msg}\"\n when :info then\n @logger.info \"MONGODB [INFO] #{msg}\"\n when :debug then\n @logger.debug \"MONGODB [DEBUG] #{msg}\"\n else\n @logger.debug \"MONGODB [DEBUG] #{msg}\"\n end\n end", "def default_formatter\n if protocol == :syslog\n # Format is text output without the time\n SemanticLogger::Formatters::Default.new(time_format: nil)\n else\n SemanticLogger::Formatters::Syslog.new(facility: facility, level_map: level_map, max_size: max_size)\n end\n end", "def log_formatter; end", "def log_formatter; end", "def logger(**opts); end", "def log_fmt(msg)\n \"[connection:#{connection.identifier}] [channel:#{self.class.id}] #{msg}\"\n end", "def datetime_format\n @logger.first.datetime_format\n end", "def default_io_logger(logger_io, progname)\n logger = Logger.new(logger_io)\n logger.progname = progname\n logger.datetime_format = '%Y-%m-%d %H:%M:%D %Z'\n logger\n end", "def reset_logging\n\t\tMongrel2.reset_logger\n\tend", "def configure_logging(logger)\n logger.level = LOG_LEVEL\n logger.datetime_format = '%Y-%m-%d %H:%M:%S'\n logger.formatter = proc do |severity, datetime, progname, msg|\n color = case severity\n when \"DEBUG\" then :light_white\n when \"INFO\" then :light_yellow\n when \"WARN\" then :light_red\n when \"ERROR\" then :blue\n when \"FATAL\" then :magenta\n when \"UNKNOWN\" then :cyan\n end\n \"#{datetime}: #{msg.colorize(color)}\\n\"\n end\n logger\nend", "def setup_default_logger(logger)\n progname = 'Expectacle'\n @logger = if logger == :syslog\n Syslog::Logger.new(progname)\n else\n default_io_logger(logger, progname)\n end\n @logger.level = Logger::INFO\n @logger.formatter = proc do |severity, datetime, pname, msg|\n \"#{datetime} #{pname} [#{severity}] #{msg}\\n\"\n end\n end", "def log_formatter=(_arg0); end", "def log_formatter=(_arg0); end", "def logger_output; end", "def default_formatter\n SemanticLogger::Formatters::Default.new\n end", "def colorize_logging; end", "def dlog(*args)\n if development?\n $stdout.puts \"\\n================================================\\n\"\n for arg in args\n $stdout.puts arg\n $stdout.puts \"================================================\\n\"\n end\n end\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 defaultLogger(opts=nil, parser=nil)\n if opts && parser\n #noinspection RubyArgCount\n result = Logger.new(opts[:logFile] || 'dataMetaXtra.log', 'daily', 10*1024*1024)\n result.level = case opts[:level] ? opts[:level].downcase[0] : 'i'\n when 'd'\n Logger::DEBUG\n when 'i'\n Logger::INFO\n when 'w'\n Logger::WARN\n when 'e'\n Logger::ERROR\n else\n parser.educate\n raise \"Invalid log level #{opts[:level]}\"\n end\n result.datetime_format = '%Y-%m-%d %H:%M:%S'\n result\n else\n result = Logger.new($stdout)\n result.level = Logger::WARN\n result\n end\n end", "def log_format\n if configuration.log_format.nil? || configuration.log_format.empty?\n format = '%{KIND}: %{message} on line %{line}'\n format.prepend('%{path} - ') if configuration.with_filename\n format.concat(' (check: %{check})')\n configuration.log_format = format\n end\n\n configuration.log_format\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 logger; settings(:logger); end", "def format_log_message(msg)\n \"[Cloudtasker/Server][#{id}] #{msg}\"\n end", "def log(msg, meta = {})\n puts \"#{msg} --- #{meta}\"\nend", "def format_log(msg)\n msg = colorize_log(msg)\n msg = remove_prefix(msg)\n \"#{msg}\\n\"\n end", "def set_up_logger( file )\n # $stdout = File.new( file, \"w\" )\n logger = Logger.new( file )\n \n logger.datetime_format = \"%H:%M:%S.%L\" # HH:MM:SS\n logger.formatter = Proc.new{ |severity,datetime,prog,msg|\n str = \"#{datetime} #{severity}: #{msg}\\n\"\n str\n }\n \n logger\nend", "def logger\n ::Logger.new($stdout).tap do |log|\n log.formatter = proc do |severity, _datetime, _progname, msg|\n prep = ' ' * (severity.size + 3)\n message = msg.lines.map.with_index do |str, i|\n next str if i.zero?\n\n str.strip.empty? ? str : prep + str\n end\n color = severity.downcase.to_sym\n msg = +\"[#{SeccompTools::Util.colorize(severity, t: color)}] #{message.join}\"\n msg << \"\\n\" unless msg.end_with?(\"\\n\")\n msg\n end\n end\n end", "def logger=(_arg0); end", "def logger=(_arg0); end", "def logger=(_arg0); end", "def logger=(_arg0); end", "def logger=(_arg0); end", "def logger=(_arg0); end", "def logger=(_arg0); end", "def set_loggers_format\n [@logger, @logger_stderr].each do |logger|\n logger.formatter = proc do |severity, _datetime, progname, msg|\n # If the message already has control characters, don't colorize it\n keep_original_color = msg.include? \"\\u001b\"\n message = \"[#{Time.now.utc.strftime('%F %T')} (PID #{$PROCESS_ID} / TID #{Thread.current.object_id})] #{severity.rjust(5)} - [ #{progname} ] - \"\n message << \"#{msg}\\n\" unless keep_original_color\n LEVELS_MODIFIERS[severity.downcase.to_sym].each do |modifier|\n message = message.send(modifier)\n end\n message << \"#{msg}\\n\" if keep_original_color\n message\n end\n end\n end", "def colorize_logging=(_arg0); end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def log string, importance = 0, component = nil\n time_string = \"(\" + Time.now.strftime(DATEFORMAT) + \")\"\n\n LOGGERS.each { |logger|\n logger.log_raw(string.to_s, component.to_s, time_string) if logger.should_show(component, importance)\n }\nend", "def daemon_log args = {}\n msg = args[:msg]\n msg = \"#{$daemon[:logger_msg_prefix]}: #{msg}\" unless $daemon[:logger_msg_prefix].blank?\n sev = args[:sev] || :info\n log :msg => msg, :sev => sev, :print_log => (! $daemon[:background] || sev == :error)\nend", "def log_name\n \"##{id || was || \"?\"}\"\n end", "def named(name)\n new_name = self.progname.to_s.dup\n new_name << \".\" unless new_name.empty?\n new_name << name\n new_logger = Logger.new(*@base_args)\n [:level, :formatter, :datetime_format].each do |m|\n new_logger.send(\"#{m}=\", self.send(m))\n end\n new_logger.progname = new_name\n new_logger\n end", "def setup_logger\n logger = Log4r::Logger.new('drbman')\n logger.outputters = Log4r::StdoutOutputter.new(:console)\n Log4r::Outputter[:console].formatter = Log4r::PatternFormatter.new(:pattern => \"%m\")\n logger.level = Log4r::DEBUG\n logger.level = Log4r::INFO\n logger.level = Log4r::WARN if @user_choices[:quiet]\n logger.level = Log4r::DEBUG if @user_choices[:debug]\n # logger.trace = true\n logger\n end", "def log(s, type = :info)\n\t\tcolor = :gray\n\t\tcase type\n\t\twhen :error\n\t\t\tcolor = :red\n\t\twhen :warning\n\t\t\tcolor = :yellow\n\t\twhen :debug\n\t\t\tcolor = :purple\n\t\tend\n\t\tsuper _fmt(color, s), type\n\tend", "def default_logger\n Logger.new(debug? ? STDOUT : nil)\n end", "def __prep_logger__(name, logger = nil)\n if name.is_a?(String) && ! logger.nil?\n [name, logger.class <= Logger ? logger : Logger.new(logger)]\n elsif name.class <= Logger && logger.nil?\n [name, name]\n else\n [name, Logger.new(name)]\n end\n end", "def log\n out.sync = true\n @log ||= Logger.new(out)\n\n @log.formatter = proc do |severity, datetime, progname, msg|\n if verbose\n string = \"#{severity} [#{datetime.strftime('%Y-%m-%d %H:%M:%S.%2N')}]: \"\n else\n string = \"[#{datetime.strftime('%H:%M:%S')}]: \"\n end\n\n string += \"#{msg}\\n\"\n\n string\n end\n @log\n end", "def log_setup_info( logger, db_name, db_user, log_dir, split_step,\n meeting_id = nil, team_ids = nil, start_team_id = nil, end_team_id = nil )\n logger.info( \"DB name: #{ db_name }\" )\n logger.info( \"DB user: #{ db_user }\" )\n logger.info( \"meeting_id: #{ meeting_id.inspect }\" ) if meeting_id\n logger.info( \"team_ids: #{ team_ids.inspect }\" ) if team_ids\n logger.info( \"team_ids: (range: #{ start_team_id }...#{ end_team_id })\" ) if start_team_id && end_team_id\n logger.info( \"split step: #{ split_step } max teams processed per created DB-diff file\" )\n logger.info( \"log_dir: #{ log_dir }\" )\n logger.info( \"\\r\\n\" )\n end", "def logger_level=(level)\n ::Mongo::Logger.logger.level = case level\n when :debug\n ::Logger::DEBUG\n when :fatal\n ::Logger::FATAL\n else\n nil\n end\n end", "def logger\n if @logger.nil?\n @logger = Logger.new($stdout)\n @logger.level = Logger::WARN\n @logger.formatter = proc do |severity, datetime, m_progname, msg|\n \"[#{datetime.strftime('%F %H:%M:%S')} #{severity.red}] #{msg}\\n\"\n end\n end\n @logger\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 default_logger\n log = ::Logger.new(STDOUT)\n log.level = ::Logger::INFO\n log\n end", "def db_logger\n self.class.database_logger\n end", "def logger\n @logger ||= Doing.logger\n end", "def logger\n options.logger\n end", "def log(format: nil)\n format_pattern =\n case format\n when :author\n '%aN'\n when :message\n '%B'\n end\n\n cmd = %w[log --topo-order]\n cmd << \"--format='#{format_pattern}'\" if format_pattern\n\n output, = run_git(cmd)\n output&.squeeze!(\"\\n\") if format_pattern == :message\n\n output\n end", "def default_log_level\n\t\t\tif $DEBUG\n\t\t\t\tLogger::DEBUG\n\t\t\telsif $VERBOSE\n\t\t\t\tLogger::INFO\n\t\t\telse\n\t\t\t\tLogger::WARN\n\t\t\tend\n\t\tend", "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 ||= default_logger\n end", "def format_log(sev, _time, _prog, msg); end", "def default_formatter\n SemanticLogger::Formatters::Json.new\n end", "def default_formatter\n SemanticLogger::Formatters::Json.new\n end", "def default_formatter\n SemanticLogger::Formatters::Json.new\n end", "def logger\n $logger ||= Steno.logger(\"uhuru-repository-manager.runner\")\n end", "def log(level, msg)\n puts \"#{level}, #{@org} Customization: #{msg}\"\n end", "def logger_level; end", "def log_inspect\n type = \"COMMAND\"\n \"%-12s database=%s command=%s\" % [type, database, selector.inspect]\n end", "def default_logger\n self.logger = Logger.new(STDERR)\n\n if settings.service.debug_mode || $DEBUG\n logger.level = Logger::DEBUG\n else\n logger.level = Logger::INFO\n end\n\n logger\n end", "def default_logger\n self.logger = Logger.new(STDERR)\n\n if settings.service.debug_mode || $DEBUG\n logger.level = Logger::DEBUG\n else\n logger.level = Logger::INFO\n end\n\n logger\n end", "def log\n @options[:log] || DEFAULT_LOG_FILE\n end", "def logger; LOGGER; end", "def debug(msg); @logger.debug(msg); end", "def default_logger\n logger = Logger.new(STDOUT)\n logger.level = Logger::INFO\n logger\n end", "def default_formatter\n SemanticLogger::Formatters::Raw.new\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 default_format(f)\n @default_formatter = Log4r::PatternFormatter.new(:pattern => f)\n\n #\n # Set all current outputters\n #\n result.outputters.each do |o|\n o.formatter = @default_formatter if o.formatter.is_a?(Log4r::DefaultFormatter)\n end\n\n @default_formatter\n end", "def logger; settings.logger; end", "def initialize_log\n if @configuration[:debug].nil?\n @logger = Yell.new format: Yell::ExtendedFormat do |l|\n l.adapter :datefile, 'send.log'\n l.adapter STDOUT\n end\n else\n @logger = Yell.new format: Yell::ExtendedFormat do |l|\n l.adapter :datefile, 'test.log'\n l.adapter STDOUT\n end\n end\n end", "def logger=(writer); end", "def logger=(writer); end", "def logger=(writer); end", "def logger=(writer); end" ]
[ "0.6554253", "0.63158906", "0.61414135", "0.606089", "0.606089", "0.60294485", "0.5886083", "0.5875358", "0.5851266", "0.5831013", "0.5821225", "0.5811389", "0.5788149", "0.5788149", "0.57853806", "0.5772454", "0.5754078", "0.5710082", "0.56836396", "0.56511915", "0.5649197", "0.5645156", "0.56084144", "0.5600501", "0.55916834", "0.5580817", "0.5578868", "0.5575501", "0.5573396", "0.5573396", "0.5573396", "0.5573396", "0.5573396", "0.5573396", "0.5573396", "0.5565232", "0.55579233", "0.5555907", "0.5555907", "0.5555907", "0.5555907", "0.5555907", "0.5555907", "0.5555907", "0.5555907", "0.5555907", "0.5555907", "0.5555907", "0.5555907", "0.5555907", "0.5555907", "0.5555907", "0.5555907", "0.5555907", "0.5555907", "0.5555907", "0.5553585", "0.5547481", "0.5543696", "0.55411446", "0.5539692", "0.55291533", "0.55270994", "0.5521367", "0.55189496", "0.550912", "0.5467788", "0.54514456", "0.54449517", "0.54422617", "0.5438005", "0.5433302", "0.5428248", "0.5418045", "0.54099447", "0.5398427", "0.5390818", "0.5390719", "0.53873414", "0.53873414", "0.53873414", "0.53752214", "0.53739065", "0.53675663", "0.5361501", "0.53527844", "0.53527844", "0.5350874", "0.53495836", "0.534638", "0.53426135", "0.5340061", "0.5339798", "0.5327399", "0.53208685", "0.5317657", "0.5307287", "0.5307287", "0.5307287", "0.5307287" ]
0.5763558
16
checks if a message if a message is included in the +UNNECESSARY+ array constant
def unnecessary?(msg) UNNECESSARY.any? { |s| msg.downcase.include? s } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def include?(hint)\n (v = messages[hint]) && v.any?\n end", "def include?(error)\n (v = messages[error]) && v.any?\n end", "def check_key(key, array)\n return true if ![nil, '', '-'].include?(array[key])\n raise RuntimeError, \"#{key} is empty\"\n end", "def msg_exists(msg) \n not msg.nil? and not msg.empty?\n end", "def valid_keys?(message)\n [:sender, :sent_to, :type, :uid] - message.keys == []\n end", "def assert_includes(elem, array, message = nil)\n message = build_message message, '<?> is not found in <?>.', elem, array\n assert_block message do\n array.include? elem\n end\n end", "def check_single_data(data:, message:)\n crit_msg(message) if data\n end", "def has_required_instructions\n unless (REQUIRED_INSTRUCTIONS & instructions.map(&:name)).size == REQUIRED_INSTRUCTIONS.size\n errors.add(:instructions, \"precisa conter pelo menos as seguintes instruções: \" + REQUIRED_INSTRUCTIONS.join(', '))\n end\n end", "def array_include(a1, a2) \n return (a1 - a2).empty?\n end", "def warning?\n messages && messages.length > 0\n end", "def verify_message(message)\n characters = message.chars\n if @elements.all? { |element|\n characters = element.evaluate(characters)\n characters != false\n } && characters.empty?\n puts 'YES'\n else\n puts 'NO'\n end\n end", "def valid_contents?(arr)\n arr.each { |e| return false unless (1..@size_pow).include?(e) }\n true\n end", "def untranslated?\n return false if obsolete? || fuzzy?\n if @msgstr.is_a? Array\n return @msgstr.map {|ms| ms.str}.join.empty?\n end\n @msgstr.nil? || @msgstr.str.empty?\n end", "def has_messages?\n\t\t\treturn !(messages.empty?)\n\t\tend", "def invalid_interactions?(arr)\n valid_interactions = %w(inhibitor agonism antagonism other neutral agonist inducer antagonist)\n valid_targets = %w(protein dna rna drug)\n # If this is not an array is incorrect\n return false unless arr.class == Array\n # [OPQ][0-9][A-Z0-9]{3}[0-9]|[A-NR-Z][0-9]([A-Z][A-Z0-9]{2}[0-9]){1,2}\n # (Regexp for UniProt id provided by UniProt)\n uniprot_regex = Regexp.new('[OPQ][0-9][A-Z0-9]{3}[0-9]|[A-NR-Z][0-9]([A-Z][A-Z0-9]{2}[0-9]){1,2}', Regexp::EXTENDED)\n arr.each do |value|\n # If value is not an array is incorrect\n return true unless value.class == Array\n return true unless valid_interactions.include?(value[1]) # Check interaction\n return true unless valid_targets.include?(value[2]) # Check molecule type\n return true unless uniprot_regex.match(value[4]) # Check uniprot uri\n end\n false\n end", "def test_xyz_not_in_arr\n refute_includes(list, 'ttt')\n end", "def include_none?(*items)\n items = items.first if items.length == 1 && items.first.kind_of?(Array)\n (self & items).empty?\n end", "def valid_add_entry_req\n if !params[:add_entry_req].nil?\n add_er_vals = params[:add_entry_req].values\n add_er_vals.each_slice(3) do |incoming_qual, grade, info|\n if (!incoming_qual.empty? && grade.empty?) ||\n (incoming_qual.empty? && (!grade.empty? || !info.empty?))\n return false\n end\n end\n end\n return true\n end", "def check_valid(key, array, values)\n return true if [nil, '', '-'].include?(array[key])\n return true if values.map(&:to_s).include?(array[key].to_s)\n raise RuntimeError, \"Invalid value for #{key}\"\n end", "def all_required(data, fields)\t\t\n\t\tif fields.nil? == true\n\t\t\treturn true\n\t\tend\n\t\t@api_errmsg = Array.new\n\t\tfields = fields.split(',')\n\t\tflag = true\n\t\tfields.each do |name|\n\t\t\tif data[name].nil?\n\t\t\t @api_errmsg.push(name)\n\t\t\t flag = false\n\t\t\tend\n\t\tend\n\t\tif flag == true\n\t\t return true\n\t\tend\n\t\treturn false\n\tend", "def test_file_must_not_contain_array()\n\t\tmustnotcontain = Array.new()\n\t\tmustnotcontain << @multilinefilecontents.split(\"\\n\")[1]\n\t\tmustnotcontain << @multilinefilecontents.split(\"\\n\")[2]\n\n\t\tCfruby::FileEdit.file_must_not_contain(@multilinefilename, mustnotcontain)\n\t\tFile.open(@multilinefilename, File::RDONLY) { |fp|\n\t\t\tlines = fp.readlines()\n\t\t\tassert_equal(@multilinefilecontents.split(\"\\n\").length-2, lines.length)\n\t\t\tmustnotcontain.each() { |line|\n\t\t\t\tassert_equal(false, lines.include?(line))\n\t\t\t}\n\t\t}\t\t\n\tend", "def can_be_used_jointly?\n ids = order.order_promo_codes.collect(&:promo_code_id).uniq\n singular_promo_codes = PromoCode.where(id: ids).where(combined: false)\n # cant use count since that data isnt saved yet and count would fire an query\n if order.order_promo_codes.size > 1 and singular_promo_codes.count > 0\n self.errors.add(:promo_code_id, 'Cant be used with conjuction with other codes') unless self.promo_code.combined\n end\n end", "def invalid?\n good_ones = ['Ready','Submittable','Completed','Resubmittable','InProgress']\n return !good_ones.include?(name)\n end", "def cannot_register_for_competition_reasons\n [].tap do |reasons|\n reasons << I18n.t('registrations.errors.need_name') if name.blank?\n reasons << I18n.t('registrations.errors.need_gender') if gender.blank?\n reasons << I18n.t('registrations.errors.need_dob') if dob.blank?\n reasons << I18n.t('registrations.errors.need_country') if country_iso2.blank?\n end\n end", "def checkmated?(sente) # sente is loosing\n ou = look_for_ou(sente)\n x = 1\n while (x <= 9)\n y = 1\n while (y <= 9)\n if (@array[x][y] &&\n (@array[x][y].sente != sente))\n if (@array[x][y].movable_grids.include?([ou.x, ou.y]))\n return true\n end\n end\n y = y + 1\n end\n x = x + 1\n end\n return false\n end", "def assert_not_include(collection, element, message = \"\")\n full_message = build_message(message, \"<?> expected not to be included in \\n<?>.\",\n element, collection)\n assert_block(full_message) { !collection.include?(element) }\n end", "def valid?(array)\n array.include?(0) || array.sum != 180\nend", "def any?\n messages.count.positive?\n end", "def refute_told_to(message)\n return unless messages.map(&:first).include? message\n raise \"Was told to #{message.inspect}, but should not have been!\"\n end", "def entered_all_obligatory_fields?(array)\n @contact_form.obligatory_field_ids.each do |field_id|\n if array.blank? || array[\"#{field_id}\"].blank?\n return false\n end\n end\n\n true\n end", "def check_array!(key, arr)\n if arr\n if arr.any?{|val| val.nil?}\n handle_error(key, :invalid_type, \"invalid value in array parameter #{param_name(key)}\")\n end\n else\n handle_error(key, :missing, \"missing parameter for #{param_name(key)}\")\n end\n end", "def test_any_match_empty\n stream = FromArray.new([])\n assert(\n !stream.any_match { raise ScriptError, 'Should not be called' },\n 'Stream is empty, any_match should be false!'\n )\n end", "def __messages__\n defined?(messages) ? Array[*messages] : nil\n end", "def formation_met? formation\npieces = [@board[formation[0]], @board[formation[1]], @board[formation[2]]]\npieces.uniq.length == 1 && (pieces[0] != PIECE[:blank])\nend", "def incorrect\n if !@user_1_array.include? user_2\n correct == false\n wrong_letters << user_2\n end\nend", "def check_array(array,target)\n if array.include?(target)\n return true\n else\n return false\n end\nend", "def const_defined?(*args)\n raise ArgumentError, \"too many arguments (#{args.size} for 1..2)\"\n end", "def required_args_present?(metric, args)\n (@metrics[metric]['required'] - args.keys).empty?\n end", "def non_include?(*args)\n !include? *args\n end", "def exclude_all?(arr, arr2)\n ! include_any?(arr, arr2)\n end", "def has_elements? desired_elements \n return which_elements_missing?(desired_elements).empty?\n end", "def multiple_pieces?\n 1 < all_coords.count { |coord| self[coord] != :empty }\n end", "def bad_zero?(letters, values, non_zero)\n (0...letters.length).any? do |index|\n values[index].zero? && non_zero.include?(letters[index])\n end\n end", "def require_array_match(arr)\n\t\tfilter_two_arrays(self, arr, true)\n\tend", "def noticeAction\n (@possibleValues[-1].length == 1)\n end", "def exclusion_guard(arr)\n arr | required_fields\n end", "def setup_args_valid?(argsArr)\r\n if nil==argsArr[0] or argsArr[0]==\"\"\r\n return \"Bot token cannot be empty or nil.\"\r\n elsif nil==argsArr[1] or argsArr[1]==\"\"\r\n return \"Bot clientId cannot be empty or nil.\"\r\n elsif nil==argsArr[2]\r\n return \"Bot command prefix cannot be nil.\"\r\n end\r\n\r\n return nil\r\n end", "def in_arr? (arr, text, exact)\n\tif exact\n\t\treturn arr.include? text\n\telse\n\t\treturn arr.any?{|s| s.include? text}\n\tend\nend", "def include?(arr, value)\n !(arr.select { |element| element == value }).empty?\nend", "def ensure_not_referenced_by_any_line_item\n if line_items.count.zero?\n return true\n else\n errors[:base] << \"Line Items present\" #这是什么意思\n return false\n end\n end", "def \n \n find_valid_calls(planeteer_calls)\n \n valid_calls = [\"Earth!\", \"Wind!\", \"Fire!\", \"Water!\", \"Heart!\"]\n \n planeteer_calls.detect do |element|\n if valid_calls.include? (element) \n element end \n end\n \nend", "def include?(array, value)\r\n array.count(value) > 0\r\nend", "def check_non_templates(manifest)\n manifest['configuration']['templates'].each do |property, template|\n empty = Common.parameters_in_template(template).length == 0\n\n next unless empty\n STDOUT.puts \"global role manifest template #{property.red} is used as a constant\"\n @has_errors += 1\n end\nend", "def correct_message_for(error)\r\n return true if @message.blank? || error.nil?\r\n \r\n if error.is_a?(String)\r\n return error == @message\r\n elsif error.is_a?(Array)\r\n return error.include?(@message)\r\n end\r\n end", "def unsatisfied\n Array((operands.detect {|op| op.is_a?(Array) && op[0] == :unsatisfied} || [:unsatisfied])[1..-1])\n end", "def must_send(send_array, msg=nil)\n ExecutionAssay.assert!(:message=>msg, :backtrace=>caller) do\n self.__send__(*send_array)\n end\n end", "def assert_does_not_contain(collection, x, extra_msg = \"\")\n collection = [collection] unless collection.is_a?(Array)\n msg = \"#{x.inspect} found in #{collection.to_a.inspect} \" + extra_msg\n case x\n when Regexp: assert(!collection.detect { |e| e =~ x }, msg)\n else assert(!collection.include?(x), msg)\n end \n end", "def fail_message(component, lookup)\n return false if processed.include?(component)\n processed << component\n puts \"missing #{component}\".bold.red\n puts \"looking up #{lookup}\".bold.blue\n return true\nend", "def long_planeteer_calls(array)\n array.any? do |word|\n word.size > 4\n end\nend", "def not_include?(element)\n !include?(element)\n end", "def include_array?(array)\n array.any? { |member| array?(member) }\n end", "def assert_does_not_contain(collection, x, extra_msg = \"\")\n collection = [collection] unless collection.is_a?(Array)\n msg = \"#{x.inspect} found in #{collection.to_a.inspect} \" + extra_msg\n case x\n when Regexp: assert(!collection.detect { |e| e =~ x }, msg)\n else assert(!collection.include?(x), msg)\n end \n end", "def long_planeteer_calls(array)\n array.any? { |word| word.length > 4}\nend", "def doesNotContainSpecial(userID)\n if !userID.include?(\"!\") && !userID.include?(\"#\") && !userID.include?(\"$\")\n puts \"true\"\n else\n puts \"false\"\n end\nend", "def has_message?\n has_message\n # && messages.count > 0\n end", "def any_unrecognized_keys?(expected, given)\n unrecognized_keys(expected, given).any?\n end", "def must_contain(parms, list)\n list.each do |i|\n raise \"#{i.to_s} required\" unless parms[i]\n end\nend", "def any_eob_processed?\n self.insurance_payment_eobs.length >= 1\n end", "def ok?\n [ :remote_addr, :price, :subscription_id, :transaction_id, :checksum , :jurnalo_user_id ].inject( true ){ |s,x| s && !(send(x).blank?) }\n end", "def not_include?(element)\n !self.include?(element)\n end", "def commit_msg_empty?(msg)\n msg.lines.grep(/^(?!#).*\\S.*^/).empty?\nend", "def check_array( lines )\r\n status = false\r\n lines.each { |line| status = true if check_string(line) }\r\n return status\r\n end", "def computer_offense_check(spaces, space1, space2, space3)\n\n ((spaces[space1] + spaces[space2]).include?(\"OO\") ||\n (spaces[space2] + spaces[space3]).include?(\"OO\") || \n (spaces[space1] + spaces[space3]).include?(\"OO\")) && \n (spaces[space1] + spaces[space2] + spaces[space3]).include?(\"X\") == false\n\nend", "def include_all?(*items)\n items = items.first if items.length == 1 && items.first.kind_of?(Array)\n (items - self).empty?\n end", "def game_crash(array)\n raise StandardError, 'Why did you do this to me, John?' if array.include?('-crash')\n end", "def require_if_present(names); end", "def validate_parts_presence!(grid_infos, part_uids)\n if grid_infos.count != part_uids.count\n raise Tus::Error, \"some parts for concatenation are missing\"\n end\n end", "def legal(word)\n @illegal_words[word] == nil && @legal_limbo[word] == nil\n end", "def ensure_not_referenced_by_any_line_item\nif line_items.count.zero?\nreturn true\nelse\nerrors[:base] << \"Line Items present\"\nreturn false\nend\nend", "def error?\n message.fields[0] == 'WE'\n end", "def assert_includes(collection, obj, msg = T.unsafe(nil)); end", "def include?(array, target)\n matches = array.select { |element| element == target }\n !matches.empty?\nend", "def ensure_not_referenced_by_any_line_item\n\nif line_items.count.zero?\nreturn true\nelse\nerrors[:base] << \"Line Items present\"\nreturn false\nend\nend", "def clickbait\n bait = [\"Won't Believe\", \"Secret\", \"Top [number]\", \"Guess\"]\n #check inclusion\n if title && !bait.any? { |bait| title.include?(bait) }\n #add errors 'if .. &&..'\n errors.add(:title, \"take me down a click-hole...\")\n end\n end", "def include_atoms?(atoms_arr)\n atoms_arr.each do |a|\n return false if !include_atom?(a)\n end\n true\n end", "def event_in_list\n if !SYSTEM_DATA[\"events\"].map { |x| x[\"name\"] }.include?(event)\n errors.add(:event, \"not included in list of valid events\")\n end\n end", "def check_no_orphans\n [@start, @stop].any? { |x| @raw.include? x }\n end", "def has_message_id?\n !fields.select { |f| f.responsible_for?('Message-ID') }.empty?\n end", "def required_params?\n @unincluded_params = []\n\n required_params.each do |param|\n unless params.include?(param)\n unincluded_params << param\n end\n end\n\n unincluded_params.empty?\n end", "def does_not_contain(&block)\n [:does_not_contain, block]\n end", "def does_not_contain(&block)\n [:does_not_contain, block]\n end", "def process_in_list\n if !SYSTEM_DATA[\"processes\"].map { |x| x[\"code\"] }.include?(process)\n errors.add(:process, \"Step: #{step} - #{process} not included in list of valid statuses\")\n end\n end", "def ensure_not_referenced_by_any_line_item \n if line_items.count.zero?\n return true\n else\n errors[:base] << \"Line Items present!\"\n return false\n end\n end", "def members_not_responding\n memb = sent_messages.map { |sm| (sm.msg_status || -1) < MessagesHelper::MsgDelivered ? sm.member : nil }.compact\n end", "def allowed(data) #Extension 1\n allow = [\"tee\", \"dee\", \"deep\", \"bop\", \"boop\", \"la\",\n \"na\", \"doop\", \"dop\", \"plop\", \"suu\", \"woo\", \"shi\",\n \"shu\", \"blop\", \"ditt\", \"hoo\", \"doo\", \"poo\"]\n if allow.include?(data)\n allowed = true\n else\n allowed = false\n end\n end", "def position_taken? (board_array, index)\n is_free = board_array[index] == \" \" || board_array[index] == \"\" || board_array[index] == nil\n !is_free\nend", "def got_three?(arr)\n !!(arr.map(&:to_s).join =~ /(.)\\1\\1/)\nend", "def ensure_not_referenced_by_any_line_item\n\n if line_items.count.zero?\n return true\n else\n errors[:base] << \"Line Items present\"\n return false\n\nend\nend", "def empty_trap_required\n is_human = true\n params.slice(*TheCommentsBase.config.empty_inputs).values.each{|v| is_human = (is_human && v.blank?) }\n\n if !is_human\n k = t('the_comments.trap')\n v = t('the_comments.trap_message')\n @errors[ k ] = [ v ]\n end\n end", "def found_multiple?\n @flags.size > 1\n end" ]
[ "0.6057573", "0.5822726", "0.57911474", "0.5776648", "0.57605225", "0.5666967", "0.56531197", "0.5646304", "0.5641864", "0.5624863", "0.56123346", "0.55909103", "0.55693555", "0.55274177", "0.5518616", "0.5515986", "0.54583704", "0.54120874", "0.5407269", "0.54070616", "0.53778815", "0.5372139", "0.5367156", "0.5362384", "0.531962", "0.53188634", "0.52945566", "0.5289491", "0.5281639", "0.5281171", "0.5279468", "0.5278358", "0.5275066", "0.52609515", "0.5260147", "0.5257516", "0.52438056", "0.5243593", "0.524102", "0.52376294", "0.5226963", "0.5226447", "0.52161026", "0.52120507", "0.5211895", "0.52108294", "0.520836", "0.52044886", "0.51991767", "0.51986164", "0.51863486", "0.51854026", "0.51790416", "0.51786876", "0.5178045", "0.51761764", "0.5174993", "0.51732457", "0.5172745", "0.5172613", "0.5171894", "0.516999", "0.5154579", "0.5145492", "0.5143335", "0.51425177", "0.5138063", "0.5135297", "0.51329386", "0.5124025", "0.51228136", "0.5121552", "0.5119966", "0.5114271", "0.5110272", "0.510986", "0.5104128", "0.5100851", "0.51002634", "0.5099111", "0.50983936", "0.5096152", "0.50944823", "0.5094267", "0.50847626", "0.50767666", "0.50743186", "0.5074243", "0.50728106", "0.5072214", "0.5072214", "0.50691277", "0.5067951", "0.5066669", "0.50621533", "0.5060281", "0.5056687", "0.50519484", "0.50501615", "0.5048491" ]
0.6494653
0
takes a log message and returns the message formatted
def format_log(msg) msg = colorize_log(msg) msg = remove_prefix(msg) "#{msg}\n" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format_log_message(msg)\n \"[Cloudtasker/Server][#{id}] #{msg}\"\n end", "def format_message(severity, timestamp, progname, msg)\n \"#{AUTHORIZATION_SYSTEM_LOG_MSG_PREFIX} #{timestamp.to_formatted_s(:db)} #{severity} #{msg}\\n\" \n end", "def format_log_message file, lineno, line, parameters\n message = insert_parameters(line, parameters)\n return \"#{file[:file_name]}@#{lineno}: #{message}\"\nend", "def format_message(message)\n format = log_format\n puts format % message\n\n puts \" #{message[:reason]}\" if message[:kind] == :ignored && !message[:reason].nil?\n end", "def format_log(sev, _time, _prog, msg); end", "def format_message(severity, timestamp, progname, msg)\n # remove the function name from the caller location\n location = caller(3).first.gsub(/:in `.*'$/, \"\")\n \"#{timestamp.strftime(datetime_format)} #{severity} #{Socket.gethostname}(#{Process.pid}) #{progname} #{location} #{msg}\\n\"\n end", "def format_msg(hash, level)\n @level = level # Log level\n str = \"\" # Final String we return. We keep appending to this\n count = 0 # Use to indent on 2nd+ iteration\n\n str_keys_values = add_key_values_to_str(hash)\n s_msg = split_msg(str_keys_values) # Split message incase it's MAX_CHAR+ chars\n\n s_msg.each do |n|\n str += count == 0 ? \"#{add_log_level(str)}#{get_date} | \" : \"#{add_log_level(str)}\"\n str += count == 0 ? \"#{n}\\n\" : \" \" * (get_date.length) + \" | #{n}\\n\" # Indent if 2nd+ iteration\n count += 1\n end\n\n str\n end", "def format_log(sev, _time, _prog, msg)\n \"[#{sev.downcase}]: #{msg}\\n\"\n end", "def format_message\n return @format_message if @format_message\n\n @format_message = self.message.dup\n\n if self.line\n @format_message << \" near line #{self.line}\"\n end\n\n if self.code\n @format_message << \": #{format_code}\"\n end\n\n @format_message\n end", "def log_message(message, log_type = \"INFO\")\n stamp = \"#{Time.now.strftime(\"%H:%M:%S\")}|#{log_type}> \"\n message = \"\" if message.nil?\n message = message.inspect unless message.is_a?(String)\n message = privatize(message)\n message.split(\"\\n\").map{|l| \"#{l.length == 0 ? \"\" : stamp}#{l}\"}.join(\"\\n\")\n end", "def format_message(severity, msg, *msg_args)\n\n # create new string for working copy\n message = String.new(@msg_pattern.to_s)\n\n # check severity and substitute (linear form)\n message = message.sub(GRFormatter::SEVERITY_TAG.to_s, severity.to_s) if message.include? GRFormatter::SEVERITY_TAG\n\n # check caller and substitute (extended form)\n if(message.include?(GRFormatter::CALLER_TAG) )then\n callers = caller()[1].to_s\n\n callers = callers[0, (callers.index(':in'))]\n \n message = message.sub(GRFormatter::CALLER_TAG, callers)\n end\n\n # check message\n if(message.include?(GRFormatter::MSG_TAG) )then\n\n # have some parameters\n if(msg_args != nil && msg_args.size() > 0)\n # iterator\n index = -1\n\n # substitute with\n message = msg.gsub(\"%s\") {|w| w = msg_args[index+=1] }\n else\n\n # replace only the message\n message = message.sub(GRFormatter::MSG_TAG, msg)\n end\n end\n\n message\n end", "def textLogFormat _args\n \"textLogFormat _args;\" \n end", "def format_message(severity, ts, progname, msg)\n \"#{ts.strftime '%Y-%m-%d %H:%M:%S'} #{severity.chars.first} #{msg}\\n\"\n end", "def format(log_record)\n msg_txt = self.formatMessage(log_record)\n msg_txt = msg_proc.call(log_record, msg_txt) if msg_proc\n return unless msg_txt\n\n lvl = @level_labels[log_record.level]\n indent = @indent || 0\n spacer = ''\n wrap_width = @width - indent\n if log_record.level.intValue < JavaUtilLogger::Level::INFO.intValue\n spacer = ' '\n wrap_width -= 2\n end\n msg = wrap_width > 0 ? Console.wrap_text(msg_txt, wrap_width) : [msg_txt]\n sb = java.lang.StringBuilder.new()\n msg.each_with_index do |line, i|\n if i == 0\n fmt = java.lang.String.format(@format_string,\n log_record.millis,\n log_record.logger_name,\n log_record.logger_name,\n lvl,\n msg[i],\n log_record.thrown,\n spacer)\n else\n fmt = java.lang.String.format(@format_string,\n log_record.millis, '', '', '', msg[i], nil, spacer)\n end\n sb.append(fmt)\n sb.append(LINE_END) if @width < 0 || fmt.length < @width\n end\n sb.toString()\n end", "def format_log_entry(message, dump = nil)\n if Rails.application.config.colorize_logging\n if @@row_even\n @@row_even = false\n message_color, dump_color = \"4;36;1\", \"0;1\"\n else\n @@row_even = true\n message_color, dump_color = \"4;35;1\", \"0\"\n end\n\n log_entry = \" \\e[#{message_color}m#{message}\\e[0m \"\n log_entry << \"\\e[#{dump_color}m%#{String === dump ? 's' : 'p'}\\e[0m\" % dump if dump\n log_entry\n else\n \"%s %s\" % [message, dump]\n end\n end", "def format_message(message)\n case message\n when Exception\n format_exception(message)\n when String\n format_string(message)\n else\n format_generic_object(message)\n end\n end", "def formatted_message(message)\n \"#{timestamp}#{message}\\n\".freeze if message\n end", "def format_log(raw)\n return \"...\" unless raw\n raw.split(\"\\n\").map do |l|\n # clean stuff we don't need\n l.gsub!(/I\\s+|\\(\\w*\\)|within bounds/, \"\") # gsub(/\\(\\w*\\)/, \"\"\")\n # if ok, span is green\n ok = l =~ /\\[ok\\]/\n if l =~ /\\[\\w*\\]/\n # get some data we want...\n l.gsub(/\\[\\S*\\s(\\S*)\\]\\W+INFO: (\\w*-?\\w*|.*)?\\s\\[(\\w*)?\\]/, \"<span class='gray'>\\\\1</span> | <span class='#{ok ? 'green' : 'red'}'>\\\\3</span> |\").\n # take only the integer from cpu\n gsub(/cpu/, \"cpu %\").gsub(/(\\d{1,3})\\.\\d*%/, \"\\\\1\").\n # show mem usage in mb\n gsub(/memory/, \"mem mb\").gsub(/(\\d*kb)/) { ($1.to_i / 1000).to_s }\n else\n l.gsub(/\\[\\S*\\s(\\S*)\\]\\W+INFO: \\w*\\s(\\w*)/, \"<span class='gray'>\\\\1</span> | <span class='act'>act</span> | \\\\2\")\n end\n\n end.reverse.join(\"</br>\")\n end", "def format_message(severity, timestamp, progname, msg)\n # $stderr.puts \"format_message: #{msg}\"\n sprintf \"%s,%03d %7s: %s%s\\n\",\n timestamp.strftime(\"%Y-%m-%d %H:%M:%S\"),\n (timestamp.usec / 1000).to_s,\n severity,\n prefix.nil? ? \"\" : \"#{prefix} \",\n msg\n end", "def format(severity, message, *msg_args)\n # format time\n msg1 = format_time(Time.now)\n\n # format message\n msg2 = format_message(severity.to_s, message,*msg_args)\n\n # return unify of message parts\n msg = msg1 << msg2\n end", "def format_message( message, severity=@level, time=Time.now )\n severity = (severity.nil?) ? (\"\") : (severity.to_s.upcase + \": \")\n\n \"[%s] (Dixi) %s%s\\n\"%[ time.strftime(@time_format),\n severity,\n message.to_s ]\n end", "def format(level, context, message)\n msg = message.evaluated_message\n\n case msg\n when Hash\n # Assume caller is following conventions\n log = msg.dup\n else\n # Otherwise treat as String\n log = { :message => msg.to_s.strip }\n end\n\n log[:timestamp] = timestamp\n log[:level] = format_level(level)\n log[:pid] = Process.pid\n\n unless Thread.current == Thread.main\n log[:thread] = Thread.current.object_id\n end\n\n log[:context] = context\n\n if message.ndc.any?\n log[:ndc] = message.ndc.to_a\n end\n\n if message.error\n error = message.error\n\n log[:error_class] = error.class.to_s\n log[:error_message] = error.message\n log[:error_backtrace]\n\n if error.respond_to?(:backtrace)\n backtrace = error.backtrace\n backtrace = backtrace.take(backtrace_limit) if backtrace_limit\n log[:error_backtrace] = backtrace.join(\"\\n\")\n end\n end\n\n JSON.generate(log.to_h)\n end", "def format_message(severity, datetime, progname, msg)\n if String === msg then\n msg.inject('') { |s, line| s << super(severity, datetime, progname, line.chomp) }\n else\n super\n end\n end", "def format_message level, time, msg\n prefix = case level\n when \"warn\"; \"WARNING: \"\n when \"error\"; \"ERROR: \"\n else \"\"\n end\n \"[#{time.to_s}] #{prefix}#{msg.rstrip}\\n\"\n end", "def colorize_log(msg)\n ACTIONS.each { |a| msg = color(msg, a[:color]) if msg.downcase.include?(a[:match]) }\n return msg\n end", "def format_message(*args)\n old_format_message(*args)\n end", "def format(message)\n formatter = formatter_for(message.class)\n if formatter&.respond_to?(:call)\n formatter.call(message)\n else\n message\n end\n end", "def formatted_message\n \"#{@message} (#{@code})\"\n end", "def log_format\n if configuration.log_format.nil? || configuration.log_format.empty?\n format = '%{KIND}: %{message} on line %{line}'\n format.prepend('%{path} - ') if configuration.with_filename\n format.concat(' (check: %{check})')\n configuration.log_format = format\n end\n\n configuration.log_format\n end", "def format_message(msg)\n \"#{@method_name} #{msg}\"\n end", "def format(level, context, message)\n msg = message.to_s.strip\n thread = thread_context ? \"[#{thread_name}] - \" : nil\n\n if message.ndc.any?\n msg = \"#{thread}#{level.to_s.upcase} - #{context} #{message.ndc.join(' ')} - #{msg}\"\n else\n msg = \"#{thread}#{level.to_s.upcase} - #{context} - #{msg}\"\n end\n\n with_backtrace(message, msg)\n end", "def format(arg)\n str = if arg.is_a?(Exception)\n \"#{arg.class}: #{arg.message}\\n\\t\" <<\n arg.backtrace.join(\"\\n\\t\") << \"\\n\"\n elsif arg.respond_to?(:to_str)\n arg.to_str\n else\n arg.inspect\n end\nend", "def message(message)\n log.info(message.to_s)\n end", "def log_formatter; end", "def log_formatter; end", "def format_message(message) # :nodoc:\n msg = message.gsub(/(\\r|\\n|\\r\\n)/, '<br>')\n msg.gsub(/[{}\\\\\"]/, \"\\\\\\\\\\\\0\") # oh dear\n end", "def log_fmt(msg)\n \"[connection:#{connection.identifier}] [channel:#{self.class.id}] #{msg}\"\n end", "def format_msg_with_context(msg)\n msg\n end", "def to_s\n lines = if @source_lines.nil?\n ''\n else\n # @type [Hash<Symbol, Int>] @source_lines\n \":#{@source_lines.values.uniq.join('-')}\"\n end\n\n message = @message\n message = message.split(\"\\n\").map(&:strip).join(' ') unless @preformatted\n message += \"\\nLog pattern: '#{@pattern}'\" if Logger.debug?\n\n <<~MSG\n #{@source_file}#{lines}: #{@level.to_s.upcase}\n #{message}\n MSG\n end", "def processRegularUserMessage(message)\r\n return formatMessageText(message[:message])\r\n end", "def make_log( type, msg )\n return \"#{type} #{msg}\"\nend", "def log_debug(message)\n return message\n end", "def convert_message_line(line)\n line_array = line.split(' ')\n human_timestamp = Time.parse(line_array[0..2].join(' '))\n format(human_timestamp, line_array, 3)\nend", "def log_msg(message: , time: Time.now)\n return \"[#{time}, #{message}]\"\nend", "def to_log_format\n @log_format ||= begin\n attributes = []\n attributes << \"#{LOG_ATTR_ENV}=#{env}\" unless env.nil?\n attributes << \"#{LOG_ATTR_SERVICE}=#{service}\"\n attributes << \"#{LOG_ATTR_VERSION}=#{version}\" unless version.nil?\n attributes << \"#{LOG_ATTR_TRACE_ID}=#{trace_id}\"\n attributes << \"#{LOG_ATTR_SPAN_ID}=#{span_id}\"\n attributes << \"#{LOG_ATTR_SOURCE}=#{Core::Logging::Ext::DD_SOURCE}\"\n attributes.join(' ')\n end\n end", "def log(format: nil)\n format_pattern =\n case format\n when :author\n '%aN'\n when :message\n '%B'\n end\n\n cmd = %w[log --topo-order]\n cmd << \"--format='#{format_pattern}'\" if format_pattern\n\n output, = run_git(cmd)\n output&.squeeze!(\"\\n\") if format_pattern == :message\n\n output\n end", "def log_formatter=(_arg0); end", "def log_formatter=(_arg0); end", "def jira_summary_formatting(message)\n message = message.gsub('&lt;', '<')\n .gsub('u0026lt;', '<')\n .gsub('&gt;', '>')\n .gsub('u0026gt;', '>')\n .gsub('&amp;', '&')\n .gsub('u0026amp;', '&')\n\n message = message[0..250]\n end", "def formatted_message\n case @text_align\n when :center\n align_center\n when :left\n @message\n when :right\n align_right\n end\n end", "def pretty_hash_message(msg_hash)\n message = msg_hash['message']\n if msg_hash['errors']\n msg_hash['errors'].each do |k,v|\n if msg_hash['errors'][k]\n message = \"#{message}:\\n#{k}: #{v}\"\n end\n end\n end\n message\n end", "def log_message( level, message )\n\n end", "def to_s; message; end", "def format_message(type, message, opts=nil)\n opts ||= {}\n message = \"[#{@resource}] #{message}\" if opts[:prefix]\n message\n end", "def get_log\n if @format == :markdown\n log = `git log --pretty=format:\"* %ad %s %n%b\" --date=short #{@since}`\n log.gsub /^$\\n/, ''\n else\n `git log --pretty=format:\"*<li>%ad %s%n%b</li>\" --date=short #{@since}`\n end\nend", "def message(text)\n GitPusshuTen::Log.message(text)\n end", "def log(message)\n puts Time.now.strftime('[%d-%b-%Y %H:%M:%S] ') + message\n end", "def message\n props[ LOG_PROP_NAME ] if props\n end", "def log_message(event)\n puts event.message.inspect\n end", "def clean(message)\n message = message.to_s.dup\n message.strip!\n message.gsub!(/%/, '%%') # syslog(3) freaks on % (printf)\n message.gsub!(/\\e\\[[^m]*m/, '') # remove useless ansi color codes\n return message\n end", "def format(text); end", "def syslog_packet_formatter(log)\n packet = SyslogProtocol::Packet.new\n packet.hostname = host\n packet.facility = @facility\n packet.severity = @level_map[log.level]\n packet.tag = application.gsub(' ', '')\n packet.content = formatter.call(log, self)\n packet.time = log.time\n packet.to_s\n end", "def to_s\n return \"log(#{self.arg.to_s})\"\n end", "def get_message_formatted(message, timestamp)\r\n {\r\n data: message,\r\n timestamp: timestamp\r\n }\r\n end", "def colorize_logging; end", "def log_entry(type, message)\n \"#{message_type(type)}#{message_body(type, message)}\".freeze\n end", "def get_message (source, event, args)\n\n args.inject([]) { |r, a|\n r << a if a.is_a?(Symbol) or a.is_a?(String)\n r\n }.join(' ')\n end", "def message(string)\n to_console loggify(string, :message, :green)\n to_file loggify(string, :message)\n end", "def formatted\n message = \"\\n#{@exception.class}: #{@exception.message}\\n \"\n message << @exception.backtrace.join(\"\\n \")\n message << \"\\n\\n\"\n end", "def clean(message)\n message = message.to_s.dup\n message.strip!\n message.gsub!(/%/, '%%') # syslog(3) freaks on % (printf)\n message.gsub!(/\\e\\[[^m]*m/, '') # remove useless ansi color codes\n return message\n end", "def render_log(log)\n # Borrow private method from colorize gem.\n log.send(:scan_for_colors).map do |mode, color, background, text|\n if [mode, color, background].all?(&:nil?)\n text\n else\n style = []\n\n case mode.to_i\n when 1\n style << 'font-weight: bold;'\n when 4\n style << 'text-decoration: underline;'\n end\n\n if name = render_color(color.to_i - 30)\n style << \"color: #{name};\"\n end\n if name = render_color(background.to_i - 40)\n style << \"background-color: #{name};\"\n end\n\n content_tag(:span, text, style: style.join(' '))\n end\n end.join.gsub(\"\\n\", '<br>')\n end", "def combined_log\n messages.join.strip\n end", "def log_sometext(str)\n log str\n end", "def detail\n log = parse_log\n if orphan?\n penultimate_message(log)\n elsif target_recently_created?(log)\n creation_message(log)\n else\n latest_message(log)\n end\n rescue StandardError => e\n Rails.env.production? ? raise(e) : \"\"\n end", "def format(tag, time, record)\n return [tag, record].to_msgpack\n end", "def format(tag, time, record)\n return [tag, record].to_msgpack\n end", "def formatted format\n {:status => status, :error => exception.message}.send to_format(format)\n end", "def log_message(log_msg_txt)\n `logger -t job specification #{log_msg_txt}`\n puts log_msg_txt\n end", "def _format_mail(message)\n <<~EOM\n\n ==> Sending email to #{message.to.join(\", \")}\n #{message}\n\n EOM\n end", "def sanitized_message\n message.to_s[0,140]\n end", "def format_issue(issue)\n t(config.jira.format == 'one-line' ? 'issue.oneline' : 'issue.oneline',\n key: issue.key,\n summary: issue.summary,\n status: issue.status.name,\n assigned: optional_issue_property('unassigned') { issue.assignee.displayName },\n url: format_issue_link(issue.key))\n end", "def full_message(attribute, message)\n return message if attribute == :base\n\n if message =~ /\\A\\^/\n I18n.t(:\"errors.format.full_message\", {\n default: \"%{message}\",\n message: message[1..-1]\n })\n else\n original_full_message(attribute, message)\n end\n end", "def log(message)\n puts message\n end", "def log_message(message)\r\n @log.log_message(message)\r\n end", "def pretty_print(msg)\n if logger.level == Capistrano::Logger::IMPORTANT\n pretty_errors\n\n msg = msg.slice(0, 57)\n msg << '.' * (60 - msg.size)\n print msg\n else\n puts msg\n end\nend", "def log(message)\n lines = message.split(\"\\n\")\n first_line = lines.shift\n stderr.puts first_line\n # If the message is multiple lines,\n # indent subsequent lines to align with the\n # log type prefix (\"ERROR: \", etc)\n unless lines.empty?\n prefix, = first_line.split(\":\", 2)\n return if prefix.nil?\n\n prefix_len = prefix.length\n prefix_len -= 9 if color? # prefix includes 9 bytes of color escape sequences\n prefix_len += 2 # include room to align to the \": \" following PREFIX\n padding = \" \" * prefix_len\n lines.each do |line|\n stderr.puts \"#{padding}#{line}\"\n end\n end\n rescue Errno::EPIPE => e\n raise e if @config[:verbosity] >= 2\n\n exit 0\n end", "def log(message); logger.info(message); end", "def log_fmt_timestamp(time)\n [(time/3600).to_i, (time/60 % 60).to_i, (time % 60).to_i].map{|t| t.to_s.rjust(2,'0')}.join(':')\n end", "def format_msg_with_context(msg)\n if @context_hash.keys.length > 0\n msg_context = '['\n @context_hash.each do |k, v|\n msg_context += \"#{k}=#{v} \"\n end\n msg_context += '] '\n msg = msg.prepend(msg_context)\n end\n msg\n end", "def do_log(log)\r\n log.debug \"This is a message with level DEBUG\"\r\n log.info \"This is a message with level INFO\"\r\n log.warn \"This is a message with level WARN\"\r\n log.error \"This is a message with level ERROR\"\r\n log.fatal \"This is a message with level FATAL\"\r\nend", "def standard(text)\n GitPusshuTen::Log.standard(text)\n end", "def format(hash ={})\n # Create a Message Data where all hash keys become methods for convenient interpolation\n # in issue text.\n msgdata = MessageData.new(*arg_names)\n begin\n # Evaluate the message block in the msg data's binding\n msgdata.format(hash, &message_block)\n rescue StandardError => e\n raise RuntimeError, \"Error while reporting issue: #{issue_code}. #{e.message}\", caller\n end\n end", "def format(tag, time, record)\n newrecord = {}\n\n begin\n if record['severity']\n newrecord['severity'] = Integer(record['severity'])\n else\n newrecord['severity'] = @severity\n end\n rescue\n newrecord['severity'] = @severity\n end\n\n newrecord['type'] = tag.to_s\n newrecord['agent_time'] = time.to_s\n newrecord['manager'] = @manager\n newrecord['class'] = @source\n newrecord['source'] = @hostname\n newrecord['description'] = record['message']\n newrecord['custom_info'] = record\n\n newrecord.to_msgpack\n end", "def format(message, colour = nil, style = nil)\n c = @map[:colour][colour.to_sym] unless colour.nil?\n\n if style.nil?\n t = 0\n else\n t = @map[:style][style.to_sym]\n end\n\n \"\\e[#{t};#{c}m#{message}\\e[0m\"\n end", "def to_s\n message\n end", "def to_s\n message\n end", "def to_s\n message\n end", "def to_s\n message\n end", "def to_s\n message\n end", "def to_s\n message\n end" ]
[ "0.7287236", "0.72169155", "0.7044046", "0.6987145", "0.68418026", "0.6765429", "0.67498034", "0.6730842", "0.6724308", "0.67067987", "0.6705526", "0.6690692", "0.666397", "0.66603094", "0.66213804", "0.6608459", "0.6568617", "0.6529895", "0.65196097", "0.64855164", "0.64723796", "0.6464935", "0.6357788", "0.63574576", "0.633308", "0.6308394", "0.63081586", "0.6307292", "0.6262347", "0.624698", "0.62420416", "0.6228652", "0.6189392", "0.6178863", "0.6178863", "0.6149481", "0.6083707", "0.60759854", "0.6061601", "0.6058907", "0.605662", "0.59943604", "0.59728247", "0.59432924", "0.59378654", "0.59233004", "0.592028", "0.592028", "0.5877869", "0.58356863", "0.5829291", "0.58270925", "0.5809993", "0.5806168", "0.5800299", "0.5761379", "0.57491577", "0.5747107", "0.5741196", "0.5731635", "0.572993", "0.57254654", "0.57247144", "0.57170266", "0.5705702", "0.56996185", "0.5699258", "0.56969994", "0.5672992", "0.5658729", "0.56202924", "0.5580011", "0.5561077", "0.55588734", "0.55521774", "0.55521774", "0.55458313", "0.55426", "0.554079", "0.5529747", "0.5514178", "0.54849255", "0.54772335", "0.5464032", "0.5463377", "0.54614383", "0.54404175", "0.5430228", "0.54166204", "0.54062474", "0.5399753", "0.53913665", "0.5389166", "0.5379308", "0.5374568", "0.5374568", "0.5374568", "0.5374568", "0.5374568", "0.5374568" ]
0.77879244
0
colorize messages that are specified in ACTIONS constant
def colorize_log(msg) ACTIONS.each { |a| msg = color(msg, a[:color]) if msg.downcase.include?(a[:match]) } return msg end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_formatted_action(msg, opts={})\n m = [self.timestamp] + msg\n\n unless opts[:no_truncate]\n if m.map(&:first).join(' ').length > self.term_width\n fixed_length = m[0,2].map(&:first).join(' ').length\n m[2][0] = m[2][0][0,(term_width - fixed_length - 4)] + ' … '\n end\n end\n\n o = []\n m.each_with_index do |e,i|\n val, colors = e\n colors.each do |c|\n val = val.send c\n end\n o << val\n end\n\n puts o.join ' '\n end", "def colorize(text, status = :normal)\n case status\n when :success\n text.green\n when :error\n text.red\n when :warning\n text.yellow\n when :neutral\n text.blue\n else\n text.white\n end\n end", "def output_message message, color\n case color\n when :black\n puts message.black\n when :red\n puts message.red\n when :green\n puts message.green\n when :yellow\n puts message.yellow\n when :blue\n puts message.blue\n when :magenta\n puts message.magenta\n when :cyan\n puts message.cyan\n else\n puts message\n end\n end", "def record(action, *arguments)\n msg = \"\"\n msg << color(ACTION_COLORS[action]) if Compass.configuration.color_output\n msg << \"#{action_padding(action)}#{action}\"\n msg << color(:clear) if Compass.configuration.color_output\n msg << \" #{arguments.join(' ')}\"\n log msg\n end", "def to_color_log\n @lines.map.with_index do |val, i|\n case val[0][:status] \n when \" \"\n \"\\033[90m#{i} #{val[0][:status]} #{val[0][:string]}\\033[0m\"\n when \"+\"\n \"\\033[32m#{i} #{val[0][:status]} #{val[0][:string]}\\033[0m\"\n when \"-\"\n \"\\033[31m#{i} #{val[0][:status]} #{val[0][:string]}\\033[0m\"\n when \"*\"\n \"\\033[36m#{i} #{val[0][:status]} #{val[0][:string]}\\033[0m\"\n end\n end.join(\"\\n\") + \"\\n\"\n end", "def puts_action(name, color, arg)\n printf color(color, \"%11s %s\\n\"), name, arg\n end", "def red(msg)\n \"\\033[31m#{msg}\\033[39m\"\nend", "def say_blue( msg, options=[] )\n options = options.unshift( '' ) unless options.empty?\n say \"<%= color(%q{#{msg}}, CYAN #{options.join(', ')}) %>\\n\" unless @silent\n end", "def colorize(* colors)\n buff = []\n colors.each{|color| buff << color_code(color)}\n buff << self << color_code(:off)\n buff.join\n end", "def red(text)\n colorize(text, 31)\nend", "def log( *msg )\n\t\t\toutput = colorize( msg.flatten.join(' '), 'cyan' )\n\t\t\t$stderr.puts( output )\n\t\tend", "def shout(message)\n output.puts Paint[message, :bold, :red ]\n end", "def puts_color( msg, color=nil )\n color_set( color ); puts msg; color_end\n end", "def color_codes\n {\n info: '#63C5DC',\n warning: 'warning',\n success: 'good',\n fatal: 'danger'\n }\n end", "def display_info_about_app\n info_msg = \"Look Dude or Dudette ! All You Need To Know Is That This Is A Great App And You Should Be Very Happy It Fell Into Your Lap. It Will Help You Navigate The World Of Pharmacies, Especially If You Are An Orc Or A Kobolt Or One Of Those UnderWorld Creatures! And If You Happen To Be A DarkElf, Know That Drizzt D'Urden Is A Good Friend Of This ... WhatEver This Is!\"\n puts \"\" \n puts \" -- #{ info_msg } -- \".colorize(:color => :light_blue, :background => :white)\n puts \"\" \nend", "def print_status(msg, color)\n cprint RESET + BOLD\n cprint WHITE + \"[ \"\n cprint \"#{ msg } \", color\n cprint WHITE + \"] \" + RESET\n end", "def print_status(msg, color)\n cprint RESET + BOLD\n cprint WHITE + \"[ \"\n cprint \"#{ msg } \", color\n cprint WHITE + \"] \" + RESET\n end", "def color\n if not @title\n 'blank'\n elsif @warnings\n 'missing'\n elsif @missing\n 'missing'\n elsif @approved\n if @approved.length < 5\n 'ready'\n elsif @comments\n 'commented'\n else\n 'reviewed'\n end\n elsif @text or @report\n 'available'\n elsif @text === undefined\n 'missing'\n else\n 'reviewed'\n end\n end", "def statuses(status)\n puts \"\\n#{status}\\n\".colorize(:green)\nend", "def green(text)\n colorize(text, 32)\nend", "def red\n colorize(:red)\nend", "def colorized?; end", "def action(message)\n print(6, message)\n end", "def colorize_logging; end", "def cprint (msg = \"\", color = \"\")\n\n # Identify method entry\n debug_print \"#{ self } : #{ __method__ }\\n\"\n\n # This little check will allow us to take a Constant defined color\n # As well as a [0-256] value if specified\n if (color.is_a?(String))\n debug_print \"Custom color specified for cprint\\n\"\n @output.write(color)\n elsif (color.between?(0, 256))\n debug_print \"No or Default color specified for cprint\\n\"\n @output.write(\"\\e[38;5;#{ color }m\")\n end\n\n @output.write(msg)\n end", "def iconcolor #NEED TO FIX ROUTE CODE COLORS\n mycolor=\"red\"\n mycolor=\"green\" if Entity.iconColorMgr=='normal' and !self.actiontypes.empty? and self.actiontypes.order('created_at DESC').limit(1).first.recent_activity\n mycolor=\"green\" if Entity.iconColorMgr=='collection'\n if Entity.iconColorMgr=='route'\n mycolor=\"blue\" if self.routes.first==Route.first\n mycolor=\"yellow\" if self.routes.last==Route.last\n end\n # \"green\" # green if recent action\n # \"red\" # red if no recent\n mycolor\n end", "def textColor(theColor, target = nil)\n return if theColor.nil?\n views = @alert.window.contentView.subviews # the standard label fields\n case target\n when 'message' then views[4].textColor = MEalert.getColor(theColor, 'textColor')\n when 'informative' then views[5].textColor = MEalert.getColor(theColor, 'textColor')\n else @coloration[:text] = theColor\n end\n end", "def cprint (msg = \"\", color = \"\")\n\n # Identify method entry\n debug_print \"#{ self } : #{ __method__ }\\n\"\n\n # This little check will allow us to take a Constant defined color\n # As well as a [0-256] value if specified\n if (color.is_a?(String))\n debug_print \"Custom color specified for cprint\\n\"\n STDOUT.write(color)\n elsif (color.between?(0, 256))\n debug_print \"No or Default color specified for cprint\\n\"\n STDOUT.write(\"\\e[38;5;#{ color }m\")\n end\n\n STDOUT.write(msg)\n end", "def action_strs\n @action_strs ||= user_data_as_array('action')\n @action_strs\n end", "def message(string)\n puts\n puts \"[#{colorize(\"--\", \"blue\")}] #{ string }\"\nend", "def print msg, color\n @text[2] = @text[1]\n @text[1] = @text[0]\n @text[0] = Message.new(msg, color, 18)\n end", "def colorize_logging=(_arg0); end", "def format_message(type, message, opts=nil)\n # Get the format of the message before adding color.\n message = super\n\n # Colorize the message if there is a color for this type of message,\n # either specified by the options or via the default color map.\n if opts.has_key?(:color)\n color = COLORS[opts[:color]]\n message = \"#{color}#{message}#{COLORS[:clear]}\"\n else\n message = \"#{COLOR_MAP[type]}#{message}#{COLORS[:clear]}\" if COLOR_MAP[type]\n end\n\n message\n end", "def colorize(text, color)\n\t\"\\e[#{Colors[color]}m#{text}\\e[0m\"\nend", "def success_message\n puts \"Correct!\".green\nend", "def colorize(color, text)\n \"\\e[#{color}m#{text}\\e[0m\"\n end", "def colorize(text, color_code); \"\\e[#{color_code}m#{text}\\e[0m\"; end", "def message_types\n {\n create: [:light_cyan, :cyan],\n store: [:light_cyan, :cyan],\n update: [:light_cyan, :cyan],\n reset: [:light_cyan, :cyan],\n\n event: [:light_magenta, :magenta],\n\n timer: [:light_blue, :blue],\n\n info: [:white, :light_grey],\n test: [:white, :light_grey],\n debug: [:white, :light_grey],\n\n input: [:light_yellow, :yellow],\n output: [:light_green, :green],\n\n error: [:light_red, :red],\n\n config: [:light_blue, :blue],\n dsl: [:light_blue, :blue],\n editor: [:light_blue, :blue],\n drb: [:light_blue, :blue],\n }\n end", "def process_text text, color = \"#000000\"\n end", "def colorize(s, c = :green)\n %{\\e[#{c == :green ? 33 : 31}m#{s}\\e[0m}\n end", "def trace( *msg )\n\t\t\treturn unless Rake.application.options.trace\n\t\t\toutput = colorize( msg.flatten.join(' '), 'yellow' )\n\t\t\t$stderr.puts( output )\n\t\tend", "def colorize(text, color=nil)\n CLIColorize.colorize(text, color)\n end", "def html_out(msg, color_name=\"black\")\n\t\t\trgb = Color::RGB::by_name color_name\n\t\t\tputs \"<span style='color:#{rgb.css_rgb};'>#{msg}</span>\"\n\t\tend", "def blue(text)\n colorize(text, 34)\nend", "def report_message(message, state)\n color = state == true ? :green : :red\n str = message.colorize(color)\n output_to_path(str)\n store(str, state)\n end", "def print_action_sum\n string = 'Liked: ' + @total_likes.to_s.colorize(:red) +\n ' Followed: ' + @total_follows.to_s.colorize(:red) +\n ' Unfollowed: ' + @total_unfollows.to_s.colorize(:red)\n print_time_stamp\n puts string\n end", "def red\n colorize(31)\n end", "def get_color\n completed? ? 'info' : 'warning'\n end", "def flash_message_defaults(resource_name, action, status, past_tense)\n controller_with_namespace = [resource_namespace, controller_name].compact.join('.')\n\n [\n :\"flash.#{controller_with_namespace}.#{action}.#{status}_html\",\n :\"flash.#{controller_with_namespace}.#{action}.#{status}\",\n :\"flash.#{controller_name}.#{action}.#{status}_html\",\n :\"flash.#{controller_name}.#{action}.#{status}\",\n :\"flash.actions.#{action}.#{status}\",\n \"#{resource_name} was successfully #{past_tense}.\"\n ]\n end", "def success(*args)\n color(32, *args)\n end", "def output_color(text, color=text.to_i)\r\n # Color matches: 1 - Black; 2 - White; 3 - Red; 4 - Yellow; 5 - Green; 6 - Blue; 7 - Gold\r\n colors = { 1 => 30, 2 => 36, 3 => 31, 4 => 33, 5 => 35, 6 => 34, 7 => 220 }\r\n # \\e[47m Is for the grey foreground \\e[{color} is for picking the color and \\e[0m is for resetting the terminal.\r\n \"\\e[1m\\e[47m\\e[#{colors[color]}m#{text}\\e[0m\\e[22m\"\r\n end", "def instruction_message\n puts \"\\nMASTERMIND is a color guessing game where the computer generates a \\\nrandom string of four characters representing the base colors #{\"(r)ed\".red}, \\\n#{\"(g)reen\".green}, #{\"(b)lue\".blue}, and/or #{\"(y)ellow\".yellow}. \\\nThe intermediate difficulty level is six characters and adds \\\n#{\"(m)agenta\".magenta} and the advanced difficulty level is eight characters \\\nand adds #{\"(c)yan\".cyan}. \\\nThe string is only guaranteed to contain one color. The player must submit \\\nguesses to try to find the generated combination. Guesses are not case sensitive.\"\n\n puts \"\\nEnter #{\"(p)lay\".green}, #{\"(i)nstructions\".yellow} or #{\"(q)uit\".red}\"\n end", "def action_for_message\n val = message_context_session.delete(:context)\n context = val && val.to_s\n super || context && begin\n args = payload['text'].try!(:split) || []\n action = action_for_message_context(context)\n [[action, type: :message_context, context: context], args]\n end\n end", "def success_style(success)\n green_style(success)\nend", "def message(action)\n render_to_string :partial => 'messages/status', :locals => {:player => request_user, :action => action}\n end", "def msg(m, fg = nil, bg = nil)\n m\nend", "def msg(m, fg = nil, bg = nil)\n m\nend", "def severity_color(level)\n case level\n when \"DEBUG\"\n \"\\033[0;34;40m[DEBUG]\\033[0m\" # blue\n when \"INFO\"\n \"\\033[1;37;40m[INFO]\\033[0m\" # bold white\n when \"WARN\"\n \"\\033[1;33;40m[WARN]\\033[0m\" # bold yellow\n when \"ERROR\"\n \"\\033[1;31;40m[ERROR]\\033[0m\" # bold red\n when \"FATAL\"\n \"\\033[7;31;40m[FATAL]\\033[0m\" # bold black, red bg\n else\n \"[#{level} # none\"\n end\n end", "def colorize!(color_code) \"#{COLORS[color_code]}#{self.to_s}\\e[0m\" ; end", "def status_color(accepted)\n if accepted == 0\n return \"style=\\\"color:red;\\\"\"\n elsif accepted == 1\n return \"style=\\\"color:gray;\\\"\"\n elsif accepted == 2\n return \"style=\\\"color:black;\\\"\"\n else\n return \"style=\\\"color:red;\\\"\"\n end\n end", "def status_color\n if self.success && self.error_text.nil?\n return 'green'\n elsif self.success\n return 'yellow'\n else\n return 'red'\n end\n end", "def alert(message)\n $stdout.puts(message.green)\nend", "def colorize *args\n $terminal.color(*args)\nend", "def yellow\n colorize(33)\n end", "def error_message( msg, details='' )\n\t\t$stderr.puts colorize( 'bold', 'white', 'on_red' ) { msg } + ' ' + details\n\tend", "def text_urgent(text); text_green(text);end", "def process_messages(type)\n message_hash = {\n '_correct' => [\n 'Correct!',\n 'That\\'s right',\n 'Nice, good choice!',\n 'A fine letter you picked',\n 'Thumbs up from me'\n ],\n '_incorrect' => [\n 'Not quite the right guess...',\n 'Getting closer... I hope anyway',\n 'Nope, not what I\\'m looking for',\n 'A compeltely different letter would have done the trick.'\n ],\n '_invalid' => [\n 'That guess is simply unacceptable! Humph.',\n 'Ensure you\\'re typing unused letters only or save',\n 'Input invalid. Beep boop.',\n 'Executioner: invalid input huh... this player isn\\'t takin\\' us seriously. Best sort \\'im out.'\n ],\n '_serialise' => ['Serialising...', 'Saving...', 'Committing your performance to memory!']\n }\n to_print = message_hash[type].sample\n message_colour(type, to_print)\n end", "def write(message)\n messages << remove_ansi_colors(message)\n end", "def ui_action(message)\n puts message\n yield\n end", "def msg(m, fg = nil, bg = nil)\n m\n end", "def basic_status_and_output(messages); end", "def colorize(string, level)\n case level\n when 1\n string\n when 2\n string.color(:green)\n when 3\n string.color(:yellow)\n when 4\n string.color(:red)\n end\n end", "def output(message, type)\n puts \"\\e[31m[ ✘ ]\\e[0m #{message}\" if type == 'error'\n puts \"\\e[32m[ ✔︎ ]\\e[0m #{message}\" if type == 'success'\n puts \"\\e[33m[ ✻ ]\\e[0m #{message}\" if type == 'info'\nend", "def colorize_text(text)\n return text unless ActiveRecordQueryTrace.colorize\n # Try to convert the choosen color from string to integer or try\n # to use the colorize as the color code\n colors = {\n true => \"38\", \"blue\" => \"34\", \"light red\" => \"1;31\",\n \"black\" => \"30\", \"purple\" => \"35\", \"light green\" => \"1;32\",\n \"red\" => \"31\", \"cyan\" => \"36\", \"yellow\" => \"1;33\",\n \"green\" => \"32\", \"gray\" => \"37\", \"light blue\" => \"1;34\",\n \"brown\" => \"33\", \"dark gray\" => \"1;30\", \"light purple\" => \"1;35\",\n \"white\" => \"1;37\", \"light cyan\" => \"1;36\"\n }\n color_code = colors[ActiveRecordQueryTrace.colorize] ||\n ActiveRecordQueryTrace.colorize.to_s\n unless /\\d+(;\\d+){0,1}/.match(color_code)\n raise \"Invalid color. Use one of #{ colors.keys } or a valid color code\"\n end\n \"\\e[#{ color_code }m#{ text }\\e[0m\"\n end", "def display_array(messages)\n max_length = messages.map{|m| m.nil? ? '' : m.uncolorize }.max_by(&:length).length\n breaker = ('-'*max_length).green\n messages.each do |msg|\n if msg.nil?\n tell_user breaker\n elsif msg[0] == '-' && msg[-1] == '-'\n msg = msg[1..-2]\n extra_space = (max_length - msg.uncolorize.length) / 2\n extra_space = 1 if extra_space < 1\n spacer = '-'*extra_space\n if msg.colorized?\n tell_user \"#{spacer.green}#{msg}#{ (max_length-msg.length)%2 == 1 ? (spacer+'-').green : spacer.green }\"\n else\n tell_user \"#{spacer}#{msg}#{spacer}\".green\n end\n else\n tell_user msg\n end\n end\n tell_user \"\\n\"\n end", "def colorize(params)\n if params.is_a? Hash\n text = self\n params.each do |regexp, color|\n text = text.gsub(regexp, \"\\\\0\".colorize(color))\n end\n return text\n end\n Yummi::colorize self, params\n end", "def colorize(*args)\n shell.set_color(*args)\n end", "def colorize txt, fg, bg, flags\n txt\n end", "def color\n\t\tif name == \"Broken\"\n\t\t\tcolor = \"red\"\n\t\telsif name == \"Needs Attention\"\n\t\t\tcolor = \"orange\"\n\t\telsif name == \"Working\"\n\t\t\tcolor = \"green\"\n\t\telse\n\t\t\tcolor = \"\"\n\t\tend\n\t\treturn color\n end", "def set_colors\n if @color_output \n @c_app_info = @color_app_info\n @c_app_exe = @color_app_exe\n @c_command = @color_command\n @c_description = @color_description\n @c_parameter = @color_parameter\n @c_usage = @color_usage\n \n @c_error_word = @color_error_word\n @c_error_name = @color_error_name\n @c_error_description = @color_error_description\n \n @c_bold = @color_bold\n @c_reset = @color_reset\n else\n @c_app_info, @c_app_exe, @c_command, \n @c_description, @c_parameter, @c_usage, \n @c_bold, @c_reset, @c_error_word, \n @c_error_name, @c_error_description = [\"\"]*11\n end\n end", "def action=(action)\n @message[:action] = action\n end", "def colorize(text, color_code)\n \"\\e[#{color_code}m#{text}\\e[0m\"\nend", "def generate_color(status)\n if status == :completed\n :green\n elsif status == :failed\n :red\n else\n :yellow\n end\n end", "def process_options\n puts ScrumyChangeColor::ALLOWED_COLORS.join(', ') if @options.list_colors\n end", "def colorize(effect)\n if STDOUT.tty? && ENV['TERM']\n \"\\033[0;#{30+COLORS.index(effect.to_sym)}m#{self}\\033[0m\"\n else\n self\n end\n rescue\n self\n end", "def colored\n reparse\n parsed_colors[:string].apply_colors(parsed_colors[:colors])\n end", "def log_action msg\n\t\t\t\tputs '=> ' + msg\n\t\t\tend", "def to_text\n \n output_res=[]\n \n if @seq_rejected\n output_res<< \"[#{@tuple_id},#{@order_in_tuple}] Sequence #{seq_name} had the next actions: \".bold.underline + \" REJECTED: #{@seq_rejected_by_message}\".red \n # puts @seq_name.bold + bold + ' REJECTED BECAUSE ' +@seq_rejected_by_message.bold if @seq_rejected \n else\n output_res<< \"[#{@tuple_id},#{@order_in_tuple}] Sequence #{seq_name} had the next actions: \".bold.underline \n \n end\n \n n=1\n withMessage = [\"ActionIsContaminated\",\"ActionVectors\",\"ActionBadAdapter\",\"ActionLeftAdapter\",\"ActionRightAdapter\"] \n color = red\n \n @actions.sort!{|e,f| e.start_pos<=>f.start_pos}.each do |a| \n a_type=a.action_type\n color = a.apply_decoration(\" EXAMPLE \") \n color2 =a.apply_decoration(\" #{a_type.center(8)} \") \n \n reversed_str = '' \n \n if a.reversed\n reversed_str = \" REVERSED \".bold \n end\n \n output_res<< \" [#{n}] \".bold + color2+ \" #{a.title} \".ljust(24).reset + \" [ \" + \" #{a.start_pos+1}\".center(6) + \" , \" + \"#{a.end_pos+1}\".center(6) + \" ]\" + clear.to_s + \"#{a.message}\".rjust(a.message.size+8) + reversed_str\n \n n +=1 \n end\n \n pos = 0\n res = '' \n \n @seq_fasta_orig.each_char do |c|\n \n @actions.each do |a|\n c= a.decorate(c,pos) \n \n end \n \n res += c\n \n pos += 1\n end \n \n output_res<< res\n \n if SHOW_QUAL and @seq_qual_orig\n res = '' \n pos=0 \n output_res<< ''\n @seq_fasta_orig.each_char do |c2|\n c=@seq_qual_orig[pos].to_s+' '\n @actions.each do |a|\n c= a.decorate(c,pos) \n\n end \n res += c\n pos += 1\n end\n \n output_res<< res\n end\n \n if SHOW_FINAL_INSERTS \t\t \n output_res<< \"INSERT ==>\"+get_inserts.join(\"\\nINSERT ==>\")\n output_res<< \"=\"*80\n end\n # puts @seq_name.bold + bold + ' rejected because ' +@seq_rejected_by_message.bold if @seq_rejected \n\n return output_res\n end", "def bold_warning(*args)\n color('1;33', *args)\n end", "def colorize(text, color_code)\n \"\\e[#{color_code}m#{text}\\e[0m\"\nend", "def colorize(text, color_code)\n \"\\e[#{color_code}m#{text}\\e[0m\"\nend", "def colorize(text, color_code)\n \"\\e[#{color_code}m#{text}\\e[0m\"\nend", "def error_message( msg, details='' )\n\t\t\t$stderr.puts colorize( 'bold', 'white', 'on_red' ) { msg } + details\n\t\tend", "def notify aAction, aMessage\n printf \"%12s %s\\n\", aAction, aMessage\n end", "def formatter(text, action)\n case action\n when 'lowercase'\n return text.downcase\n when 'uppercase'\n return text.upcase\n when 'camelcase'\n return text.downcase.gsub(/\\b\\w/){$&.upcase}\n when 'snakecase'\n return text.gsub! ' ', '_'\n when 'reverse'\n return text\n .split('')\n .reverse()\n .join('')\n when 'countchar'\n return text.gsub(' ', '').split('').length\n when 'countword'\n return text.gsub('\\n',' ').split(' ').length\n when 'countline'\n return text.split('\\n').length\n end\nend", "def colorize( *args )\n\t\t\tstring = ''\n\n\t\t\tif block_given?\n\t\t\t\tstring = yield\n\t\t\telse\n\t\t\t\tstring = args.shift\n\t\t\tend\n\n\t\t\tending = string[/(\\s)$/] || ''\n\t\t\tstring = string.rstrip\n\n\t\t\treturn ansi_code( args.flatten ) + string + ansi_code( 'reset' ) + ending\n\t\tend", "def colorize( *args )\n\t\t\tstring = ''\n\n\t\t\tif block_given?\n\t\t\t\tstring = yield\n\t\t\telse\n\t\t\t\tstring = args.shift\n\t\t\tend\n\n\t\t\tending = string[/(\\s)$/] || ''\n\t\t\tstring = string.rstrip\n\n\t\t\treturn ansi_code( args.flatten ) + string + ansi_code( 'reset' ) + ending\n\t\tend", "def colorize( *args )\n\t\t\tstring = ''\n\n\t\t\tif block_given?\n\t\t\t\tstring = yield\n\t\t\telse\n\t\t\t\tstring = args.shift\n\t\t\tend\n\n\t\t\tending = string[/(\\s)$/] || ''\n\t\t\tstring = string.rstrip\n\n\t\t\treturn ansi_code( args.flatten ) + string + ansi_code( 'reset' ) + ending\n\t\tend", "def colorize( *args )\n\t\t\tstring = ''\n\n\t\t\tif block_given?\n\t\t\t\tstring = yield\n\t\t\telse\n\t\t\t\tstring = args.shift\n\t\t\tend\n\n\t\t\tending = string[/(\\s)$/] || ''\n\t\t\tstring = string.rstrip\n\n\t\t\treturn ansi_code( args.flatten ) + string + ansi_code( 'reset' ) + ending\n\t\tend", "def colorize( *args )\n\t\t\tstring = ''\n\n\t\t\tif block_given?\n\t\t\t\tstring = yield\n\t\t\telse\n\t\t\t\tstring = args.shift\n\t\t\tend\n\n\t\t\tending = string[/(\\s)$/] || ''\n\t\t\tstring = string.rstrip\n\n\t\t\treturn ansi_code( args.flatten ) + string + ansi_code( 'reset' ) + ending\n\t\tend" ]
[ "0.6814007", "0.651351", "0.64046085", "0.63501096", "0.62814885", "0.6226943", "0.60223216", "0.5982107", "0.59337145", "0.59144056", "0.58934546", "0.5865128", "0.5863261", "0.5855968", "0.5854905", "0.58496714", "0.58496714", "0.5847925", "0.5846873", "0.5845119", "0.5840962", "0.5828198", "0.58167404", "0.5810942", "0.58063406", "0.57629", "0.57602084", "0.5748377", "0.5737919", "0.57113963", "0.5701681", "0.56876755", "0.56837565", "0.56652635", "0.5641836", "0.5640672", "0.5621483", "0.5600124", "0.55916184", "0.55903757", "0.55777615", "0.5571885", "0.5570306", "0.5567211", "0.55657506", "0.5554188", "0.5522803", "0.55018103", "0.549416", "0.54874575", "0.5480268", "0.5477673", "0.54683036", "0.5463452", "0.54629123", "0.54580986", "0.54580986", "0.5448877", "0.544535", "0.5441067", "0.5435549", "0.5433738", "0.54306185", "0.5426437", "0.5422585", "0.5417181", "0.5414287", "0.5407638", "0.53985214", "0.53898036", "0.5386474", "0.5382028", "0.5377158", "0.5371824", "0.5361632", "0.5361459", "0.53596514", "0.53559554", "0.535404", "0.53538597", "0.53506064", "0.5342968", "0.5339589", "0.53323525", "0.5328572", "0.5327321", "0.53244114", "0.53220725", "0.5318496", "0.5316395", "0.5316395", "0.5316395", "0.5314223", "0.530862", "0.5302272", "0.52819234", "0.52819234", "0.52819234", "0.52819234", "0.52819234" ]
0.8019794
0
remove prefix defined in +PREFIX_REGEX+ from message
def remove_prefix(msg) msg.sub(PREFIX_REGEX, "|") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strip_prefix(name)\n name.sub /^[xX][rR](_?)/, \"\"\nend", "def strip_prefix(str, prefix)\n str.start_with?(prefix) ? str.slice(prefix.length..-1) : str\n end", "def remove_prefix!(string)\n string.gsub!(\"#{VM_PREFIX}_\", '')\n string.gsub!(VM_PREFIX, '')\nend", "def strip_prefix(string)\n string[/^OK.(.*)/, 1]\n end", "def clean_subject(string)\n without_label = string.gsub(subject_prefix_regex, '')\n if without_label =~ REGARD_RE\n \"Re: #{remove_regard(without_label)}\"\n else\n without_label\n end\n end", "def prefix\n match(/Prefix\\s+:\\s+([^\\s])/)\n end", "def clean_message(message); end", "def delete_prefixed(prefix)\n raise NotImplementedError\n end", "def clean_message\n self.message = Loofah.fragment(self.message).scrub!(:strip).text\n end", "def deprefix(str)\n str.gsub(/^-[a-zA-Z0-9]+-/, '')\n end", "def remove_prefix_refs(ref)\n regex = %r{\\Arefs/(?<stripped_ref>.+)\\Z}\n match = regex.match(ref)\n fail InvalidRefPrefixError, \"ref: #{ref}\" unless match\n match[:stripped_ref]\n end", "def sanitize_prefixed_tags_from(soap)\n soap.gsub /(m|env):/, ''\n end", "def remove_envelope(message)\n generator.strip(message)\n end", "def prefix\n regexify(bothify(fetch('aircraft.prefix')))\n end", "def unprefix_index(index)\n index.sub(/^\\d{14}_/, '')\n end", "def delete_pre_address(address)\n address = address.sub(/^\\s*mail\\:\\s*/i, '')\n address.gsub(/.*\\,\\s+(\\d+\\b\\s+\\w)/i, '\\1')\n end", "def remove_prefix(conten)\n conten.gsub(/#{path_prefix}([^\"]*)/, \"\\\\1.json\")\n end", "def clean(message)\n message = message.to_s.dup\n message.strip!\n message.gsub!(/%/, '%%') # syslog(3) freaks on % (printf)\n message.gsub!(/\\e\\[[^m]*m/, '') # remove useless ansi color codes\n return message\n end", "def delete_prefix(str)\n s = dup\n s.delete_prefix!(str)\n s\n end", "def clean(message)\n message = message.to_s.dup\n message.strip!\n message.gsub!(/%/, '%%') # syslog(3) freaks on % (printf)\n message.gsub!(/\\e\\[[^m]*m/, '') # remove useless ansi color codes\n return message\n end", "def strip_filename_prefix(filename, prefix)\n f = filename.rpartition(File.basename(filename))\n f[1] = strip_prefix(f[1], prefix)\n f.join\n end", "def handle_prefixes\n return identifier if identifier.blank?\n identifier.strip!\n identifier.gsub!(DOI_MATCH, '') if identifier\n end", "def remove_prefix_and_suffix(table)\n super(table.sub(/\\A[a-z0-9_]*\\./, ''))\n end", "def to_telegram(msg)\n msg.gsub(/\\./,\" STOP\")\nend", "def remove(pattern)\n gsub pattern, ''\n end", "def test_String_006_remove_prefix\n \n puts2(\"\")\n puts2(\"#######################\")\n puts2(\"Testcase: test_String_006_remove_prefix\")\n puts2(\"#######################\")\n \n sMyFile = \"some_long_filename.log\"\n puts2(\"\\nReturn the file extension for: \" + sMyFile)\n sMyFilePrefix = sMyFile.remove_prefix(\".\")\n puts2(\"File name: \" + sMyFilePrefix)\n #\n sMyEmailAddress = \"[email protected]\"\n puts2(\"\\nReturn the Domain Name of the Email address: \" + sMyEmailAddress)\n sMyUserAccount = sMyEmailAddress.remove_prefix(\"@\")\n puts2(\"User account: \" + sMyUserAccount)\n \n sMyString = \"This is a test\"\n puts2(\"\\nReturn the string with the first word removed: \" + sMyString)\n sMyFirstWord = sMyString.remove_prefix(\" \")\n puts2(\"First word: \" + sMyFirstWord)\n \n sMyString = \" String with leading & trailing white space \"\n puts2(\"\\nReturn the first word of the String: \" + sMyString)\n sMyFirstWord = sMyString.remove_prefix(\" \")\n puts2(\"First word: \" + sMyFirstWord)\n \n sMyString = \" No delimiter specified \"\n puts2(\"\\nReturn the whole String if: \" + sMyString)\n sMyFirstWord = sMyString.remove_prefix(\"\")\n puts2(\"String: \" + sMyFirstWord)\n \n sMyString = \" Multiple delimiter-characters that are in the specified string \"\n puts2(\"\\nReturn the string with the first word removed: \" + sMyString)\n sMyFirstWord = sMyString.remove_prefix(\" #\")\n puts2(\"First word: \" + sMyFirstWord)\n \n sMyString = \" Delimiter character is NOT in the string \"\n puts2(\"\\nReturn the whole String if: \" + sMyString)\n sMyFirstWord = sMyString.remove_prefix(\".\")\n puts2(\"String: \" + sMyFirstWord)\n \n end", "def clean(message)\n message = message.to_s.strip\n message.gsub!(/\\e\\[[0-9;]*m/, '') # remove useless ansi color codes\n message\n end", "def remove_augment(old_form, prefix_preposition)\n # deal first with prefix preposition like απο in αποθνησκω\n #puts old_form\n form = old_form.clone\n prefix_preps = ['','']\n if prefix_preposition\n @all_prefix_prepositions.values.each do |prep| #something like επ απ αν προσ\n if form =~ /^#{prep}/\n form.sub!(/^#{prep}/,'')\n # reverse_prefix_prepositions maps απο to απ, etc.\n prefix_preps = [prep, @reverse_prefix_prepositions[prep]]\n end\n end\n end\n\n beginning_string =\n @all_augmented_beginnings.detect { |beginning| form =~ /^#{beginning}/ }\n new_form =\n if @reverse_augments[beginning_string]\n form.sub(/^#{beginning_string}/, @reverse_augments[beginning_string] )\n else\n form.sub(/^ε([^υ])/,'\\1')\n end\n #puts new_form\n r =\n if new_form =~ /^[αειουηωᾳῳῃ]/\n prefix_preps[0] + new_form\n else\n prefix_preps[1] + new_form\n end\n #puts r\n return r\n end", "def trim_underscore_prefix(name)\n if config['allow_leading_underscore']\n # Remove if there is a single leading underscore\n name = name.gsub(/^_(?!_)/, '')\n end\n\n name\n end", "def tstrip(term)\n ['au:','ti:','abs:','feed:'].each do |prefix|\n term = term.split(':', 2)[1] if term.start_with?(prefix)\n end\n term#.gsub(\"'\", \"''\").gsub('\"', \"'\")\n end", "def append_without_prefix(string); end", "def trim_underscore_prefix(name)\n if config['allow_leading_underscore']\n # Remove if there is a single leading underscore\n name = name.sub(/^_(?!_)/, '')\n end\n\n name\n end", "def strip_message_from_whitespace msg\n msg.split(\"\\n\").map(&:strip).join(\"\\n#{add_spaces(10)}\")\n end", "def optional_prefix(prefix, message)\n [prefix + message, message]\nend", "def remove_appended_messages(text)\n return nil if text.nil? || text.empty?\n string = text.to_s # ensure we have a string\n\n # ------------ Original Message ------------\n string.gsub! /(<[\\w\\s=:\"#]+>|^)+[-=]+.*Original Message.*/mi, ''\n\n # ------------ Forwarded Message ------------\n string.gsub! /(<[\\w\\s=:\"#]+>|^)+[-=]+.*Forwarded Message.*/mi, ''\n\n # From: Seth Vargo <[email protected]>\n # Send: Tues, Oct 9, 2012\n # To: Robbin Stormer <[email protected]>\n # Subject: Cookies and Cream\n string.gsub! /(<[\\w\\s=:\"#]+>|^)+From:.*Sent:.*(To:.*)?.*(Cc:.*)?.*(Subject:.*)?.*/im, ''\n\n # On Oct 9, 2012, at 6:48 PM, Robbin Stormer wrote:\n string.gsub! /(<[\\w\\s=:\"#]+>|^)+On.+at.+wrote:.*/mi, ''\n\n # Begin forwarded message:\n string.gsub! /(<[\\w\\s=:\"#]+>|^)+Begin\\ forwarded\\ message:.*/mi, ''\n string.strip!\n string\n end", "def prefix\n ''\n end", "def to_telegram(message)\n message.gsub(/\\./, \" STOP\")\nend", "def to_telegram message\n message.gsub(/\\./, \" STOP\")\nend", "def remove_message(name)\n\t\tend", "def removeNamespace(prefix) \n @obj.removeNamespace(prefix)\n end", "def to_telegram (message)\n message.gsub(/\\./, \" STOP\") \nend", "def remove!(pattern)\n gsub! pattern, ''\n end", "def remove_suffix!(pattern)\n gsub!(/#{pattern}\\z/, '')\n self\n end", "def strip_message_from_whitespace(msg)\n msg.split(\"\\n\").map(&:strip).join(\"\\n#{add_spaces(10)}\")\n end", "def strip_message_from_whitespace(msg)\n msg.split(\"\\n\").map(&:strip).join(\"\\n#{add_spaces(10)}\")\n end", "def truncate(msg, extra = 0)\n max = MAX_MESSAGE_LENGTH - @prefix.length - 3 - extra\n msg = msg[0..max] if msg.length > max\n msg\n end", "def remove_negations\n\n logger(\"Removing negations in #{@prefix.compact.join(\" \").to_s}\")\n\n prefix_array_reduced = @prefix.compact.join(\" \").to_s.gsub(/[\\/\\*]\\s0\\s[A-Za-z1-9]+|-\\s((([1-9][0-9]*\\.?[0-9]*)|(\\.[0-9]+)|[A-Za-z]+))\\s\\1|[\\+-\\/\\*]\\s0\\s0|[\\/\\*]\\s[A-Za-z0-9]+\\s0/,\"0\").gsub(/\\/\\s([A-Za-z1-9])\\s\\1/,\"1\")\n\n logger(\"Reduced to #{prefix_array_reduced}\")\n\n @prefix = prefix_array_reduced.split\n prefix_array_reduced = prefix_array_reduced.split.join(\" \")\n\n if !/\\/\\s([A-Za-z1-9])\\s\\1|[\\/\\*]\\s0\\s[A-Za-z1-9]+|-\\s((([1-9][0-9]*\\.?[0-9]*)|(\\.[0-9]+)|[A-Za-z]+))\\s\\2|[\\+-\\/\\*]\\s0\\s0|[\\/\\*]\\s[A-Za-z0-9]+\\s0/.match(prefix_array_reduced).nil?\n remove_negations\n else\n if !/^-\\s[\\/\\*\\+-].*0$/.match(prefix_array_reduced).nil?\n prefix_array_reduced.slice!(0..1)\n prefix_array_reduced.slice!((prefix_array_reduced.length-2)..(prefix_array_reduced.length-1))\n end\n return prefix_array_reduced\n end\n\n end", "def restore_prefix\n @removals.each do |removal|\n if removal.affix_type == 'DP'\n @current_word = removal.subject\n break\n end\n end\n\n @removals.each do |removal|\n if removal.affix_type == 'DP'\n @removals.delete(removal)\n end\n end\n end", "def regex_lineprefix\n Regexp.new(\"line#{VM_PREFIX}\")\nend", "def without_nick(message)\n possible_nick, command = message.split(' ', 2)\n if possible_nick.casecmp(at_nick) == 0\n command\n else\n message\n end\n end", "def value_without_scheme_prefix\n return value unless identifier_scheme.present? &&\n identifier_scheme.identifier_prefix.present?\n\n base = identifier_scheme.identifier_prefix\n value.gsub(base, '').sub(%r{^/}, '')\n end", "def handle_prefix(event)\n return false if event.channel.pm?\n\n @prefix_setcmd = event.content.strip.to_s\n @server = event.server.id\n check_user_or_nick(event)\n\n if @prefix_setcmd =~ /^(!dm prefix check)\\s*$/i\n @prefix_check = $db.execute \"select prefix from prefixes where server = #{@server}\"\n if @prefix_check.empty?\n event.respond(content: 'This servers prefix is set to: !roll')\n return true\n else\n event.respond(content: \"This servers prefix is set to: #{@prefix_check[0].join(', ')}\")\n return true\n end\n end\n\n if @prefix_setcmd =~ /^(!dm prefix reset)\\s*$/i\n if event.user.defined_permission?(:manage_messages) == true ||\n event.user.defined_permission?(:administrator) == true ||\n event.user.permission?(:manage_messages, event.channel) == true\n $db.execute \"delete from prefixes where server = #{@server}\"\n event.respond(content: 'Prefix has been reset to !roll')\n return true\n else\n event.respond(content: \"#{@user} does not have permissions for this command\")\n return true\n end\n end\n\n if @prefix_setcmd =~ /^(!dm prefix)/i\n if event.user.defined_permission?(:manage_messages) == true ||\n event.user.defined_permission?(:administrator) == true ||\n event.user.permission?(:manage_messages, event.channel) == true\n # remove command syntax and trailing which will be added later\n @prefix_setcmd.slice!(/!dm prefix\\s*/i)\n\n if @prefix_setcmd.empty?\n # do nothing if the set command is empty\n return true\n end\n\n if @prefix_setcmd.size > 10\n event.respond(content: 'Prefix too large. Keep it under 10 characters')\n return true\n end\n @prefix_prune = @prefix_setcmd.delete(' ')\n $db.execute \"insert or replace into prefixes(server,prefix,timestamp) VALUES (#{@server},\\\"!#{@prefix_prune}\\\",CURRENT_TIMESTAMP)\"\n event.respond(content: \"Prefix is now set to: !#{@prefix_prune}\")\n true\n else\n event.respond(content: \"#{@user} does not have permissions for this command\")\n true\n end\n end\nend", "def remove_listlibrary_headers str\n # Lots of messages have Message-Id headers added;\n # Date headers were added to 3 in ruby-list, 2 in chipy\n # 3 messages in ruby-list have Date headers added\n # 2 messages in chipy have Date headers added\n while str =~ /^X-ListLibrary-Added-Header: (.*)$/\n header = $1 # Thanks, Perl\n header.sub!('\\n','') # yes, remove a literal \\n that yaml didn't parse\n str.sub!(/^#{header}: .*\\n/, '')\n str.sub!(/^X-ListLibrary-Added-Header: .*\\n/, '')\n end\n str\nend", "def original_email(email)\n if email.match(/\\[\\w+-\\d+\\]/)\n email.sub(/\\[\\w+-\\d+\\]/, '')\n else\n email\n end\n end", "def to_telegram(msg)\n msg.gsub(\".\", \" STOP\")\nend", "def unprefixed(path)\n OneCfg::Config::Utils.unprefixed(path, @prefix)\n end", "def regex_stop_prefix\n Regexp.new(\"\\\\.line#{VM_PREFIX}\")\nend", "def sanitize\n\t\[email protected]!(/[^a-zA-Z]/, \"\")\n\t\[email protected]!\n\n\t\tremainder = @message.length % 5\n\t\tif remainder > 0\n\t\t\t(5 - remainder).times do\t\t\t\t\n\t\t\t\t@message << \"X\"\n\t\t\tend\n\t\tend\n\n\t\t@grouped = @message.scan(/...../)\n\tend", "def remove_name_classifications(proto_record)\n proto_record[:full_name] = proto_record[:full_name].sub(/\\s-\\s[A-Z\\s]*/, '')\n end", "def process_message(event, dict, prefix)\r\n if nil==dict or nil==prefix or event.content.strip == \"\" or event.content.strip[0].eql?(prefix)\r\n return\r\n end\r\n\r\n log_message(event, dict)\r\n end", "def sanitize_mods_name_label(label)\n label.sub(/:$/, '')\n end", "def remove_name_classifications(proto_record)\n proto_record[:full_name] = proto_record[:full_name].sub(/\\s-\\s[A-Z\\s]*/, \"\")\n end", "def to_telegram (foo)\n foo.gsub(/[.]/, \" STOP\")\n end", "def to_telegram message\n message.gsub(/\\./, \" STOP\")\n end", "def to_telegram message\n p message\n message.gsub(/[.]/, \" STOP\")\nend", "def to_telegram(message)\n return message.gsub(\".\", \" STOP\")\nend", "def delete_prefixed(prefix)\n instrument :delete_prefixed, prefix: prefix do\n maps = ActiveStorage::ImgurKeyMapping.by_prefix_key(prefix)\n maps.each do |map|\n client.image.image_delete(map.imgur_id)\n map.destroy!\n end\n end\n end", "def without_instruction(text)\n text.gsub(/^you (should|must)/i, '').gsub(/\\.$/, '')\n end", "def prefix\n nil\n end", "def validate_message(message)\n\n\n validated_message = message.gsub(/[^a-zA-Z]/, '').upcase.gsub('J','I')\n\n\n end", "def destroy_message(string)\n array = string.partition(\":\")\n\tfinal = array[0] + array[1]\nend", "def sanitize_label(label)\n label.gsub(%r![^a-z0-9_\\-.]!i, \"\")\n end", "def tidy(object, prefix)\n object.gsub!(prefix, '')\n object.chomp!(\".html\")\n \n object = @utils.partial(object, \"remove\") if object.include?('.scss') \n object.chomp!(\".scss\")\n \n object\n end", "def prefix (prefix, message)\n yield(prefix, message)\n end", "def unified_message\n notice.message.gsub(/(#<.+?):[0-9a-f]x[0-9a-f]+(>)/, '\\1\\2')\n end", "def wrap_prefix(prefix)\n prefix\n end", "def fix_name(name)\n if name[0,1] == '^'\n return \"#{ARTML.prefix}#{name[1..-1].strip}\"\n else\n return name.strip\n end\n end", "def prefixes; end", "def prefixes; end", "def prefixes\n prefix.split(NAMESPACE_PATTERN)\n end", "def prefixes\n prefix.split(NAMESPACE_PATTERN)\n end", "def _prefixes; end", "def regex_op_prefix\n Regexp.new(\"\\\\(line#{VM_PREFIX}\")\nend", "def clean_module_name(module_name)\n module_name.gsub /[\\-@]/, ''\n end", "def name_without_prefix\n info(:name_without_the_prefix)\n end", "def extract_test_prefix(bot_comment_body, settings=nil)\n test_prefix = nil\n if settings\n test_prefix = settings['test_prefix']\n else\n if Properties && Properties['settings']\n Properties['settings'].values.each do |test_settings|\n if test_settings['test_prefix'] && bot_comment_body.start_with?(test_settings['test_prefix'])\n # In case a valid test prefix happens to be a substring of another\n if test_prefix.nil? || (test_prefix && test_settings['test_prefix'].start_with?(test_prefix))\n test_prefix = test_settings['test_prefix']\n end\n end\n end\n end\n if !test_prefix\n # Do our best to find the prefix since we don't know it beforehand\n if bot_comment_body =~ /^([^:(]+:) /\n test_prefix = $1.strip\n elsif bot_comment_body =~ /^([^ (]+) /\n test_prefix = $1.strip\n end\n end\n end\n test_prefix\nend", "def str_prefix\n\t\t\t\t\"\"\n\t\t\tend", "def real_message\n m = full_message.split(\"\\n\").reject { |l| l.start_with?('#', \"#{SIG_KEY}:\") }.join(\"\\n\")\n /\\A\\s*(.*?)\\s*\\Z/m.match(m).captures.first\n end", "def prefix!(prefix=\"DEFAULT\")\n @session.chanserv.set(self.name, :prefix, prefix)\n end", "def strip_namespace\n split(\":\").last\n end", "def remove_lookup_context_prefixes(index = nil, *prefixes)\n prefixes.each do |prefix|\n if index\n if lookup_context.prefixes[index] == prefix\n lookup_context.prefixes.delete_at(index)\n end\n else\n lookup_context.prefixes.delete(prefix)\n end\n end\n end", "def scrub_plugin_name name\n\t\t\t\t\treturn name.gsub(\"(remote check)\", \"\").gsub(\"(uncredentialed check)\", \"\").gsub(/(\\(\\d.*\\))/, \"\")\n\t\t\t\tend", "def prefix=(_); end", "def unsubscribe(prefix)\n ffi_delegate.set_unsubscribe(prefix)\n end", "def sanitized_message\n message.to_s[0,140]\n end", "def prefix!( *pf )\r\n clone.prefix(*pf)\r\n end", "def regex_arrow_prefix\n Regexp.new(\"->line#{VM_PREFIX}\")\nend", "def get_prefixed_words(prefix)\n # FILL ME IN\n unless valid_word?(prefix)\n return \"Invalid input (string should only consist of letters).\"\n end\n output = findWords(prefix)\n if output.length() == 0\n return \"No prefixed words found!\"\n end\n output\n end", "def remove_formatting(str)\n Name.clean_incoming_string(str.gsub(/[_*]/, ''))\n end", "def remove_non_amino_acids(sequence)\n sequence.gsub(Nonstandard_AA_re, '')\n end" ]
[ "0.6854396", "0.67723227", "0.66307056", "0.6620254", "0.6306731", "0.62043434", "0.6190567", "0.6183674", "0.6120959", "0.61186594", "0.60173446", "0.60004866", "0.5987845", "0.5985826", "0.5896774", "0.584607", "0.5818836", "0.5769092", "0.57543695", "0.57396597", "0.57192534", "0.5690415", "0.564679", "0.56242263", "0.5597992", "0.5594235", "0.5575338", "0.5574723", "0.5574461", "0.55681956", "0.5561364", "0.55531037", "0.5541742", "0.55362743", "0.5507142", "0.5505074", "0.54860353", "0.54717994", "0.5467091", "0.5465535", "0.5459718", "0.54560584", "0.5453044", "0.5437312", "0.5437312", "0.5431922", "0.5428441", "0.5425692", "0.5407075", "0.5362136", "0.53546417", "0.5350288", "0.5343893", "0.5342076", "0.53418976", "0.5331076", "0.5328433", "0.5309998", "0.5305595", "0.5292881", "0.52878124", "0.5287492", "0.5279957", "0.5273073", "0.52491707", "0.5241335", "0.52370065", "0.52285117", "0.52083176", "0.5198256", "0.5197745", "0.518773", "0.51768404", "0.5174567", "0.5164761", "0.51588607", "0.51327616", "0.512883", "0.512883", "0.5127213", "0.5127213", "0.5116784", "0.5104039", "0.5101926", "0.5100846", "0.50830084", "0.50563526", "0.50554246", "0.5054311", "0.50531965", "0.5047721", "0.50445867", "0.50428754", "0.50395036", "0.5036537", "0.5026388", "0.5023865", "0.5014929", "0.50083333", "0.50067854" ]
0.8711799
0
send all other methods back to logger instance
def method_missing(method, *args, &block) @targets.each { |t| t.send(method, *args, &block) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def method_missing(m, *args, &block)\n \tRails.logger.send m, *args, &block\n end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end", "def log; end", "def log; end", "def log; end", "def log; end", "def log; end", "def log; end", "def log; end", "def log; end", "def logger ; @log end", "def log_writer; end", "def logger_output; end", "def log=(logger); end", "def log\n end", "def log=(log); end", "def logger=(logger); end", "def logger=(logger); end", "def flush\n return unless @buffer.size > 0\n @log.write_method(@buffer.slice!(0..-1).join)\n end", "def autoflush_log; end", "def autoflush_log; end", "def logger=(writer); end", "def logger=(writer); end", "def logger=(writer); end", "def logger=(writer); end", "def logger=(writer); end", "def method_missing(method_symbol, *args)\n init() unless @logger\n if args.length > 0\n @logger.send(method_symbol, *args)\n else\n @logger.send(method_symbol)\n end\n end", "def log_stuff\r\n log.info(\"TestLogger is here to log stuff.\")\r\n log.warn(\"TestLogger is finishged logging. Be careful.\")\r\n end", "def _roda_after_90__common_logger(result)\n super if result && _common_log_request?(result)\n end", "def log_state\n super\n end", "def method_missing(m, *args, &block)\n Rails.logger.send m, *args, &block\n end", "def send(method, *args)\n super\n rescue StandardError => e\n args[1].debug \"#{e}\\n #{e.backtrace.first}\" # args[1] is the logger\n end", "def rescuer\n begin\n yield\n rescue Exception => e\n # write to log files \n end\n end", "def with_logging(method_name = nil)\n method_name ||= caller[0][/`([^']*)'/, 1]\n result = yield\n self.log method_name, result\n result\n end", "def logs\n end", "def flush\n @logger.flush if @logger.respond_to?(:flush)\n end", "def reset_own_logger\n self.logger = nil\n end", "def flush\n @log.flush if @log.respond_to?(:flush)\n end", "def invoke_with_call_chain(*args)\n super\n @logger.flush\n exit(1) if respond_to?(:error?) && error?\n end", "def trace_log!\n Merb.logger.auto_flush = true\n end", "def reopen_logs; end", "def log()\n @log\n end", "def log\n self.class.log\n end", "def log \n\t\t\tArrow::Logger[ self.class ]\n\t\tend", "def autoflush_log=(_arg0); end", "def autoflush_log=(_arg0); end", "def log_dispatch(method, args=[])\n\t\t\tmeth_str = self.class.to_s + \"#\" + method.to_s\n\t\t\tmeth_str += \" #{args.inspect}\" unless args.empty?\n\t\t\tlog \"Dispatching to: #{meth_str}\"\n\t\tend", "def method_missing(m, *args, &block)\n if @replay_log\n @replay_log.send(m, *args, &block)\n end\n @normal_log.send(m, *args, &block)\n end", "def fancy_log\n\n @log.collect { |msg| fancy_print(msg) }\n end", "def logs\n\n end", "def method_missing(name, *args)\n if @logger && @logger.respond_to?(name)\n @logger.send(name, *args)\n end\n end", "def method_missing(m, *args)\n init unless @initialized\n @logger.level = level_from_sym(level) if @level_frozen\n res = @logger.__send__(m, *args)\n end", "def logger=(_arg0); end", "def logger=(_arg0); end", "def logger=(_arg0); end", "def logger=(_arg0); end", "def logger=(_arg0); end", "def logger=(_arg0); end", "def logger=(_arg0); end", "def supporting_method\n logger.warn 'This does nothing'\n end", "def logger; LOGGER; end", "def log(*args); end", "def log\n\t\t\t@log_proxy ||= ClassNameProxy.new( self.class )\n\t\tend", "def log\n\t\t\t@log_proxy ||= ClassNameProxy.new( self.class )\n\t\tend", "def log\n\t\t\t@log_proxy ||= ClassNameProxy.new( self.class )\n\t\tend", "def log\n\t\t\t@log_proxy ||= ClassNameProxy.new( self.class )\n\t\tend", "def log\n\t\t\t@log_proxy ||= ClassNameProxy.new( self.class )\n\t\tend", "def reset_logging\n\t\tTreequel.reset_logger\n\tend", "def log level, message; write level, message, caller[0] unless level > @level end", "def log\n @log\n end", "def with_logger\n yield\n end", "def reset_logging\n\t\tRoninShell.reset_logger\n\tend", "def flush_all!\n logger.flush if logger.respond_to?(:flush)\n end", "def logL\n raise \"No implemented\"\n end", "def log!(msg)\n log_info(msg)\n puts(msg)\nend", "def process_with_silent_log(method_name, *args)\n if logger\n @old_logger_level = logger.level\n if Rails.version >= '3.2'\n silence do\n process_without_silent_log(method_name, *args)\n end\n else\n logger.silence do\n process_without_silent_log(method_name, *args)\n end\n end\n else\n process_without_silent_log(method_name, *args)\n end\n end", "def log(*args)\nend", "def method_missing(meth, *args, &block)\n for_all_loggers(meth, *args, &block)\n end", "def log(message); logger.info(message); end", "def method_missing( sym, msg=nil, &block )\n\t\t\t\treturn super unless LEVEL.key?( sym )\n\t\t\t\tsym = :debug if @force_debug\n\t\t\t\tVerse.logger.add( LEVEL[sym], msg, @classname, &block )\n\t\t\tend", "def method_missing(name, *args, &)\n @loggers.each do |logger|\n logger.send(name, args, &) if logger.respond_to?(name)\n end\n end", "def end_method(method)\n\n return if !method.failed? or method.skipped?\n\n if not @logger.console.empty? then\n puts indent(underline(\"console.log:\"))\n puts indent(@logger.console.rstrip)\n puts\n end\n\n if not @logger.netlog.empty? then\n puts indent(underline(\"network requests:\"))\n puts indent(@logger.netlog.rstrip)\n puts\n end\n\n end", "def method_missing( sym, msg=nil, &block )\n\t\t\t\treturn super unless LEVEL.key?( sym )\n\t\t\t\tsym = :debug if @force_debug\n\t\t\t\tMUES.logger.add( LEVEL[sym], msg, @classname, &block )\n\t\t\tend" ]
[ "0.69424206", "0.6931033", "0.6931033", "0.6931033", "0.6931033", "0.6931033", "0.6931033", "0.6931033", "0.6931033", "0.6931033", "0.6931033", "0.6931033", "0.6931033", "0.6931033", "0.6931033", "0.6931033", "0.6931033", "0.6931033", "0.6931033", "0.6931033", "0.69254184", "0.69254184", "0.69254184", "0.69254184", "0.69254184", "0.69254184", "0.69254184", "0.69254184", "0.68857867", "0.6739812", "0.6734587", "0.67217326", "0.670253", "0.65851474", "0.658444", "0.658444", "0.64975786", "0.64342785", "0.64342785", "0.6432561", "0.6432561", "0.6432561", "0.6432561", "0.6432561", "0.6397296", "0.6396914", "0.6387284", "0.6363315", "0.63589287", "0.6352884", "0.63507414", "0.63381684", "0.6330412", "0.6325353", "0.6304222", "0.628195", "0.6258909", "0.62539726", "0.62519705", "0.62460047", "0.62399334", "0.621859", "0.6202379", "0.6202379", "0.61941296", "0.6190875", "0.6186319", "0.6183157", "0.6174575", "0.6167223", "0.6143069", "0.6143069", "0.6143069", "0.6143069", "0.6143069", "0.6143069", "0.6143069", "0.61362803", "0.61344683", "0.6132154", "0.613025", "0.613025", "0.613025", "0.613025", "0.613025", "0.61038095", "0.60974133", "0.6089044", "0.60681427", "0.60622734", "0.60616237", "0.60396487", "0.59986037", "0.59928966", "0.5985794", "0.59834677", "0.5981771", "0.59716994", "0.59669995", "0.5949522", "0.59450495" ]
0.0
-1
set color based one the defined constants. If a third option is set to +true+, the string will be made bold. CLEAR to the is automatically appended to the string for reset
def color(text, color, bold = false) bold = bold ? BOLD : "" "#{bold}#{color}#{text}#{CLEAR}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cyan; if @options[:colors]; \"\\e[1;36m\" else \"\" end end", "def color(text, color)\n if COLORS[color]\n \"#{start_color color}#{text}#{reset_color}\"\n end\n end", "def color(text, color, mode_options = {}) # :doc:\n return text unless colorize_logging\n color = self.class.const_get(color.upcase) if color.is_a?(Symbol)\n mode = mode_from(mode_options)\n clear = \"\\e[#{MODES[:clear]}m\"\n \"#{mode}#{color}#{text}#{clear}\"\n end", "def set_color(bool)\n b = bool ? true : false\n deb \"Setting color mode to: #{yellow bool} --> #{white b.to_s}\"\n b = false if bool.to_s.match( /(off|false)/ )\n deb \"Setting color mode to: #{yellow bool} --> #{white b.to_s}\"\n if block_given?\n puts \"TODO!!! scolara qui\"\n yield\n puts \"TODO ricolora qui\"\n end\n $colors_active = bool\n end", "def SetTextColor(r, g=-1, b=-1, storeprev=false)\n\t\t#Set color for text\n\t\tif ((r==0 and :g==0 and :b==0) or :g==-1)\n\t\t\t@text_color=sprintf('%.3f g', r/255.0);\n\t\telse\n\t\t\t@text_color=sprintf('%.3f %.3f %.3f rg', r/255.0, g/255.0, b/255.0);\n\t\tend\n\t\t@color_flag=(@fill_color!=@text_color);\n\t\tif (storeprev)\n\t\t\t# store color as previous value\n\t\t\t@prevtext_color = [r, g, b]\n\t\tend\n\tend", "def SetCmykTextColor(c, m, y, k, storeprev=false)\n\t\t#Set color for text\n\t\t@text_color=sprintf('%.3f %.3f %.3f %.3f k', c, m, y, k);\n\t\t@color_flag=(@fill_color!=@text_color);\n\t\tif (storeprev)\n\t\t\t# store color as previous value\n\t\t\t@prevtext_color = [c, m, y, k]\n\t\tend\n\tend", "def chco\n (foreground || \"FFFFFF\") + \",\" + super\n end", "def say_blue( msg, options=[] )\n options = options.unshift( '' ) unless options.empty?\n say \"<%= color(%q{#{msg}}, CYAN #{options.join(', ')}) %>\\n\" unless @silent\n end", "def bold_red(output)\n color('1;31', output)\n end", "def reset_colors\n @color_output = false\n\n #Term::ANSIColor.coloring = true\n c = Term::ANSIColor\n @color_app_info = c.intense_white + c.bold\n @color_app_exe = c.intense_green + c.bold\n @color_command = c.intense_yellow\n @color_description = c.intense_white\n @color_parameter = c.intense_cyan\n @color_usage = c.intense_black + c.bold\n \n @color_error_word = c.intense_black + c.bold\n @color_error_name = c.intense_red + c.bold\n @color_error_description = c.intense_white + c.bold\n \n @color_bold = c.bold\n @color_reset = c.reset\n end", "def set_colors\n if @color_output \n @c_app_info = @color_app_info\n @c_app_exe = @color_app_exe\n @c_command = @color_command\n @c_description = @color_description\n @c_parameter = @color_parameter\n @c_usage = @color_usage\n \n @c_error_word = @color_error_word\n @c_error_name = @color_error_name\n @c_error_description = @color_error_description\n \n @c_bold = @color_bold\n @c_reset = @color_reset\n else\n @c_app_info, @c_app_exe, @c_command, \n @c_description, @c_parameter, @c_usage, \n @c_bold, @c_reset, @c_error_word, \n @c_error_name, @c_error_description = [\"\"]*11\n end\n end", "def color(text, *color_options)\n color_code = ''\n color_options.each do |color_option|\n color_option = color_option.to_s\n if color_option != ''\n if !(color_option =~ /\\d+/)\n color_option = const_get(\"ANSI_ESCAPE_#{ color_option.upcase }\")\n end\n color_code += ';' + color_option\n end\n end\n color_enabled? ? \"\\e[0#{ color_code }m#{ text }\\e[0m\" : text\n end", "def colorize!(color_code) \"#{COLORS[color_code]}#{self.to_s}\\e[0m\" ; end", "def add_bright_color(str, color)\n color = color.to_s.sub(\"bright_\", \"\").to_sym\n str = reset_prev_formatting str, :color\n \"\\e[1m\\e[#{TC_CONFIG[:colors][color].to_s}m#{str}\"\n end", "def colorize!; @colors = true; end", "def settextcolorind(*)\n super\n end", "def s(val); @style = val; end", "def colored_string\n color(to_bold_s)\n end", "def reset_colors\n @color_output ||= true\n\n # Build the default colors\n Term::ANSIColorHI.coloring = color_output\n c = Term::ANSIColorHI\n @color_app_info = c.intense_white + c.bold\n @color_app_exe = c.intense_green + c.bold\n @color_command = c.intense_yellow\n @color_description = c.intense_white\n @color_parameter = c.intense_cyan\n @color_usage = c.intense_black + c.bold\n \n @color_error_word = c.intense_black + c.bold\n @color_error_name = c.intense_red + c.bold\n @color_error_description = c.intense_white + c.bold\n \n @color_bold = c.bold\n @color_reset = c.reset\n @screen_clear = \"\\e[H\\e[2J\"\n end", "def color\n @red ? \"R\" : \"B\"\n end", "def colorize(text, *options)\n\n font_style = ''\n foreground_color = '0'\n background_color = ''\n\n options.each do |option|\n if option.kind_of?(Symbol)\n foreground_color = \"3#{COLORS[option]}\" if COLORS.include?(option)\n font_style = \"#{STYLES[option]};\" if STYLES.include?(option)\n elsif option.kind_of?(Hash)\n option.each do |key, value|\n case key\n when :color; foreground_color = \"3#{COLORS[value]}\" if COLORS.include?(value)\n when :background; background_color = \"4#{COLORS[value]};\" if COLORS.include?(value)\n when :on; background_color = \"4#{COLORS[value]};\" if COLORS.include?(value)\n when :style; font_style = \"#{STYLES[value]};\" if STYLES.include?(value)\n end\n end\n end\n end\n return \"\\e[#{background_color}#{font_style}#{foreground_color}m#{text}\\e[0m\"\n end", "def color(*options)\n return '' if mode.zero? || options.empty?\n mix = []\n color_seen = false\n colors = ANSI_COLORS_FOREGROUND\n\n options.each{ |option|\n case option\n when Symbol\n if color = colors[option]\n mix << color\n color_seen = :set\n elsif ANSI_EFFECTS.key?(option)\n mix << effect(option)\n elsif option == :random\n mix << random(color_seen)\n color_seen = :set\n else\n raise ArgumentError, \"Unknown color or effect: #{ option }\"\n end\n\n when Array\n if option.size == 3 && option.all?{ |n| n.is_a? Numeric }\n mix << rgb(*(option + [color_seen])) # 1.8 workaround\n color_seen = :set\n else\n raise ArgumentError, \"Array argument must contain 3 numerals\"\n end\n\n when ::String\n if option =~ /^#?(?:[0-9a-f]{3}){1,2}$/i\n mix << hex(option, color_seen)\n color_seen = :set\n else\n mix << rgb_name(option, color_seen)\n color_seen = :set\n end\n\n when Numeric\n integer = option.to_i\n color_seen = :set if (30..49).include?(integer)\n mix << integer\n\n when nil\n color_seen = :set\n\n else\n raise ArgumentError, \"Invalid argument: #{ option.inspect }\"\n\n end\n\n if color_seen == :set\n colors = ANSI_COLORS_BACKGROUND\n color_seen = true\n end\n }\n\n wrap(*mix)\n end", "def set_colors\n if color_output\n @c_app_info = @color_app_info\n @c_app_exe = @color_app_exe\n @c_command = @color_command\n @c_description = @color_description\n @c_parameter = @color_parameter\n @c_usage = @color_usage\n \n @c_error_word = @color_error_word\n @c_error_name = @color_error_name\n @c_error_description = @color_error_description\n \n @c_bold = @color_bold\n @c_reset = @color_reset\n else\n @c_app_info, @c_app_exe, @c_command, @c_description,\n @c_parameter, @c_usage, @c_bold, @c_reset, @c_error_word,\n @c_error_name, @c_error_description = [\"\"]*12\n end\n end", "def green(string)\n \"\\033[0;32m#{string}\\033[0m\"\nend", "def green(string)\n \"\\033[0;32m#{string}\\033[0m\"\nend", "def disable_colorization=(value); end", "def color(str, c)\n ENV['NO_COLOR'] ? str : \"\\033[#{c}m#{str}\\033[0m\"\n end", "def set(color)\n color == :w ? whites : blacks\n end", "def display_color\n if @deleted\n return '#FF0000' # Red\n elsif !@enabled\n return '#AAAAAA' # Gray\n end\n \n '#000000'\n end", "def change_color(color)\n self.font.color = color\n end", "def SetDrawColor(r, g=-1, b=-1)\n\t\t#Set color for all stroking operations\n\t\tif ((r==0 and g==0 and b==0) or g==-1)\n\t\t\t@draw_color=sprintf('%.3f G', r/255.0);\n\t\telse\n\t\t\t@draw_color=sprintf('%.3f %.3f %.3f RG', r/255.0, g/255.0, b/255.0);\n\t\tend\n\t\tif (@page>0)\n\t\t\tout(@draw_color);\n\t\tend\n\tend", "def blue = \"\\e[36m#{self}\\e[0m\"", "def change_font_color\n #Code essentially used from Clay Allsop's RubyMotion: iOS Development with Ruby\n #with a few tweeks\n #\n #Get the color_field text\n color_prefix = @color_field.text\n #Downcase the color_field text and append \"Color\"\n color_method = \"#{color_prefix.downcase}Color\"\n #If the color exists, create as UIColor.colorColor\n if UIColor.respond_to?(color_method)\n @font_color = UIColor.send(color_method)\n @font_label.textColor = @font_color\n #For fun I added that the text color also becomes the toggle background color when ON\n @switch_font.onTintColor = @font_color\n @switch_font.tintColor = @font_color\n else\n #If the color is not known, display an alert to inform user\n UIAlertView.alloc.initWithTitle(\"Invalid Color\",\n message: \"#{color_prefix.capitalize} is not a usable color at this time\",\n delegate: nil,\n cancelButtonTitle: \"OK\",\n otherButtonTitles: nil).show\n end\n end", "def bold(*args)\n color('1', *args)\n end", "def cp(text, opts={})\n embolden = opts[:bold] ? COLORS[:bold] : ''\n color = opts[:color] || default_color\n puts \"#{embolden}#{COLORS[color]}#{text}#{COLORS[:clear]}\"\n end", "def set_color(t,tcolor=\"green\",fcolor=\"gray\")\n if t\n tcolor\n else\n fcolor\n end\n end", "def bold; \"\\e[1m#{self}\\e[22m\" end", "def colorize(text, color)\n\t\"\\e[#{Colors[color]}m#{text}\\e[0m\"\nend", "def output_color(text, color=text.to_i)\r\n # Color matches: 1 - Black; 2 - White; 3 - Red; 4 - Yellow; 5 - Green; 6 - Blue; 7 - Gold\r\n colors = { 1 => 30, 2 => 36, 3 => 31, 4 => 33, 5 => 35, 6 => 34, 7 => 220 }\r\n # \\e[47m Is for the grey foreground \\e[{color} is for picking the color and \\e[0m is for resetting the terminal.\r\n \"\\e[1m\\e[47m\\e[#{colors[color]}m#{text}\\e[0m\\e[22m\"\r\n end", "def decorate(options = {})\n return string if !self.class.enabled? || string.length == 0\n escape_sequence = [\n Colored2::TextColor.new(options[:foreground]),\n Colored2::BackgroundColor.new(options[:background]),\n Colored2::Effect.new(options[:effect])\n ].compact.join\n\n colored = ''\n colored << escape_sequence if options[:beginning] == :on\n colored << string\n if options[:end]\n colored << no_color if options[:end] == :off && !colored.end_with?(no_color)\n colored << escape_sequence if options[:end] == :on\n end\n colored\n end", "def setDefaultColor\n self.changeColor A_NORMAL, COLOR_WHITE, COLOR_BLACK\n end", "def add_normal_color(str, color)\n str = reset_prev_formatting str, :color\n \"\\e[#{TC_CONFIG[:colors][color].to_s}m#{str}\"\n end", "def green(string)\n \"\\033[0;32m#{string}\\e[0m\"\nend", "def green(string)\n \"\\033[0;32m#{string}\\e[0m\"\nend", "def set_style(*v)\n styles = v.map { |i| @@style[i.to_sym] }.transpose\n prepend(\"\\e[\" << styles[0].join(';') << 'm')\n concat(\"\\e[\" << styles[1].join(';') << 'm')\n end", "def color=(color) #SETTER\n @color = \"##{color.downcase}\"\n end", "def green=(value)\n end", "def setDrawColor(color)\n puts(\"draw color set to \" + color)\n @drawColor = color\n end", "def method_missing(name, *args)\n if @colours.include? name\n \"#{@colours[name]}#{args[0]}\\033[0m\"\n else\n \"#{@default}#{args[0]}\\033[0m\"\n end\n end", "def red(string)\n \"\\033[0;33m#{string}\\033[0m\"\nend", "def red(string)\n \"\\033[0;33m#{string}\\033[0m\"\nend", "def ctrlSetTextColor _obj, _args\n \"_obj ctrlSetTextColor _args;\" \n end", "def init_colors\n $desc_color = \"#{GREEN}\" # color of description portion\n # color the title based on priority\n $p5color = \"#{BLUE}#{BOLD}\" \n $p4color = \"#{MAGENTA}\" \n $p3color = \"#{CYAN}#{BOLD}\" \n $p2color = \"#{BOLD}\"\n $p1color = \"#{YELLOW}#{ON_RED}\"\n #\n # color for only the type column\n $bugcolor = \"#{BLACK}#{ON_RED}\"\n $enhcolor = \"#{GREEN}\"\n $feacolor = \"#{CYAN}\"\n\n # color for row of started event\n $startedcolor = \"#{STANDOUT}\"\n\n cols = %x[tput colors] rescue 8\n cols = cols.to_i\n if cols >= 256\n $desc_color = \"\\x1b[38;5;236m\" # 256 colors, grey\n $p5color = \"\\x1b[38;5;57m\" # some kinda blue\n $p4color = \"\\x1b[38;5;239m\" # grey. 256 colors\n $p3color = \"\\x1b[38;5;244m\" # grey, 256 colors\n end\n end", "def set(red, green, blue, alpha = nil); end", "def colour(name, text)\n if Pry.color\n \"\\001#{Pry::Helpers::Text.send name, '{text}'}\\002\".sub '{text}', \"\\002#{text}\\001\"\n else\n text\n end\nend", "def puts_color( msg, color=nil )\n color_set( color ); puts msg; color_end\n end", "def set_color(string, *colors)\n ansi_colors = colors.map { |color| lookup_color(color) }\n \"#{ansi_colors.join}#{string}#{CLEAR}\"\n end", "def setDrawColorViaRGB(r, g, b)\n while r > 255\n r -= 255\n end\n while g > 255\n g -= 255\n end\n while b > 255\n b -= 255\n end\n puts(\"draw color set to RGB values: (\" + r.to_s + \", \" + g.to_s + \", \" + b.to_s + \")\")\n @drawColor = FXRGB(r, g, b)\n end", "def set_text_color_a(color = RFPDF::COLOR_PALETTE[:black], colorspace = :rgb)\n if colorspace == :cmyk\n SetCmykTextColor(color[0], color[1], color[2], color[3])\n else\n SetTextColor(color[0], color[1], color[2])\n end\n end", "def color(text, color_code)\n ::Guard::UI.send(:color_enabled?) ? \"\\e[0#{ color_code }m#{ text }\\e[0m\" : text\n end", "def color(red, green, blue)\n r = red << 4\n g = green << 5\n b = blue << 6\n send(RESET ^ (r | g | b))\n rescue\n end", "def statecolor(state)\n\t\tif state == \"running\"\n\t\t\t\"color: green;\".html_safe\n\t\telsif state == \"poweroff\"\n\t\t\t\"color: gray;\".html_safe\n\t\telse\n\t\t\t\"color: yellow;\".html_safe\n\t\tend\n\tend", "def setcolorrep(*)\n super\n end", "def bold(output)\n color('1', output)\n end", "def colorize txt, fg, bg, flags\n txt\n end", "def green(text)\n colorize text, \"\\033[1;32m\"\n end", "def color_to_use\n return :no_bg_color if value == :none\n value =~ /^on_/ ? value : \"on_#{value}\".to_sym\n end", "def color(options)\n set RGhost::Color.create(options)\n end", "def colorize(color, bold_or_options = nil)\n is_bold = bold_or_options.is_a?(TrueClass)\n is_underline = false\n\n if bold_or_options.is_a?(Hash)\n is_bold ||= bold_or_options[:bold]\n is_underline = bold_or_options[:underline]\n end\n\n raise ArgumentError('Color must be a symbol') unless color.is_a?(Symbol)\n color_const = color.to_s.upcase.to_sym\n\n raise ArgumentError('Unknown color') unless self.class.const_defined?(color_const)\n ascii_color = self.class.const_get(color_const)\n\n s = surround_with_ansi(ascii_color)\n s = s.bold if is_bold\n s = s.underline if is_underline\n s\n end", "def colorize(color, text)\n \"\\e[#{color}m#{text}\\e[0m\"\n end", "def scr_bold\n print \"\\33[1m\"\nend", "def green txt\n \"\\033[32m#{txt}\\033[0m\"\n end", "def reset\n # color is enabled by default, can be turned of by switch --no-color\n Term::ANSIColor.coloring = true\n end", "def ✘\n colorize(\"✘\", :red)\n end", "def blue=(value)\n end", "def puts_blue(string)\n puts \"\\033[34m\" + string + \"\\033[0m\"\nend", "def lnbSetColor _args\n \"lnbSetColor _args;\" \n end", "def on_49(_) { fg: fg_color(9) } end", "def bold(str)\n console_bold=\"\\e[1m\"\n console_reset=\"\\e[0m\"\n \"#{console_bold}#{str}#{console_reset}\"\nend", "def colorize txt, fg, bg, flags\n fgc = (fg.nil? || Color === fg ) ? fg : Color.parse(fg)\n bgc = (bg.nil? || Color === bg) ? bg : Color.parse(bg)\n esc = []\n esc << '01' if flags[:b]\n esc << '03' if flags[:i]\n esc << '04' if flags[:u]\n esc << '07' if flags[:r]\n esc << \"38;05;#{fgc.xterm256}\" if fgc\n esc << \"48;05;#{bgc.xterm256}\" if bgc\n \n esc.empty? ? txt : \"\\e[#{esc.join(';')}m#{txt}\\e[0m\" \n end", "def SetCmykFillColor(c, m, y, k, storeprev=false)\n\t\t#Set color for all filling operations\n\t\t@fill_color=sprintf('%.3f %.3f %.3f %.3f k', c, m, y, k);\n\t\t@color_flag=(@fill_color!=@text_color);\n\t\tif (storeprev)\n\t\t\t# store color as previous value\n\t\t\t@prevtext_color = [c, m, y, k]\n\t\tend\n\t\tif (@page>0)\n\t\t\tout(@fill_color);\n\t\tend\n\tend", "def colour(name, text)\n if Pry.color\n str = Pry::Helpers::Text.send(name, text)\n unless str.start_with?(\"\\001\")\n str = \"\\001#{Pry::Helpers::Text.send name, '{text}'}\\002\".sub '{text}', \"\\002#{text}\\001\"\n end\n str\n else\n text\n end\nend", "def reset_use_color\n @use_color = true\n end", "def ListView_SetTextBkColor(hwnd, clrTextBk) send_listview_message(hwnd, :SETTEXTBKCOLOR, lparam: clrTextBk) end", "def change_text_color(color)\n @text_color = color\n @text_entry.refresh\n self.redraw\n end", "def color\n\t\t \t\t\t\"El color de tu vaca es #{@color}\"\n\t\t \t\tend", "def colorized?; end", "def colorize(text, color_code); \"\\e[#{color_code}m#{text}\\e[0m\"; end", "def set(red, green, blue, alpha=255)\n self.red = red\n self.green = green\n self.blue = blue\n self.alpha = alpha\n end", "def red=(value)\n end", "def lbSetColor _obj, _args\n \"_obj lbSetColor _args;\" \n end", "def format_color(name, text)\n if Pry.color\n \"\\001#{Pry::Helpers::Text.send name, '{text}'}\\002\".sub '{text}', \"\\002#{text}\\001\"\n else\n text\n end\nend", "def ctrlSetForegroundColor _obj, _args\n \"_obj ctrlSetForegroundColor _args;\" \n end", "def __strval_optkeys\n super() << 'selectcolor' << 'title'\n end", "def colorised(enable)\n return ->(x) {\n if (OPTIONS.key?(x))\n OPTIONS[x][:key] + ' ' +\n ((enable and OPTIONS[x][:modified]) ?\n OPTIONS[x][:arg].red.underline :\n OPTIONS[x][:arg])\n else\n enable ? x.red : x\n end\n }\nend", "def red(string)\n \"\\033[0;31m#{string}\\e[0m\"\nend", "def red(string)\n \"\\033[0;31m#{string}\\e[0m\"\nend", "def colorize(*args)\n shell.set_color(*args)\n end", "def decorate(string, *colors)\n return string if string.empty? || !enabled\n validate(*colors)\n ansi_colors = colors.map { |color| lookup(color) }\n ansi_string = \"#{ansi_colors.join}#{string}#{ANSI::CLEAR}\"\n if ansi_string =~ /(#{Regexp.quote(ANSI::CLEAR)}){2,}/\n ansi_string.gsub!(/(#{Regexp.quote(ANSI::CLEAR)}){2,}/, '')\n end\n matches = ansi_string.scan(/#{Regexp.quote(ANSI::CLEAR)}/)\n if matches.length >= 2\n ansi_string.sub!(/#{Regexp.quote(ANSI::CLEAR)}/, ansi_colors.join)\n end\n ansi_string\n end", "def color\n @color || $def_fg_color\n end" ]
[ "0.6677382", "0.6523837", "0.64401305", "0.6429064", "0.6332658", "0.6314553", "0.62296116", "0.6217173", "0.6187157", "0.61654097", "0.61489826", "0.61371535", "0.61299527", "0.61029667", "0.60989356", "0.6089932", "0.60790133", "0.60770655", "0.60742164", "0.60416317", "0.6024708", "0.60191584", "0.60124576", "0.600561", "0.600561", "0.5990472", "0.5989572", "0.5989081", "0.5984457", "0.59596455", "0.59575266", "0.59562933", "0.59267277", "0.5925082", "0.5920027", "0.59138983", "0.5902365", "0.59003764", "0.588546", "0.5885113", "0.5881196", "0.5876932", "0.5867514", "0.5867514", "0.5856282", "0.58554864", "0.5850313", "0.5844511", "0.5830536", "0.58286136", "0.58286136", "0.5823442", "0.5819601", "0.58168477", "0.58080363", "0.5805401", "0.5803369", "0.57990026", "0.57897586", "0.5788405", "0.578527", "0.5780153", "0.57651544", "0.5752906", "0.5742622", "0.57361364", "0.5731948", "0.57317716", "0.57308483", "0.5715403", "0.57075083", "0.57063186", "0.570447", "0.5702618", "0.56980187", "0.5690697", "0.5685492", "0.5685169", "0.568258", "0.56814563", "0.5678391", "0.5671907", "0.5665704", "0.5663787", "0.56422293", "0.56345195", "0.5634319", "0.5632155", "0.5626772", "0.5622576", "0.56218773", "0.5606199", "0.5579404", "0.5573918", "0.55711997", "0.5552005", "0.5552005", "0.5546767", "0.55466837", "0.5546577" ]
0.71913946
0
Used when the validation_hint is optional
def has_validation_hint? validation_hint.present? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validation_default; false; end", "def validation_default; true; end", "def validation_default; true; end", "def validation\n # Rails.logger.debug \"#{self.class}.#{__method__} Default validator is empty\"\n end", "def validation_context\n {}\n end", "def validated?; end", "def has_required?; end", "def extra_validations\n success\n end", "def validation; end", "def validation; end", "def validation_class\n if self.required?\n 'required' \n else\n ''\n end\n end", "def validate!(t)\n # None.\n end", "def supports_validate_constraints?\n false\n end", "def supports_validate_constraints?\n false\n end", "def validate\n super \n end", "def has_required?\n false\n end", "def validate\n super\n end", "def perform_validation?\n self.skip_validation == true ? false : true\n end", "def validations\n {}\n end", "def required\n @optional = false\n end", "def validator; end", "def skip_validations\n true\n end", "def valid_params?; end", "def validate!\n # pass\n end", "def is_valid; end", "def validate!; end", "def validate!; end", "def validate!; end", "def _before_validation\n end", "def validate!\n super()\n self\n end", "def required_by_default?; end", "def validate\n super\n\n check_optional_property :collection, String\n check_optional_property :create, String\n check_optional_property :delete, String\n check_optional_property :flush, String\n check_optional_property :prefetch, String\n check_optional_property :request_to_query, String\n check_optional_property :resource_to_request_patch, String\n check_optional_property :return_if_object, String\n check_optional_property :self_link, String\n end", "def value_required?\n false\nend", "def subclass_validations ; true ; end", "def without_validations\n with_validations(false)\n end", "def before_validation_callback\n end", "def hint_hint\n \"(<span class=\\\"required\\\">*</span> indicates a required field)\"\n end", "def validate_options; end", "def perform_validation\n raise NotImplementedError\n end", "def patch_valid?\n validate(false).empty?\n end", "def validate\n super\n validates_presence [:code, :preference, :type_param_id, :application_id]\n end", "def pre_validation\n\n end", "def validate_on_create=(_arg0); end", "def validate!\n true\n end", "def validated; end", "def if_present(params = {}, &block); validation_chain.if_present(params, &block); end", "def pre_validation\n\n\n end", "def validator=(_); end", "def validate; end", "def validate; end", "def validate; end", "def validate; end", "def required\n !!parameter[:required]\n end", "def run_validations\n true\n end", "def if_absent(params = {}, &block); validation_chain.if_absent(params, &block); end", "def required_by_default?\n false\n end", "def run_validations!\n run_callbacks(:validation) do\n super\n end\n end", "def validate_params\n @calls << [:validate_params]\n end", "def validate_build\n end", "def valid?; end", "def valid?; end", "def valid?; end", "def valid?; end", "def valid?; end", "def supports_validations?\n true\n end", "def optional?\n\t\t!required?\n\tend", "def validate\n true\n end", "def initialize(params = {})\n super\n self.is_valid = true\n end", "def enforce_not_null(options = {})\n args = build_validation_args(options, :not_null, :blank)\n return if args.first.is_a?(Hash)\n validates_presence_of(*args)\n end", "def validate\n # add errors if not validate\n end", "def literal_validation; end", "def literal_validation; end", "def validate\n end", "def validate\n validate_summary\n validate_duration\n validate_kind\n validate_state\n validate_created_at\n\n super\n end", "def email_required?; false end", "def validation\n :wf_point?\n end", "def optional?\n !@required\n end", "def validate?\n !!validation\n end", "def run_validations!\n super\n include_typecasting_errors\n errors.empty?\n end", "def validate!\n # Set @error_text if the options are not valid\n end", "def is_valid?\n end", "def required?\n !optional?\n end", "def optional?\n not required\n end", "def validate(options); end", "def validate\n end", "def validate\n end", "def validate\n end", "def validate\n end", "def validate\n end", "def validate\n end", "def should_validate\n validation_trigger\n end", "def add_validation_errors(value); end", "def validate\n @invalid=false\n end", "def validate_question params\n\n end", "def validate\n fail 'sub class to implement'\n end", "def required?\n true\n end", "def valid?(_) true end", "def valid?(_) true end", "def validate\n raise NoMethodError, \"must define method 'validate'\"\n end", "def is_valid\n\tend" ]
[ "0.70188755", "0.7011366", "0.7011366", "0.6994977", "0.69183826", "0.6731706", "0.6680499", "0.66651666", "0.6631223", "0.6631223", "0.6576727", "0.6568121", "0.65278417", "0.65278417", "0.65068513", "0.64715475", "0.6469731", "0.6444738", "0.6433472", "0.64201564", "0.6376176", "0.634884", "0.6321492", "0.63199615", "0.631748", "0.6315408", "0.6315408", "0.6315408", "0.6307584", "0.6300878", "0.6294369", "0.62937397", "0.6275694", "0.62728816", "0.62629884", "0.6240878", "0.6187756", "0.6181574", "0.61592275", "0.61582065", "0.6140903", "0.61299086", "0.6122648", "0.60981256", "0.6096531", "0.6094105", "0.6084865", "0.607639", "0.6055734", "0.6055734", "0.6055734", "0.6055734", "0.60468936", "0.60284126", "0.6019856", "0.6018301", "0.6010703", "0.5999788", "0.599961", "0.59972894", "0.59972894", "0.59972894", "0.59972894", "0.59972894", "0.599025", "0.5981633", "0.59695554", "0.59539306", "0.5949542", "0.59447443", "0.59446764", "0.59446764", "0.590891", "0.59077454", "0.5901958", "0.5900831", "0.58896744", "0.5880329", "0.58730304", "0.5867746", "0.58676547", "0.5860197", "0.5842347", "0.5840241", "0.58321196", "0.58321196", "0.58321196", "0.5830188", "0.5830188", "0.5830188", "0.58271945", "0.58259916", "0.5824141", "0.5821024", "0.5814461", "0.58138704", "0.58130974", "0.58130974", "0.58115727", "0.5810667" ]
0.7436239
0
makes sure the same user can't make multiple offers to the same trade
def trade_is_not_a_repeat # see if the record has been created, and has an id assigned number_that_can_exist = id.nil? ? 0 : 1 if Offer.where(user_id: user_id, trade_id: trade_id).length > number_that_can_exist errors.add(:user_id, "user has already made an offer for this trade") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_sure_no_duplicate_offers\n other_offer = self.sender.active_offer_between_user_for_textbook(self.reciever_id, self.textbook_id)\n\n if other_offer.nil?\n if self.listing.nil?\n\t if self.selling?\n self.errors.add(:reciever_id, \"You don't have a current listing 'For Sale' for this book. You must post a listing before sending an offer to sell your book.\")\n\t else\n self.errors.add(:reciever_id, \"#{self.reciever.username} doesn't have a current listing 'For Sale' for this book.\")\n\t end\n\n return false\n\tend\n \n return true\n end\n\n if self.reciever_id == other_offer.reciever_id\n self.errors.add(:reciever_id, \"You already sent #{self.reciever.username} an offer for this book. You can check your offers sent by navigating to the 'Offers' page in the upper-left links then clicking 'View sent offers here'. (note: once a user rejects (not counter offers) your offer for a particular book, you may only respond to their offers)\")\n return false\n elsif other_offer.selling? != self.selling?\n other_offer.update_status(2)\n return true\n else\n self.errors.add(:reciever_id, \"#{self.reciever.username}'s removed their listing for this book!\")\n end\n end", "def create\n flag = true\n item = Item.find(params[:trades][:item_id])\n offer = Item.find(params[:trades][:offer_id])\n passive_trade = PassiveTrade.find(params[:trades][:passive_trade_id])\n if !item.live? or !offer.live? \n flag = false\n end\n t = Trade.where(:item_id => item.id, :offer_id => offer.id).where(\"status != 'REJECTED' and status != 'DELETED'\") unless (flag == false)\n if t.present?\n flag = false\n end\n if flag \n t = Trade.where(:item_id => offer.id, :offer_id => item.id)\n if t.present?\n flag = false\n end\n if flag and current_user and current_user.id == offer.user_id\n trade = Trade.new(params[:trades])\n trade.status = 'ACTIVE'\n trade.save\n\n passive_trade.trade_comments.each do |tc|\n tc.trade_id = trade.id\n tc.save\n end\n passive_trade.trade_terms.each do |tt|\n tt.trade_id = trade.id\n tt.save\n end\n passive_trade.transactions.each do |t|\n t.trade_id = trade.id\n t.save\n end\n\n redirect_location = trade_path(trade)\n \n # if (InfoAndSetting.sm_on_o_made and item.user.notify_received_offer)\n # # Send mail if offer accepted\n # TradeMailer.offer_made_offerer(offer.id,offer.user.id,item.id,item.user.id).deliver\n # TradeMailer.offer_made_owner(offer.id,offer.user.id,item.id,item.user.id).deliver\n # end\n end\n # When user moves back rejected offer to offers\n # if flag and params[:undo_reject] == \"true\"\n # t = Trade.where(:item_id => item.id, :offer_id => offer.id).where(\"status = 'REJECTED'\").first\n # if t.present?\n # t.status = \"DELETED\"\n # t.save\n # end\n # trade = Trade.new(params[:trade])\n # trade.status = 'ACTIVE'\n # trade.save\n # redirect_location = trade_offers_item_path(item) +\"?back_to_offer=true\"\n # else\n # redirect_location = my_offers_item_path(item)\n # session[:offered_item] = offer.title\n # end\n elsif t.present?\n redirect_location = trade_path(t.first)\n else\n redirect_location = passive_trade_path(passive_trade)\n # session[:offered_item] = offer.title\n end\n \n redirect_to redirect_location\n \n # respond_to do |format|\n # if @trade.save\n # format.html { redirect_to @trade, notice: 'Trade was successfully created.' }\n # format.json { render json: @trade, status: :created, location: @trade }\n # else\n # format.html { render action: \"new\" }\n # format.json { render json: @trade.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def attemp_buying\n\n end", "def have_enough_items_to_trade?\n fetch_inventory\n\n is_valid = true\n\n max_avaliable_quantity = @offer[:records].map {|x|\n [x.item_name.to_sym ,x.quantity]}.to_h\n\n @offer[:items].each do |item, quantity|\n if quantity > max_avaliable_quantity[item.to_sym]\n is_valid = false\n add_error(:offer, :items, {item.to_sym =>\n \"Not enough items, only #{max_avaliable_quantity[item.to_sym]} available\"})\n end\n end\n\n max_avaliable_quantity = @for[:records].map {|x|\n [x.item_name.to_sym ,x.quantity]}.to_h\n\n @for[:items].each do |item, quantity|\n if quantity > max_avaliable_quantity[item.to_sym]\n is_valid = false\n add_error(:for, :items, {item.to_sym =>\n \"Not enough items, only #{max_avaliable_quantity[item.to_sym]} available\"})\n end\n end\n is_valid\n end", "def cannot_edit(_offer)\n !session[:is_administrator] && _offer.unbilled_balance <= 0\n end", "def reject_offer\n @auction = @current_user.auctions.find(params[:auction_id])\n @offer = @auction.offers.find(params[:offer_id])\n Alert.transaction do\n Alert.offer_to_reject_response!(@offer, @decision)\n if @decision\n @offer.reject!\n end\n end\n end", "def make_deal!\n if deal_with_other_offers \n if selling?\n Deal.create!(:buyer_id => self.reciever_id, :seller_id => self.sender_id, :price => self.price, :textbook_id => self.textbook_id, :description => self.listing.description)\n else\n Deal.create!(:buyer_id => self.sender_id, :seller_id => self.reciever_id, :price => self.price, :textbook_id => self.textbook_id, :description => self.listing.description)\n end\n\n sender_listing = sender.listing_from_textbook(textbook_id)\n sender_listing.destroy if sender_listing.nil? == false\n\n reciever_listing = reciever.listing_from_textbook(textbook_id)\n reciever_listing.destroy if reciever_listing.nil? == false\n else\n return false\n end\n end", "def check_offer\n offered_char = Character.find_by_name(offer)\n if offered_char != nil\n if offered_char.user_id != user_id\n self.update_attributes(offer: \"none\")\n end\n else \n self.update_attributes(offer: \"none\")\n end \n end", "def deal_with_other_offers\n if self.selling?\n if self.sender.nil? == false\n self.sender.active_offers_for_textbook(self.textbook_id).each do |offer|\n offer.update_status(3)\n\n if self.sender_id == offer.sender_id\n\t Offer.notify_buyer_book_sold(offer.reciever,offer.sender,textbook)\n\t else\n\t Offer.notify_buyer_book_sold(offer.sender,offer.reciever,textbook)\n\t end\n\t end\n end\n\tif self.reciever.nil? == false\n\t self.reciever.active_offers_for_textbook(self.textbook_id).each do |offer|\n\t offer.update_status(4)\n\n if self.sender_id == offer.sender_id\n\t Offer.notify_seller_book_bought(offer.reciever,offer.sender,textbook)\n\t else\n\t Offer.notify_seller_book_bought(offer.sender, offer.reciever, textbook)\n\t end\n\t end\n\tend\n else\n if self.sender.nil? == false\n self.sender.active_offers_for_textbook(self.textbook_id).each do |offer|\n offer.update_status(4)\n\n if self.sender_id == offer.sender_id\n\t Offer.notify_seller_book_bought(offer.reciever, offer.sender, textbook)\n\t else\n\t Offer.notify_seller_book_bought(offer.sender, offer.reciever, textbook)\n\t end\n\t end\n\tend\n\tif self.reciever.nil? == false\n\t self.reciever.active_offers_for_textbook(self.textbook_id).each do |offer|\n\t offer.update_status(3)\n\n if self.sender_id == offer.sender_id\n Offer.notify_buyer_book_sold(offer.reciever, offer.sender, textbook)\n\t else\n Offer.notify_buyer_book_sold(offer.sender, offer.reciever, textbook)\n\t end\n\t end\n\tend\n end\n end", "def add_partners_TEMP_DANGEROUS\n User.find(:all).each do |user|\n Partnership.create(:inviter => logged_in_user, :receiver => user) if logged_in_user.dealership != user.dealership\n end\n redirect_to :back\n end", "def newtrade\n # @this = \"this\"\n # @this = Trade.find(2)\n\n#\n # name = \"Apple Inc. - Common Stock\"\n # tick = \"AAPL\"\n # vol = 90\n # price = 243.42\n # total = 22320\n # type = \"Sell\"\n name = params[:name]\n tick = params[:tick]\n vol = params[:vol].to_i\n price = params[:price].to_f\n total = params[:total].to_f\n type = params[:type]\n tc = \"Trade Complete\"\n if type == \"Buy\" # IF ONE START 11111111111111\n\n @currentuser = current_user\n w = @currentuser.wallet\n if Trade.where(ticker: params[:tick]).exists?\n if w > total\n @trade = Trade.where(ticker: params[:tick]).first\n @trade.volume += vol\n @trade.save\n @currentuser.wallet -= total\n @currentuser.save\n @text = tc\n elsif w < total\n @text = \"You do not have enough units to make this trade.\"\n end\n else #graduate to using first_or_create\n @trade = @currentuser.trades.create(stock: name,\n ticker: tick,\n tradeprice: total,\n volume: vol,\n stockprice: price)\n @currentuser.wallet -= total\n @currentuser.save\n @text = tc\n end\n else # ELSE ONE START 11111111111111\n @currentuser = current_user\n w = @currentuser.wallet\n if Trade.where(ticker: params[:tick]).exists? # IF TWO START 222222222222\n if Trade.where(ticker: params[:tick]).first.volume >= vol\n @trade = Trade.where(ticker: params[:tick]).first\n @trade.volume -= vol\n @trade.save\n @currentuser.wallet += total\n @currentuser.save\n @text = tc\n else\n @text = \"You do not have enough shares to make this trade.\"\n end\n else # ElSE TWO START 222222222222\n @text = \"Could not complete trade. You do not have enough shares in this company.\"\n end # IF TWO END 222222222222\n end # IF ONE END 11111111111111\n\n\n end", "def valid_option_ask!(trade)\n option = Option.find(trade.instrument_id)\n if optiontyp == \"call\"\n if trade.user.portfolio.usd - trade.user.portfolio.usd_in_margin >= trade.amount\n true\n else\n trade.destroy\n false\n end\n elsif option.typ == \"put\"\n if trade.user.portfolio.funds - trade.user.portfolio.funds_in_margin >= option.strike*trade.price\n true\n else\n trade.destroy\n false\n end\n end\n end", "def check_bids(user, new_bid)\r\n previous_winner = self.bid.last.owner\r\n if user.credits < new_bid\r\n raise TradeException, \"Not enough money!\" unless user.credits >= new_bid\r\n elsif self.bid.last.value == new_bid\r\n raise TradeException, \"That's already the highest bid!\"\r\n elsif self.bid.last.value < new_bid\r\n previous_winner.credits += self.bid.last.value\r\n previous_winner.credits_in_auction -= self.bid.last.value\r\n user.credits -= new_bid\r\n user.credits_in_auction += new_bid\r\n end\r\n end", "def execute(bid, ask)\n #don't prefer buyer or seller\n sale_price = (bid.price + ask.price)/2\n if @instrument == \"Option\"\n #if selling, either have position, or margin requirements, else delete\n if valid_option_ask!(ask) && valid_option_bid!(bid)\n #which one is more\n if bid.amount > ask.amount\n ActiveRecord::Base.transaction do\n bid.user.create_or_update_position(ask.amount, @instrument, @instrument_id, \"bid\")\n bid.user.portfolio.decrement!(:funds,sale_price*ask.amount)\n ask.user.remove_from_position(ask.amount, @instrument, @instrument_id, \"ask\")\n ask.user.portfolio.increment!(:funds,sale_price*ask.amount)\n bid.decrement!(:amount, ask.amount)\n ask.destroy\n end\n else\n ActiveRecord::Base.transaction do\n bid.user.create_or_update_position(bid.amount, @instrument, @instrument_id, \"bid\")\n bid.user.portfolio.decrement!(:funds,sale_price*ask.amount)\n ask.user.remove_from_position(bid.amount, @instrument, @instrument_id, \"ask\")\n ask.user.portfolio.increment!(:funds,sale_price*ask.amount)\n ask.decrement!(:amount, bid.amount)\n bid.destroy\n end\n #TODO: what if they are equal?\n end\n end\n elsif @instrument == \"Currency\"\n if can_buy_usd!(bid) && can_sell_usd!(ask)\n if bid.amount > ask.amount\n ActiveRecord::Base.transaction do\n bid.user.create_or_update_position(ask.amount, @instrument, @instrument_id)\n bid.user.portfolio.decrement!(:funds,sale_price*ask.amount)\n ask.user.remove_from_position(bid.amount, @instrument, @instrument_id)\n ask.user.portfolio.increment!(:funds,sale_price*ask.amount)\n bid.decrement!(:amount, ask.amount)\n ask.destroy\n end\n else\n ActiveRecord::Base.transaction do\n bid.user.create_or_update_position(bid.amount, @instrument, @instrument_id)\n bid.user.portfolio.decrement!(:funds,sale_price*ask.amount)\n ask.user.remove_from_position(bid.amount, @instrument, @instrument_id)\n ask.user.portfolio.increment!(:funds,sale_price*ask.amount)\n ask.decrement!(:amount, bid.amount)\n bid.destroy\n end\n end\n end\n end\n end", "def check_buyable\n raise PermissionDeniedError, \"出品したアイテムはサポートできません\" if @item.owner?(current_user)\n end", "def sell_at_any_cost(percent_decrease = 0.3)\n market_name = @market_name\n open_orders_url = get_url({ :api_type => \"market\", :action => \"open_orders\", :market => market_name })\n open_orders = call_secret_api(open_orders_url)\n #cancel all orders\n if open_orders.size > 0\n open_orders.each do |open_order|\n cancel_order_url = get_url({ :api_type => \"market\", :action => \"cancel_by_uuid\", :uuid => open_order[\"OrderUuid\"] })\n call_secret_api(cancel_order_url)\n end\n end\n # call sell bot again with lower profit\n sell_order = sell_bot(percent_decrease)\nend", "def create\n # offer holen\n offer_type = params[:shop_transaction][:offer_type]\n if offer_type === 'resource'\n offer = Shop::ResourceOffer.find(params[:shop_transaction][:offer_id])\n elsif offer_type === 'bonus'\n offer = Shop::BonusOffer.find(params[:shop_transaction][:offer_id])\n elsif offer_type === 'platinum'\n offer = Shop::PlatinumOffer.find(params[:shop_transaction][:offer_id])\n elsif offer_type === 'special_offer'\n offer = Shop::SpecialOffer.find(params[:shop_transaction][:offer_id])\n raise BadRequestError.new('no special offer') if offer.nil?\n raise ForbiddenError.new('already bought special offer') unless offer.buyable_by_character(current_character)\n else\n raise BadRequestError.new('invalid offer type')\n end\n\n if offer_type === 'bonus' && offer.currency === Shop::Transaction::CURRENCY_GOLDEN_FROGS\n price = { 3 => offer.price }\n raise ForbiddenError.new('not enough resources to pay for offer') unless current_character.resource_pool.have_at_least_resources(price)\n current_character.resource_pool.remove_resources_transaction(price)\n success = offer.credit_to(current_character)\n\n @shop_transaction = Shop::Transaction.new({\n character: current_character,\n offer: offer.to_json,\n state: Shop::Transaction::STATE_CLOSED\n })\n elsif offer_type === 'special_offer'\n ActiveRecord::Base.transaction(:requires_new => true) do\n\n shop_special_offers_transaction = Shop::SpecialOffersTransaction.find_or_create_by_character_id_and_external_offer_id(current_character.id, offer.external_offer_id)\n shop_special_offers_transaction.lock!\n\n if shop_special_offers_transaction.purchase.nil?\n purchase = shop_special_offers_transaction.create_purchase({\n character_id: current_character.id,\n external_offer_id: offer.external_offer_id,\n })\n else\n purchase = shop_special_offers_transaction.purchase\n end\n\n # lokale transaction erzeugen\n @shop_transaction = Shop::Transaction.create({\n character: current_character,\n offer: offer.to_json,\n state: Shop::Transaction::STATE_CREATED\n })\n\n # transaction zum payment provider schicken\n virtual_bank_transaction = {\n customer_identifier: current_character.identifier, # TODO: send access_token instead (to prove, that user has logged in to game server)\n credit_amount_booked: offer.price,\n booking_type: Shop::Transaction::TYPE_DEBIT,\n transaction_id: @shop_transaction.id,\n }\n\n account_response = CreditShop::BytroShop.get_customer_account(current_character.identifier)\n raise BadRequestError.new(\"Could not connect to Shop to get account balance\") unless (account_response[:response_code] == Shop::Transaction::API_RESPONSE_OK)\n credit_amount = account_response[:response_data][:amount]\n\n @shop_transaction.credit_amount_before = credit_amount\n @shop_transaction.save\n\n\n raise ForbiddenError.new('too few credits') if credit_amount < offer.price\n transaction_response = CreditShop::BytroShop.post_virtual_bank_transaction(virtual_bank_transaction, current_character.identifier)\n\n if transaction_response[:response_code] === Shop::Transaction::API_RESPONSE_OK\n @shop_transaction.credit_amount_after = transaction_response[:response_data][:amount]\n @shop_transaction.state = Shop::Transaction::STATE_CONFIRMED\n @shop_transaction.credit_amount_booked = offer.price\n @shop_transaction.save\n\n ActiveRecord::Base.transaction(:requires_new => true) do\n if !purchase.redeemed? && !shop_special_offers_transaction.redeemed?\n purchase.special_offer.credit_to(current_character)\n purchase.redeemed_at = Time.now\n purchase.save!\n\n shop_special_offers_transaction.redeemed_at = Time.now\n shop_special_offers_transaction.state = Shop::Transaction::STATE_REDEEMED\n shop_special_offers_transaction.save!\n\n @shop_transaction.state = Shop::Transaction::STATE_BOOKED\n @shop_transaction.save\n else\n @shop_transaction.state = Shop::Transaction::STATE_ERROR_NOT_BOOKED\n @shop_transaction.save\n raise BadRequestError.new(\"Could not book shop offer\")\n end\n end\n\n # transaction abschliessen\n @shop_transaction.state = Shop::Transaction::STATE_CLOSED\n @shop_transaction.save\n else # payment rejected\n @shop_transaction.state = Shop::Transaction::STATE_REJECTED\n @shop_transaction.save\n end\n\n success = @shop_transaction.save\n end\n else\n # lokale transaction erzeugen\n @shop_transaction = Shop::Transaction.create({\n character: current_character,\n offer: offer.to_json,\n state: Shop::Transaction::STATE_CREATED\n })\n\n # transaction zum payment provider schicken\n virtual_bank_transaction = {\n customer_identifier: current_character.identifier, # TODO: send access_token instead (to prove, that user has logged in to game server)\n credit_amount_booked: offer.price,\n booking_type: Shop::Transaction::TYPE_DEBIT,\n transaction_id: @shop_transaction.id,\n }\n\n account_response = CreditShop::BytroShop.get_customer_account(current_character.identifier)\n raise BadRequestError.new(\"Could not connect to Shop to get account balance\") unless (account_response[:response_code] == Shop::Transaction::API_RESPONSE_OK)\n credit_amount = account_response[:response_data][:amount]\n\n @shop_transaction.credit_amount_before = credit_amount\n @shop_transaction.save\n\n\n raise ForbiddenError.new('too few credits') if credit_amount < offer.price\n transaction_response = CreditShop::BytroShop.post_virtual_bank_transaction(virtual_bank_transaction, current_character.identifier)\n\n if transaction_response[:response_code] === Shop::Transaction::API_RESPONSE_OK\n @shop_transaction.credit_amount_after = transaction_response[:response_data][:amount]\n @shop_transaction.state = Shop::Transaction::STATE_CONFIRMED\n @shop_transaction.credit_amount_booked = offer.price\n @shop_transaction.save\n\n ActiveRecord::Base.transaction do\n if offer.credit_to(current_character)\n @shop_transaction.state = Shop::Transaction::STATE_BOOKED\n @shop_transaction.save\n else\n @shop_transaction.state = Shop::Transaction::STATE_ERROR_NOT_BOOKED\n @shop_transaction.save\n raise BadRequestError.new(\"Could not book shop offer\")\n end\n end\n\n # transaction abschliessen\n @shop_transaction.state = Shop::Transaction::STATE_CLOSED\n @shop_transaction.save\n else # payment rejected\n @shop_transaction.state = Shop::Transaction::STATE_REJECTED\n @shop_transaction.save\n end\n\n success = @shop_transaction.save\n end\n\n\n respond_to do |format|\n if success\n format.html { redirect_to @shop_transaction, notice: 'Transaction was successfully created.' }\n format.json { render json: @shop_transaction, status: :created, location: @shop_transaction }\n else\n format.html { render action: \"new\" }\n format.json { render json: @shop_transaction.errors, status: :unprocessable_entity }\n end\n end\n end", "def user_accept(user_id)\n\n cancels = {}\n user = User.find(user_id)\n\n # For each trade line\n trade_lines.each do |x|\n if x.inventory_own.user_id == user_id\n # We accept only the user's portion of the trade\n x.user_from_accepted = true\n x.save\n \n # If this inventory item is involved in other trades\n # then those trades are invalidated\n user_own(user_id).inventory_own.trades.each do |y|\n if y.id != x.trade_id\n cancels[y.id] = y\n end\n end\n\n # If this inventory item is involved in other trades\n # then those trades are invalidated\n user_need(user_id).inventory_need.trades.each do |y|\n if y.id != x.trade_id\n cancels[y.id] = y\n end\n end\n \n cancels.keys.each do |z|\n trade = cancels[z]\n\n unless trade.declined?\n trade.trade_lines.each { |w| w.user_from_accepted = false }\n trade.trade_lines.each { |w| w.save }\n note = trade.trade_notes.build\n note.comment = \"Sorry, I accepted another trade\"\n note.user_id = user_id\n trade.save\n end\n end\n end\n end\n end", "def create\n if params[:trade_id]\n trade = Trade.find params[:trade_id]\n item = trade.item\n offer = trade.offer\n if current_user and trade.item.user_id == current_user.id\n if trade.active?\n accepted_offer = AcceptedOffer.new\n accepted_offer.trade_id = params[:trade_id]\n accepted_offer.user_id = current_user.id\n accepted_offer.recent_tradeya = true\n if accepted_offer.save\n trade.update_attribute(:status, \"ACCEPTED\")\n item.reduce_quantity\n offer.reduce_quantity\n copy2me = (params[:copy2me] == 'true')\n # this is an immediate notification with Publisher's message\n #EventNotification.add_2_notification_q(NOTIFICATION_TYPE_IMIDIATE, NOTIFICATION_OFFER_ACCEPTED, offer.user_id, {:trade_id => trade.id, :msg => params[:msg], :copy2me => copy2me, :chk_user_setting => true})\n TradeMailer.offer_accepted_offerer(offer.id,offer.user.id,item.id,item.user.id).deliver\n TradeMailer.offer_accepted_owner(offer.id,offer.user.id,item.id,item.user.id).deliver\n TradeMailer.review_reminder_offerer(offer.user.id,item.user.id).deliver_in(3.days)\n TradeMailer.review_reminder_owner(offer.user.id,item.user.id).deliver_in(3.days)\n # to show count of offers accepted in daily or weekly notification mails\n EventNotification.add_2_notification_q(NOTIFICATION_TYPE_USER_SETTING, NOTIFICATION_OFFER_ACCEPTED, offer.user_id, {:trade_id => trade.id, :msg => params[:msg], :copy2me => copy2me}) unless (offer.user.notification_frequency == NOTIFICATION_FREQUENCY_IMMEDIATE or !offer.user.notify_offer_accepted)\n \n # Alert.add_2_alert_q(ALERT_TYPE_OFFER, OFFER_ACCEPTED, offer.user_id, nil, trade.id)\n end\n end\n end\n # if item.completed?\n # redirect_to accepted_offers_item_path(item)\n # else\n # redirect_to trade_offers_item_path(item)\n # end\n redirect_to past_trades_user_path(current_user,:trade => trade.id)\n end\n end", "def require_self_enabled_cross_selling\n if @entity.try(:self_enabled_cross_sell) != true\n redirect_to [:admin, @entity, :cross_selling_lists]\n end\n end", "def sell_pending\n end", "def user_update(user_id)\n trade_lines.each do |x|\n if x.inventory_own.user_id != user_id\n x.user_from_accepted = false \n else\n x.user_from_accepted = true\n end\n x.save\n end\n end", "def sell_to_offer(offer,item)\r\n active = item.active?\r\n item.activate if !active\r\n #offer.from.credits +=offer.price*offer.quantity\r\n purchase = Purchase.create(item,offer.quantity,item.owner,offer.from)\r\n purchase.adapt_price_to_offer(offer)\r\n purchase.prepare\r\n PurchaseActivity.successful(purchase).log\r\n offer.delete\r\n item.deactivate if !active\r\n end", "def hold_sell_trade(hnum, snum, tnum, player, game, acquired_hotel)\n snum = snum.to_i\n tnum = tnum.to_i\n # do nothing when holding shares\n # deal with selling of shares\n if (snum > 0)\n # give player money\n acquired_game_hotel = game.game_hotels.where(name: acquired_hotel).first\n acquired_hotel_share_price = acquired_game_hotel.share_price\n player.cash = player.cash + (acquired_hotel_share_price * snum)\n # remove shares from stock cards and return to game pool\n snum.times do\n card = player.stock_cards.where(hotel: acquired_hotel).first\n player.stock_cards.delete(card)\n game.stock_cards << card\n end\n\n player.save\n game.save\n end\n\n # deal with trading of shares\n if (tnum > 0)\n dominant_hotel = game.dominant_hotel\n num_of_trades = tnum/2\n num_of_trades.times do\n 2.times do\n a_card = player.stock_cards.where(hotel: acquired_hotel).first\n player.stock_cards.delete(a_card)\n game.stock_cards << a_card\n end\n d_card = game.stock_cards.where(hotel: dominant_hotel).first\n game.stock_cards.delete(d_card)\n player.stock_cards << d_card\n end\n\n player.save\n game.save\n end\n end", "def validate_transferrable\n (buyer_items + seller_items).each do |item|\n fail NonTransferrableError unless item.kind_of?(Transferrable)\n end\n end", "def credit_unlimited?\n #if prepaid?\n # raise \"Prepaid users do not have credit\"\n credit == -1\n end", "def valuate_sell_article(article)\n return if article.unlimited?\n return if article.sell_locked?\n (0..article.quantity - 1).each {\n if rand(100) < depletion_rate\n deplenish_article(article)\n if article.rare?\n $game_shops.add_on_trade_flow(article.item)\n end\n end\n }\n end", "def place_offer(proposer, amount)\n\t\t\tif proposer.balance >= amount\n\t\t\t\tsell_to(proposer, amount) if @owner.decide(:consider_proposed_trade, game: @owner.game, player: @owner, proposer: proposer, property: self, amount: amount).is_yes?\n\t\t\tend\n\t\tend", "def sell_unambigous_cargo\n tx_log = []\n transaction_data = {side: 'sell'}\n current_hold.each do |cargo_name, cargo_amt|\n cargo_price = current_market[cargo_name]\n if cargo_amt > 0 and !Data.is_cargo_banned(cargo_name, @game.current_planet) and Cargos.can_sell(cargo_name, cargo_price)\n\n sell(cargo_name, cargo_amt, cargo_price, transaction_data)\n tx_log << \"[#{cargo_amt} #{cargo_name} at #{cargo_price} for income of #{cargo_price * cargo_amt} credits]\"\n end\n end\n if transaction_data.length > 1\n @game.take_action('trade', {transaction: transaction_data})\n Util.log(\"Selling unambigious cargo: #{tx_log.join(', ')}\")\n true\n else\n false\n end\n end", "def shares_available_for_purchase?\n if Stock.all.find_by(id: trade.stock_id).shares_available < trade.num_shares\n return false\n else\n return true\n end\n end", "def has_different_point_values?\n offer_value = Inventory.evaluate_items(@offer[:items])\n for_value = Inventory.evaluate_items(@for[:items])\n if offer_value != for_value\n add_error(:for, :items,\n \"Invalid Offer, the items offered and received do not worth the same\")\n true\n else false; end\n end", "def create_event_tickets(event)\n # Ensures that the event creator doesn't request to join his own event and no users request twice.\n unused_users = User.all.to_a.reject!{ |u| u == event.user}\n rand(4..6).times do\n ticket = Ticket.new(\n event: event,\n user: unused_users.sample\n )\n unused_users.delete(ticket.user)\n ticket.status = ['pending', 'accepted'].sample\n ticket.save\n end\nend", "def validate_over_1000_vendor_sells\n total_trokaAki = Interaction.by_month.joins(:user =>:roles).where(:user_id => self.user_id, :roles => { :name => \"vendor\"}).group(\"interactions.user_id\").count\n unless total_trokaAki.size == 0\n if total_trokaAki.first.last > 1000\n ValidatorMailer.vendor_over_1000_warning(self.user_id).deliver\n end\n end\n end", "def uniqueness_by_votable\n errors.add(\"you already voted!\") if Vote.where(votable: self.votable, user_id: self.user_id).count > 0\n end", "def sell_stocks(prompt, user)\n puts `clear`\n view_my_stocks(prompt, user)\n stock_name = search_stock_symbol(prompt)\n stock_name_string = stock_name.stock_symbol\n current_stock_qty = self.stocks.where(stock_symbol: stock_name_string).sum(:stock_qty)\n puts \"Please enter the amount of #{stock_name_string} shares you'd like to sell:\"\n quantity = gets.chomp.to_i\n if quantity > current_stock_qty || quantity == 0 \n puts \"You do not have enough shares to sell\".colorize(:red)\n main_menu(prompt, self)\n else\n total_price = (quantity * stock_name.current_price) \n quantity = (quantity * -1 )\n Trade.create(stock_id: stock_name.id, user_id: self.id, stock_qty: quantity, stock_price_when_purchased: stock_name.current_price)\n self.update(balance: self.balance += total_price )\n puts \"You have sold #{quantity * -1} shares of #{stock_name.stock_symbol} for a total of $#{total_price}\"\n end\n self.trades.where(stock_id: stock_name.id).destroy_all if self.stocks.where(stock_symbol: stock_name_string).sum(:stock_qty) == 0\n main_menu(prompt, self)\n end", "def sell_bot(percent_decrease = 0.1)\n market_name = @market_name\n currency = @currency\n low_24_hr, last_price, ask_price = get_market_summary(market_name)\n sell_price = last_price - percent_decrease*last_price\n get_balance_url = get_url({ :api_type => \"account\", :action => \"currency_balance\", :currency => currency })\n balance_details = call_secret_api(get_balance_url)\n sell_price = \"%.8f\" % sell_price\n if balance_details and balance_details[\"Available\"] and balance_details[\"Available\"] > 0.0\n p [market_name, last_price, balance_details[\"Available\"], sell_price]\n sell_limit_url = get_url({ :api_type => \"market\", :action => \"sell\", :market => market_name, :quantity => balance_details[\"Available\"], :rate => sell_price })\n puts \"Selling coin...\".yellow\n p [{ :api_type => \"market\", :action => \"sell\", :market => market_name, :quantity => balance_details[\"Available\"], :rate => sell_price }]\n order_placed = call_secret_api(sell_limit_url)\n puts (order_placed and !order_placed[\"uuid\"].nil? ? \"Success\".green : \"Failed\".red)\n cnt = 1\n while cnt <= 3 and order_placed and order_placed[\"uuid\"].nil? #retry\n puts \"Retry #{cnt} : Selling coin...\".yellow\n sleep(1) # half second\n order_placed = call_secret_api(sell_limit_url)\n puts (order_placed and !order_placed[\"uuid\"].nil? ? \"Success\".green : \"Failed\".red)\n cnt += 1\n end\n p [order_placed, \"Sell #{balance_details[\"Available\"]} of #{market_name} at #{sell_price}\"]\n else\n puts \"Insufficient Balance\".red\n end\nend", "def buy?(buyer)\r\n if buyer.credits < self.price or not self.active or buyer == self.owner\r\n false\r\n return\r\n end\r\n owner.credits += self.price\r\n buyer.credits -= self.price\r\n self.owner.remove_owned(self)\r\n self.owner = buyer \r\n buyer.add_owned(self)\r\n self.active = false\r\n true \r\n end", "def buy\n if @product.price <= @user.coin_credit # Checks whether the user has enough coin_credit or not\n purchase\n else\n @user.errors.add(:coin_credit, :not_enough_credit)\n false\n end\n end", "def same_survivor?\n if @offer[:survivor_id].to_i == @for[:survivor_id].to_i\n add_error(:for, :survivor_id, \"not allowed to trade with self\")\n return true\n end\n\n return false\n end", "def owner_only_offers_reward?\n self.rewards_count == 1 && self.rewards.visible[0].sender == self.person\n end", "def unredeemable?\n payment_owed? && !(ProductStrategy === self.order.promotion.strategy) \n end", "def only_one_deal_of_each_type\n errors.add(:type, \"– You have already created a #{type} for #{product.name}. Please remove the existing deal before creating a new one.\") unless\n Deal.where({ product_id: product_id, type: type }).count.zero? or Deal.where({ product_id: product_id, type: type }).first.id == id\n end", "def display_trade_option?(user)\n trade = Trade.new(\"user1\" => @current_user, \"user2\" => user)\n trade.valid_trade\n end", "def destroy\n trade = Trade.find(params[:id])\n # if trade.accepted_offer.nil? or current_user.pub?(trade.item)\n # trade.destroy\n # else\n trade.update_attribute(\"status\", \"DELETED\")\n # end\n\n # Alert.add_2_alert_q(ALERT_TYPE_TRADEYA, OFFER_DELETED, trade.item.user.id, nil, trade.id)\n \n #mail notification (Mohammad Faizan)\n # if trade.item.user.notify_offer_changed?(MAIL) then EventNotificationMailer.offer_on_tradeya_deleted(trade.item,trade.offer).deliver end\n if trade.item.user.notify_offer_changed then EventNotification.add_2_notification_q(NOTIFICATION_TYPE_USER_SETTING, NOTIFICATION_OFFER_ON_TRADEYA_DELETED, trade.item.user.id, {:trade_id => trade.id}) end\n\n if params[:manageOffer]\n if params[:manageOffer] == \"SUCCESSFUL\"\n @successfulOffers = Trade.get_user_successful_offers(current_user.id)\n elsif params[:manageOffer] == \"PAST\"\n @pastOffers = Trade.get_user_past_offers(current_user.id)\n elsif params[:manageOffer] == \"CURRENT\"\n @currentOffers = Trade.get_user_current_offers(current_user.id)\n end\n else\n @item = trade.item\n #@trades = @item.trades\n @userReviews = User.get_user_reviews(@item.user_id)\n @comments = Comment.item_comments(@item.id)\n @accepted_offers = @item.accepted_trades\n @trades = @item.other_trades\n \n @status = @item.item_status\n \n @offererReviews = Array.new\n @trades.each do |trade|\n offerer = trade.offer.user_id\n @offererReviews.push(User.get_user_reviews(offerer))\n end\n\n #Generating Reviews about accepted offerers \n @accepted_offererReviews = Array.new\n @accepted_offers.each do |trade|\n offerer = trade.offer.user_id\n @accepted_offererReviews.push(User.get_user_reviews(offerer))\n end\n \n @offer_open4cats = @item.offer_open4cats\n\n @pub = false\n @offerer = false\n\n if current_user\n @pub = current_user.pub?(@item)\n @offerer = current_user.offerer?(@item.id)\n end\n\n # Generating mutual connections\n @mc = Hash.new #mutual connections\n @amc = Hash.new #accepted mutual connections\n @offerer_mc = [] #offerer or potential offerer's mutual connection with item owner\n if @pub \n @trades.each do |trade|\n if !@mc[trade.offer.user.id] or @mc[trade.offer.user.id].nil?\n @mc[trade.offer.user.id] = MutualFriend.get_mutual_friends_details(current_user.id, trade.offer.user.id)\n # connections = fb_mutual_friends(current_user,trade.offer.user)\n # connections.concat(twitter_mutual_friends(current_user,trade.offer.user))\n # @mc[trade.offer.user.id] = connections\n end\n end\n @accepted_offers.each do |trade|\n if !@amc[trade.offer.user.id] or @amc[trade.offer.user.id].nil?\n @amc[trade.offer.user.id] = MutualFriend.get_mutual_friends_details(current_user.id, trade.offer.user.id)\n # connections = fb_mutual_friends(current_user,trade.offer.user)\n # connections.concat(twitter_mutual_friends(current_user,trade.offer.user))\n # @amc[trade.offer.user.id] = connections\n end\n end\n elsif current_user\n # offerer or potential offerer's mutual connection with item owner\n # connections = fb_mutual_friends(current_user,@item.user)\n # connections.concat(twitter_mutual_friends(current_user,@item.user))\n # @offerer_mc = connections\n @offerer_mc = MutualFriend.get_mutual_friends_details(current_user.id, @item.user.id)\n end\n end\n render :layout => false\n end", "def buy!(buyer_planet, amount)\n raise GameLogicError.new(\"Cannot buy 0 or less! Wanted: #{amount}\") \\\n if amount <= 0\n amount = from_amount if amount > from_amount\n \n cost = (amount * to_rate).ceil\n buyer_source, bs_attr = self.class.resolve_kind(buyer_planet, to_kind)\n buyer_target, bt_attr = self.class.resolve_kind(buyer_planet, from_kind)\n if system?\n seller_target = nil\n else\n seller_target, _ = self.class.resolve_kind(planet, to_kind)\n end\n \n stats = CredStats.buy_offer(buyer_planet.player, cost) \\\n if seller_target.nil? && to_kind == KIND_CREDS\n \n buyer_has = buyer_source.send(bs_attr)\n raise GameLogicError.new(\"Not enough funds for #{buyer_source\n }! Wanted #{cost} #{bs_attr} but it only had #{buyer_has}.\"\n ) if buyer_has < cost\n \n # Used to determine whether to send notification or not.\n original_amount = from_amount\n \n # Subtract resource that buyer is paying with from him.\n buyer_source.send(:\"#{bs_attr}=\", buyer_has - cost)\n # Add resource that buyer has bought from seller.\n buyer_target.send(:\"#{bt_attr}=\", \n buyer_target.send(bt_attr) + amount)\n # Add resource that buyer is paying with to seller. Unless:\n # * its a system offer\n # * or #to_kind is creds and planet currently does not have an owner\n seller_target.send(\n :\"#{bs_attr}=\", seller_target.send(bs_attr) + cost\n ) unless seller_target.nil?\n # Reduce bought amount from offer.\n self.from_amount -= amount\n \n objects = [buyer_source, buyer_target]\n # We might not have seller target. See above.\n objects.push seller_target unless seller_target.nil?\n objects.uniq.each { |obj| self.class.save_obj_with_event(obj) }\n\n if from_amount == 0\n # Schedule creation of new system offer.\n CallbackManager.register(\n without_locking { galaxy },\n CALLBACK_MAPPINGS[from_kind],\n Cfg.market_bot_random_resource_cooldown_date\n ) if system?\n destroy!\n else\n save!\n end\n percentage_bought = amount.to_f / original_amount\n\n MarketRate.subtract_amount(galaxy_id, from_kind, to_kind, amount)\n\n # Create notification if:\n # * It's not a system notification\n # * Enough of the percentage was bought\n # * Sellers planet currently has a player.\n Notification.create_for_market_offer_bought(\n self, buyer_planet.player, amount, cost\n ) if ! system? &&\n percentage_bought >= CONFIG['market.buy.notification.threshold'] &&\n ! planet.player_id.nil?\n\n stats.save! unless stats.nil?\n\n amount\n end", "def no_other_reservations_on_this_time_period\n item_reservations.each do |ir|\n item = ir.item\n amount_available = item.get_availability(pick_up_time.to_datetime, return_time.to_datetime, id)\n if ir.amount > amount_available\n if amount_available > 0\n errors.add(:items, errors.generate_message(:items, :too_few_available, { :item_title => item.title, :count => amount_available.to_s }))\n else\n errors.add(:items, errors.generate_message(:items, :none_available, { :item_title => item.title }))\n end \n end\n end \n end", "def allow_user_submit(user)\n current? and !expired_for_user(user)\n end", "def allow_user_submit(user)\n current? and !expired_for_user(user)\n end", "def allow_user_submit(user)\n current? and !expired_for_user(user)\n end", "def validate_records\n have_enough_items_to_trade?\n end", "def book_once_aday\n errors.add(:user, 'Guest can book only once a day') if booked_in_same_day?\n end", "def chargeable? listing\n listing.seller?(@user) && listing.new? \n end", "def sell_stock(user)\n quote = Stock.stock_quote(Stock.all.find(self.stock_id).symbol)\n sell_trade = Trade.create(status: \"pending\", investor_id: user.id, num_shares: self.num_shares,\n stock_price: quote.delayed_price, bought_sold: \"In progress\", stock_id: self.stock_id, date: Date.today)\n sell_trade.purchase_price = quote.delayed_price * sell_trade.num_shares\n user.deposit_funds(sell_trade.purchase_price)\n original_order = Trade.all.find(self.id)\n original_order.bought_sold = \"sold\"\n original_order.save\n sell_trade.bought_sold = \"sell order\"\n sell_trade.status = \"completed\"\n sell_trade.save\n puts \"\\nCongratulations! You have successfully sold #{sell_trade.num_shares} shares of #{quote.company_name}\"\n end", "def check_for_buyout\n if self.is_bought_out\n if self.bought_out_by_team_id\n self.subcontracts.future_years.each do |sub|\n sub.salary_amount *= 0.6\n sub.this_is_a_buyout = true\n sub.save!\n\n # update GM's annual actions to not allow more buyouts\n actions = AnnualGmAction.find_by_team_id_and_year(self.bought_out_by_team_id, current_year)\n actions.has_bought_out = true\n actions.bought_out_player_id = self.player.id\n actions.save!\n end\n end\n end\n end", "def has_editorial_or_stock_for_sale\n return false if self.requests.length == 0\n self.requests.each do |r|\n return false if r.state == \"denied\"\n end\n true\n end", "def execute_trade!\n offer_inventory = @offer[:records].map{ |e| [e.item_name.to_sym, e]}.to_h\n for_inventory = @for[:records].map{ |e| [e.item_name.to_sym, e]}.to_h\n\n @offer[:items].each do |name, quantity|\n offer_inventory[name.to_sym].quantity -= quantity\n for_inventory[name.to_sym].quantity += quantity\n end\n\n @for[:items].each do |name, quantity|\n for_inventory[name.to_sym].quantity -= quantity\n offer_inventory[name.to_sym].quantity += quantity\n end\n\n ActiveRecord::Base.transaction do\n @offer[:records].each(&:save)\n @for[:records].each(&:save)\n end\n end", "def validate_ownership\n buyer_items.each { |item| item.validate_owner seller }\n seller_items.each { |item| item.validate_owner buyer }\n end", "def can_bid_on?(offer)\n owns = (self == offer.user)\n in_transaction = offer.responses.any? { |r| r.status != 'open' }\n offer.is_parent_offer? && !owns && !in_transaction\n end", "def check_textbook_id_and_reciever_id\n return false if Textbook.find_by_id(self.textbook_id).nil? || User.find_by_id(self.reciever_id).nil?\n\n if reciever_id === sender_id\n self.errors.add(:reciever_id, \"You can't send an offer to yourself!\")\n\treturn false\n end\n\n if self.sender.listing_from_textbook(self.textbook_id) && self.sender.listing_from_textbook(self.textbook_id).selling? != self.selling?\n if self.selling?\t\n self.errors.add(:reciever_id, \"You're currently listing this book 'Looking For' not 'For Sale'. You must list this book 'For Sale' before sending selling offers for it\")\n\t return false\n\t else\n self.errors.add(:reciever_id, \"You're currently listing this book 'For Sale'. You must remove that listing before sending offers to other users to buy theirs\")\n\t return false\n\n\t end\n end\n\n return true\n end", "def ensure_unique_athlete_per_prediction\n \terrors.add(:athlete_id, \"Already chosen\") if @duplicate_athlete_ids.present? and @duplicate_athlete_ids.include?(athlete_id)\n\tend", "def submit_fees\n raise('to be implemented by caller')\n end", "def buyer\n user = User.last\n offer = Offer.all.order('RANDOM()').first\n Remembers.buyer(user, offer)\n end", "def must_have_all_the_same_users\n if signature_pages.map{|signature_page| signature_page.signing_capacity.user }.uniq.length > 1\n errors.add(:base, \"Cannot hold more than one user's signature pages\")\n end\n end", "def cannot_like_same_data_point_twice\n\t\tsameLikes = Like.where(:user_id => self.user_id, :data_point_id => self.data_point_id)\n \tif sameLikes.count >= 1\n \t\terrors.add(:base, \"cannot like twice the same photo\")\n \tend\n \tend", "def can_buy_drug?(price, qty)\n wallet > (price * qty) \n end", "def sell_confirmed\n end", "def buy_item(item_to_buy, user)\r\n fail \"only users can buy items in behalve of an organisation\" if (user.organisation)\r\n fail \"only users that are part of #{self.name} can buy items for it\" unless (is_member?(user))\r\n fail \"would exceed #{user.email}'s organisation limit for today\" unless within_limit_of?(item_to_buy, user)\r\n fail \"not enough credits\" if item_to_buy.price > self.credits\r\n fail \"Item not in System\" unless (DAOItem.instance.item_exists?(item_to_buy.id))\r\n\r\n old_owner = item_to_buy.owner\r\n\r\n #Subtracts price from buyer\r\n self.credits = self.credits - item_to_buy.price\r\n #Adds price to owner\r\n old_owner.credits += item_to_buy.price\r\n #decreases the limit of the buyer\r\n @member_limits[user.email].spend(item_to_buy.price) unless self.limit.nil? || is_admin?(user)\r\n\r\n item_to_buy.bought_by(self)\r\n end", "def offenses_to_check; end", "def can_add_stock?(ticker_symbol)\n under_stock_limit? && !stock_already_added?(ticker_symbol)\n end", "def startTrading market,hashLeft,btcLeft,tradingPrice\n\n startID = Pricepoint.last.id\n\n #Set these:\n\n username = \"whateverYourNameIS\"\n hashKey = \"YourKeyHereLotsOfNUmbers\"\n hashSecret = \"YourSecretHereLooksSimilar\" \n\n @api = Hashnest::API.new(username, hashKey, hashSecret)\n \n market = 19 #change this for other market\n origHashLeft = hashLeft\n origBtcLeft = btcLeft\n\n @api.quick_revoke market, \"sale\"\n @api.quick_revoke market, \"purchase\"\n\n\n minBuyAmount = 200\n minSaleAmount = 200\n sellMin = tradingPrice\n buyMax = tradingPrice\n\n sellSpread = 0.00005\n buySpread = 0.00004\n\n\n middle = (sellMin + buyMax) / 2.0\n\n minOrder = 93\n\n btcLeft = origBtcLeft\n hashLeft = origHashLeft\n\n \n updatedOrders = updateOrders market,minBuyAmount,minSaleAmount\n lSale = updatedOrders[0]\n hBuy = updatedOrders[1]\n sellInfo = [0,lSale]\n buyInfo = [0,hBuy]\n\n #Check initial sell and buy\n hashBal = hashBalance market\n sellAmount = hashBal[0] - hashLeft\n\n btcBal = btcBalance\n buyBtc = btcBal[0] - btcLeft\n buyAmount = (buyBtc / buyMax).round\n\n puts \"####### Starting trading Middle: #{middle} - Buying: #{buyAmount} - Selling: #{sellAmount} #######\"\n\n while (Pricepoint.last.id <= startID)\n #Check if we should buy or sell\n \n updatedOrders = updateOrders market,minBuyAmount,minSaleAmount\n lSale = updatedOrders[0]\n hBuy = updatedOrders[1]\n secSale = updatedOrders[2]\n secBuy = updatedOrders[3]\n\n if (lSale > sellMin)\n #Price is good to sell\n\n if (minSaleAmount > minOrder)\n minSaleAmount = minSaleAmount * 0.9\n end\n\n\n #Check how much we can sell\n hashBal = hashBalance market\n sellAmount = hashBal[0] - hashLeft\n #If this is larger than 0, lets go on\n\n if (sellAmount > minOrder)\n #Check if we're already selling the right amount\n if ((hashBal[1] - sellAmount).abs < 50)\n #Check if the price is right\n sellDiff = (sellInfo[1] - lSale).abs\n secSellDiff = (sellInfo[1] - secSale).abs\n if (sellDiff > 0.000000009 || secSellDiff > 0.000000011)\n puts \"Sell Price is wrong, changing price...\"\n sellInfo = revokeAndPlaceNewSell market, minBuyAmount, minSaleAmount, sellMin, sellAmount\n end\n \n\n else\n puts \"Cancelling and placing new sell order\"\n sellInfo = revokeAndPlaceNewSell market, minBuyAmount, minSaleAmount, sellMin, sellAmount\n end\n else\n puts \"Hashamount is #{sellAmount}, we can't sell less than #{minOrder}\"\n end\n else\n puts \"Lowest sell: #{lSale}, our min price: #{sellMin} = We can't sell!\"\n if ((minSaleAmount * 1.2) < sellAmount)\n minSaleAmount = minSaleAmount * 1.2\n end\n sellInfo = [0,lSale]\n end\n\n\n if (hBuy < buyMax)\n #Price is good to buy\n if (minBuyAmount > minOrder)\n minBuyAmount = minBuyAmount * 0.95\n end\n\n #Check how much we can buy\n btcBal = btcBalance\n buyBtc = btcBal[0] - btcLeft\n buyAmount = (buyBtc / hBuy).round\n\n #If this is larger than 0, lets go on\n if (buyAmount > minOrder)\n\n #Check if we're already buying the right amount\n if ((btcBal[1] - buyBtc).abs < 0.1 )\n puts \"We are buying the right amount\"\n\n #Check if the price is right\n buyDiff = (buyInfo[1] - hBuy).abs\n secBuyDiff = (buyInfo[1]- secBuy).abs\n\n #puts \"BuyDiff #{buyDiff} sec #{secBuyDiff}\"\n if (buyDiff > 0.000000009 || secBuyDiff > 0.000000011)\n puts \"Buy Price is wrong, changing price...\"\n buyInfo = revokeAndPlaceNewBuy market, minBuyAmount, minSaleAmount, buyMax, buyAmount\n end\n\n\n else\n puts \"Cancelling and placing new buy order\"\n buyInfo = revokeAndPlaceNewBuy market, minBuyAmount, minSaleAmount, buyMax, buyAmount\n end\n\n else\n puts \"Hashamout is #{buyAmount}, we can't buy less than #{minOrder} hash\"\n end\n\n\n else\n puts \"Highest buy: #{hBuy}, our max price: #{buyMax} = We can't buy!\"\n if ((minBuyAmount * 1.2) < buyAmount)\n minBuyAmount = minBuyAmount * 1.2\n end\n buyInfo = [0,hBuy]\n end\n\n puts \"Last order sell #{sellInfo[0]} for #{sellInfo[1]} and buy #{buyInfo[0]} for #{buyInfo[1]}\"\n \n\n distanceToBuy = buyMax - buyInfo[1]\n btcLeft = origBtcLeft * (1 - distanceToBuy/buySpread)\n if btcLeft < 0.0\n btcLeft = 0.0\n end\n\n distanceToSell = sellInfo[1] - sellMin\n hashLeft = origHashLeft * (1 - distanceToSell/sellSpread)\n if hashLeft < 0.0\n hashLeft = 0.0\n end\n\n\n puts \"Buy distance from middle: #{distanceToBuy*100000}, new btcLeft: #{btcLeft}, new minBuyAmount #{minBuyAmount}\"\n puts \"Sell distance from middle: #{distanceToSell*100000}, new hashLeft: #{hashLeft}, new minSaleAmount #{minSaleAmount}\"\n\n total = totalBtcValue market,hBuy\n puts \"####### Total now: #{total} #######\"\n\n end\n end", "def index\n @suggestions = policy_scope(Item).order(expiration: :desc)\n\n Reservation.joins(:item)\n .where('items.pickup_time < ?', Time.now)\n .destroy_all\n\n @reservations = policy_scope(Reservation).order(created_at: :desc)\n @reservation = Reservation.new\n authorize @reservation\n\n # CAROUSEL: OTHER UNIQUE ITEMS BY SAME SUPPLIER\n @my_owned_items = Item.all.where(user: current_user)\n @same_supplier_items = []\n @in_cart = []\n @reservations.each do |reservation|\n @same_supplier_items |= reservation.item.user.items\n @in_cart << reservation.item\n end\n @same_supplier_items.select! { |item| item.pickup_time.to_datetime > DateTime.now }\n @same_supplier_items -= @in_cart\n @same_supplier_items -= @my_owned_items\n\n # CAROUSEL: OTHERS WITH SAME ITEMS IN CART ALSO HAVE THESE IN CART\n @other_reserved_items = []\n @my_reserved_items = []\n @reservations.each do |my_reservation|\n my_reservation.item.reservations.each do |same_reservation|\n same_reservation.user.reservations.each do |other_reservation|\n if other_reservation.user_id == current_user.id\n @my_reserved_items |= [other_reservation.item]\n else\n @other_reserved_items |= [other_reservation.item]\n end\n end\n end\n end\n @other_reserved_items.uniq!\n\n @other_reserved_items.select! { |item| item.pickup_time.to_datetime > DateTime.now }\n @other_reserved_items -= @my_reserved_items\n @other_reserved_items -= @my_owned_items\n\n # CAROUSEL: OTHERS WHO BOUGHT WHAT YOU'VE BOUGHT ALSO BOUGHT\n if @others_purchased_items = Order.all\n .where(state: 'paid')\n .where.not(user_id: current_user.id)\n .map(&:purchased_items)\n .flatten\n .map(&:item)\n .uniq!\n @others_purchased_items.select! { |item| item.pickup_time.to_datetime > DateTime.now }\n\n if @my_purchased_items = Order.all\n .where(state: 'paid')\n .where(user_id: current_user.id)\n .map(&:purchased_items)\n .flatten\n .map(&:item)\n .uniq!\n @others_purchased_items -= @my_purchased_items\n @others_purchased_items -= @my_owned_items\n end\n end\n\n # SHOPPING CART: SEPARATE ITEMS BY SELLER\n @reservations_suppliers = []\n @reservations.each do |reservation|\n supplier = reservation.item.user\n @reservations_suppliers |= [supplier]\n end\n @reservations_suppliers_with_reserved = @reservations_suppliers.map { |supplier|\n [\n supplier,\n @reservations\n .joins(:item)\n .where(items: { user_id: supplier.id })\n ]\n }\n\n if user_signed_in?\n @purchased_item = PurchasedItem.new\n @subtotal_price = 0\n @total_price = 0\n @total_items = 0\n @reservations.each do |reservation|\n @subtotal_price += reservation.item.price * reservation.quantity\n @total_items += reservation.quantity\n end\n @percent = 5.0\n @amount = @subtotal_price\n @subtotal_price = @subtotal_price * (1 / (1 + (@percent/100)))\n @commission = @amount - @subtotal_price\n else\n redirect_to reservations_error_path\n end\n end", "def no_duplicate_items_in_vouch_list\n vouch_list = wish_list.user.vouch_list_primary\n return if vouch_list.nil?\n\n if vouch_list.vouch_items.find_by_business_id(self.business_id).present?\n errors.add(:vouch_list, \"already contains item \\\"#{self.business.name}\\\".\")\n end\n end", "def reset_trades(x, user_id)\n\n\n end", "def require_same_user\n if params[:id].to_i != current_actor.id\n flash[:error] = \"Unable to complete withdrawal. Invalid user.\".t\n redirect_to money_path(current_actor) and return\n end\n end", "def can_be_rejected?\n self.applied?\n end", "def settle_item_purchase(seller, buyer, item)\n seller.credits += item.price + Integer((item.price * SELL_BONUS).ceil)\n buyer.credits -= item.price\n end", "def pair_validator(uniq_items)\n gift = false\n pair = false\n\n for item in uniq_items\n if item.promo == \"PAIR\"\n item.pair_gift ? gift = true : pair = true\n end\n end\n\n gift && pair\n end", "def buy_ticket\n customer = find_customer_by_id()\n film = find_film_by_id()\n screening = find_screening_by_hour()\n return 'sorry, but there is no space in the room' if screening.tickets_avalible < 1 \n customer.funds -= film.price\n customer.tickets_bougth += 1\n screening.tickets_avalible -= 1\n screening.update()\n customer.update()\n end", "def create\n if @assignment.active_offer.present? &&\n @assignment.active_offer.status != 'withdrawn'\n render_error(message: I18n.t('active_offers.already_exists'))\n return\n end\n\n start_transaction_and_rollback_on_exception do\n offer = @assignment.offers.create!\n @assignment.update!(active_offer: offer)\n render_success @assignment.active_offer\n end\n end", "def can_sell?\n inventory.any? { |inv| inv.price > 0 }\n end", "def assign_available_slots(teams_bidding_info)\n teams_bidding_info.each do |tb|\n tb[:bids].each do |bid|\n topic_id = bid[:topic_id]\n num_of_signed_up_teams = SignedUpTeam.where(topic_id: topic_id).count\n max_choosers = SignUpTopic.find(bid[:topic_id]).try(:max_choosers)\n if num_of_signed_up_teams < max_choosers\n SignedUpTeam.create(team_id: tb[:team_id], topic_id: bid[:topic_id])\n break\n end\n end\n end\n end", "def trade; end", "def must_have_no_duplicate_products\n seen = []\n items.each do |item|\n if seen.include?(item.product.uuid) then\n errors.add(:items, \"cannot have duplicate products\")\n else\n seen << item.product.uuid\n end\n end\n end", "def dangling?\n shares.count < 1 && invitations.active.count < 1\n end", "def offer_available?\n #return self.approved? && self.offers.last.present? && self.offers.last.effective?\n return self.offers.last.present? && self.offers.last.effective?\n end", "def check_if_approval_is_required\n !offer_request.blank?\n end", "def trade_is_open\n unless trade && trade.status == Trade::STATUSES['open']\n errors.add(:trade_id, \"Offers cannot be made unless the trade is open.\")\n end\n end", "def make_trade(prompt, user)\n puts `clear`\n view_my_stocks(prompt, user)\n puts \"Your available balance is \" + \"$#{self.balance.round(2)}\".colorize(:green)\n stock_name = search_stock_symbol(prompt)\n puts \"Please enter the quantity of #{stock_name.stock_symbol} you'd like to purchase:\"\n stock_qty = gets.chomp.to_i\n\n if stock_qty <= 0\n puts \"You have entered an invalid number\"\n main_menu(prompt, self)\n end \n\n trade_total = (stock_qty * stock_name.current_price).to_f\n\n if self.balance > trade_total\n self.update(balance: self.balance -= trade_total)\n Trade.create(stock_id: stock_name.id, user_id: self.id, stock_qty: stock_qty, stock_price_when_purchased: stock_name.current_price)\n puts `clear`\n puts \"You purchased #{stock_qty} stocks of #{stock_name.stock_symbol} for a total of\" + \" $#{trade_total.round(2)}\".colorize(:green) + \" at $#{stock_name.current_price} per share.\"\n puts \"Your current available balance is \" + \"$#{self.balance.round(2)}\".colorize(:green)\n else\n puts `clear`\n puts \"You do not have sufficient funds to complete this transaction, please try to purchase a smaller amount.\".colorize(:red)\n end\n main_menu(prompt, self)\n end", "def buy_ticket(ticket)\n if @funds >= ticket.price\n @funds -= ticket.price\n else\n return \"not enough funds\"\n end\n end", "def buy_no_contracts\n #set variables\n @contract_id = params.fetch(\"contract_id\")\n @contract_row = Contract.where({ :id => @contract_id }).at(0)\n @market_id = @contract_row.market.id\n @season_id = @contract_row.market.season.id\n @club_id = @contract_row.market.season.club.id\n \n @number_of_contracts = params.fetch(\"quantity_buy_no\")\n @membership_row = Membership.where({ :users_id => current_user.id, :seasons_id => @season_id, :goes_to => \"seasons_table\"}).at(0)\n @user_asset_rows = @membership_row.assets\n @user_season_funds_row = @user_asset_rows.where({ :membership_id => @membership_row.id, :category => \"season_fund\"}).at(0)\n @user_starting_season_funds = @user_season_funds_row.quantity\n @starting_contract_asset_row = @user_asset_rows.where({ :membership_id => @membership_row.id, :contract_id => @contract_id, :category => \"contract_quantity_b\"}).at(0) #membership_row.id is probably unnecessary.\n \n #confirm user actually belongs to the Season associated with this Contract/Market and that the market is active\n if (@membership_row.present?) && (@contract_row.market.status == \"active\")\n \n #Confirm number is a positive integer.\n if @number_of_contracts.to_i < 1 || @number_of_contracts.include?(\".\")\n flash[:alert] = \"There was an error processing your request.\"\n else\n #check if user already has an asset row associated with this contract (contract id matches and category is \"contract_quantity_b\").\n #If user does, skip step, otherwise, if user does not, create a new asset with a quantity of 0.\n if @starting_contract_asset_row.present?\n else\n new_asset = Asset.new\n new_asset.membership_id = @membership_row.id\n new_asset.season_id = @season_id\n new_asset.contract_id = @contract_id\n new_asset.category = \"contract_quantity_b\"\n new_asset.quantity = 0\n new_asset.save\n end\n\n #add variable to track contract_asset_row now that we know it must exist:\n @contract_asset_row = @user_asset_rows.where({ :membership_id => @membership_row.id, :contract_id => @contract_id, :category => \"contract_quantity_b\"}).at(0) #membership_row.id is probably unnecessary.\n \n #algorithm (C= b * ln(e^(q1/b) + e^(q2/b)...))\n #consider updating contract table to include column for quantity outstanding to avoid many of these calculations\n liquidity_param = 50 #set liquidity parameter (b) for now. Later might allow custommization or make b variable.\n\n #calculate price/cost by running price_check algo\n total_cost = @contract_row.price_check(@contract_id, liquidity_param, @number_of_contracts, \"no\")\n \n #(1) remove accumulated funds from user's season_funds, (2) add contract asset (3) later, make it so this is reflected in transaction table(probably in a first step and base everything off transaction)\n #Update tables based on actions above.\n\n if total_cost > @user_season_funds_row.quantity\n flash[:alert] = \"Insufficient funds. Sell some contracts or request more funds from the Season owner.\"\n else\n # remove accumulated funds from user's season_funds. Consider updating method to be based on subtraction from current amount instead of current way.\n @user_season_funds_row.quantity = @user_season_funds_row.quantity - total_cost\n @user_season_funds_row.save\n\n #update contract quantity in assets table to reflect new purchase\n @contract_asset_row.quantity = @contract_asset_row.quantity + @number_of_contracts.to_i\n @contract_asset_row.save\n\n #update contract quantity in contracts table to reflect new outstanding balance\n #if market is a 'Classical' category, then instead of adding a no contract, add a yes contract for every other contract...at least for now.\n if @contract_row.category == \"Classical\"\n @contract_row.market.contracts.where.not({ :id => @contract_row.id }).each do |add_contract|\n add_contract.quantity_a = add_contract.quantity_a + @number_of_contracts.to_i\n add_contract.save\n end\n elsif @contract_row.category == \"Independent\"\n @contract_row.quantity_b = @contract_row.quantity_b + @number_of_contracts.to_i\n @contract_row.save\n end\n\n if @number_of_contracts.to_i == 1\n flash[:notice] = \"Yay! \" + @number_of_contracts.to_s + \" no contract was sucessfully purchased for \" + number_to_currency(total_cost) + \".\"\n else\n flash[:notice] = \"Yay! \" + @number_of_contracts.to_s + \" no contracts were sucessfully purchased for \" + number_to_currency(total_cost) + \".\"\n end\n end\n end\n \n #add instance variables needed for partials that are refreshed\n @contract_rows = @contract_row.market.contracts.order({ :created_at => :asc })\n @membership_id = @membership_row.id\n @season_membership_rows = Membership.where({ :seasons_id => @season_id, :goes_to => \"seasons_table\"})\n @market_row = @contract_row.market\n\n respond_to do |format|\n format.js { render 'contract_templates/render_contracts.js.erb' }\n end\n\n else\n flash[:alert] = \"You are not authorized to perform this action.\"\n end\n\n end", "def suitable_quaters\n required_amount * 2\n end", "def agreed\n @choosen = []\n @my_mentees = Pair.find_by_user_id(current_user.id).mentee_id\n if @my_mentees.is_a?(Integer)\n if Pair.find_by_user_id(@my_mentees) != nil\n @my_mentees_choice = Pair.find_by_user_id(@my_mentees).mentee_id\n if @my_mentees_choice == current_user.id\n @choosen.push(@my_mentees)\n end\n end\n else\n @my_mentees.each do |mentee|\n @mentees_matches = Pair.find_by_user_id(mentee).mentee_id\n if @mentees_matches.is_a?(Integer)\n if @mentees_matches == current_user.id\n @choosen.push(@mentees_matches)\n end\n elsif @mentees_matches != nil\n @mentees_matches.each do |me|\n if me == current_user.id\n @choosen.push(me)\n end\n end\n end\n end\n end\n return @choosen.last\n end", "def can_buy_any_from_market?(entity)\n @game.share_pool.shares.group_by(&:corporation).each do |corporation, shares|\n next unless corporation.ipoed\n return true if can_buy_shares?(entity, shares)\n end\n\n false\n end", "def release_unequippable_items(item_gain = true)\n loop do\n last_equips = equips.dup\n @equips.each_with_index do |item, i|\n if !equippable?(item.object) || !etype_can_equip?(i, item.object)\n trade_item_with_party(nil, item.object) if item_gain\n item.object = nil\n end\n end\n return if equips == last_equips\n end\n end", "def can_buy_presidents_share?(_entity, share, corporation)\n share.percent < corporation.presidents_percent || share.owner != @game.share_pool\n end", "def buy_tickets\n tally = films().map {|ticket| ticket.price.to_f}\n tally.each {|price| @wallet -= price}\n num_of_tickets\n screenings = tickets().map{|ticket| ticket.screening}\n screenings_flat = screenings.flatten\n screenings_flat.map {|screening| screening.tickets_available -= 1}\n screenings_flat.each {|screening| p screening.update }\n update()\n end", "def can_add_stock?(ticker_symbol)\n under_stock_limit? && !stock_already_added?(ticker_symbol)\n end", "def allow(ids); end", "def set_offer\n @offer = Offer.find(params[:id])\n authorize @offer\n end", "def dean_approve_awards(user)\n for award in awards.valid\n award.update_attribute(:amount_awarded, award.amount_requested) if award.amount_awarded.blank?\n award.update_attribute(:amount_awarded_user_id, user.id)\n end\n update_attribute(:approved_at, Time.now)\n end" ]
[ "0.6968255", "0.6415409", "0.6087627", "0.588009", "0.5879429", "0.5853544", "0.58353084", "0.5822977", "0.5810023", "0.5779928", "0.57678455", "0.57532203", "0.57504547", "0.5744216", "0.57348293", "0.573474", "0.573332", "0.5725953", "0.5718551", "0.5717363", "0.5712558", "0.57087815", "0.56964386", "0.5676701", "0.5651738", "0.5645963", "0.56359816", "0.563591", "0.5626624", "0.5625477", "0.56174767", "0.5603497", "0.5598314", "0.5579996", "0.5554065", "0.5553912", "0.55510473", "0.553984", "0.55132353", "0.5512797", "0.5506188", "0.5505595", "0.5489307", "0.54869705", "0.5476756", "0.5472887", "0.54668546", "0.54668546", "0.54668546", "0.54630923", "0.5462735", "0.5446371", "0.5441531", "0.5430612", "0.5426542", "0.5420326", "0.541492", "0.5409481", "0.54075325", "0.5404757", "0.5394612", "0.539433", "0.5387682", "0.5378089", "0.53776133", "0.537138", "0.5350588", "0.5342038", "0.5335899", "0.5331008", "0.532509", "0.53204924", "0.53201956", "0.5312132", "0.53118175", "0.5294245", "0.5291291", "0.52854186", "0.52790636", "0.5271535", "0.5271001", "0.5268656", "0.5261497", "0.5260661", "0.5252732", "0.5251865", "0.5249247", "0.5249162", "0.5240148", "0.5239671", "0.5239433", "0.52376276", "0.52294904", "0.5226821", "0.5219346", "0.52189106", "0.52113205", "0.520905", "0.5207181", "0.51999503" ]
0.72359073
0
makes sure a trade is open to offers before creating an offer
def trade_is_open unless trade && trade.status == Trade::STATUSES['open'] errors.add(:trade_id, "Offers cannot be made unless the trade is open.") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n flag = true\n item = Item.find(params[:trades][:item_id])\n offer = Item.find(params[:trades][:offer_id])\n passive_trade = PassiveTrade.find(params[:trades][:passive_trade_id])\n if !item.live? or !offer.live? \n flag = false\n end\n t = Trade.where(:item_id => item.id, :offer_id => offer.id).where(\"status != 'REJECTED' and status != 'DELETED'\") unless (flag == false)\n if t.present?\n flag = false\n end\n if flag \n t = Trade.where(:item_id => offer.id, :offer_id => item.id)\n if t.present?\n flag = false\n end\n if flag and current_user and current_user.id == offer.user_id\n trade = Trade.new(params[:trades])\n trade.status = 'ACTIVE'\n trade.save\n\n passive_trade.trade_comments.each do |tc|\n tc.trade_id = trade.id\n tc.save\n end\n passive_trade.trade_terms.each do |tt|\n tt.trade_id = trade.id\n tt.save\n end\n passive_trade.transactions.each do |t|\n t.trade_id = trade.id\n t.save\n end\n\n redirect_location = trade_path(trade)\n \n # if (InfoAndSetting.sm_on_o_made and item.user.notify_received_offer)\n # # Send mail if offer accepted\n # TradeMailer.offer_made_offerer(offer.id,offer.user.id,item.id,item.user.id).deliver\n # TradeMailer.offer_made_owner(offer.id,offer.user.id,item.id,item.user.id).deliver\n # end\n end\n # When user moves back rejected offer to offers\n # if flag and params[:undo_reject] == \"true\"\n # t = Trade.where(:item_id => item.id, :offer_id => offer.id).where(\"status = 'REJECTED'\").first\n # if t.present?\n # t.status = \"DELETED\"\n # t.save\n # end\n # trade = Trade.new(params[:trade])\n # trade.status = 'ACTIVE'\n # trade.save\n # redirect_location = trade_offers_item_path(item) +\"?back_to_offer=true\"\n # else\n # redirect_location = my_offers_item_path(item)\n # session[:offered_item] = offer.title\n # end\n elsif t.present?\n redirect_location = trade_path(t.first)\n else\n redirect_location = passive_trade_path(passive_trade)\n # session[:offered_item] = offer.title\n end\n \n redirect_to redirect_location\n \n # respond_to do |format|\n # if @trade.save\n # format.html { redirect_to @trade, notice: 'Trade was successfully created.' }\n # format.json { render json: @trade, status: :created, location: @trade }\n # else\n # format.html { render action: \"new\" }\n # format.json { render json: @trade.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def create\n if @assignment.active_offer.present? &&\n @assignment.active_offer.status != 'withdrawn'\n render_error(message: I18n.t('active_offers.already_exists'))\n return\n end\n\n start_transaction_and_rollback_on_exception do\n offer = @assignment.offers.create!\n @assignment.update!(active_offer: offer)\n render_success @assignment.active_offer\n end\n end", "def create\n # offer holen\n offer_type = params[:shop_transaction][:offer_type]\n if offer_type === 'resource'\n offer = Shop::ResourceOffer.find(params[:shop_transaction][:offer_id])\n elsif offer_type === 'bonus'\n offer = Shop::BonusOffer.find(params[:shop_transaction][:offer_id])\n elsif offer_type === 'platinum'\n offer = Shop::PlatinumOffer.find(params[:shop_transaction][:offer_id])\n elsif offer_type === 'special_offer'\n offer = Shop::SpecialOffer.find(params[:shop_transaction][:offer_id])\n raise BadRequestError.new('no special offer') if offer.nil?\n raise ForbiddenError.new('already bought special offer') unless offer.buyable_by_character(current_character)\n else\n raise BadRequestError.new('invalid offer type')\n end\n\n if offer_type === 'bonus' && offer.currency === Shop::Transaction::CURRENCY_GOLDEN_FROGS\n price = { 3 => offer.price }\n raise ForbiddenError.new('not enough resources to pay for offer') unless current_character.resource_pool.have_at_least_resources(price)\n current_character.resource_pool.remove_resources_transaction(price)\n success = offer.credit_to(current_character)\n\n @shop_transaction = Shop::Transaction.new({\n character: current_character,\n offer: offer.to_json,\n state: Shop::Transaction::STATE_CLOSED\n })\n elsif offer_type === 'special_offer'\n ActiveRecord::Base.transaction(:requires_new => true) do\n\n shop_special_offers_transaction = Shop::SpecialOffersTransaction.find_or_create_by_character_id_and_external_offer_id(current_character.id, offer.external_offer_id)\n shop_special_offers_transaction.lock!\n\n if shop_special_offers_transaction.purchase.nil?\n purchase = shop_special_offers_transaction.create_purchase({\n character_id: current_character.id,\n external_offer_id: offer.external_offer_id,\n })\n else\n purchase = shop_special_offers_transaction.purchase\n end\n\n # lokale transaction erzeugen\n @shop_transaction = Shop::Transaction.create({\n character: current_character,\n offer: offer.to_json,\n state: Shop::Transaction::STATE_CREATED\n })\n\n # transaction zum payment provider schicken\n virtual_bank_transaction = {\n customer_identifier: current_character.identifier, # TODO: send access_token instead (to prove, that user has logged in to game server)\n credit_amount_booked: offer.price,\n booking_type: Shop::Transaction::TYPE_DEBIT,\n transaction_id: @shop_transaction.id,\n }\n\n account_response = CreditShop::BytroShop.get_customer_account(current_character.identifier)\n raise BadRequestError.new(\"Could not connect to Shop to get account balance\") unless (account_response[:response_code] == Shop::Transaction::API_RESPONSE_OK)\n credit_amount = account_response[:response_data][:amount]\n\n @shop_transaction.credit_amount_before = credit_amount\n @shop_transaction.save\n\n\n raise ForbiddenError.new('too few credits') if credit_amount < offer.price\n transaction_response = CreditShop::BytroShop.post_virtual_bank_transaction(virtual_bank_transaction, current_character.identifier)\n\n if transaction_response[:response_code] === Shop::Transaction::API_RESPONSE_OK\n @shop_transaction.credit_amount_after = transaction_response[:response_data][:amount]\n @shop_transaction.state = Shop::Transaction::STATE_CONFIRMED\n @shop_transaction.credit_amount_booked = offer.price\n @shop_transaction.save\n\n ActiveRecord::Base.transaction(:requires_new => true) do\n if !purchase.redeemed? && !shop_special_offers_transaction.redeemed?\n purchase.special_offer.credit_to(current_character)\n purchase.redeemed_at = Time.now\n purchase.save!\n\n shop_special_offers_transaction.redeemed_at = Time.now\n shop_special_offers_transaction.state = Shop::Transaction::STATE_REDEEMED\n shop_special_offers_transaction.save!\n\n @shop_transaction.state = Shop::Transaction::STATE_BOOKED\n @shop_transaction.save\n else\n @shop_transaction.state = Shop::Transaction::STATE_ERROR_NOT_BOOKED\n @shop_transaction.save\n raise BadRequestError.new(\"Could not book shop offer\")\n end\n end\n\n # transaction abschliessen\n @shop_transaction.state = Shop::Transaction::STATE_CLOSED\n @shop_transaction.save\n else # payment rejected\n @shop_transaction.state = Shop::Transaction::STATE_REJECTED\n @shop_transaction.save\n end\n\n success = @shop_transaction.save\n end\n else\n # lokale transaction erzeugen\n @shop_transaction = Shop::Transaction.create({\n character: current_character,\n offer: offer.to_json,\n state: Shop::Transaction::STATE_CREATED\n })\n\n # transaction zum payment provider schicken\n virtual_bank_transaction = {\n customer_identifier: current_character.identifier, # TODO: send access_token instead (to prove, that user has logged in to game server)\n credit_amount_booked: offer.price,\n booking_type: Shop::Transaction::TYPE_DEBIT,\n transaction_id: @shop_transaction.id,\n }\n\n account_response = CreditShop::BytroShop.get_customer_account(current_character.identifier)\n raise BadRequestError.new(\"Could not connect to Shop to get account balance\") unless (account_response[:response_code] == Shop::Transaction::API_RESPONSE_OK)\n credit_amount = account_response[:response_data][:amount]\n\n @shop_transaction.credit_amount_before = credit_amount\n @shop_transaction.save\n\n\n raise ForbiddenError.new('too few credits') if credit_amount < offer.price\n transaction_response = CreditShop::BytroShop.post_virtual_bank_transaction(virtual_bank_transaction, current_character.identifier)\n\n if transaction_response[:response_code] === Shop::Transaction::API_RESPONSE_OK\n @shop_transaction.credit_amount_after = transaction_response[:response_data][:amount]\n @shop_transaction.state = Shop::Transaction::STATE_CONFIRMED\n @shop_transaction.credit_amount_booked = offer.price\n @shop_transaction.save\n\n ActiveRecord::Base.transaction do\n if offer.credit_to(current_character)\n @shop_transaction.state = Shop::Transaction::STATE_BOOKED\n @shop_transaction.save\n else\n @shop_transaction.state = Shop::Transaction::STATE_ERROR_NOT_BOOKED\n @shop_transaction.save\n raise BadRequestError.new(\"Could not book shop offer\")\n end\n end\n\n # transaction abschliessen\n @shop_transaction.state = Shop::Transaction::STATE_CLOSED\n @shop_transaction.save\n else # payment rejected\n @shop_transaction.state = Shop::Transaction::STATE_REJECTED\n @shop_transaction.save\n end\n\n success = @shop_transaction.save\n end\n\n\n respond_to do |format|\n if success\n format.html { redirect_to @shop_transaction, notice: 'Transaction was successfully created.' }\n format.json { render json: @shop_transaction, status: :created, location: @shop_transaction }\n else\n format.html { render action: \"new\" }\n format.json { render json: @shop_transaction.errors, status: :unprocessable_entity }\n end\n end\n end", "def expireOffer()\n # Put the offer date in the past\n @item['offer']['window']['start'] = \"2016-01-01 00:00:00 +10\"\n @item['offer']['window']['end'] = \"2016-01-01 00:00:00 +10\"\n \n @offer_operation = :expire\n @media_operation = :update\n if @trailer\n @trailer_operation = :update\n end\n end", "def place_offer(proposer, amount)\n\t\t\tif proposer.balance >= amount\n\t\t\t\tsell_to(proposer, amount) if @owner.decide(:consider_proposed_trade, game: @owner.game, player: @owner, proposer: proposer, property: self, amount: amount).is_yes?\n\t\t\tend\n\t\tend", "def attemp_buying\n\n end", "def create_offer\n end", "def sell_to_offer(offer,item)\r\n active = item.active?\r\n item.activate if !active\r\n #offer.from.credits +=offer.price*offer.quantity\r\n purchase = Purchase.create(item,offer.quantity,item.owner,offer.from)\r\n purchase.adapt_price_to_offer(offer)\r\n purchase.prepare\r\n PurchaseActivity.successful(purchase).log\r\n offer.delete\r\n item.deactivate if !active\r\n end", "def create\n if params[:trade_id]\n trade = Trade.find params[:trade_id]\n item = trade.item\n offer = trade.offer\n if current_user and trade.item.user_id == current_user.id\n if trade.active?\n accepted_offer = AcceptedOffer.new\n accepted_offer.trade_id = params[:trade_id]\n accepted_offer.user_id = current_user.id\n accepted_offer.recent_tradeya = true\n if accepted_offer.save\n trade.update_attribute(:status, \"ACCEPTED\")\n item.reduce_quantity\n offer.reduce_quantity\n copy2me = (params[:copy2me] == 'true')\n # this is an immediate notification with Publisher's message\n #EventNotification.add_2_notification_q(NOTIFICATION_TYPE_IMIDIATE, NOTIFICATION_OFFER_ACCEPTED, offer.user_id, {:trade_id => trade.id, :msg => params[:msg], :copy2me => copy2me, :chk_user_setting => true})\n TradeMailer.offer_accepted_offerer(offer.id,offer.user.id,item.id,item.user.id).deliver\n TradeMailer.offer_accepted_owner(offer.id,offer.user.id,item.id,item.user.id).deliver\n TradeMailer.review_reminder_offerer(offer.user.id,item.user.id).deliver_in(3.days)\n TradeMailer.review_reminder_owner(offer.user.id,item.user.id).deliver_in(3.days)\n # to show count of offers accepted in daily or weekly notification mails\n EventNotification.add_2_notification_q(NOTIFICATION_TYPE_USER_SETTING, NOTIFICATION_OFFER_ACCEPTED, offer.user_id, {:trade_id => trade.id, :msg => params[:msg], :copy2me => copy2me}) unless (offer.user.notification_frequency == NOTIFICATION_FREQUENCY_IMMEDIATE or !offer.user.notify_offer_accepted)\n \n # Alert.add_2_alert_q(ALERT_TYPE_OFFER, OFFER_ACCEPTED, offer.user_id, nil, trade.id)\n end\n end\n end\n # if item.completed?\n # redirect_to accepted_offers_item_path(item)\n # else\n # redirect_to trade_offers_item_path(item)\n # end\n redirect_to past_trades_user_path(current_user,:trade => trade.id)\n end\n end", "def trade action\n bid_ask=action==:buy ? :ask : :bid\n\n\tp = @price[:bid] if @price && @price[:bid] && bid_ask==:bid#memoize\n\tp = @price[:ask] if @price && @price[:ask] && bid_ask==:ask#memoize\n\tp = price(action) unless p\n bid_ask=action==:buy ? \"B\":\"S\" #reverse because its BTCUSD pair\n\tvolume = @options[:volume]\n\n params = {'username' => ENV['ROCK_USERNAME'],\n\t 'password' => ENV['ROCK_PASSWORD'],\n\t 'api_key' => ENV['ROCK_KEY'],\n\t 'fund_name'=> 'BTCUSD',\n\t\t 'order_type'=>bid_ask,\n\t\t 'amount' => volume,\n\t\t 'price' => p\n\t }\n\tresponse = RestClient.post(\"https://www.therocktrading.com/api/place_order\", params, {})\n r_json=JSON.parse(response)\n if !r_json[\"result\"][0].key?(\"order_id\")\n #order was not accepted by exchnage\n return false\n end\n\torder_id = r_json[\"result\"][0][\"order_id\"]\n retries = @options[:trade_retries]\n (1..retries).each do |attempt|\n if !open_orders.include?(order_id)\n return true\n end\n if attempt == retries\n cancel_order order_id\n logger.info \"failed to fill #{action} order at #{exchange}\"\n return false\n else\n logger.info \"Attempt #{attempt}/#{retries}: #{action} order #{order_id} still opening, waiting for close to\"\n sleep(1)\n end\n end\n return false\n\n\n end", "def can_bid_on?(offer)\n owns = (self == offer.user)\n in_transaction = offer.responses.any? { |r| r.status != 'open' }\n offer.is_parent_offer? && !owns && !in_transaction\n end", "def create\n @exchange_trade_good = ExchangeTradeGood.new(exchange_trade_good_params)\n @exchange_trade_good.citizen = current_citizen \n @exchange_trade_good.turn = Global.singleton.turn \n @exchange_trade_good.price = @exchange_trade_good.trade_good ? @exchange_trade_good.trade_good.exchange_price : 0\n\n if params[:buy_or_sell] == 'sell'\n @exchange_trade_good.selling = true\n else\n params[:buy_or_sell] = 'buy'\n @exchange_trade_good.selling = false\n end\n \n respond_to do |format|\n if @exchange_trade_good.save\n format.html { redirect_to \"/citizens/#{current_citizen.id}?tab=inventory\", notice: 'Trade good traded.' }\n format.json { render json: @exchange_trade_good, status: :created, location: \"/citizens/#{current_citizen.id}?tab=inventory\" }\n else\n format.html { render :new }\n format.json { render json: @exchange_trade_good.errors, status: :unprocessable_entity }\n end\n end\n end", "def do_close\n self.void_pending_purchase_orders\n self.closed_at = Time.now.utc\n self.kase.sweep_max_reward_price_cache if self.kase\n self.send_canceled\n end", "def deal_with_other_offers\n if self.selling?\n if self.sender.nil? == false\n self.sender.active_offers_for_textbook(self.textbook_id).each do |offer|\n offer.update_status(3)\n\n if self.sender_id == offer.sender_id\n\t Offer.notify_buyer_book_sold(offer.reciever,offer.sender,textbook)\n\t else\n\t Offer.notify_buyer_book_sold(offer.sender,offer.reciever,textbook)\n\t end\n\t end\n end\n\tif self.reciever.nil? == false\n\t self.reciever.active_offers_for_textbook(self.textbook_id).each do |offer|\n\t offer.update_status(4)\n\n if self.sender_id == offer.sender_id\n\t Offer.notify_seller_book_bought(offer.reciever,offer.sender,textbook)\n\t else\n\t Offer.notify_seller_book_bought(offer.sender, offer.reciever, textbook)\n\t end\n\t end\n\tend\n else\n if self.sender.nil? == false\n self.sender.active_offers_for_textbook(self.textbook_id).each do |offer|\n offer.update_status(4)\n\n if self.sender_id == offer.sender_id\n\t Offer.notify_seller_book_bought(offer.reciever, offer.sender, textbook)\n\t else\n\t Offer.notify_seller_book_bought(offer.sender, offer.reciever, textbook)\n\t end\n\t end\n\tend\n\tif self.reciever.nil? == false\n\t self.reciever.active_offers_for_textbook(self.textbook_id).each do |offer|\n\t offer.update_status(3)\n\n if self.sender_id == offer.sender_id\n Offer.notify_buyer_book_sold(offer.reciever, offer.sender, textbook)\n\t else\n Offer.notify_buyer_book_sold(offer.sender, offer.reciever, textbook)\n\t end\n\t end\n\tend\n end\n end", "def of_generate_offer\n supplier = params[:supplier]\n request = params[:request]\n offer_no = params[:offer_no]\n offer_date = params[:offer_date] # YYYYMMDD\n offer = nil\n offer_item = nil\n code = ''\n\n if request != '0'\n offer_request = OfferRequest.find(request) rescue nil\n offer_request_items = offer_request.offer_request_items rescue nil\n if !offer_request.nil? && !offer_request_items.nil?\n # Format offer_date\n offer_date = (offer_date[0..3] + '-' + offer_date[4..5] + '-' + offer_date[6..7]).to_date\n # Try to save new offer\n offer = Offer.new\n offer.offer_no = offer_no\n offer.offer_date = offer_date\n offer.offer_request_id = offer_request.id\n offer.supplier_id = supplier\n offer.payment_method_id = offer_request.payment_method_id\n offer.created_by = current_user.id if !current_user.nil?\n offer.discount_pct = offer_request.discount_pct\n offer.discount = offer_request.discount\n offer.project_id = offer_request.project_id\n offer.store_id = offer_request.store_id\n offer.work_order_id = offer_request.work_order_id\n offer.charge_account_id = offer_request.charge_account_id\n offer.organization_id = offer_request.organization_id\n if offer.save\n # Try to save new offer items\n offer_request_items.each do |i|\n offer_item = OfferItem.new\n offer_item.offer_id = offer.id\n offer_item.product_id = i.product_id\n offer_item.description = i.description\n offer_item.quantity = i.quantity\n offer_item.price = i.price\n offer_item.tax_type_id = i.tax_type_id\n offer_item.created_by = current_user.id if !current_user.nil?\n offer_item.project_id = i.project_id\n offer_item.store_id = i.store_id\n offer_item.work_order_id = i.work_order_id\n offer_item.charge_account_id = i.charge_account_id\n if !offer_item.save\n # Can't save offer item (exit)\n code = '$write'\n break\n end # !offer_item.save?\n end # do |i|\n # Update totals\n offer.update_column(:totals, Offer.find(offer.id).total)\n else\n # Can't save offer\n code = '$write'\n end # offer.save?\n else\n # Offer request or items not found\n code = '$err'\n end # !offer_request.nil? && !offer_request_items.nil?\n else\n # Offer request 0\n code = '$err'\n end # request != '0'\n if code == ''\n code = I18n.t(\"ag2_purchase.offers.generate_offer_ok\", var: offer.id.to_s)\n end\n @json_data = { \"code\" => code }\n render json: @json_data\n end", "def make_sure_no_duplicate_offers\n other_offer = self.sender.active_offer_between_user_for_textbook(self.reciever_id, self.textbook_id)\n\n if other_offer.nil?\n if self.listing.nil?\n\t if self.selling?\n self.errors.add(:reciever_id, \"You don't have a current listing 'For Sale' for this book. You must post a listing before sending an offer to sell your book.\")\n\t else\n self.errors.add(:reciever_id, \"#{self.reciever.username} doesn't have a current listing 'For Sale' for this book.\")\n\t end\n\n return false\n\tend\n \n return true\n end\n\n if self.reciever_id == other_offer.reciever_id\n self.errors.add(:reciever_id, \"You already sent #{self.reciever.username} an offer for this book. You can check your offers sent by navigating to the 'Offers' page in the upper-left links then clicking 'View sent offers here'. (note: once a user rejects (not counter offers) your offer for a particular book, you may only respond to their offers)\")\n return false\n elsif other_offer.selling? != self.selling?\n other_offer.update_status(2)\n return true\n else\n self.errors.add(:reciever_id, \"#{self.reciever.username}'s removed their listing for this book!\")\n end\n end", "def can_buy()\n event = Event.find_by(id: self.event_id)\n if Time.now > event.start_date then\n halt msg: 'can_buy() fail' \n false\n else\n true\n end\n end", "def newOffer()\n @offer_operation = :create\n end", "def trade; end", "def startTrading market,hashLeft,btcLeft,tradingPrice\n\n startID = Pricepoint.last.id\n\n #Set these:\n\n username = \"whateverYourNameIS\"\n hashKey = \"YourKeyHereLotsOfNUmbers\"\n hashSecret = \"YourSecretHereLooksSimilar\" \n\n @api = Hashnest::API.new(username, hashKey, hashSecret)\n \n market = 19 #change this for other market\n origHashLeft = hashLeft\n origBtcLeft = btcLeft\n\n @api.quick_revoke market, \"sale\"\n @api.quick_revoke market, \"purchase\"\n\n\n minBuyAmount = 200\n minSaleAmount = 200\n sellMin = tradingPrice\n buyMax = tradingPrice\n\n sellSpread = 0.00005\n buySpread = 0.00004\n\n\n middle = (sellMin + buyMax) / 2.0\n\n minOrder = 93\n\n btcLeft = origBtcLeft\n hashLeft = origHashLeft\n\n \n updatedOrders = updateOrders market,minBuyAmount,minSaleAmount\n lSale = updatedOrders[0]\n hBuy = updatedOrders[1]\n sellInfo = [0,lSale]\n buyInfo = [0,hBuy]\n\n #Check initial sell and buy\n hashBal = hashBalance market\n sellAmount = hashBal[0] - hashLeft\n\n btcBal = btcBalance\n buyBtc = btcBal[0] - btcLeft\n buyAmount = (buyBtc / buyMax).round\n\n puts \"####### Starting trading Middle: #{middle} - Buying: #{buyAmount} - Selling: #{sellAmount} #######\"\n\n while (Pricepoint.last.id <= startID)\n #Check if we should buy or sell\n \n updatedOrders = updateOrders market,minBuyAmount,minSaleAmount\n lSale = updatedOrders[0]\n hBuy = updatedOrders[1]\n secSale = updatedOrders[2]\n secBuy = updatedOrders[3]\n\n if (lSale > sellMin)\n #Price is good to sell\n\n if (minSaleAmount > minOrder)\n minSaleAmount = minSaleAmount * 0.9\n end\n\n\n #Check how much we can sell\n hashBal = hashBalance market\n sellAmount = hashBal[0] - hashLeft\n #If this is larger than 0, lets go on\n\n if (sellAmount > minOrder)\n #Check if we're already selling the right amount\n if ((hashBal[1] - sellAmount).abs < 50)\n #Check if the price is right\n sellDiff = (sellInfo[1] - lSale).abs\n secSellDiff = (sellInfo[1] - secSale).abs\n if (sellDiff > 0.000000009 || secSellDiff > 0.000000011)\n puts \"Sell Price is wrong, changing price...\"\n sellInfo = revokeAndPlaceNewSell market, minBuyAmount, minSaleAmount, sellMin, sellAmount\n end\n \n\n else\n puts \"Cancelling and placing new sell order\"\n sellInfo = revokeAndPlaceNewSell market, minBuyAmount, minSaleAmount, sellMin, sellAmount\n end\n else\n puts \"Hashamount is #{sellAmount}, we can't sell less than #{minOrder}\"\n end\n else\n puts \"Lowest sell: #{lSale}, our min price: #{sellMin} = We can't sell!\"\n if ((minSaleAmount * 1.2) < sellAmount)\n minSaleAmount = minSaleAmount * 1.2\n end\n sellInfo = [0,lSale]\n end\n\n\n if (hBuy < buyMax)\n #Price is good to buy\n if (minBuyAmount > minOrder)\n minBuyAmount = minBuyAmount * 0.95\n end\n\n #Check how much we can buy\n btcBal = btcBalance\n buyBtc = btcBal[0] - btcLeft\n buyAmount = (buyBtc / hBuy).round\n\n #If this is larger than 0, lets go on\n if (buyAmount > minOrder)\n\n #Check if we're already buying the right amount\n if ((btcBal[1] - buyBtc).abs < 0.1 )\n puts \"We are buying the right amount\"\n\n #Check if the price is right\n buyDiff = (buyInfo[1] - hBuy).abs\n secBuyDiff = (buyInfo[1]- secBuy).abs\n\n #puts \"BuyDiff #{buyDiff} sec #{secBuyDiff}\"\n if (buyDiff > 0.000000009 || secBuyDiff > 0.000000011)\n puts \"Buy Price is wrong, changing price...\"\n buyInfo = revokeAndPlaceNewBuy market, minBuyAmount, minSaleAmount, buyMax, buyAmount\n end\n\n\n else\n puts \"Cancelling and placing new buy order\"\n buyInfo = revokeAndPlaceNewBuy market, minBuyAmount, minSaleAmount, buyMax, buyAmount\n end\n\n else\n puts \"Hashamout is #{buyAmount}, we can't buy less than #{minOrder} hash\"\n end\n\n\n else\n puts \"Highest buy: #{hBuy}, our max price: #{buyMax} = We can't buy!\"\n if ((minBuyAmount * 1.2) < buyAmount)\n minBuyAmount = minBuyAmount * 1.2\n end\n buyInfo = [0,hBuy]\n end\n\n puts \"Last order sell #{sellInfo[0]} for #{sellInfo[1]} and buy #{buyInfo[0]} for #{buyInfo[1]}\"\n \n\n distanceToBuy = buyMax - buyInfo[1]\n btcLeft = origBtcLeft * (1 - distanceToBuy/buySpread)\n if btcLeft < 0.0\n btcLeft = 0.0\n end\n\n distanceToSell = sellInfo[1] - sellMin\n hashLeft = origHashLeft * (1 - distanceToSell/sellSpread)\n if hashLeft < 0.0\n hashLeft = 0.0\n end\n\n\n puts \"Buy distance from middle: #{distanceToBuy*100000}, new btcLeft: #{btcLeft}, new minBuyAmount #{minBuyAmount}\"\n puts \"Sell distance from middle: #{distanceToSell*100000}, new hashLeft: #{hashLeft}, new minSaleAmount #{minSaleAmount}\"\n\n total = totalBtcValue market,hBuy\n puts \"####### Total now: #{total} #######\"\n\n end\n end", "def make_deal!\n if deal_with_other_offers \n if selling?\n Deal.create!(:buyer_id => self.reciever_id, :seller_id => self.sender_id, :price => self.price, :textbook_id => self.textbook_id, :description => self.listing.description)\n else\n Deal.create!(:buyer_id => self.sender_id, :seller_id => self.reciever_id, :price => self.price, :textbook_id => self.textbook_id, :description => self.listing.description)\n end\n\n sender_listing = sender.listing_from_textbook(textbook_id)\n sender_listing.destroy if sender_listing.nil? == false\n\n reciever_listing = reciever.listing_from_textbook(textbook_id)\n reciever_listing.destroy if reciever_listing.nil? == false\n else\n return false\n end\n end", "def newtrade\n # @this = \"this\"\n # @this = Trade.find(2)\n\n#\n # name = \"Apple Inc. - Common Stock\"\n # tick = \"AAPL\"\n # vol = 90\n # price = 243.42\n # total = 22320\n # type = \"Sell\"\n name = params[:name]\n tick = params[:tick]\n vol = params[:vol].to_i\n price = params[:price].to_f\n total = params[:total].to_f\n type = params[:type]\n tc = \"Trade Complete\"\n if type == \"Buy\" # IF ONE START 11111111111111\n\n @currentuser = current_user\n w = @currentuser.wallet\n if Trade.where(ticker: params[:tick]).exists?\n if w > total\n @trade = Trade.where(ticker: params[:tick]).first\n @trade.volume += vol\n @trade.save\n @currentuser.wallet -= total\n @currentuser.save\n @text = tc\n elsif w < total\n @text = \"You do not have enough units to make this trade.\"\n end\n else #graduate to using first_or_create\n @trade = @currentuser.trades.create(stock: name,\n ticker: tick,\n tradeprice: total,\n volume: vol,\n stockprice: price)\n @currentuser.wallet -= total\n @currentuser.save\n @text = tc\n end\n else # ELSE ONE START 11111111111111\n @currentuser = current_user\n w = @currentuser.wallet\n if Trade.where(ticker: params[:tick]).exists? # IF TWO START 222222222222\n if Trade.where(ticker: params[:tick]).first.volume >= vol\n @trade = Trade.where(ticker: params[:tick]).first\n @trade.volume -= vol\n @trade.save\n @currentuser.wallet += total\n @currentuser.save\n @text = tc\n else\n @text = \"You do not have enough shares to make this trade.\"\n end\n else # ElSE TWO START 222222222222\n @text = \"Could not complete trade. You do not have enough shares in this company.\"\n end # IF TWO END 222222222222\n end # IF ONE END 11111111111111\n\n\n end", "def close_sale\n self.active = false\n if winner?\n self.owner = winner?\n self.save\n end\n end", "def buy?(buyer)\r\n if buyer.credits < self.price or not self.active or buyer == self.owner\r\n false\r\n return\r\n end\r\n owner.credits += self.price\r\n buyer.credits -= self.price\r\n self.owner.remove_owned(self)\r\n self.owner = buyer \r\n buyer.add_owned(self)\r\n self.active = false\r\n true \r\n end", "def buys_ticket(film, show_time)\n viewing = film.find_specific_screening(show_time)\n admission_price = viewing[0].price\n if self.check_funds(admission_price) == true\n @funds -= viewing[0].price\n new_ticket = Ticket.new({\n 'film_id' => film.id,\n 'customer_id' => self.id,\n 'screening_id' => viewing[0].id\n })\n new_ticket.save\n self.update\n else\n return \"No Sale\"\n end\n end", "def pre_pay_offered\n end", "def create_points_order\n @deal = Deal.find(params[:deal_id])\n if current_consumer.total_points >= (@deal.price * 2)\n @order = Order.new\n @order.consumer_id = current_consumer.id\n @order.deal_id = params[:deal_id]\n @order.address = current_consumer.address\n if @order.save\n @consumer.total_points = (@consumer.total_points - (@deal.price.to_i*2))\n @consumer.save #this just returns false, how do i get it to actually save\n if @deal.has_exceeded_threshold?\n @deal.threshold_reached = true\n @deal.save\n end\n redirect_to edit_consumer_order_path(current_consumer, @order)\n else\n flash[:notice] = 'You have already bought a ticket for this raffle!'\n redirect_to :back\n end\n else\n flash[:notice] = 'You do not have enough points!'\n redirect_to :back\n end\n end", "def bidding_open?\n return self.auction_end.blank? || self.auction_end.future?\n end", "def buy_it_now\n\t\t# find item with respect to its ID\n @item = Item.find(params[:id])\n\n\t\t# can't buy closed item, security\n if @item.closed\n gflash :error => \"Unknown action\"\n else\n\t\t\t# can't buy your own items\n if current_user == @item.user\n gflash :error => \"You cannot buy your own item!\"\n elsif current_user.money >= @item.bin_price\n\t\t\t\t# if there are bids, refund highest bidder\n if @item.bids.first\n @highest_bid = @item.bids.sort_by{|b| b.price}.last\n highest_bidder = @highest_bid.bidder\n highest_bidder.update_attribute(:money, highest_bidder.money+@highest_bid.price)\n end\n\t\t\t\t\n\t\t\t\t# show pop up regarding BIN success\n gflash :success => \"Congratulations! You have bought the item.\"\n @item.closed = true\n\n\t\t\t\t# automatically replace the html to show the auction is now closed using ajax so\n\t\t\t\t# refreshing the page is not necessary, i.e. automatically update the auction closed box\n render :juggernaut => {:type => :send_to_all} do |page|\n page.replace_html :show_item_time, \"\"\n page.replace_html :bid_id, \"\"\n page.replace_html :highest_bid, \"Auction is closed!\"\n page.replace_html :show_item_bin_button, \"\"\n page.replace_html :show_item_watch, \"\"\n page.replace_html :show_item_stop, \"\"\n page.replace_html \"item_time_#{@item.id}\", :partial => 'items/search_time_ticker', :object => @item\n page.visual_effect :highlight, \"item_time_#{@item.id}\", :duration => 5\n end\n\n\t\t\t\t# update item attribute\n @item.update_attribute(:closed,true)\n\n\t\t\t\t# add money to the seller\n\t\t\t\tposter = @item.user\n poster.update_attribute(:money, [email protected]_price)\n\n\t\t\t\t# deduct the money from the buyer\n current_user.update_attribute(:money,[email protected]_price)\n\n\t\t\t\t# create new transaction\n\t\t\t\ttransaction = Transaction.new\n \t transaction.seller_id = poster.id\n \t transaction.buyer_id = current_user.id\n \t transaction.item_id = @item.id\n \t transaction.price = @item.bin_price\n \t transaction.save\n else\n gflash :error => \"Cannot afford to buy this item\"\n end\n end\n redirect_to :controller => 'items', :action => 'show', :id => params[:item_id]\n end", "def after_accepted\n # repute points\n self.repute_accept\n \n # cash rewards\n if self.kase && self.kase.offers_reward?\n self.kase.rewards.active.each do |reward|\n reward.cash!\n end\n end\n end", "def buy\n @showtime = Showtime.find_by(id: params[:id])\n if @showtime.openSeats > 0\n @showtime.openSeats -= 1\n else\n @showtime.openSeats == 0\n end\n @showtime.save\n render \"show.json.jbuilder\"\n end", "def create\n \t@trade = Trade.new(params[:trade])\n \tif @trade.save\n \t\tredirect_to trades_path, flash: { notice: \"Your order has been received\"}\n \telse\n\t\tredirect_to trades_path, flash: { alert: \"Sorry, your order has been declined.\"}\n \tend\n end", "def sell_pending\n end", "def buy_ticket(ticket)\n if @funds >= ticket.price\n @funds -= ticket.price\n else\n return \"not enough funds\"\n end\n end", "def buy!(buyer_planet, amount)\n raise GameLogicError.new(\"Cannot buy 0 or less! Wanted: #{amount}\") \\\n if amount <= 0\n amount = from_amount if amount > from_amount\n \n cost = (amount * to_rate).ceil\n buyer_source, bs_attr = self.class.resolve_kind(buyer_planet, to_kind)\n buyer_target, bt_attr = self.class.resolve_kind(buyer_planet, from_kind)\n if system?\n seller_target = nil\n else\n seller_target, _ = self.class.resolve_kind(planet, to_kind)\n end\n \n stats = CredStats.buy_offer(buyer_planet.player, cost) \\\n if seller_target.nil? && to_kind == KIND_CREDS\n \n buyer_has = buyer_source.send(bs_attr)\n raise GameLogicError.new(\"Not enough funds for #{buyer_source\n }! Wanted #{cost} #{bs_attr} but it only had #{buyer_has}.\"\n ) if buyer_has < cost\n \n # Used to determine whether to send notification or not.\n original_amount = from_amount\n \n # Subtract resource that buyer is paying with from him.\n buyer_source.send(:\"#{bs_attr}=\", buyer_has - cost)\n # Add resource that buyer has bought from seller.\n buyer_target.send(:\"#{bt_attr}=\", \n buyer_target.send(bt_attr) + amount)\n # Add resource that buyer is paying with to seller. Unless:\n # * its a system offer\n # * or #to_kind is creds and planet currently does not have an owner\n seller_target.send(\n :\"#{bs_attr}=\", seller_target.send(bs_attr) + cost\n ) unless seller_target.nil?\n # Reduce bought amount from offer.\n self.from_amount -= amount\n \n objects = [buyer_source, buyer_target]\n # We might not have seller target. See above.\n objects.push seller_target unless seller_target.nil?\n objects.uniq.each { |obj| self.class.save_obj_with_event(obj) }\n\n if from_amount == 0\n # Schedule creation of new system offer.\n CallbackManager.register(\n without_locking { galaxy },\n CALLBACK_MAPPINGS[from_kind],\n Cfg.market_bot_random_resource_cooldown_date\n ) if system?\n destroy!\n else\n save!\n end\n percentage_bought = amount.to_f / original_amount\n\n MarketRate.subtract_amount(galaxy_id, from_kind, to_kind, amount)\n\n # Create notification if:\n # * It's not a system notification\n # * Enough of the percentage was bought\n # * Sellers planet currently has a player.\n Notification.create_for_market_offer_bought(\n self, buyer_planet.player, amount, cost\n ) if ! system? &&\n percentage_bought >= CONFIG['market.buy.notification.threshold'] &&\n ! planet.player_id.nil?\n\n stats.save! unless stats.nil?\n\n amount\n end", "def check_for_close\n if self.event_name == 'spree.set_special_price'\n current_date = Time.zone.now\n if self.promotion_rules.present?\n if self.changed.include? 'expires_at'\n if self.expires_at < current_date\n PromotionJob.start_promotion(self,'close') if self.promotion_actions.where(:type =>'Spree::Promotion::Actions::Discount').present?\n end\n if self.expires_at > current_date && self.starts_at < current_date\n PromotionJob.start_promotion(self,'start') if self.promotion_actions.where(:type =>'Spree::Promotion::Actions::Discount').present?\n end\n end\n if self.changed.include? 'starts_at'\n if self.starts_at < current_date\n PromotionJob.start_promotion(self,'start') if self.promotion_actions.where(:type =>'Spree::Promotion::Actions::Discount').present?\n end\n end\n end\n end\n end", "def hold_sell_trade(hnum, snum, tnum, player, game, acquired_hotel)\n snum = snum.to_i\n tnum = tnum.to_i\n # do nothing when holding shares\n # deal with selling of shares\n if (snum > 0)\n # give player money\n acquired_game_hotel = game.game_hotels.where(name: acquired_hotel).first\n acquired_hotel_share_price = acquired_game_hotel.share_price\n player.cash = player.cash + (acquired_hotel_share_price * snum)\n # remove shares from stock cards and return to game pool\n snum.times do\n card = player.stock_cards.where(hotel: acquired_hotel).first\n player.stock_cards.delete(card)\n game.stock_cards << card\n end\n\n player.save\n game.save\n end\n\n # deal with trading of shares\n if (tnum > 0)\n dominant_hotel = game.dominant_hotel\n num_of_trades = tnum/2\n num_of_trades.times do\n 2.times do\n a_card = player.stock_cards.where(hotel: acquired_hotel).first\n player.stock_cards.delete(a_card)\n game.stock_cards << a_card\n end\n d_card = game.stock_cards.where(hotel: dominant_hotel).first\n game.stock_cards.delete(d_card)\n player.stock_cards << d_card\n end\n\n player.save\n game.save\n end\n end", "def give_bid(auction, bid)\r\n if Time.now > auction.due_date\r\n raise TradeException, \"Out of time\"\r\n elsif auction.bid.last != nil\r\n if auction.bid.last.owner != self\r\n auction.set_bid(self, bid)\r\n else\r\n auction.update_bid(self,bid)\r\n end\r\n else\r\n auction.set_bid(self,bid)\r\n end\r\n end", "def create\n @deal = Deal.find(params[:deal_id])\n @order = Order.new\n @order.consumer_id = current_consumer.id\n @order.deal_id = params[:deal_id]\n @order.address = current_consumer.address\n if @order.save\n create_charge #This method must be called ONLY if an order has already been created, otherwise it will break.\n @consumer.total_points = (@consumer.total_points + 1)\n @consumer.save\n if @deal.has_exceeded_threshold?\n @deal.threshold_reached = true\n @deal.save\n end\n else\n flash[:notice] = 'You have already purchased a ticket for this item. Goodluck!'\n redirect_to :back\n end\n end", "def buy_ticket\n customer = find_customer_by_id()\n film = find_film_by_id()\n screening = find_screening_by_hour()\n return 'sorry, but there is no space in the room' if screening.tickets_avalible < 1 \n customer.funds -= film.price\n customer.tickets_bougth += 1\n screening.tickets_avalible -= 1\n screening.update()\n customer.update()\n end", "def buy_item(item)\r\n if !item.active || item.price > self.credits\r\n false\r\n else\r\n seller = item.owner\r\n price = item.price\r\n\r\n seller.give_credits(price)\r\n self.take_credits(price)\r\n seller.remove_item(item)\r\n self.add_item(item)\r\n item.active = false\r\n true\r\n end\r\n end", "def test_transaction_opened\n response = @gateway.setup_purchase(400, @options)\n\n # now try to authorize the payment, issuer simulator keeps the payment open\n response = @gateway.capture(response.transaction['transactionID'])\n\n assert_failure response\n assert_equal 'Open', response.transaction['status'], 'Transaction should remain open'\n end", "def have_enough_items_to_trade?\n fetch_inventory\n\n is_valid = true\n\n max_avaliable_quantity = @offer[:records].map {|x|\n [x.item_name.to_sym ,x.quantity]}.to_h\n\n @offer[:items].each do |item, quantity|\n if quantity > max_avaliable_quantity[item.to_sym]\n is_valid = false\n add_error(:offer, :items, {item.to_sym =>\n \"Not enough items, only #{max_avaliable_quantity[item.to_sym]} available\"})\n end\n end\n\n max_avaliable_quantity = @for[:records].map {|x|\n [x.item_name.to_sym ,x.quantity]}.to_h\n\n @for[:items].each do |item, quantity|\n if quantity > max_avaliable_quantity[item.to_sym]\n is_valid = false\n add_error(:for, :items, {item.to_sym =>\n \"Not enough items, only #{max_avaliable_quantity[item.to_sym]} available\"})\n end\n end\n is_valid\n end", "def shares_available_for_purchase?\n if Stock.all.find_by(id: trade.stock_id).shares_available < trade.num_shares\n return false\n else\n return true\n end\n end", "def open?\n @ban_until > Time.now\n end", "def open?\n @ban_until > Time.now\n end", "def offer_available?\n #return self.approved? && self.offers.last.present? && self.offers.last.effective?\n return self.offers.last.present? && self.offers.last.effective?\n end", "def ready_to_exchange?\n self.balance >= self.promotion.points_to_exchange\n end", "def sell_at_any_cost(percent_decrease = 0.3)\n market_name = @market_name\n open_orders_url = get_url({ :api_type => \"market\", :action => \"open_orders\", :market => market_name })\n open_orders = call_secret_api(open_orders_url)\n #cancel all orders\n if open_orders.size > 0\n open_orders.each do |open_order|\n cancel_order_url = get_url({ :api_type => \"market\", :action => \"cancel_by_uuid\", :uuid => open_order[\"OrderUuid\"] })\n call_secret_api(cancel_order_url)\n end\n end\n # call sell bot again with lower profit\n sell_order = sell_bot(percent_decrease)\nend", "def initialize(offers)\n if data_exist?(offers)\n @@offers = offers\n @@order = Order.new_order\n end\n end", "def create\n @trade_request = TradeRequest.new\n # Store parameters from form\n t_r = params[:trade_request]\n @trade_request.offeror_id = t_r[:offeror_id]\n @trade_request.offeree_id = t_r[:offeree_id]\n @trade_request.outgoing_cash = t_r[:outgoing_cash]\n @trade_request.incoming_cash = t_r[:incoming_cash]\n @trade_request.completed = false\n # Set the response turn to the opposite party in the trade request\n @trade_request.response_turn = TradeRequest.getOtherParty(@trade_request, current_user.team_id)\n @trade_request.outgoing_properties = params[:outgoing_property]\n @trade_request.incoming_properties = params[:incoming_property]\n # TODO: remove can trade outgoing and incoming logic\n can_trade_outgoing = TradeRequest.tradeable(@trade_request.outgoing_properties)\n can_trade_incoming = TradeRequest.tradeable(@trade_request.incoming_properties)\n if can_trade_outgoing && can_trade_incoming && @trade_request.cash_valid\n if @trade_request.save\n redirect_to trade_requests_path, notice: \"Your trade request was successfully submitted\"\n else\n redirect_to trade_requests_path, notice: \"Specify properties or cash form each team\"\n end\n else\n flash[:error] = \"Invalid offers!\"\n redirect_to trade_requests_path\n end\n end", "def accept\n offer = Offer.find(params[:id])\n if offer \n if offer.product.user.id == @current_user.id\n if offer.offer_status == Offer.OFFER_OFFERED\n conversation = Conversation.new\n conversation.seller = @current_user\n conversation.buyer = offer.user\n conversation.offer = offer\n conversation.save()\n \n offer.offer_status = Offer.OFFER_ACCEPTED\n offer.conversation_id = conversation.id\n offer.save()\n \n offer.product.sold_status = Product.SOLD_IN_TRANSACTION\n offer.product.save()\n\n notify(\"NOTIF_NEW_CONVERSATION\", {\n conversation: {\n id: conversation.id,\n is_seller: false,\n prev_message: nil\n },\n user: {\n id: @current_user.id,\n username: @current_user.username,\n first_name: @current_user.first_name,\n last_name: @current_user.last_name\n },\n offer: {\n id: offer.id,\n price: offer.price\n },\n product: {\n id: offer.product.id,\n product_name: offer.product.product_name,\n price: offer.product.price\n }\n }, offer.user_id)\n\n OfferMailer.offer_accepted_email(offer.user, offer, offer.product, offer.product.user, conversation).deliver_later!(wait: 15.seconds)\n \n render status: 200, json: {conversation_id: conversation.id}\n else\n render status: 471, json: {error: true}\n end\n else\n render status: 472, json: {error: true}\n end\n else\n render status: 404, json: {error: true}\n end\n end", "def free_storage_valid_thru_date\n sale_date =\n if self.auction_datum.present? && self.auction_datum.auction_date.present?\n self.yard.utc_sale_date_with_time_for_date(self.auction_datum.auction_date)\n elsif self.sale_confirmed_date.present?\n self.sale_confirmed_date\n else\n DateTime.now\n end\n # No bid history at all may be a data issue,\n # but as far as we're concerned here, it's \n # 3 business days.\n if self.bid_histories.empty?\n self.three_business_days_later_inclusive(sale_date)\n # Kiosk winners get 3 days\n elsif self.high_bid_is_kiosk?\n self.three_business_days_later_inclusive(sale_date)\n # Next scenarios depend on bid type existing\n elsif self.bid_histories.first.bid_type.present?\n bid_type_code = self.bid_histories.first.bid_type.code\n # Live Auction winners / prelim-bid winners / \n # counter-bid (offline) / Buy Now winners / Sale Now \n # winners get 7 days (counting sale_date).\n if bid_type_code == BidType::AURORA_LIVE_BID_CODE || \n bid_type_code == BidType::AURORA_PRELIM_BID_CODE || \n bid_type_code == BidType::AURORA_BUY_NOW_CODE || \n bid_type_code == BidType::FIGS_SALE_NOW_CODE ||\n !self.current_buyer_also_high_bidder?\n sale_date + 6.days\n # Unknown code was received, per Karla they get 3\n # days. (todo: important enough to email us so we know?)\n elsif bid_type_code.present?\n logger.info(\"Unknown bid type received, code is: #{bid_type_code}\")\n self.three_business_days_later_inclusive(sale_date)\n # Code not present also gets the three (we should prevent\n # this scenario in the api, but you know, safety first)\n else\n logger.info(\"BidType.code not present on bid type of description: #{self.bid_histories.first.bid_type.description}\")\n self.three_business_days_later_inclusive(sale_date)\n end\n # All other scenarios get 3 business days\n # (so incomplete data scenarios will get 3 days).\n else\n self.three_business_days_later_inclusive(sale_date)\n end\n end", "def trade_is_not_a_repeat\n # see if the record has been created, and has an id assigned\n number_that_can_exist = id.nil? ? 0 : 1\n if Offer.where(user_id: user_id, trade_id: trade_id).length > number_that_can_exist\n errors.add(:user_id, \"user has already made an offer for this trade\")\n end\n end", "def make_trade(prompt, user)\n puts `clear`\n view_my_stocks(prompt, user)\n puts \"Your available balance is \" + \"$#{self.balance.round(2)}\".colorize(:green)\n stock_name = search_stock_symbol(prompt)\n puts \"Please enter the quantity of #{stock_name.stock_symbol} you'd like to purchase:\"\n stock_qty = gets.chomp.to_i\n\n if stock_qty <= 0\n puts \"You have entered an invalid number\"\n main_menu(prompt, self)\n end \n\n trade_total = (stock_qty * stock_name.current_price).to_f\n\n if self.balance > trade_total\n self.update(balance: self.balance -= trade_total)\n Trade.create(stock_id: stock_name.id, user_id: self.id, stock_qty: stock_qty, stock_price_when_purchased: stock_name.current_price)\n puts `clear`\n puts \"You purchased #{stock_qty} stocks of #{stock_name.stock_symbol} for a total of\" + \" $#{trade_total.round(2)}\".colorize(:green) + \" at $#{stock_name.current_price} per share.\"\n puts \"Your current available balance is \" + \"$#{self.balance.round(2)}\".colorize(:green)\n else\n puts `clear`\n puts \"You do not have sufficient funds to complete this transaction, please try to purchase a smaller amount.\".colorize(:red)\n end\n main_menu(prompt, self)\n end", "def create(options={})\n build_no_db(params[:transaction])\n\n thisaccept = nil\n if(params[:extend])\n userid = current_user.id\n acceptanceid = params[:acceptanceid]\n thisaccept=Acceptance.find(acceptanceid)\n p \"checking an extend\"\n if(thisaccept == nil || thisaccept.user_id!=userid)\n @acceptance.errors.add(:spot, \"not available at this time\")\n @acceptance.status = \"failed\"\n end \n end\n\n # Check cache first\n #if(@acceptance.status == \"failed\" || !ResourceOfferHanlder.validate_reservation(@acceptance.resource_offer_id, @acceptance, true))\n # @acceptance.errors.add(:spot, \"not available at this time\")\n # @acceptance.status = \"failed\"\n #end\n\n \n respond_to do |format|\n if @acceptance.status != \"failed\" and @acceptance.save and @acceptance.validate_and_charge()\n p thisaccept\n if(thisaccept)\n p \"changing status to extended\"\n thisaccept.status = \"extended\"\n thisaccept.save\n @acceptance.start_time = thisaccept.start_time\n end\n @acceptance.save\n presenter = Api::V3::AcceptancesPresenter.new\n acceptance_json = presenter.as_json(@acceptance)\n #format.html { redirect_to @acceptance, notice: 'acceptance was successfully created.' }\n p acceptance_json\n format.json { render json: {:acceptance => acceptance_json, :success=>true}, status: :created, location: @acceptance }\n else\n #format.html { render action: \"new\" }\n p [\"errors\", @acceptance.errors]\n format.json { render json: {:success => false, :error=>@acceptance.errors}}\n end\n end\n end", "def open?\n (AVAILABLE == status) and in_redemption_period?\n end", "def check_for_buyout\n if self.is_bought_out\n if self.bought_out_by_team_id\n self.subcontracts.future_years.each do |sub|\n sub.salary_amount *= 0.6\n sub.this_is_a_buyout = true\n sub.save!\n\n # update GM's annual actions to not allow more buyouts\n actions = AnnualGmAction.find_by_team_id_and_year(self.bought_out_by_team_id, current_year)\n actions.has_bought_out = true\n actions.bought_out_player_id = self.player.id\n actions.save!\n end\n end\n end\n end", "def check_if_approval_is_required\n !offer_request.blank?\n end", "def open?\n open_date < Time.now && !past_deadline? rescue nil\n end", "def can_add_stock?(ticker_symbol)\n under_stock_limit? && !stock_already_added?(ticker_symbol)\n end", "def execute_trade!\n offer_inventory = @offer[:records].map{ |e| [e.item_name.to_sym, e]}.to_h\n for_inventory = @for[:records].map{ |e| [e.item_name.to_sym, e]}.to_h\n\n @offer[:items].each do |name, quantity|\n offer_inventory[name.to_sym].quantity -= quantity\n for_inventory[name.to_sym].quantity += quantity\n end\n\n @for[:items].each do |name, quantity|\n for_inventory[name.to_sym].quantity -= quantity\n offer_inventory[name.to_sym].quantity += quantity\n end\n\n ActiveRecord::Base.transaction do\n @offer[:records].each(&:save)\n @for[:records].each(&:save)\n end\n end", "def trade(ticker, day)\n # this day's price\n price = @account.broker.exchange.quote(ticker, day)\n\n# if @last_purchase.key? ticker # If we've purchased this stock before, we continue with Dr. Rushton's trading rule.\n if @account.portfolio[ticker] == 0 # try to buy the given ticker\n last_hold_time = if @last_purchase[ticker][:buy_day] && @last_purchase[ticker][:sell_day]\n @last_purchase[ticker][:buy_day] - @last_purchase[ticker][:sell_day]\n else\n 0\n end\n \n # Wait for a time interval equal to gamma * HT to pass (cool-down period) OR Price < P to buy more\n if(!@last_purchase.key?(ticker) || \n price < @last_purchase[ticker][:price] || \n @last_purchase[ticker][:sell_day] - day >= @gamma * last_hold_time)\n s = @account.buy_amap(ticker, day, @amount_per_company)\n @last_purchase[ticker] = {price: price, buy_day: day}\n puts \"bought #{s} shares of #{ticker} on #{@account.broker.exchange.eod(ticker, day).date}\" if $DEBUG\n end\n else # try to sell our holdings of the given ticker\n # compute t, the return multiplier, given the interval between now and last purchase of the given stock (ticker)\n t = @fn_t.call(@last_purchase[ticker][:buy_day] - day)\n\n # compute alpha, given the value t, to determine the percentage gain multiplier\n alpha = @fn_alpha.call(t)\n\n puts \"t = #{t}\", \"alpha = #{alpha}\" if $DEBUG\n\n puts \"price of #{ticker} on #{@account.broker.exchange.eod(ticker, day).date} is #{price}\" if $DEBUG\n\n if(price > (1.0 + alpha) * @last_purchase[ticker][:price])\n s = @account.sell_all(ticker, day)\n @last_purchase[ticker][:sell_day] = day\n puts \"sold #{s} shares of #{ticker} on #{@account.broker.exchange.eod(ticker, day).date}\" if $DEBUG\n end\n end\n# else # We use SMA to make our initial purchase of each stock\n# # compute average over number of days\n# avg = average_price(ticker, day)\n\n # if price > avg -> price - avg = positive\n # price < avg -> price - avg = negative\n # price = avg -> price - avg = 0\n# @price_relation_to_average[\"#{ticker}#{day}\"] = price - avg\n\n # decide whether the price has just upcrossed or downcrossed the MA line\n# if(price > avg && @price_relation_to_average[\"#{ticker}#{day + 1}\"] < 0) # upcross - BUY as much as possible\n# s = @account.buy_amap(ticker, day, @amount_per_company)\n# @last_purchase[ticker] = {price: price, buy_day: day}\n# puts \"bought #{s} shares of #{ticker} on #{@account.broker.exchange.eod(ticker, day).date}\" if $DEBUG\n# end\n# end\n \n puts \"account: #{@account.to_s(day)}\" if $DEBUG\n end", "def wait_until_open_confirmed; end", "def create\n offer = Offer.where(user_id: @current_user.id, product_id: params[:product_id]).first\n if offer\n render status: 471, json: {error: true}\n else\n product = Product.find(params[:product_id])\n if product\n if product.user.id != @current_user.id\n if product.sold_status != Product.SOLD_SOLD\n offer = Offer.new\n offer.user = @current_user\n offer.price = params[:price]\n offer.offer_status = Offer.OFFER_OFFERED\n offer.product = product\n if offer.save()\n\n notify(\"NOTIF_NEW_OFFER\", {\n user: {\n id: @current_user.id,\n username: @current_user.username,\n first_name: @current_user.first_name,\n last_name: @current_user.last_name,\n },\n offer: {\n id: offer.id,\n price: offer.price,\n created_at: offer.created_at.strftime('%-l:%M%P')\n },\n product: {\n id: product.id,\n product_name: product.product_name\n }\n }, product.user_id)\n\n OfferMailer.new_offer_email(product.user, offer, product, @current_user).deliver_later!(wait: 15.seconds)\n\n payload = {\n error: false,\n id: offer.id\n }\n render status: 200, json: payload\n else\n errors = []\n offer.errors.keys.each do |key|\n errors << {field: key, message: offer.errors.full_messages_for(key).first}\n end\n payload = {\n error: true,\n errors: errors\n }\n render status: 200, json: payload\n end\n else\n render status: 473, json: {error: true}\n end\n else\n render status: 472, json: {error: true}\n end\n else\n render status: 404, json: {error: true}\n end\n end\n end", "def buy\n\t\t@dates = Bus.where(:status => :open).select{|b| !b.maximum_seats || b.available_tickets('from_waterloo') > 0 || b.available_tickets('to_waterloo') > 0 }.collect {|b| b.date }.uniq\n\t\t@gmapkey = Keys.gmap\n\tend", "def create_new_offering(award_info, quarter, appl)\r\n\t\toffering = Offering.create(:name => award_info.Award_title, :description => award_info.Award_description, :quarter_offered_id => quarter.id, :unit_id => UNIT_ID)\r\n#\t\tputs \" Created \" + offering.name + \" offering for quarter id: \" + offering.quarter_offered_id .to_s\r\n\t\t\r\n\t\t# Creating enrty in the award type linking table\r\n\t\tOfferingAwardType.create(:offering_id => offering.id, :award_type_id => award_info.award_type_id)\r\n\t\t\r\n\t\t# Fgures out when to use 0, 5, or 20 as the max score \r\n\t\t# Add in the Offering Review Criterion\r\n\t\tmax_score = 0\r\n\t\tunless award_info.award_type_id == 1 # There is no max score for leadership awards so it is kept at 0\r\n\t\t\tif appl.YEAR.to_i > 2004 \r\n\t\t\t\tmax_score = 20\r\n\t\t\telse\r\n\t\t\t\t# max_score = 5\r\n\t\t\tend\r\n\t\tend\r\n\t\t\r\n\t\tif appl.YEAR.to_i > 2004 \r\n\t\t\tOfferingReviewCriterion.create(:offering_id => offering.id, :title => \"Total\", :max_score => max_score)\r\n\t\tend\r\n\t\t\r\n\t\t# Create Application Review Decision Types\r\n\t\tdecision_types = Hash[\"Yes, Interview\" => YES_INTERVIEW_ID, \"Yes\" => YES_ID, \"No\" => NO_ID]\r\n\t\tdecision_types.each do |decision_type, application_status_type_id|\r\n\t\t\tappl_review_decision_type = ApplicationReviewDecisionType.new\r\n\t\t\tappl_review_decision_type.offering_id = offering.id\r\n\t\t\tappl_review_decision_type.title = decision_type\r\n\t\t\tappl_review_decision_type.application_status_type_id = application_status_type_id\r\n\t\t\tif decision_type == \"No\"\r\n\t\t\t\tappl_review_decision_type.yes_option = 0\r\n\t\t\telse\r\n\t\t\t\tappl_review_decision_type.yes_option = 1\r\n\t\t\tend\r\n\t\t\tappl_review_decision_type.save!\r\n\t\tend\r\n\t\t# Create Offering Statuses\r\n\t\toffering_statuses = Hash[\"Awarded\" => AWARDED_ID, \"Not Awarded After Interview\" => NOT_INTERVIEW_ID, \"Not Awarded\" => NOT_AWARDED_ID]\r\n\t\toffering_statuses.each do |offering_status, application_status_type_id|\r\n\t\t\tOfferingStatus.create(:offering_id => offering.id, :public_title => offering_status, :application_status_type_id => application_status_type_id)\r\n\t\tend\r\n\t\t\r\n\t\t# Add in the open_date and and the deadline\r\n\t\toffering.open_date = quarter.first_day\r\n\t\toffering.deadline = quarter.first_day + 3.months\r\n#\t\tputs \" Offering open: #{offering.open_date} close: #{offering.deadline}\"\r\n\t\t\r\n\t\t# Save the offering\r\n\t\toffering.save! \r\n\t\t\r\n\t\treturn offering\r\n\t\t\r\n\tend", "def buy\n outcome_id = params[:outcome_id]\n outcome = Outcome.find(outcome_id)\n\n if outcome.market.is_closed\n flash[:error] = \"Market is closed\"\n return redirect_to outcome.market \n end\n \n current_position = outcome.position_for_user(current_user)\n\n share_count = (params.include? :buy_share_count) ? params[:buy_share_count].to_i : 10\n\n if share_count < 0\n flash[:error] = \"Invalid share count\"\n return redirect_to outcome.market \n end\n\n total_shares = share_count\n if outcome.shares_available < share_count\n flash[:error] = \"There are not enough shares available\"\n return redirect_to outcome.market \n end\n\n if ! current_position.nil?\n total_shares += current_position.total_user_shares\n end\n \n current_price = outcome.buy_price(share_count)\n \n position = Position.new(\n :outcome => outcome, \n :user => current_user, \n :delta_user_shares => share_count,\n :delta_user_account_value=> -1 * share_count * current_price,\n :total_user_shares => total_shares,\n :direction => :buy,\n :outcome_price => current_price\n )\n \n if position.save\n logger.info \"Created position: \" + position.to_s\n current_user.cash = current_user.cash + position.delta_user_account_value\n current_user.save\n flash[:message] = \"Buy successful -- %.2f shares @ $%.2f cost %.2f\" % \n [position.delta_user_shares, position.outcome_price, -1 * position.delta_user_account_value]\n\n outcome.market.had_sale(position)\n outcome.market.save\n \n clear_caches(outcome)\n redirect_to outcome.market\n else\n flash[:error] = position.errors\n \n redirect_to outcome.market\n end\n \n end", "def to_be_done()\r\n\t\t#\r\n\t\t# loss_trig_price = price - loss\r\n\t\t# loss_price = price - loss - 10\r\n\t\t# obuy \t = push_buy( \t\t quantity: quantity, price: price )\r\n\t\t# monitor_filled( obuy )\r\n\t\t# obuy_stp = push_buy_stop( quantity: quantity, loss_trig_price: loss_trig_price, loss_price: loss_price )\r\n\t\t#\r\n\t\t#\r\n\t\t# loss_trig_price = price + loss\r\n\t\t# loss_price = price + loss + 10\r\n\t\t# osell = push_sell( \t\t quantity: quantity, price: price)\r\n\t\t# monitor_filled( osell )\r\n\t\t# osell_stp = push_sell_stop( quantity: quantity, loss_trig_price: loss_trig_price, loss_price: loss_price)\r\n\t\t#\r\n\r\n\r\n\t\t# modo mais simples primeiro\r\n\t\t# entrar a market\r\n\t\tloss_trig_price = price - loss\r\n\t\tloss_price = price - loss - 10\r\n\t\tobuy \t = push_buy( \t\t quantity: quantity, price: 0 )\r\n\t\tmonitor_filled( obuy )\r\n\t\tobuy_stp = push_buy_stop( quantity: quantity, loss_trig_price: loss_trig_price, loss_price: loss_price )\r\n\r\n\r\n\t\tloss_trig_price = price + loss\r\n\t\tloss_price = price + loss + 10\r\n\t\tosell = push_sell( \t\t quantity: quantity, price: 0)\r\n\t\tmonitor_filled( osell )\r\n\t\tosell_stp = push_sell_stop( quantity: quantity, loss_trig_price: loss_trig_price, loss_price: loss_price)\r\n\tend", "def do_buy(number)\r\r\n $game_party.lose_currency(@gold_window.currency, number * buying_price)\r\r\n $game_party.gain_item(@item, number)\r\r\n end", "def update_others!\n if status_changed?\n\n if waiting_for_sell? || declined?\n ::Users::Notification.where(related_model_type:'Trading::BuyRequest', related_model_id: self.id).update_all(status: ::Users::Notification::Status::DELETED)\n end\n\n if waiting_for_sell?\n self.items.each{|item| item.status = ::Item::Status::BUYING; item.save; }\n\n elsif declined? || canceled?\n\n self.items.each{|item| item.activate! }\n\n elsif sold?\n\n self.items.each{|item| item.deactivate! }\n ::NotificationMail.create_from_mail(buyer.parent_id, seller.parent_id, UserMailer.new_buy_request_to_seller_parent(self) )\n\n end\n end\n end", "def create\n if current_user.present?\n Item.transaction do\n item = Item.find(params[:item_id].to_i)\n if item.remain <= 0\n #如果已被抢完,提示投资下一期\n flash[:info] = \"该期已投完,请投资下一期\"\n elsif item.remain > params[:amount].to_i\n #如果还没被抢完,可以抢,创建一条抢投记录,更新期数的已投和剩余的人次数\n if current_user.available.blank?\n flash[:info] = \"请先注册并充值\"\n elsif current_user.cash_flows.count == 1 && current_user.cash_flows.first.cash_flow_description == Dict::CashFlowDescription.prize\n flash[:info] = \"注册红包仅可用于投标\"\n elsif current_user.available >= params[:amount].to_i\n numbers = item.number_array.sample(params[:amount].to_i)\n order = ProductOrder.create_for(current_user, params[:item_id].to_i, params[:amount].to_i, numbers.join(\" \"))\n already = item.already + params[:amount].to_i\n remain = item.remain - params[:amount].to_i\n number_array = item.number_array - numbers\n item.update_already_remain(already, remain, number_array)\n flash[:info] = \"参与成功!\"\n else\n flash[:info] = \"您的账户余额不足,请充值\"\n end\n elsif item.remain <= params[:amount].to_i\n if current_user.available.blank?\n flash[:info] = \"请先注册并充值\"\n elsif current_user.available > params[:amount].to_i\n #如果已最后剩余的被抢完,除了更新记录外,还要创建新的一期,及开奖\n numbers = item.number_array\n order = ProductOrder.create_for(current_user, params[:item_id].to_i, item.remain, numbers.join(\" \"))\n already = item.already + item.remain\n remain = item.remain - item.remain\n number_array = item.number_array - numbers\n item.update_already_remain(already, remain, number_array)\n #更新产品信息\n item_product = item.product\n item_product.already += 1\n item_product.remain -= 1\n item_product.save\n #生成新的期数\n not_finish_product = Product.where(\"already != numbers\").order(\"weight desc\").first\n if not_finish_product.present?\n Item.create(product_id: not_finish_product.id, already: 0, remain: not_finish_product.total_price, number_array: (10000001..(10000000+not_finish_product.total_price)).to_a)\n end\n flash[:info] = \"参与成功!\"\n else\n flash[:info] = \"您的账户余额不足,请充值\"\n end\n end\n end\n else\n flash[:info] = \"请先登录\"\n end\n redirect_to :actions => \"index\"\n end", "def approved\n @trader = current_trader\n end", "def funds_available?\n if self.num_shares * Stock.find(self.stock_id).quote > Account.find_by(investor_id: self.investor_id).balance\n self.status = \"canceled\"\n self.bought_sold = \"Funds to execute trade were unavailable.\"\n puts \"Your account does not have the funds available to execute this trade.\"\n return false\n else\n true\n end\n end", "def buy_item(item, log = true)\n seller = item.owner\n\n if seller.nil?\n Analytics::ItemBuyActivity.with_buyer_item_price_success(self, item, false).log if log\n return false, \"item_no_owner\" #Item does not belong to anybody\n elsif self.credits < item.price\n Analytics::ItemBuyActivity.with_buyer_item_price_success(self, item, false).log if log\n return false, \"not_enough_credits\" #Buyer does not have enough credits\n elsif !item.active?\n Analytics::ItemBuyActivity.with_buyer_item_price_success(self, item, false).log if log\n return false, \"buy_inactive_item\" #Trying to buy inactive item\n elsif !seller.items.include?(item)\n Analytics::ItemBuyActivity.with_buyer_item_price_success(self, item, false).log if log\n return false, \"seller_not_own_item\" #Seller does not own item to buy\n end\n\n seller.release_item(item)\n\n TradingAuthority.settle_item_purchase(seller, self, item)\n\n item.deactivate\n self.attach_item(item)\n\n item.notify_change\n\n Analytics::ItemBuyActivity.with_buyer_item_price_success(self, item).log if log\n\n return true, \"Transaction successful\"\n end", "def make_withdraw\n\t\tif Qiwicoin::Client.instance.get_balance >= self.amount && self.address.present?\n\t\t\tself.qc_tx_id = Qiwicoin::Client.instance.send_to_address(self.address, self.amount.to_f)\n\t\t\tself.save\n\t\tend\n end", "def buy_ticket(screening)\n\n #Exit function if customer can't afford or tickets ran out\n return nil if !(can_afford?(screening.price) && screening.tickets_available?)\n #Reduce money\n spend_money(screening.price)\n #Update customer on db\n update\n #Create ticket\n new_ticket = Ticket.new({'screening_id' => screening.id, 'customer_id' => @id})\n #Save ticket to database\n new_ticket.save\n #Remove ticket from screening\n screening.sold_ticket\n #Update screening\n screening.update\n\n end", "def offer\n end", "def offer\n end", "def offer\n end", "def sell_stock(user)\n quote = Stock.stock_quote(Stock.all.find(self.stock_id).symbol)\n sell_trade = Trade.create(status: \"pending\", investor_id: user.id, num_shares: self.num_shares,\n stock_price: quote.delayed_price, bought_sold: \"In progress\", stock_id: self.stock_id, date: Date.today)\n sell_trade.purchase_price = quote.delayed_price * sell_trade.num_shares\n user.deposit_funds(sell_trade.purchase_price)\n original_order = Trade.all.find(self.id)\n original_order.bought_sold = \"sold\"\n original_order.save\n sell_trade.bought_sold = \"sell order\"\n sell_trade.status = \"completed\"\n sell_trade.save\n puts \"\\nCongratulations! You have successfully sold #{sell_trade.num_shares} shares of #{quote.company_name}\"\n end", "def commit\n offer = Offer.find(params[:id])\n if offer\n if offer.product.user_id == @current_user.id\n if offer.offer_status != Offer.OFFER_COMPLETED\n conversation = offer.conversation\n conversation_id = conversation.id\n conversation.destroy\n\n product = offer.product\n product.sold_status = Product.SOLD_SOLD\n product.save\n\n SearchEntry.destroy_index product\n \n offer.offer_status = Offer.OFFER_COMPLETED\n offer.save\n\n notify(\"NOTIF_TRANSACTION_FINISHED\", {\n conversation: conversation_id,\n user: {\n id: @current_user.id,\n username: @current_user.username,\n first_name: @current_user.first_name,\n last_name: @current_user.last_name\n },\n product: {\n id: product.id,\n product_name: product.product_name\n },\n offer: {\n price: offer.price\n }\n }, offer.user_id)\n\n render status: 200, json: {error: false, id: offer.id}\n else\n render status: 471, json: {error: true}\n end\n else\n render status: 472, json: {error: true}\n end\n else\n render status: 404, json: {error: true}\n end\n end", "def sell_bot(percent_decrease = 0.1)\n market_name = @market_name\n currency = @currency\n low_24_hr, last_price, ask_price = get_market_summary(market_name)\n sell_price = last_price - percent_decrease*last_price\n get_balance_url = get_url({ :api_type => \"account\", :action => \"currency_balance\", :currency => currency })\n balance_details = call_secret_api(get_balance_url)\n sell_price = \"%.8f\" % sell_price\n if balance_details and balance_details[\"Available\"] and balance_details[\"Available\"] > 0.0\n p [market_name, last_price, balance_details[\"Available\"], sell_price]\n sell_limit_url = get_url({ :api_type => \"market\", :action => \"sell\", :market => market_name, :quantity => balance_details[\"Available\"], :rate => sell_price })\n puts \"Selling coin...\".yellow\n p [{ :api_type => \"market\", :action => \"sell\", :market => market_name, :quantity => balance_details[\"Available\"], :rate => sell_price }]\n order_placed = call_secret_api(sell_limit_url)\n puts (order_placed and !order_placed[\"uuid\"].nil? ? \"Success\".green : \"Failed\".red)\n cnt = 1\n while cnt <= 3 and order_placed and order_placed[\"uuid\"].nil? #retry\n puts \"Retry #{cnt} : Selling coin...\".yellow\n sleep(1) # half second\n order_placed = call_secret_api(sell_limit_url)\n puts (order_placed and !order_placed[\"uuid\"].nil? ? \"Success\".green : \"Failed\".red)\n cnt += 1\n end\n p [order_placed, \"Sell #{balance_details[\"Available\"]} of #{market_name} at #{sell_price}\"]\n else\n puts \"Insufficient Balance\".red\n end\nend", "def buy_ticket(film_to_see, screen)\n if (@funds >= film_to_see.price) && (screen.tickets_sold < screen.tickets_limit) # Limit the available tickets for screenings.\n new_ticket = Ticket.new({'cust_id' => @id, 'film_id' => film_to_see.id, 'screen_id' => screen.id})\n new_ticket.save()\n @funds -= film_to_see.price\n update()\n screen.tickets_sold += 1 #count of tickets sold of particular screen\n screen.update()\n return new_ticket\n end\n return nil\n end", "def waiver?\n free_agent? && !waiver_bid\n end", "def buy(amount)\n @bought_amount += amount if amount_remaining >= amount\n end", "def purchasing?\n auction.buy_it_now_price == amount\n end", "def buy_new_item(item_to_buy, quantity, account)\n return false if item_to_buy.auction\n preowner = item_to_buy.owner\n\n if (Integer(item_to_buy.price*quantity) > self.credits and item_to_buy.currency == \"credits\") or Integer(item_to_buy.quantity)<quantity\n Activity.log(account, \"item_bought_failure\", item_to_buy, self)\n Activity.log(account, \"item_sold_failure\", item_to_buy, preowner)\n return false\n end\n\n\n if !item_to_buy.wishlist_users.empty? and item_to_buy.quantity == quantity and !item_to_buy.permanent\n item_to_buy.wishlist_users.each {|trader| trader.remove_from_wishlist(item_to_buy); item_to_buy.wishlist_users.delete(trader)}\n end\n\n Holding.ship_item(item_to_buy, item_to_buy.owner, self, quantity)\n Activity.log(account, \"item_bought_success\", item_to_buy, self)\n Activity.log(account, \"item_sold_success\", item_to_buy, preowner)\n Mailer.item_sold(preowner.e_mail, \"Hi #{preowner.name}, \\n #{self.name} bought your Item #{item_to_buy.name}.\n Please Contact him for completing the trade. His E-Mail is: #{self.e_mail}\")\n\n return true\n end", "def guard_reopen?\n !self.expired?\n end", "def create\n @offer = Offer.new(offer_params)\n @offer.user = current_user\n authorize @offer\n\n respond_to do |format|\n if @offer.save\n Offer.delay.reindex\n\n format.html { redirect_to @offer, notice: 'Offer was successfully created.' }\n format.json { render :show, status: :created, location: @offer }\n else\n format.html { render :new }\n format.json { render json: @offer.errors, status: :unprocessable_entity }\n end\n end\n end", "def can_add_stock?(ticker_symbol)\n under_stock_limit? && !stock_already_added?(ticker_symbol)\n end", "def off_market_check\n if status == 'on market'\n self.status = 'missed'\n update_workshifter_hours_balance\n gen_next_assignment\n elsif status == 'on market (late)'\n self.status = 'blown'\n update_workshifter_hours_balance\n gen_next_assignment\n end\n self.save!\n end", "def high_bid_is_copart_buy_now?\n get_high_bid_bid_type_code == BidType::AURORA_BUY_NOW_CODE\n end", "def offer_params\n params.require(:offer).permit(:advertiser_name, :url, :description, :starts_at, :ends_at, :premium, :offer_state)\n end", "def approve!\n inventory.restock!(self, Time.current, inventory_check)\n update!(adjustment: difference)\n end", "def create\n save_auto_completes\n\n @avia_buyer = AviaBuyer.new(params[:avia_buyer])\n session[:avia_buyer] = @avia_buyer\n @avia_ticket = AviaTicket.new(params[:avia_ticket])\n session[:avia_ticket] = @avia_ticket\n\n all_valid = @avia_buyer.valid?\n all_valid = false unless @avia_ticket.valid?\n\n if all_valid\n AviaTicketMailer.send_manager_avia_ticket(@avia_buyer, @avia_ticket).deliver\n\n session[:avia_ticket] = nil\n @avia_ticket = AviaTicket.new\n\n render :action => :create\n else\n render :action => :new\n end\n end", "def withdraw(exit_date, estimated_return_date, pickup_company, pickup_company_contact, additional_comments, quantity_to_withdraw, folio = '-')\n return status if cannot_withdraw?\n\n if quantity_to_withdraw != '' && quantity_to_withdraw < quantity.to_i\n self.quantity = quantity.to_i - quantity_to_withdraw\n quantity_withdrawn = quantity_to_withdraw\n else\n self.status = InventoryItem::OUT_OF_STOCK\n quantity_withdrawn = quantity\n self.quantity = 0\n end\n\n save\n\n # Withdraw from WarehouseLocations\n withdraw_from_locations(quantity_withdrawn) if warehouse_locations?\n\n CheckOutTransaction.create(\n inventory_item_id: id,\n concept: 'Salida granel',\n additional_comments: additional_comments,\n exit_date: exit_date,\n estimated_return_date: estimated_return_date,\n pickup_company: pickup_company,\n pickup_company_contact: pickup_company_contact,\n quantity: quantity_withdrawn,\n folio: folio\n )\n true\n end", "def create\n offer = params[:offer]\n @offer = Offer.new\n @offer.publicated = false\n @offer.prizes_attributes = offer[:prizes_attributes]\n @offer.name = offer[:name]\n @offer.start_date = offer[:start_date]\n @offer.end_date = offer[:end_date]\n @offer.created_at = Time.now\n @offer.updated_at = Time.now\n @offer.photo = offer[:photo]\n @offer.branch = Branch.find(offer[:branch_id])\n @offer.description = offer[:description]\n @offer.publication_date = offer[:publication_date]\n @offer.start_date = @offer.start_date.change({:hour => (offer[:start_hour]).to_i})\n @offer.end_date = @offer.end_date.change({:hour => (offer[:end_hour]).to_i})\n @offer.is_first_game = [true, false].sample\n\n\n respond_to do |format|\n if params[:title_ids].nil?\n format.html { redirect_to :back , notice: @offer.name + ' posee errores o no posee intereses.' }\n end\n if @offer.save\n title_ids = params[:title_ids]\n unless title_ids.nil?\n title_ids.each do |id|\n offers_titles = OffersTitles.new\n offers_titles.offer_id = @offer.id\n offers_titles.title_id = id\n offers_titles.save\n end\n end\n format.html { redirect_to users_offers_company_user_path , notice: @offer.name + ' fue creada correctamente.' }\n format.json { render json: @offer, status: :created, location: @offer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @offer.errors, status: :unprocessable_entity }\n end\n end\n end", "def faab?\n free_agent? && !waiver_bid.nil?\n end", "def trade_item_with_party(new_item, old_item)\n return false if new_item && !$game_party.has_item?(new_item)\n $game_party.force_gain_item(old_item, 1)\n $game_party.force_gain_item(new_item, -1)\n return true\n end" ]
[ "0.6683461", "0.6553436", "0.6346874", "0.6118842", "0.6109499", "0.61002755", "0.60825926", "0.60546196", "0.60336137", "0.60102606", "0.59325975", "0.59066606", "0.59035206", "0.5885251", "0.58825547", "0.5834772", "0.5830133", "0.58266807", "0.58033866", "0.5790515", "0.5761192", "0.570821", "0.57013285", "0.5701028", "0.56968397", "0.5685238", "0.5664515", "0.56400573", "0.5621622", "0.5621122", "0.5617748", "0.5616489", "0.561496", "0.5584201", "0.55705065", "0.55702263", "0.55666053", "0.5561489", "0.5534733", "0.55332243", "0.55185646", "0.55058485", "0.5500291", "0.5484385", "0.5483148", "0.5483148", "0.5479748", "0.5478112", "0.54716307", "0.54670453", "0.5447685", "0.54471177", "0.54400104", "0.54342073", "0.5432312", "0.54277134", "0.5418397", "0.5413684", "0.54039884", "0.53976965", "0.53903985", "0.53901297", "0.5387067", "0.5386664", "0.5385637", "0.5373159", "0.53686154", "0.53643066", "0.53622043", "0.5358", "0.5357824", "0.5349127", "0.5348913", "0.53479445", "0.5345812", "0.5345714", "0.5341023", "0.5339964", "0.5339964", "0.5339964", "0.53323823", "0.53255945", "0.5309721", "0.5305188", "0.52965695", "0.5293263", "0.5290184", "0.5283377", "0.52776843", "0.52752674", "0.5267893", "0.5266881", "0.5266193", "0.5262392", "0.52623373", "0.52581596", "0.5257538", "0.52563685", "0.5256267", "0.52554786" ]
0.7134383
0
makes sure only offers for the same console are valid
def user_on_same_console if user.nil? || trade.nil? || user.console != trade.user.console errors.add(:trade_id, "Trade must be for the same console") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_sure_no_duplicate_offers\n other_offer = self.sender.active_offer_between_user_for_textbook(self.reciever_id, self.textbook_id)\n\n if other_offer.nil?\n if self.listing.nil?\n\t if self.selling?\n self.errors.add(:reciever_id, \"You don't have a current listing 'For Sale' for this book. You must post a listing before sending an offer to sell your book.\")\n\t else\n self.errors.add(:reciever_id, \"#{self.reciever.username} doesn't have a current listing 'For Sale' for this book.\")\n\t end\n\n return false\n\tend\n \n return true\n end\n\n if self.reciever_id == other_offer.reciever_id\n self.errors.add(:reciever_id, \"You already sent #{self.reciever.username} an offer for this book. You can check your offers sent by navigating to the 'Offers' page in the upper-left links then clicking 'View sent offers here'. (note: once a user rejects (not counter offers) your offer for a particular book, you may only respond to their offers)\")\n return false\n elsif other_offer.selling? != self.selling?\n other_offer.update_status(2)\n return true\n else\n self.errors.add(:reciever_id, \"#{self.reciever.username}'s removed their listing for this book!\")\n end\n end", "def test_appellation_validity\n assert @valid_appellation_1.valid?\n assert @valid_appellation_2.valid?\n end", "def test_guest_cannot_buy_drink_if_they_have_insufficient_funds\n @room1.add_drinks_to_stock(@drink1)\n @room1.add_drinks_to_stock(@drink2)\n guest6=Guest.new(\"Kaka\", 1.00, \"Always look on the bright side of life.\")\n guest6.show_tab\n expected = \"You can't afford this drink.\"\n assert_equal(expected, @room1.refuse_guest_drink_if_they_cannot_afford_it(guest6, @drink1))\n end", "def validate_hashes\n super unless BYPASS_COMMANDS.include?(command)\n end", "def valid_input\n\t\t#adds single word commands\n\t\tvalid = ['help', 'wait', 'inventory']\n\t\tlocation = find_room_in_dungeon(@player.location)\n\t\tlocation.connections.each do |direction, destination|\n\t\t\tvalid << direction.to_s\n\t\tend\n\t\t\n\t\t#adds two word commands\n\t\[email protected] do |reference|\n\t\t\t['eat', 'throw', 'examine', 'drop'].each do |action|\n\t\t\tvalid << action + \" \" + reference.to_s\n\t\t\tend\n\t\tend\n\t\tif @player.location == @other_player.location || @player.location == :Lair\n\t\t\[email protected] do |reference|\n\t\t\t\tvalid << 'give' + \" \" + reference.to_s\n\t\t\tend\n\t\tend\n\t\tif @player.inventory.include?(:crystal) && @other_player.inventory.include?(:crystal)\n\t\t\tvalid << 'wob crystal'\n\t\tend\n\t\tcase @player.location\n\t\twhen :Laboratorium then\n\t\t\tvalid << 'look tools'\n\t\t\tvalid << 'take crystal' unless @crystal_taken > 1\n\t\twhen :garden then\n\t\t\tvalid << 'look plants'\n\t\t\tvalid << 'take beans' unless @beans_taken\n\t\twhen :Lounge then\n\t\t\tvalid << 'look chair'\n\t\t\tvalid << 'take pills' unless @pills_taken\n\t\twhen :Library then\n\t\t\tvalid << 'look pedestal'\n\t\t\tvalid << 'take box' unless @box_taken\n\t\twhen :Study then\n\t\t\tvalid << 'look papers'\n\t\t\tvalid << 'take notes' unless @notes_taken\n\t\twhen :Lair then\n\t\t\tvalid << 'wob box' if @player.inventory.include?(:box)\n\t\t\tvalid << 'look creature'\n\t\t\tvalid << 'take creature'\n\t\tend\n\t\tvalid.each do |string|\n\t\t\tputs string\n\t\tend\n\tend", "def valid; end", "def bad_examples deck\n puts 'The following are not valid sets:'\n bad1 deck\n bad2 deck\n print 'Select enter key when done with examples, and game will begin!!'\n gets.chomp.eql? \"\\n\"\nend", "def invalid_command\n puts \"Please enter a valid command\"\nend", "def invalid_command\n puts \"Please enter a valid command\"\nend", "def is_command_valid?(command)\n\t\tAVAILABLE_COMMANDS.include?(command)\n\tend", "def invalid_command\n puts \"Please enter a valid command\"\nend", "def user_items\n puts \"\\nLets see if you collected the correct items: \"\n#sleep arguement to build suspense\n puts \"Confirming please wait...\"\n sleep(4)\n puts \".........................\"\n sleep(3)\n puts \"...........in progress\"\n sleep(2)\n puts \"......complete\"\n sleep(2)\n\n# verification that the items_collected equal valid_items\n if $items_collected == [\"key\", \"ruby\"] or $items_collected == [\"key\", \"trolls_head\"]\n puts \"\\nYou have the correct combination!\\n\\n\"\n winner\n else\n puts \"\\nYou have the wrong combination\\n\\n\"\n game_over\n end\nend", "def valid_item\n @windows[Win_Help].move_to(2)\n #@windows[Win_Help].show\n @active_battler.current_action.clear\n @active_battler.current_action.set_item(@item.id)\n if @item.for_dead_friend? and !$game_system.actors_bodies? \n if $game_map.passable?(@cursor.x, @cursor.y, 0) and\n (occupied_by?(@cursor.x, @cursor.y) == nil)\n open_revive_window\n end\n else\n @active_battler.current_action.set_item(@item.id)\n @targets = get_targets\n if @targets.empty?\n Sound.play_buzzer\n else\n Sound.play_decision\n @cursor.active = false \n @windows[Win_Confirm].ask(Command_Confirm::Item) \n @windows[Win_Status].dmg_preview(3, @active_battler, @item, @targets)\n @windows[Win_Help].move_to(2)\n #@windows[Win_Help].show\n end\n end\n end", "def invalid_command\n puts \"Please enter a valid command\"\n #invalid_command\n # code invalid_command here\nend", "def _entry_2_validatecommand(*args)\n\n end", "def validate_input_last input\r\n\t\t if @console\r\n\t\t input.match(/\\A[[:alpha:][:blank:]]+\\z/) || (check_enter input)\r\n\t\t else\r\n\t\t input.match(/\\A[[:alpha:][:blank:]]+\\z/) && !(check_enter input)\r\n\t\t end\r\n\t\t end", "def verify_selection(user_input)\n VALID_SELECTIONS.include?(user_input)\nend", "def test_arg_check_prospectors_valid\n ret = arg_check_prospectors '1'\n assert_equal ret, 0\n end", "def print_show_number_error\n puts \"Shows are available only for Audis: 1, 2, 3. Please enter a valid show number\"\n book_tickets\n end", "def check!\n error = proc { | message | raise ArgumentError.new( message ) }\n set1_keys = set1.keys\n set2_keys = set2.keys\n set1_size = set1.size\n set2_size = set2.size\n\n # Check set1\n set1.each do | target , options |\n message = \"Preferences for #{ target.inspect } in `set1` do not match availabilities in `set2`!\"\n options = options.first if options.first.is_a?( Array )\n error[ message ] unless \\\n # Anything there is a preference for is in the other set\n ( options.all? { | preference | set2_keys.include?( preference ) } )\n end\n\n # Check set2 the same way\n set2.each do | target , options |\n message = \"Preferences for #{ target.inspect } in `set2` do not match availabilities in `set1`!\"\n options = options.first if options.first.is_a?( Array )\n error[ message ] unless \\\n # Anything there is a preference for is in the other set\n ( options.all? { | preference | set1_keys.include?( preference ) } )\n end\n\n # We've run the check\n self.checked = true\n end", "def ensure_mode_validity!\n @topline = @topline.clamp 0, [num_lines - 1, 0].max\n @botline = [@topline + buffer.content_height, num_lines].min - 1\n end", "def ask_usable(unit)\n\tend", "def validate_environment(context)\n return if context.bash?\n raise(Cliqr::Error::IllegalCommandError,\n 'Cannot run another shell within an already running shell')\n end", "def validate_command\n if requester != player\n errors.add(:allowed, I18n.t(\"errors.not_authorized\"))\n end\n unless airlift?\n if game.actions_taken == 4\n errors.add(:allowed, I18n.t(\"player_actions.no_actions_left\"))\n end\n if proposal.turn_nr != game.turn_nr\n errors.add(:allowed, I18n.t(\"movement_proposals.expired\"))\n end\n if destination_is_not_a_neighbor? && another_player_is_not_at_destination?\n errors.add(:allowed, I18n.t(\"movement_proposals.not_allowed\"))\n end\n end\n end", "def check_validity(choice)\n valid_options = ['pick up', 'use', 'display inventory', 'move']\n @valid_choices.include?(choice.to_sym) || valid_options.include?(choice)\n end", "def atb_press_valid\n if @selected == @active_battler\n #open menu actor\n actor_menu_open\n #@windows[Win_Help].show\n disable_cursor\n else\n #move cursor to active battler\n Sound.play_decision\n set_active_cursor\n end\n end", "def validate_instance\n super\n # @wfd_show/edit_paramaeters must be arrays of symbols\n @wfd_show_parameters.each_with_index do |sp,i|\n unless sp.kind_of? Symbol then\n raise ArgumentError.new( \"permitted show parameter at [ #{ i } ] = #{ sp.to_s } is not a Symbol\" )\n end\n end\n @wfd_edit_parameters.each_with_index do |ep,i|\n unless ep.kind_of? Symbol then\n raise ArgumentError.new( \"permitted edit parameter at [ #{ i } ] = #{ ep.to_s } is not a Symbol\" )\n end\n end\n # @wfd_show/edit_parameters must not have duplicates\n dup_param1 = @wfd_show_parameters.detect {|e| @wfd_show_parameters.rindex(e) != @wfd_show_parameters.index(e) }\n unless dup_param1.nil? then\n raise ArgumentError.new( \"permitted show parameter #{ dup_param1 } occurs more than once.\")\n end\n dup_param1 = @wfd_edit_parameters.detect {|e| @wfd_edit_parameters.rindex(e) != @wfd_edit_parameters.index(e) }\n unless dup_param1.nil? then\n raise ArgumentError.new( \"permitted edit parameter #{ dup_param1 } occurs more than once.\")\n end\n # intersection of both arrays should be empty because at any time\n # a parameter can only be shown or editable...\n dup_params = @wfd_show_parameters & @wfd_edit_parameters\n unless dup_params.length == 0\n raise ArgumentError.new( \"parameters #{ dup_params.to_s } are defined to both show and edit\" )\n end\n end", "def checks; end", "def desk_options\n#items that can be found in the desk\n desk_items = [\n \"\\u{1F511}\" + \" \" + \"key\",\n \"\\u{270F}\" + \" \" + \"pencil\",\n \"\\u{1F4B5}\" + \" \" + \"money\",\n \"\\u{1F354}\" + \" \" + \"hamburger\",]\n\n# Ask user to pick an item\n\tputs \"Choose and item to take with you: \"\n\n# Loop through desk items array and print options to console\n# prints the desk items and its value\n (0...desk_items.length).each do |i|\n\t\tputs \"#{i+1} - #{desk_items[i]}\"\n\tend\n\n# user input placeholder\n\tprint \"> \"\n\n# getting the users choice\n\tchoice = $stdin.gets.chomp.to_i - 1\n\t@selected_from_desk = desk_items[choice]\n\n# if-statement to determine which item they chose and then adding it to the items_collected array\n\tif choice == 0\n\t\tputs \"\\nThe #{@selected_from_desk} has been added to your bag\"\n $items_collected << \"key\"\n clear_screen\n\t\tputs \"\\nYou found a letter on the desk. It says 'Find your way to the castle and bring me my things!'\"\n sleep(5)\n options_when_walking_away_from_desk\n\telsif choice == 1\n\t\tputs \"\\nThe #{@selected_from_desk} has been added to your bag\"\n $items_collected << \"pencil\"\n clear_screen\n\t\tputs \"\\nYou found a letter on the desk. It says 'Find your way to the castle and bring me my things!'\"\n sleep(5)\n options_when_walking_away_from_desk\n\telsif choice == 2\n\t\tputs \"\\nThe #{@selected_from_desk} has been added to your bag\"\n $items_collected << \"money\"\n clear_screen\n\t\tputs \"\\nYou found a letter on the desk. It says 'Find your way to the castle and bring me my things!'\"\n sleep(5)\n options_when_walking_away_from_desk\n\telsif choice == 3\n\t\tputs \"\\nThe #{@selected_from_desk} has been added to your bag\"\n $items_collected << \"hamburger\"\n clear_screen\n\t\tputs \"\\nYou found a letter on the desk. It says 'Find your way to the castle and bring me my things!'\"\n sleep(5)\n options_when_walking_away_from_desk\n else\n puts \"\\n***Please choose an item that is available!***\\n\\n\"\n desk_options\n# printing out users selection\n puts \"\\nYou selected: #{@selected_from_desk}\"\n end\nend", "def has_different_point_values?\n offer_value = Inventory.evaluate_items(@offer[:items])\n for_value = Inventory.evaluate_items(@for[:items])\n if offer_value != for_value\n add_error(:for, :items,\n \"Invalid Offer, the items offered and received do not worth the same\")\n true\n else false; end\n end", "def _entry_4_validatecommand(*args)\n\n end", "def check_offer\n offered_char = Character.find_by_name(offer)\n if offered_char != nil\n if offered_char.user_id != user_id\n self.update_attributes(offer: \"none\")\n end\n else \n self.update_attributes(offer: \"none\")\n end \n end", "def _entry_5_validatecommand(*args)\n\n end", "def _entry_1_validatecommand(*args)\n\n end", "def _entry_1_validatecommand(*args)\n\n end", "def invalid_command\n # code invalid_command here\n puts \"Please enter a valid command\"\nend", "def validate_tool_index(tool_index)\n if tool_index < 0 || tool_index > @tools_list.count - 1\n puts \"Incorrect tool number. Entered tool number should be between 1 and #{@tools_list.count}.\".red\n false\n else\n true\n end\n end", "def use_item\n\n if @inventory.empty?\n slow_type(\"\\nYou don't have anything in your inventory\")\n\n else\n print_inventory_items\n\n use_item = TTY::Prompt.new\n\n choices = []\n @options = []\n @inventory.each do |item_id|\n inventory_item = find_item_by_id(item_id)\n choices << { name: inventory_item.name, value: inventory_item.item_id }\n end\n\n item_id = use_item.select(slow_type(\"\\nWhat would you like to use?\"), choices)\n \n selected_item = find_item_by_id(item_id)\n \n use_on = TTY::Prompt.new\n\n choices = []\n @options = []\n current_cell_items.each do |item_id|\n item = find_item_by_id(item_id)\n choices << { name: item.name, value: item.item_id } unless @inventory.include?(item.item_id) || item.show_item == false\n end\n\n target_item = use_on.select(slow_type(\"\\nWhat would you like to use the #{selected_item.name} on?\"), choices)\n\n combo = @use_combos.find { |combo| combo[:item_id] == item_id && combo[:usage_location] == @current_room_id && combo[:target_id] == target_item}\n \n if combo.nil?\n slow_type(\"\\nYou cannot use these two items together\") \n \n else \n use_item_dependency(item_id)\n slow_type(combo[:message])\n\n if combo[:cell_to_unlock]\n find_room_by_id(combo[:cell_to_unlock]).isLocked = false\n game_complete if combo[:game_complete]\n\n elsif\n combo[:knocked_out]\n @guard_is_knocked_out = true\n end\n\n end\n end\n end", "def test_valid_choice_false_2\n\t\tgame = SetGame.new\n\t\tuser_input = \"4\"\n\t\tassert_equal false, game.valid_choice?(user_input, 3)\n\tend", "def test_test_harness_champ_should_be_valid\n c = setup_active_test\n cl = c.list\n assert cl.keys.include?( TEST_CHAMP ), \"test champ should be on the full champ list\"\n end", "def verifySpeakersDisplayed()\n speakers= speakersDisplayed()\n #assert_equal speakers, true, \"In people>>speaker screen speakers should be shown\"\n end", "def valid_show?\n is_valid_show = true\n if @selected_show_id.nil? or @selected_show_id.empty?\n dlg = Gtk::MessageDialog.new(@mainWindow, \n Gtk::Dialog::DESTROY_WITH_PARENT, \n Gtk::MessageDialog::QUESTION, \n Gtk::MessageDialog::BUTTONS_YES_NO, \n \"Must specify a show to create the booklet for\")\n dlg.run\n dlg.destroy\n is_valid_show = false\n end\n \n is_valid_show\n end", "def check_if_moves_are_valid(move1, move2)\n @move1 = move1\n @move2 = move2\n \n if @possible_moves.include?(@move2) == false && @possible_moves.include?(@move1) == false\n puts \"RESULT: You're both hopeless. EVERYONE LOSES. (Except for me.)\"\n elsif @possible_moves.include?(@move2) == false\n puts \"RESULT: I know this is more complicated than PSR, but it's not THAT hard. Again, your options: paper, scissors, rock, lizard or spock. That's it, #{@app_name2}. None of this \\\"#{@move1}\\\" nonsense. #{@app_name1.capitalize} wins by default.\"\n @player1.add_win(1)\n elsif @possible_moves.include?(@move1) == false\n puts \"RESULT: Dude, you have a lot of options, but #{@move1} isn't one of them. Paper, scissors, rock, lizard or spock. #{@app_name2.capitalize} wins by default.\"\n @player2.add_win(1)\n end\n end", "def test_user_input_driver_print_valid\n\n end", "def invalid\n puts \"Invalid entry, please try again.\"\n end", "def ensure_not_last_option\n return false if good.options.count == 1\n end", "def verify_signature\n super unless BYPASS_COMMANDS.include?(command)\n end", "def check(cmd)\n # check requisite options\n list.each do |item|\n if item.requisite and not(cmd.model[item.key])\n raise OptionError.new(cmd, 'option \"%s\" is requisite' % [item.long])\n end\n end\n end", "def check_command_policy\n true\n end", "def command_line_input_logic(passby)\n\tcase passby\n\t\twhen 1\n\t\t\tputs `man mv`\n\t\twhen 2\n\t\t\tputs `man cp`\n\t\twhen 3\n\t\t\tputs `man mkdir`\n\t\twhen 4\n\t\t\tputs `man ls`\n\t\twhen 5\n\t\t\tputs `man rm`\n\t\twhen 6\n\t\t\tmenu\n\t\telse\n\t\t\tputs \"Please make a selection between 1 - 6!\"\n\tend\n\tcommand_line_menu\nend", "def test_valid_choice_false_10\n\t\tgame = SetGame.new\n\t\tuser_input = \"3ab\"\n\t\tassert_equal false, game.valid_choice?(user_input, 8)\n\tend", "def arguments_valid?\n true if @commands.length > 0\n end", "def valid?; end", "def valid?; end", "def valid?; end", "def valid?; end", "def valid?; end", "def usable?; end", "def check_input_entry\n %i{assembly mut_bulk bg_bulk mut_bulk_vcf bg_bulk_vcf mut_parent bg_parent repeats_file}.each do | symbol |\n if @options.key?(symbol)\n if @options[symbol] == 'None'\n param = (symbol.to_s + '_given').to_sym\n @options[symbol] = ''\n @options.delete(param)\n end\n end\n end\n end", "def valid_option_ask!(trade)\n option = Option.find(trade.instrument_id)\n if optiontyp == \"call\"\n if trade.user.portfolio.usd - trade.user.portfolio.usd_in_margin >= trade.amount\n true\n else\n trade.destroy\n false\n end\n elsif option.typ == \"put\"\n if trade.user.portfolio.funds - trade.user.portfolio.funds_in_margin >= option.strike*trade.price\n true\n else\n trade.destroy\n false\n end\n end\n end", "def valid_command?(command)\n\t\tVALID_COMMANDS.include?(command)\n\tend", "def options_when_walking_away_from_desk\n# letting user know whats happening with the door\n puts \"\\nYou walk to the door and... \"\n sleep(2)\n if $items_collected.include?(\"key\") then\n puts \"You use the key to open the door\"\n sleep(2)\n opened_the_door_walked_outside\n else !$items_collected.include?(\"key\")\n puts \"Sorry you dont have the key, go back to the desk!\\n\\n\"\n sleep(2)\n remove_last_item_from_items_collected_at_desk\n end\nend", "def usable?(machine, raise_error=false)\n end", "def validrptTbCommand?\n\tif @commands.size < 3\n\t\treturn false \n\telsif @commands[1].size <=0\n\t\treturn false\n\telsif @commands[2].size <=0\n\t\treturn false\n\tend \n\t\treturn true \nend", "def issn; end", "def user_commands\n puts sep = \"------------------------------------------------------\".colorize(:yellow)\n prompt = TTY::Prompt.new\n commands = [\n {name: 'Place', value: 1},\n {name: 'Move', value: 2},\n {name: 'Left', value: 3},\n {name: 'Right', value: 4},\n {name: 'Report', value: 5},\n {name: 'Execute Selected Commands', value: 6},\n ]\n players_input = prompt.select(\"Select Your Commands:\", commands) \n case players_input\n when 1\n place_command = prompt_place\n @commands_sequence.push(place_command)\n p @commands_sequence\n puts sep\n user_commands\n when 2\n move_command = validate_move\n @commands_sequence.push(move_command)\n p @commands_sequence\n puts sep\n user_commands\n when 3\n left_command = validate_left\n @commands_sequence.push(left_command)\n p @commands_sequence\n puts sep\n user_commands\n when 4\n right_command = validate_right\n @commands_sequence.push(right_command)\n p @commands_sequence\n puts sep\n user_commands\n when 5\n report_command = validate_report\n @commands_sequence.push(report_command)\n p @commands_sequence\n puts sep\n user_commands\n when 6\n legal_commands = valid_commands(@commands_sequence)\n if legal_commands.length == 0\n puts \"Command sequence must begin with a Place Command\".colorize(:red)\n user_commands\n else \n return legal_commands\n end\n end \n end", "def validate_user_choice\n input = gets.chomp\n if input ==\"exit\"\n exit_screen\n elsif input == \"buy\"\n ticketing_screen\n elsif input.to_i == 1\n concert_screen\n elsif input.to_i == 2\n # if user doesn't want to buy a ticket yet, they can look for other upcoming bands and/or concerts by typing bands.\n bands_screen\n else\n unrecognized_input\n end\n end", "def test_valid_choice_false_4\n\t\tgame = SetGame.new\n\t\tuser_input = \"9\"\n\t\tassert_equal false, game.valid_choice?(user_input, 8)\n\tend", "def matches_schedule_offerings\n if self.schedule && self.offering_id != self.schedule.offering_id\n puts \"OFFERING MISMATCH: #{self.offering_id} vs. #{self.schedule.offering_id}\"\n errors.add(:offering_mismatch, '. Review offering must match schedule offering')\n end\n end", "def _entry_6_validatecommand(*args)\n\n end", "def valid?\n @input != \"exit\" && @input != \"quit\"\n end", "def check_validity square_availability\n if square_availability == \" \"\n true\n else\n puts \"Place déja occupé, réessayer!\"\n end\nend", "def valid_command?(val)\n system_command?(val) || pry_command?(val)\n end", "def test_remain_same_2\n\t\tgame = SetGame.new\n\t\tactual_output = File.new 'update_output/actual_remain_same2.txt', 'w'\n\t\t$stdout = actual_output\n\t\tgame.deck = DECK\n\t\tgame.hand = [CARD1, CARD2, CARD3, CARD4, CARD5, CARD6, CARD7, CARD8, CARD9]\n\t\tuser_input = [8,7,0]\n\t\tgame.top_card = 24\n\t\tgame.update user_input\n\t\tassert_equal 9, game.hand.size\n\t\tassert_equal 24, game.top_card\n\t\tactual_output.close\n\t\tassert_true FileUtils.compare_file('update_output/expected_remain_same2.txt', 'update_output/actual_remain_same2.txt')\n\t\tassert_equal CARD1, game.hand[0]\n\t\tassert_equal CARD2, game.hand[1]\n\t\tassert_equal CARD3, game.hand[2]\n\t\tassert_equal CARD4, game.hand[3]\n\t\tassert_equal CARD5, game.hand[4]\n\t\tassert_equal CARD6, game.hand[5]\n\t\tassert_equal CARD7, game.hand[6]\n\t\tassert_equal CARD8, game.hand[7]\n\t\tassert_equal CARD9, game.hand[8]\n\t\tassert_equal false, game.is_end\n\tend", "def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end", "def quit_with_usage_error\n quit_with_error( \"USAGE: ruby list_checker.rb <SCREEN_NAME>\" )\nend", "def validrptHivCommand?\n\tif @commands.size < 2\n\t\treturn false \n\telsif @commands[1].size <=0\n\t\treturn false\n\telsif @commands[2].size <=0\n\t\treturn false\n\telsif @commands[3].size <=0\n\t\treturn false\n\tend \n\t\treturn true \nend", "def has_prompted?(kind)\n\t\t@prompted[kind]\n\tend", "def has_prompted?(kind)\n\t\t@prompted[kind]\n\tend", "def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end", "def check_revote (list, user_list)\n system 'clear'\n check_revote = TTY::Prompt.new \n revotewinner = check_revote.select(\"There are multiple winners, would you like to revote with the tied options or have the program randomly pick an option for you?\", %w(Revote Random))\n if revotewinner == \"Revote\" \n collect_votes(list, user_list)\n else\n random_winner(list)\n end\nend", "def test_valid_choice_true_2\n\t\tgame = SetGame.new\n\t\tuser_input = \"3\"\n\t\tassert_equal true, game.valid_choice?(user_input, 3)\n\tend", "def test_guest_tab_increases_if_room_serves_them_drink\n @room1.add_drinks_to_stock(@drink1)\n @room1.add_drinks_to_stock(@drink2)\n @room1.serve_drink_to_guest(@guest2, @drink2)\n assert_equal(1.50, @guest2.show_tab())\n end", "def test_valid_choice_false_6\n\t\tgame = SetGame.new\n\t\tuser_input = \"10\"\n\t\tassert_equal false, game.valid_choice?(user_input, 8)\n\tend", "def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end", "def semact?; false; end", "def requesting_console?\n @requesting_console\n end", "def validate_selection(input)\n print \"#{input} is not a valid choice, re-enter the number or ID > \"\n return gets.strip\nend", "def validate_release \n if !system(\"origen examples\") #|| !system(\"origen specs\") \n puts \"Sorry but you can't release with failing tests, please fix them and try again.\" \n exit 1 \n else \n puts \"All tests passing, proceeding with release process!\" \n end \n end", "def valid_record?(ems)\n @edit[:errors] = []\n if ems.emstype == \"scvmm\" && ems.security_protocol == \"kerberos\" && ems.realm.blank?\n add_flash(_(\"Realm is required\"), :error)\n end\n if !ems.authentication_password.blank? && ems.authentication_userid.blank?\n @edit[:errors].push(_(\"Username must be entered if Password is entered\"))\n end\n if @edit[:new][:password] != @edit[:new][:verify]\n @edit[:errors].push(_(\"Password/Verify Password do not match\"))\n end\n if ems.supports_authentication?(:metrics) && @edit[:new][:metrics_password] != @edit[:new][:metrics_verify]\n @edit[:errors].push(_(\"C & U Database Login Password and Verify Password fields do not match\"))\n end\n if ems.kind_of?(ManageIQ::Providers::Vmware::InfraManager)\n unless @edit[:new][:host_default_vnc_port_start] =~ /^\\d+$/ || @edit[:new][:host_default_vnc_port_start].blank?\n @edit[:errors].push(_(\"Default Host VNC Port Range Start must be numeric\"))\n end\n unless @edit[:new][:host_default_vnc_port_end] =~ /^\\d+$/ || @edit[:new][:host_default_vnc_port_end].blank?\n @edit[:errors].push(_(\"Default Host VNC Port Range End must be numeric\"))\n end\n unless (@edit[:new][:host_default_vnc_port_start].blank? &&\n @edit[:new][:host_default_vnc_port_end].blank?) ||\n (!@edit[:new][:host_default_vnc_port_start].blank? &&\n !@edit[:new][:host_default_vnc_port_end].blank?)\n @edit[:errors].push(_(\"To configure the Host Default VNC Port Range, both start and end ports are required\"))\n end\n if !@edit[:new][:host_default_vnc_port_start].blank? &&\n !@edit[:new][:host_default_vnc_port_end].blank?\n if @edit[:new][:host_default_vnc_port_end].to_i < @edit[:new][:host_default_vnc_port_start].to_i\n @edit[:errors].push(_(\"The Host Default VNC Port Range ending port must be equal to or higher than the starting point\"))\n end\n end\n end\n @edit[:errors].empty?\n end", "def validator?; system('which question-validator > /dev/null 2>&1'); end", "def offenses_to_check=(_arg0); end", "def valid?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n end", "def test_it_can_validate_ship_placement\n skip\n human = Player.new(true)\n valid = \"A1 B1\"\n invalid = \"A1 B2\"\n\n assert_equal true, human.validate_ship_placement(valid, 2)\n assert_nil human.validate_ship_placement(invalid, 2)\n end", "def valid?\n result = IO.popen(\"#{Ledger.bin} -f - stats 2>&1\", 'r+') do |f|\n f.write to_ledger\n f.close_write\n f.readlines\n end\n\n $?.success? && !result.empty?\n end", "def test_valid_choice_false_7\n\t\tgame = SetGame.new\n\t\tuser_input = \"3a\"\n\t\tassert_equal false, game.valid_choice?(user_input, 8)\n\tend", "def test_2_capsicum\n refute Capsicum.sandboxed?\n assert Capsicum.enter!\n assert Capsicum.enter!\n assert Capsicum.sandboxed?\n\n assert_raises(Errno::ECAPMODE) do\n File.new(\"/dev/null\")\n end\n\n assert_raises(Errno::ECAPMODE) do\n puts `ls`\n end\n end", "def is_able?\n if gladiators.count < 2\n return false\n end\n return true\n end", "def verify\n verify_commands if commands.any?\n end", "def pbTrainerCheck(tr_type, tr_name, max_battles, tr_version = 0)\r\n return true if !$DEBUG\r\n # Check for existence of trainer type\r\n pbTrainerTypeCheck(tr_type)\r\n tr_type_data = GameData::TrainerType.try_get(tr_type)\r\n return false if !tr_type_data\r\n tr_type = tr_type_data.id\r\n # Check for existence of trainer with given ID number\r\n return true if GameData::Trainer.exists?(tr_type, tr_name, tr_version)\r\n # Add new trainer\r\n if pbConfirmMessage(_INTL(\"Add new trainer variant {1} (of {2}) for {3} {4}?\",\r\n tr_version, max_battles, tr_type.to_s, tr_name))\r\n pbNewTrainer(tr_type, tr_name, tr_version)\r\n end\r\n return true\r\nend" ]
[ "0.5410934", "0.53471756", "0.5341136", "0.52424496", "0.52302974", "0.5222446", "0.52153146", "0.521421", "0.521421", "0.5209314", "0.52080786", "0.51929", "0.51927453", "0.5164153", "0.51550186", "0.5149486", "0.5148308", "0.51479167", "0.5146003", "0.5129076", "0.51114374", "0.5111115", "0.5109817", "0.50698024", "0.506592", "0.5065541", "0.5064639", "0.5063313", "0.50583553", "0.5052873", "0.50378627", "0.5018413", "0.5017682", "0.5015638", "0.5015638", "0.5011167", "0.4995169", "0.49704078", "0.49681398", "0.49621946", "0.49620938", "0.49611488", "0.49585998", "0.49516615", "0.49397266", "0.49294952", "0.4927844", "0.4924149", "0.4916839", "0.4914429", "0.49012753", "0.48974642", "0.4895702", "0.4895702", "0.4895702", "0.4895702", "0.4895702", "0.48899314", "0.4888823", "0.4888707", "0.48863643", "0.48820868", "0.48769966", "0.48753068", "0.48734224", "0.4871375", "0.48708975", "0.48706982", "0.48706767", "0.48693874", "0.48693374", "0.48643503", "0.4857332", "0.4856783", "0.48532626", "0.4852547", "0.484931", "0.48492068", "0.48492068", "0.48459804", "0.48457277", "0.48382857", "0.48372218", "0.48363376", "0.48354492", "0.48317358", "0.48303637", "0.48299778", "0.4829901", "0.48279294", "0.48279", "0.48269153", "0.4826038", "0.48260063", "0.48250902", "0.48215786", "0.4820227", "0.48191023", "0.48189923", "0.48171583" ]
0.5532448
0
comment_block() outputs a standard Ruby comment block
def comment_block( *lines ) self.blank_line self << %[#] self.indent( "# " ) do lines.each do |line| self << line unless line.nil? end yield( self ) if block_given? end self.blank_line end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def comment( text = nil, &block )\n make_indent if @indent > 0\n \n @serial = @serial + 1\n @buffer << \"<!-- \"\n \n if text then \n @buffer << encode(text)\n elsif !block.nil? then\n capture(&block)\n end\n \n @buffer << \" -->\"\n end", "def create_comment(string, &block); end", "def create_comment(string, &block); end", "def comment(&block)\n #SWALLOW THE BLOCK\n end", "def comments(*args)\n args.push(lambda{|*x| yield(*x) }) if block_given?\n args.push GAP if args.empty?\n args.push \"\\n\"\n comment(\"\\n\", *args)\n end", "def comment_code\n block_match = /\\{([^\\{\\}]*)\\}/\n matches = @code.scan(block_match)\n return if matches.size != 1\n \n block = matches[0][0].to_s\n @code.gsub!(block_match, \"{\\n#{comment_struct_list(block)}#{@indent}}\")\n end", "def comment(contents='', &block)\n contents = build(:blank, Context, &block) if block\n '<!-- %s -->' % indent(contents)\n end", "def comment(*args)\n #:stopdoc:\n args.push(lambda{|*x| yield(*x) }) if block_given?\n args.push GAP if args.empty?\n jig = (Cache[:comment] ||= new(\"<!-- \".freeze, GAP, \" -->\\n\".freeze).freeze)\n jig.plug(GAP, *args)\n #:startdoc:\n end", "def comment(text)\n @out << \"<!-- #{text} -->\"\n nil\n end", "def render_comment(line)\n conditional, line = balance(line, ?[, ?]) if line[0] == ?[\n line.strip!\n conditional << \">\" if conditional\n\n if block_opened? && !line.empty?\n raise SyntaxError.new('Illegal nesting: nesting within a tag that already has content is illegal.', @next_line.index)\n end\n\n open = \"<!--#{conditional}\"\n\n # Render it statically if possible\n unless line.empty?\n return push_text(\"#{open} #{line} #{conditional ? \"<![endif]-->\" : \"-->\"}\")\n end\n\n push_text(open, 1)\n @output_tabs += 1\n push_and_tabulate([:comment, !conditional.nil?])\n unless line.empty?\n push_text(line)\n close\n end\n end", "def write_comment(text)\n puts \"# #{text.chomp}\" # TODO: correctly output multi-line comments\n end", "def write_comment(text)\n puts \"# #{text.chomp}\" # TODO: correctly output multi-line comments\n end", "def comment\n multi_line_comment || single_line_comment\n end", "def comment(string); end", "def comment(string); end", "def comment(string); end", "def comment(string); end", "def render_comment(line)\n conditional, content = line.scan(COMMENT_REGEX)[0]\n content.strip!\n\n if @block_opened && !content.empty?\n raise SyntaxError.new('Illegal Nesting: Nesting within a tag that already has content is illegal.')\n end\n\n try_one_line = !content.empty?\n push_silent \"_hamlout.open_comment(#{try_one_line}, #{conditional.inspect}, #{@output_tabs})\"\n @output_tabs += 1\n push_and_tabulate([:comment, !conditional.nil?])\n if try_one_line\n push_text content\n close\n end\n end", "def visit_comment(node)\n line = @original_haml_lines[node.line - 1]\n indent = line.index(/\\S/)\n @ruby_chunks << PlaceholderMarkerChunk.new(node, 'comment', indent: indent)\n end", "def new_comment comment, line_no = nil\n c = RDoc::Comment.new comment, @top_level, :ruby\n c.line = line_no\n c.format = @markup\n c\n end", "def comment(text)\n@out << \"<!-- #{text} -->\"\nnil\nend", "def getComment(var)\n return \"/* \" << var.text << \" */\\n\"\n end", "def comment(str)\n @out.comment(str)\n end", "def on_comment(comment)\n STDOUT << \"on_comment\" << \"\\n\" <<\n \" comment: \" << comment << \"\\n\"\n STDOUT.flush\n end", "def comment string = nil\n if block_given?\n @nodes << CommentNode.new(yield)\n else\n @nodes << CommentNode.new(string)\n end\n end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def add_comment(comment)\n \"\\n+++++++++++++++++++++++++++++++++++++++++ #{comment} ++++++++++++++++++++++++++++++++++++++++++++++\\n\"\n end", "def multiLineComment(comment, header = \"\")\r\n bar = \"\"\r\n hdrBar = \"\"\r\n\r\n # 3: 3 misc chars (/* )\r\n width = (@maxWidth - 3)\r\n\r\n width.times do\r\n bar += \"*\"\r\n end\r\n\r\n if (header.length > 0) # Generate a formatted header if it exists.\r\n hdrWidth = (@maxWidth - 6 - header.length) / 2\r\n\r\n hdrWidth.times do\r\n hdrBar += \" \"\r\n end # times\r\n end # if header\r\n\r\n output = <<EOF\r\n\r\n\r\n\r\n\r\n/* #{bar}\r\n#{hdrBar}-- #{header} --#{hdrBar}\r\n\r\n#{comment}\r\n\r\n#{bar} */\r\n\r\n\r\n\r\n\r\nEOF\r\n\r\n output\r\n\r\n end", "def format_comment(comment)\n comment\n end", "def add_comment comment\n \"\\n###### #{comment} ######\\n\" \n end", "def print_comment(comment)\n COLOR.send(:yellow, comment)\n end", "def comment?; end", "def comment?; end", "def comment comment\n end", "def comment=(_arg0); end", "def comment=(_arg0); end", "def comment=(_arg0); end", "def comment=(_arg0); end", "def start_comment(description = 'Description')\n str = \"#{@indent}/**\\n\"\n str += \"#{@indent} *\\t@brief\\t<##{description}#>\\n\"\n str \n end", "def print_comment\n\t\[email protected] do |comment|\n\t\t\tprint \"Error: Comment section opened but not closed\"\n\t\t\tputs \"at line: #{comment.get_nline}, column: #{comment.get_ncolumn}\" \n\t\tend\n\tend", "def block_contents(node, context)\n block_given? ? yield : ss_comments(node)\n node << (child = block_child(context))\n while tok(/;/) || has_children?(child)\n block_given? ? yield : ss_comments(node)\n node << (child = block_child(context))\n end\n node\n end", "def create_comment(string, &block)\n Nokogiri::XML::Comment.new(self, string.to_s, &block)\n end", "def visit_haml_comment(node)\n # We want to preserve leading whitespace if it exists, but add a leading\n # whitespace if it doesn't exist so that RuboCop's LeadingCommentSpace\n # doesn't complain\n line_index = node.line - 1\n lines = @original_haml_lines[line_index..(line_index + node.text.count(\"\\n\"))].dup\n indent = lines.first.index(/\\S/)\n # Remove only the -, the # will align with regular code\n # -# comment\n # - foo()\n # becomes\n # # comment\n # foo()\n lines[0] = lines[0].sub('-', '')\n\n # Adding a space before the comment if its missing\n # We can't fix those, so make sure not to generate warnings for them.\n lines[0] = lines[0].sub(/\\A(\\s*)#(\\S)/, '\\\\1# \\\\2')\n\n HamlLint::Utils.map_after_first!(lines) do |line|\n # Since the indent/spaces of the extra line comments isn't exactly in the haml,\n # it's not RuboCop's job to fix indentation, so just make a reasonable indentation\n # to avoid offenses.\n ' ' * indent + line.sub(/^\\s*/, '# ').rstrip\n end\n\n # Using Placeholder instead of script because we can't revert back to the\n # exact original comment since multiple syntax lead to the exact same comment.\n @ruby_chunks << HamlCommentChunk.new(node, lines, end_marker_indent: indent)\n end", "def comment\n @comment ||= begin\n space = node.previous_sibling and\n space.to_s.blank? && space.to_s.count(\"\\n\") == 1 and\n comment_node = space.previous_sibling\n\n if comment_node.is_a?(REXML::Comment)\n doc.restore_erb_scriptlets(comment_node.to_s.strip)\n end\n end\n end", "def process_block_comment!(index, tokens, ranges)\n start_index = index\n line_num = line_for_offset(tokens[index][1])\n while index < tokens.length - 2\n break unless tokens[index + 1][0] == :TOKEN_COMMENT\n next_line = line_for_offset(tokens[index + 1][1])\n # Tokens must be on contiguous lines\n break unless next_line == line_num + 1\n # Must not be a region comment\n comment = extract_text(tokens[index + 1][1])\n break if start_region?(comment) || end_region?(comment)\n # It's a block comment\n line_num = next_line\n index += 1\n end\n\n return index if start_index == index\n\n add_range!(create_range_span_tokens(tokens[start_index][1], tokens[index][1], REGION_COMMENT), ranges)\n index\n end", "def comment\n cyc.comment(self.to_sym)\n end", "def comment _args\n \"comment _args;\" \n end", "def comment?\n @kind == :line_comment || @kind == :block_comment\n end", "def rude_comment\n @res.write GO_AWAY_COMMENT\n end", "def as_comment_body\n\t\tcomment = \"%s: { template.%s\" % [ self.tagname, self.name ]\n\t\tcomment << self.methodchain if self.methodchain\n\t\tcomment << \" }\"\n\t\tcomment << \" with format: %p\" % [ self.format ] if self.format\n\n\t\treturn comment\n\tend", "def consume_comments; end", "def comment(comment_hash)\n time = Time.parse(comment_hash[:updated]).strftime('%b %d %H:%m')\n author = set_color(\" -- #{comment_hash[:author][:name]}\", :cyan)\n byline = \"#{author} | #{time}\\n\"\n\n [comment_hash[:body], byline].join(\"\\n\")\n end", "def build_doc_block(comment_block)\n yaml_match = /^\\s*---\\s(.*?)\\s---$/m.match(comment_block)\n return unless yaml_match\n markdown = comment_block.sub(yaml_match[0], '')\n\n begin\n config = YAML::load(yaml_match[1])\n rescue\n display_error(\"Could not parse YAML:\\n#{yaml_match[1]}\")\n end\n\n if config['name'].nil?\n puts \"Missing required name config value. This hologram comment will be skipped. \\n #{config.inspect}\"\n else\n doc_block = DocumentBlock.new(config, markdown)\n end\n end", "def make_node_comment( node )\n\t\tcomment_body = node.as_comment_body or return ''\n\t\treturn self.make_comment( comment_body )\n\tend", "def comment name\n\t\tempty = \"//\\n\"\n\n\t\tret = ''\n\t\tret << empty << empty\n\t\tret << \"// #{name}\\n\"\n\t\tret << \"// This is an object created by COBGIN\\n\"\n\t\tret << empty << empty\n\t\tret << \"// by Mickey Barboi\\n\"\n\t\tret << empty << empty << \"\\n\\n\"\n\n\t\tret\n\tend", "def get_comment(n, algebraic_structure)\n ret = <<EOS\n/**\n* Combine #{n} #{algebraic_structure}s into a product #{algebraic_structure}\n*/\nEOS\n ret.strip\nend", "def default_allows_comments?; true; end", "def comment\n comment = buffer.options.comment_line.to_s\n indent = nil\n lines = []\n\n each_line do |line, fc, tc|\n line_fc = \"#{line}.#{fc}\"\n line_tc = \"#{line}.#{tc}\"\n\n next if buffer.at_end == line_tc\n\n lines << line\n\n next if indent == 0 # can't get lower\n\n line = buffer.get(\"#{line}.#{fc}\", \"#{line}.#{tc}\")\n\n next unless start = line =~ /\\S/\n\n indent ||= start\n indent = start if start < indent\n end\n\n indent ||= 0\n\n buffer.undo_record do |record|\n lines.each do |line|\n record.insert(\"#{line}.#{indent}\", comment)\n end\n end\n end", "def read_block_comment(token)\n token.kind = :block_comment\n\n read_next()\n while (current = read_next())\n if current == ?* && peek_next() == ?/\n current = read_next()\n break\n end\n end\n\n raise_error(:unterminated_block_comment, \"Unterminated block comment\") if !current\n token.value = @source[token.from .. @marker.source_index] if !@skip_comments\n end", "def multi_line_comment\n # /*\n if @codes[@pos] == 0x2f and @codes[@pos + 1] == 0x2a\n @pos += 2\n pos0 = @pos\n # */\n while (code = @codes[@pos] != 0x2a) or @codes[@pos + 1] != 0x2f\n raise ParseError.new(\"no `*/' at end of comment\", self) if code.nil?\n @pos += 1\n end\n @pos +=2\n return ECMA262::MultiLineComment.new(@codes[pos0...(@pos-2)].pack(\"U*\"))\n else\n nil\n end\n end", "def line_comments_option; end", "def comment(text)\n @xml << \"<!-- #{text} -->\"\n nil\n end", "def f_slash_comment\n emit_comment(parse(\"\\n\"))\nend", "def comment!(comment = nil)\n mutate(:comment, comment)\n end", "def comment(comment = nil)\n set_option(:comment, comment)\n end", "def comment?\n return @assigned_paragraph_type == :comment if @assigned_paragraph_type\n return block_type.casecmp(\"COMMENT\") if begin_block? or end_block?\n return @line =~ /^[ \\t]*?#[ \\t]/\n end", "def document\n comment_code if is_multiline?\n super\n end", "def comment!(str)\n if str.include? \"\\n\"\n text! \"<!--\\n#{str}\\n-->\\n\"\n else\n text! \"<!-- #{str} -->\\n\"\n end\n end", "def comment(text)\n comments << text\n end", "def convert_xml_comment(el, opts)\n block = el.options[:category] == :block\n indent = SPACE * @current_indent\n content = el.value\n content.gsub!(/^<!-{2,}\\s*/, \"\") if content.start_with?(\"<!--\")\n content.gsub!(/-{2,}>$/, \"\") if content.end_with?(\"-->\")\n result = content.lines.map.with_index do |line, i|\n (i.zero? && !block ? \"\" : indent) +\n @pastel.decorate(\"#{@symbols[:hash]} \" + line.chomp,\n *@theme[:comment])\n end.join(NEWLINE)\n block ? result + NEWLINE : result\n end", "def _comment\n\n _save = self.pos\n while true # sequence\n _tmp = match_string(\"#\")\n unless _tmp\n self.pos = _save\n break\n end\n while true\n\n _save2 = self.pos\n while true # sequence\n _save3 = self.pos\n _tmp = apply(:_eol)\n _tmp = _tmp ? nil : true\n self.pos = _save3\n unless _tmp\n self.pos = _save2\n break\n end\n _tmp = get_byte\n unless _tmp\n self.pos = _save2\n end\n break\n end # end sequence\n\n break unless _tmp\n end\n _tmp = true\n unless _tmp\n self.pos = _save\n break\n end\n _tmp = apply(:_eol)\n unless _tmp\n self.pos = _save\n end\n break\n end # end sequence\n\n set_failed_rule :_comment unless _tmp\n return _tmp\n end", "def comments=(_arg0); end", "def comments=(_arg0); end", "def comments=(_arg0); end", "def comments=(_arg0); end", "def comments=(_arg0); end", "def getComment(var)\n return \"@* \" << var.text << \" *@\\n\"\n end", "def pygment_code_block(block)\n write_data block, 'code.rb', false\n system 'pygmentize -o block.html code.rb'\n File.open('block.html', 'r').read\n end", "def build_vorbis_comment_block\n begin\n vorbis_comm_s = [@tags[\"vendor_tag\"].length].pack(\"V\")\n vorbis_comm_s += [@tags[\"vendor_tag\"]].pack(\"A*\")\n vorbis_comm_s += [@comment.length].pack(\"V\")\n @comment.each do |c|\n vorbis_comm_s += [c.bytesize].pack(\"V\")\n vorbis_comm_s += [c].pack(\"A*\")\n end\n vorbis_comm_s\n rescue\n raise FlacInfoWriteError, \"error building vorbis comment block\"\n end\n end", "def comment!(content)\n build! do\n @_crafted << \"<!-- \"\n @_crafted << Tools.escape(content.to_s)\n @_crafted << \" -->\"\n end\n end", "def add_doc_block(comment_block)\n yaml_match = /^\\s*---\\s(.*?)\\s---$/m.match(comment_block)\n return unless yaml_match\n\n markdown = comment_block.sub(yaml_match[0], '')\n\n begin\n config = YAML::load(yaml_match[1])\n rescue\n DisplayMessage.error(\"Could not parse YAML:\\n#{yaml_match[1]}\")\n end\n\n if config['name'].nil?\n DisplayMessage.warning(\"Missing required name config value. This hologram comment will be skipped. \\n #{config.inspect}\")\n else\n doc_block = DocumentBlock.new(config, markdown)\n end\n\n @doc_blocks[doc_block.name] = doc_block if doc_block.is_valid?\n end", "def comment=(*)\n # do nothing with comment\n end", "def pretty_comment comment\n\tif comment == nil or comment.length == 0\n\t\treturn \"\"\n\tend\n\n\tbegin\n\t\tline_width = 100\n\n\t\twords = comment.scan(/\\w+|\\n/)\n\t\tlines = []\n\t\tline = \"\"\n\t\twords.each do |word|\n\t\t\tif word == \"\\n\"\n\t\t\t\tlines << line\n\t\t\t\tline = \"\"\n\t\t\telse\n\t\t\t\tif line.length + word.length > line_width\n\t\t\t\t\tlines << line\n\t\t\t\t\tline = \"\"\n\t\t\t\tend\n\n\t\t\t\tif line.length == 0\n\t\t\t\t\tline = word\n\t\t\t\telse\n\t\t\t\t\tline = line + \" \" + word\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tif line.length > 0\n\t\t\tlines << line\t\t\t\t\n\t\tend\n\t\tlines.map { |line| \n\t\t\t\"// #{line}\"\n\t\t}.join(\"\\n\")\n\trescue Exception => e\n\t\tcomment\n\tend\nend", "def banner(options = {}, &block)\n options = {\n :comment => :js\n }.update(options)\n \n if block_given?\n @_banner = yield.to_s\n elsif !@_banner\n banner = []\n banner << \"Version : #{self.scm.version}\"\n banner << \"Date : #{self.scm.date.strftime(\"%Y-%m-%d\")}\"\n\n size = banner.inject(0){|mem,b| b.size > mem ? b.size : mem }\n banner.map!{|b| \"= #{b.ljust(size)} =\" }\n div = \"=\" * banner.first.size\n banner.unshift(div)\n banner << div\n @_banner = banner.join(\"\\n\")\n end\n \n if options[:comment]\n self.comment(@_banner, :style => options[:comment])\n else\n @_banner\n end\n end" ]
[ "0.7728243", "0.7457021", "0.7457021", "0.7337075", "0.7316744", "0.72572887", "0.72345114", "0.7163429", "0.7018599", "0.6997021", "0.6969774", "0.6969774", "0.6937527", "0.6934137", "0.6934137", "0.6934137", "0.6934137", "0.6904793", "0.6896777", "0.6859331", "0.6762318", "0.67568934", "0.67553324", "0.6712109", "0.6703743", "0.66562724", "0.66562724", "0.66562724", "0.66562724", "0.66562724", "0.66562724", "0.66562724", "0.66562724", "0.66562724", "0.66562724", "0.66562724", "0.66562724", "0.66562724", "0.66562724", "0.66562724", "0.66562724", "0.66562724", "0.6643945", "0.6638737", "0.6631535", "0.66227216", "0.66214544", "0.66206765", "0.66206765", "0.6616614", "0.66153985", "0.66153985", "0.66153985", "0.66153985", "0.6580919", "0.6563918", "0.65442985", "0.65409374", "0.6441454", "0.63954544", "0.6394213", "0.6393096", "0.63927144", "0.63728", "0.63264275", "0.6315697", "0.63138276", "0.629493", "0.6280967", "0.6280186", "0.6262543", "0.62609804", "0.6256523", "0.6249798", "0.62428", "0.6197599", "0.6197394", "0.61908066", "0.61757356", "0.61736447", "0.61446893", "0.61416215", "0.6140163", "0.6138687", "0.61373526", "0.6130755", "0.6126821", "0.6118226", "0.6118226", "0.6118226", "0.6118226", "0.6118226", "0.61134726", "0.6100037", "0.6087019", "0.608411", "0.608241", "0.60747", "0.607347", "0.6057509" ]
0.72168124
7
Methods to use in controller..... to create a post we have to get the current user, and the profile he is viewing
def create_post(user, friend, text) UserPost.create(text: text,user1_id: user, user2_id: friend) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @post = Post.new(post_params)\n @post.user = current_user\n @post.save\n redirect_to @post\n\n end", "def create\n #Only the loged user can create posts for himself, not any other user.\n @post = @user.posts.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to [@user,@post], notice: @user.first_name + ', the post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n @post.user = current_user\n if @post.save\n success_post_create\n else\n error_post_save\n end\n end", "def create\r\n new_post = current_user.posts.new(post_params)\r\n new_post.save\r\n redirect_to post_path new_post\r\n end", "def create\n # with assocations, you can build through the association\n # @post = Post.new(post_params)\n #@post.user_id = current_user.id\n\n #this inherently takes the current_user's PK and store it in the FK of the new post because of the assocation we set. It essentially creates this new posts and associates the post with the user.\n # @post = current_user.posts.new(post_params)\n @post = current_user.posts.build(post_params)\n\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: \"Post was successfully created.\" }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = current_user.posts.new(post_params) #el user_id de la tabla post sera el id del usuario que actualemnte está conectado.\n \n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n @post = Post.new(post_params)\r\n\r\n #-------add current_user to user_id-----------\r\n @post.user_id = current_user.id\r\n #---------------------------------------------\r\n \r\n respond_to do |format|\r\n if @post.save\r\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\r\n format.json { render :show, status: :created, location: @post }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @post.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @post = Post.new(post_params)\n @post.user_id = current_user.id\n\n if @post.save\n redirect_to @post\n else\n render :new\n end\n end", "def create\n @post = Post.new(params[:post])\n @post.user = current_user\n @post.save\n respond_with(@post)\n end", "def create\n @post.user = current_user unless params[:post][:user_id].present?\n respond_to do |format|\n if @post.save\n format.html { redirect_to [@user, @post], notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(params[:post])\n if current_user\n @post.user_id = current_user.id\n end\n \n respond_to do |format|\n if @post.save\n format.html { redirect_to(root_path, :notice => 'Post was successfully created.') }\n format.xml { render :xml => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(params[:post].merge!(:user => current_user))\n if @post.save\n flash[:notice] = 'Your post has been created.'\n redirect_to root_path\n else\n render action: \"new\"\n end\n end", "def create\n @post = Post.new(post_params)\n @post.update_attribute(:user_id, current_user.id)\n \n if @post.save\n flash[:success] = \"Post Created\"\n redirect_to home_path\n \n else\n render action: 'new' \n \n end\n \n end", "def new \n @post = current_user.posts.build #make \n end", "def create\n @post = Post.new(post_params)\n @post.user = current_user\n if @post.save\n redirect_to post_path(@post)\n else\n render :new\n end\n end", "def create\n @post = current_user.posts.build(post_params)\n if @post.save\n redirect_to @post\n else\n render 'new'\n end\n end", "def create\n @post = @current_user.posts.build( post_params )\n # @post = Post.new( post_params,)\n\n respond_to do |format|\n if @post.save\n format.html {\n flash[:success] = \"Post was successfully created.\"\n redirect_to( @post )\n }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n authorize\n @user = current_user\n @post = Post.new(params[:post])\n @post.user_id = @user.id\n\n respond_to do |format|\n if @post.save\n flash[:notice] = 'Post was successfully created.'\n format.html { redirect_to @post}\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = current_user.posts.new(params[:post])\n if @post.save\n redirect_to @post, notice: \"Post has been created\"\n else\n render :new\n end\n end", "def create\n @post = current_user.posts.build(post_params.merge(user_id: current_user.id))\n puts @post\n if @post.save\n flash[:success] = \"Post created!\"\n redirect_to root_url\n else\n render 'static_pages/home'\n end\n end", "def create\n @post = current_user.posts.new(params[:post])\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(params[:post])\n @post.user_id = current_user.id\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to user_slug_path(current_user), notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def method_name\n @post = current_user.posts.build \n end", "def create\n\n if current_user\n @post = Post.new(post_params)\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n else\n redirect_to posts_path, notice: 'Login or register to create post'\n end\n end", "def create\n params_with_userid = post_params\n params_with_userid[:user_id] = current_user.id\n @post = Post.new(params_with_userid)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n response.location = \"posts/new\"\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = current_user.posts.new(post_params)\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\tp \"james\"\n\t\t@post = Post.new(post_params)\n\t\t# @post = current_user.posts.build(post_params)\n\t\tif @post.save\n\t\t\tredirect_to '/posts/new'\n\t\telse\n\t\t\tp \"FAILED\"\n\t\t\trender 'new'\n\t\tend\n\tend", "def create\n @post = Post.new(params[:post])\n @post.user = current_user\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: '' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n @post.user_id = current_user.id\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if current_user\n @post = Post.new(post_params)\n respond_to do |format|\n if @post.save\n flash[:success] = 'Post was successfully created.'\n format.html { redirect_to @post }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n else\n flash[:alert] = 'Sing up or Log in'\n redirect_to posts_path \n end\n end", "def create\n @post = current_user.posts.build(post_params)\n\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = current_user.posts.create(params[:post])\n\n if @post.save\n flash[:success] = 'Post was successfully created.'\n redirect_to @post\n else\n render :new\n end\n\n end", "def create\n @post = current_user.posts.new(post_params)\n user_posted!\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: t('activerecord.flash.post.success') }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n @post.user = current_user\n if @post.save\n flash[:success] = \"Post was successfully saved\"\n redirect_to post_path(@post)\n else \n render 'new'\n end\n end", "def create\n @post = Post.new(post_params)\n @post.user_id = current_user.id\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n @post.user_id = current_user.id\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n @post.user_id = current_user.id\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n @post.user_id = current_user.id\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #initialize a new post object with the parameters submitted, validated by post_params\n @post = Post.new(post_params)\n \n isComment = false\n #check whether this is actually a comment, meaning it should have kind=2 and will need an originating post id\n if params[:kind].present?\n @post.kind = params[:kind].to_i\n @post.originatingPost_id = params[:originatingPost_id].to_i\n isComment = true\n \n #otherwise, it is a post, which optionally has tags\n else\n @post.kind = 0\n @tagsToAdd = params[:tagsToAdd].split(\" \")\n @tagsToAdd.each do |t|\n @post.tags << createTag(t)\n end\n end\n \n #either way, the currently logged in user should be logged as the creator of this post/comment\n @post.user = User.find(session[:user_id])\n \n if @post.save!\n if isComment\n redirect_to action: \"show\", :id => params[:originatingPost_id] #stay on the post's show page\n else\n redirect_to action: \"show\", :id => @post.id #go to this new post's show page\n end\n else\n redirect_to action: 'new' #upon failure, try again\n end\n end", "def create\n render_forbidden and return unless can_edit?\n @post = current_user.posts.new(post_params)\n \n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: 'new' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(params[:post])\n @post.user = current_user\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # post_params is define below\n post = current_user.posts.new(post_params)\n if post.save\n redirect_to posts_path\n else\n flash[:message] = post.errors.messages\n \n redirect_to :back\n end\n end", "def create\n @post = current_user.posts.build(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post criado com sucesso.' }\n else\n format.html { render :new }\n end\n end\n end", "def create\n @post = Post.new params[:post].merge(:author => current_user)\n \n respond_to do |format|\n if @post.save\n format.html { redirect_to(@post, :notice => t('posts.show.post_created')) }\n format.xml { render :xml => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end", "def profile\n \t# Grab the username from the URL as :id\n \t# if (User.find_by_username(params[:id]))\n \t\t@username = params[:id]\n @posts = Post.all\n @newPost = Post.new\n \t# else\n \t# \t#Redirect to 404 (for now)\n \t# \tredirect_to root_path, :notice=> \"User not found!\"\n \t# end\n end", "def create\n @posts = Post.page(params[:page]).order('created_at desc')\n @post = Post.new(post_params)\n @user = User.where('account_id == ?', current_account.id)[0]\n respond_to do |format|\n if @post.save\n format.html { redirect_to '/posts' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :index }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # Remember, params stores everything sent to the server through form or\n # querystring data. By default, `form_for` will place your data in `params[:model_name]`\n @post = current_user.posts.build(params[:post])\n\n # This idiom is very common in create and update actions. `save` will return\n # false if the record is invalid. We render `new` rather than redirecting so\n # that the model state, errors and all, remains intact.\n if @post.save\n redirect_to posts_path\n else\n render :new\n end\n end", "def create\n \t@post = current_user.posts.build(create_params)\n if @post.save\n flash[:success] = \"Posted successfully\"\n redirect_to posts_path\n else\n render \"new\"\n end\n end", "def create\n authorize! :create, @post\n @post = Post.new(params[:post])\n @post.user_id = current_user.id\n \n respond_to do |format|\n if @post.save\n format.html { redirect_to(@post, :notice => 'Post was successfully created.') }\n format.xml { render :xml => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n if current_user.admin\n @post = Post.new(post_params)\n @post.user = current_user\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: \"Postitus edukalt loodud!\" }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n\n else\n flash[:notice] = 'You dont have permission to do that!'\n redirect_to posts_path\n end\n\n end", "def create\n @post = current_user.posts.new(post_params)\n respond_to do |format|\n if @post.save\n format.html { redirect_to list_of_posts_post_path(@post.user), notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_post\n if current_user.id.to_s == params[:user_id].to_s\n post = Post.new(:user_id => params[:user_id], :content => params[:content],\\\n :title => params[:title], :upvotes => 0, :downvotes => 0, :rank => 0)\n post.save!\n end\n end", "def create\n @post = Post.new(post_params)\n @post.user_id = current_user.id\n\n flash[:notice] = 'Post was successfully created.' if @post.save\n redirect_to posts_url\n end", "def create\n @post = current_user.posts.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to users_posts_path, notice: 'Post was successfully created.'}\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n @post.user_id = current_user.id\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \t# create the post\n \t# the following is the short version of getting data\n \t@post = Post.new(params[:post])\n \t# the following is the long version of getting data\n \t# @post = Post.new(params[:title], params[:url], params[:description])\n \t# @post.user_id = 1 #TODO: add in real user after we have authentication\n # @post.user_id = current_user.id\n @post.user_id = session[:user_id]\n \tif @post.save\n \t\tflash[:notice] = \"Post was created!\"\n \t\tredirect_to posts_path # \"/posts/#{@post_id}\"\n \telse # validation failure\n render :new\n end\n end", "def create\n @post = current_user.posts.build(post_params)\n if @post.save\n redirect_to root_url, notice: 'Post was successfully created.'\n else\n redirect_to root_url, notice: 'Failure creating post.'\n end\n end", "def create\n @post = if post_params[:only_followers].nil?\n Post.new(post_params.merge(user_id: current_user.id, only_followers: false))\n else\n Post.new(post_params.merge(user_id: current_user.id))\n end\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Grumbl was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = current_user.posts.new(post_params)\n if @post.save\n flash[:success] = \"Esto fue un exito.\"\n render :show\n else\n flash[:error] = \"Paa, drama.\"\n render :new\n end\n end", "def create\n @post = Post.new(post_params)\n @post.author = @current_user\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render action: 'show', status: :created, location: @post }\n else\n format.html { render action: 'new' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n @post.user = current_user\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n @post.user = current_user\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n @post.user = current_user\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n if ( @post.user_id != current_user.id )\n redirect_to posts_path, notice: 'Undifined user, post was not successfully created.'\n else\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def create\n @post = current_user.posts.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: '성공적인 메모였습니다.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n post = Post.new(post_params)\n post.author = current_user\n post.receiver = User.find(params[:profile_id])\n binding.pry\n if post.save\n respond_to do |format|\n format.html { redirect_to profile_url(post.receiver) }\n format.json { render json: post }\n end\n else\n flash[:error] = \"There was a problem creating your post!\"\n end\n end", "def create\n @post = current_user.posts.build(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = current_user.posts.build(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = current_user.posts.build(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = current_user.posts.build(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = current_user.posts.build(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @post = Post.new\n @post.user ||= current_user\n end", "def create\n\t@post = current_user.posts.build(post_params) # used to be =Post.new(post_params)\n\n\tif @post.save\n\t\tredirect_to @post\n\telse\n\t\trender 'new'\n\tend\nend", "def create\n @post = @current_user.posts.build(params[:post])\n if @post.save then\n Feed.create_post(@post)\n end\n end", "def create\n @post = Post.new(post_params)\n\t\[email protected]_id = current_profile.id\n\t\trespond_to do |format|\n if @post.save\n format.html { \n\t\t\t\t\tflash[:success] = \"New post created!\"\n\t\t\t\t\tredirect_to profile_path(current_profile)\n\t\t\t\t}\n format.json { render :show, status: :created, location: @post }\n else\n\t\t\t\tformat.js {}\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = current_user.posts.build(post_params)\n if @post.save\n redirect_to root_path\n flash[:notice] = 'Your post was saved succesfully'\n else\n flash[:notice] = 'You post could not be saved'\n render :new\n end\n end", "def create\n @post.author = current_user\n\n if @post.save\n flash[:notice] = 'Post was successfully created.'\n end\n \n respond_with @post\n end", "def profile\n # grab the username from the URL as :id\n if (User.find_by_username(params[:id]))\n @username = params[:id]\n else \n # redirect to 404 (root for now)\n redirect_to root_path, :notice=> \"User not found!\" \n end\n\n # grab the name from the URL as :id\n if (User.find_by_name(params[:id]))\n @name = params[:id]\n else\n # redirect to 404 (root for now)\n \n end\n\n # grab the name from the URL as :id\n if (User.find_by_surname(params[:id]))\n @surname = params[:id]\n else\n # redirect to 404 (root for now)\n \n end\n\n # grab the name from the URL as :id\n if (User.find_by_avatar(params[:id]))\n @avatar = params[:id]\n else\n # redirect to 404 (root for now)\n \n end\n\n # grab the name from the URL as :id\n if (User.find_by_cover(params[:id]))\n @cover = params[:id]\n else\n # redirect to 404 (root for now)\n \n \n end\n\n\n\n @posts = Post.all.where(\"user_id = ?\", User.find_by_username(params[:id]).id )\n\n @newPost = Post.new\n\n @toFollow = User.all.last(5)\n end", "def create\n @user = current_user\n @post = @user.posts.build(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @post = current_user.posts.build\n end", "def new\n @post = current_user.posts.build\n end", "def set_post_and_user\n @post = Post.find(params[:id])\n @user = @post.user\n end", "def create\n @post = Post.new(post_params)\n # 4 #\n @post.user_id = @user.id\n # #\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n authorize! :write, Post\n @post = current_user.posts.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to(@post, :notice => 'Post was successfully created.') }\n format.xml { render :xml => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n @post.user_id = current_user.id\n\n respond_to do |format|\n if @post.save\n topic = Topic.find(params[:topic_id])\n topic.last_post_at = @post.created_at\n topic.last_poster_id = @post.user_id\n topic.save\n\n format.html { redirect_to post_path(@post), notice: 'Post was successfully created.' }\n format.json { render action: 'show', status: :created, location: @post, :user_id => current_user.id }\n else\n format.html { render action: 'new' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n user_post_param\n respond_to do |format|\n if @post.save\n format.html do\n redirect_to @post, notice:\n \"Post was successfully created.\"\n end\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json do\n render json: @post.errors, status:\n :unprocessable_entity\n end\n end\n end\n end", "def create\n\n\n @post = current_user.posts.build(post_params)\n\n if @post.save\n\n render json: \"Posted successfully\", status: 201\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end", "def create\n @post = Post.new(params[:post])\n @post.user_id = current_user.id\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { redirect_to posts_path, flash: { error: @post.errors.full_messages } }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new post_params\n @post.user = current_user\n\n if @post.save\n flash[:notice] = 'Post Created'\n redirect_to post_path(@post)\n else\n flash[:alert] = 'Problem creating post'\n render :new\n end\n end", "def create\n can_create\n @post = Post.new(post_params)\n @post.user = current_user\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.new(post_params)\n @post.user_id = params[:user_id]\n if @post.save\n render json: @post, meta: { status: :created }, meta_key: 'result', status: :created\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end", "def create\n post_params = params.require(:post).permit([:title, :body, :user_id])\n @post = Post.new post_params\n @post.user = current_user\n if @post.save\n flash[:success] = \"Post was successfully created\"\n redirect_to post_path(@post)\n # redirect to show page with this post id\n else\n render :new\n end\n end", "def create\n @post = current_user.posts.new(post_params.merge(writter: current_user.name))\n\n if @post.save\n render json: {status: 1, id: @post.id.to_s, notice: \"新增成功,标题是:#{@post.title.capitalize}\", number: @post.number, errors: []}\n else\n render json: {status: -1, notice: \"新增失败,请先登录\", errors: @post.errors.full_messages}\n end\n end", "def create\n @post.character = current_user.character\n authorize! :create, @post\n create! { posts_url }\n end", "def create\n @post = Post.new(post_params)\n @post.user = current_user\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: \"Post was successfully created.\" }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = current_user.posts.new(post_params)\n\n if @post.save\n flash[:notice] = \"Post successfully saved!\"\n redirect_to posts_path\n else\n flash[:alert] = \"We could not post your blog\"\n render :new\n end\n end", "def create\n @user = User.find(params[:user_id])\n @post = @user.posts.new(post_params)\n\n if @post.save\n render json: @post, status: :created, location: [@user, @post]\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end", "def create\n @post = Post.new(post_params)\n @post.user_id = current_user.id\n @post.save\n redirect_to @post\n# respond_to do |format| \n# if @post.save \n# format.html { redirect_to @post, notice: 'Post was successfully created.' } \n# format.json { render :show, status: :created, location: @post } \n# else \n# format.html { render :new } \n# format.json { render json: @post.errors, status: :unprocessable_entity } \n# end \n# end\n end", "def create\n @post = Post.new(post_params)\n @post.user_id = current_user.email\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = current_user.posts.build(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to(@post, :notice => 'Post created.') }\n format.xml { render :xml => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n\t\t@post = Post.new(post_params)\n\t\[email protected]_id = current_user.id\n\t\tif @post.save\n\t\t\tflash[:success] = \"Post created\"\n\t\t\tredirect_to posts_path \n\t\telse\n\t\t\tflash[:error] = \"Unable to save post. Please try again\"\n\t\t\trender :create\n\t\tend\n\tend" ]
[ "0.7547521", "0.74981743", "0.7492395", "0.74666756", "0.7450499", "0.7441316", "0.7438933", "0.7397327", "0.7386466", "0.7377027", "0.73741335", "0.73680305", "0.7321365", "0.7320688", "0.7309966", "0.7309249", "0.730487", "0.7288179", "0.72781616", "0.72560495", "0.72418684", "0.7233003", "0.72105163", "0.72029895", "0.7195175", "0.7193119", "0.7183729", "0.71834815", "0.71789896", "0.7172681", "0.7170231", "0.7165529", "0.7155867", "0.715477", "0.7154132", "0.7154132", "0.7154132", "0.7154132", "0.71522707", "0.71494067", "0.714564", "0.7144944", "0.71319366", "0.7124719", "0.71206194", "0.7113786", "0.71115744", "0.711129", "0.71050113", "0.7103147", "0.7099907", "0.70924884", "0.7081203", "0.70777905", "0.7076749", "0.7072738", "0.7068937", "0.7064634", "0.7063755", "0.7061398", "0.70590657", "0.70590657", "0.70590657", "0.7058437", "0.70555806", "0.7051724", "0.704795", "0.704795", "0.704795", "0.704795", "0.704795", "0.704106", "0.7039491", "0.7031615", "0.70315224", "0.7026317", "0.70172113", "0.70135605", "0.7012602", "0.7009874", "0.7009874", "0.70077217", "0.70052916", "0.7002725", "0.69948685", "0.6993111", "0.6991225", "0.69899213", "0.69886535", "0.69869995", "0.69820195", "0.69759464", "0.6974302", "0.69727", "0.69675094", "0.6966475", "0.6962403", "0.69620025", "0.69608366", "0.6957604", "0.6957532" ]
0.0
-1
to view a post we have to get the current user, and the profile he is viewing
def view(user, friend) post = UserPost.where(user1_id: user, user2_id: friend) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @post = Post.find(params[:id])\n @user = current_user\n end", "def show\n @user = User.find(@post.user_id)\n end", "def show\n @post = Post.new\n @user = User.find params[:id]\n @posts = Post.where(\"user_id = ?\", @user[:id])\n @title = \"Profile: \" + @user.username\n end", "def show\n \n #@user = User.find_by_username(params[:slug])\n @post = Post.new\n @user =\n @profile = Profile.find_by_user_id(User.find_by_username(params[:slug]).id)\n @user = User.find(@profile.user_id)\n if current_user == @user\n @posts = Post.paginate_all_by_user_id(@user.followers.map(& :id).push(@user.id), :page => params[:page], :per_page => 10, :order=>'created_at desc')\n else\n @posts = Post.paginate_all_by_user_id(@user.id, :page => params[:page], :per_page => 10, :order=>'created_at desc')\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @profile }\n end\n end", "def show\n # gives us the user object for the current profile we're looking at.\n @user = User.find_by(user_name: params[:user_name])\n @posts = User.find_by(user_name: params[:user_name]).posts.order('created_at DESC')\n end", "def show\n @post = Post.find(params[:id])\n @user = @post.blog.user\n end", "def show\n \tif(params[:id])\n \t\t @profile = Profile.find(params[:id])\n \telse\n \t\t@profile = Profile.find_by_user_id(current_user.id)\n \tend\n # authorize! :show, @profile\n\n add_breadcrumb @profile.first_name + \" \" + @profile.last_name, \"\"\n \n @recentposts = Post.where('user_id = ?', @profile.user.id).order('id desc')\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @profile }\n end\n end", "def show\n @user = User.find(params[:id])\n @last_private_post = Post.find_by_receiver_id(current_user)\n @last_post = Post.find_by_class_room_id(current_user.class_room);\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @user }\n end\n end", "def show\n @can_edit = false\n if user_signed_in?\n @my_pre = Preference.find_by user_id: current_user.id\n @my_pro = Profile.find_by user_id: current_user.id\n @similars = find_similar\n\n if current_user.admin?\n @can_edit = true\n elsif current_user.editor? && @post.owner == current_user.id\n @can_edit = true\n end\n end\n end", "def show\n @post = current_user.posts.build\n @user = User.find(params[:id])\n if current_user == @user\n @posts = current_user.feed.paginate(page: params[:page]) \n else\n @posts = @user.posts.paginate(page: params[:page])\n end\n end", "def show\n @followers = @user.followers\n @followings = @user.followings\n @post = Post.new\n end", "def profile\n @user = @current_user\n\n render :show\n\n end", "def profile\n @user = current_user\n end", "def show\n @post = Post.find(params[:id])\n unless @post.user.id == current_user.id\n ahoy.track \"Read Post\", post_id: @post.id\n end\n end", "def show\n \tif(logged_in)\n \t\t@posts = User.find(@user.id).posts\n \telse\n \t\treturn\n \tend\n end", "def profile\n if @user == current_user or current_user.friends.include?(@user)\n posts = @user.posts\n else\n posts = @user.posts.where(is_public: true)\n end\n\n posts = posts.order(\"created_at DESC\")\n posts = add_image_and_user_to_post(posts)\n\n render json: posts, status: :ok\n end", "def profile\n \t# Grab the username from the URL as :id\n \t# if (User.find_by_username(params[:id]))\n \t\t@username = params[:id]\n @posts = Post.all\n @newPost = Post.new\n \t# else\n \t# \t#Redirect to 404 (for now)\n \t# \tredirect_to root_path, :notice=> \"User not found!\"\n \t# end\n end", "def profile\n # grab the username from the URL as :id\n if (User.find_by_username(params[:id]))\n @username = params[:id]\n else \n # redirect to root\n redirect_to root_path, :notice=> \"User not found!\" \n end\n \n #only posts by that specific user are collected from the database\n @posts = Post.all.where(\"user_id = ?\", User.find_by_username(params[:id]).id)\n @newPost = Post.new\n end", "def show\n @user = User.find(params[:id])\n @posts = Post.where(user: @user)\n @post = current_user.posts.new if @user == current_user\n @comment = Comment.new\n end", "def profile\n @profile = current_user\n end", "def show\n if user_signed_in?\n\n @post = current_user.posts.find(params[:id])\n \n if @post.user_id == current_user.id\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n else\n redirect_to action: 'index'\n end\n else\n redirect_to action: 'index'\n end \n end", "def profile\n\t\t@user = current_user\n\tend", "def show\n @user = User.where(id: @post.user_id)[0]\n @likes = UserLike.where(post_id: @post.id)\n end", "def show\n user = Userinfo.find(params[:id])\n\n @posts = user.posts\n end", "def find_own_post\n\t\t@post = current_user.posts.find(params[:id])\n\tend", "def show\n if (!@isLogin || !@isValidUser)\n return\n end\n @posts = @user.posts\n end", "def show\n @posts = @user.posts\n end", "def index\n @posts = Post.user_posts current_user\n end", "def show\n post = Post.find(params[:id])\n post_info = post.attributes\n commentaries = []\n post_comments.each do |comment|\n comment_info = comment.attributes\n comment_info[:profile] = Profile.where(user: User.find(comment[:user_id])).first\n comment_info[:user] = User.find(comment[:user_id])\n commentaries << comment_info\n end\n post_info[:comments] = commentaries\n post_info[:votes] = post_votes\n post_info[:user] = User.find(post.user.id)\n post_info[:profile] = Profile.where(user: post.user).first\n @post = post_info\n \n end", "def show\n @post = current_user.posts.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end", "def show\n @profile = @user.profile\n end", "def show\n @me = current_user\n end", "def show\n#北七喔 是user 跟 group建立多對多\n#又不是group 跟 post多對多 \n\n @posts = @group.posts.each.reverse_each\n if current_user.profile == nil\n user = current_user\n Profile.create(:user_id => user.id, :name => user.email, :age => nil, :location => nil, :gender => nil)\n end\n end", "def profile\n\t@user = current_user\n\t@title = \"This is your profile page\"\n end", "def show\n if Post.shared_post_exist?(@resource.url)\n @shared_users = Post.shared_post_users(@resource.url, current_user.id)\n end\n end", "def profile\n # grab the username from the URL as :id\n if (User.find_by_username(params[:id]))\n @username = params[:id]\n else \n # redirect to 404 (root for now)\n redirect_to root_path, :notice=> \"User not found!\" \n end\n\n # grab the name from the URL as :id\n if (User.find_by_name(params[:id]))\n @name = params[:id]\n else\n # redirect to 404 (root for now)\n \n end\n\n # grab the name from the URL as :id\n if (User.find_by_surname(params[:id]))\n @surname = params[:id]\n else\n # redirect to 404 (root for now)\n \n end\n\n # grab the name from the URL as :id\n if (User.find_by_avatar(params[:id]))\n @avatar = params[:id]\n else\n # redirect to 404 (root for now)\n \n end\n\n # grab the name from the URL as :id\n if (User.find_by_cover(params[:id]))\n @cover = params[:id]\n else\n # redirect to 404 (root for now)\n \n \n end\n\n\n\n @posts = Post.all.where(\"user_id = ?\", User.find_by_username(params[:id]).id )\n\n @newPost = Post.new\n\n @toFollow = User.all.last(5)\n end", "def show\n @user = User.find(params[:id])\n @post = Post.new\n @posts = @user.posts.paginate(:page => params[:page], :per_page => 10)\n @title = @user.name\n end", "def show\n # @u = current_user\n end", "def show\n @posts = @profile.user.posts.paginate(page: params[:page], per_page: 5)\n @comment = Comment.new\n end", "def show\n @user = User.find_by_slug(params[:user_id])\n unless @user.posts == nil\n @post = @user.posts.find(params[:id])\n @image = @post.image\n @comments = @post.comments.all\n end\n\n @title = @post.created_at\n\n respond_with(@user, @post)\n\n end", "def profile\n #grab the username from the url as :id\n if (User.find_by_username(params[:id]))\n @username = params[:id]\n else\n #redirect to 404 page not found\n redirect_to root_path, :notice=> \"User not found!\"\n end\n \n @posts = Post.all.where(\"user_id=?\", User.find_by_username(params[:id]).id)\n @newPost = Post.new\n end", "def index\n @posts = current_user.posts\n\n end", "def show\n @user = User.find_by(id: params[:id])\n @posts = @user.posts\n end", "def show\n if current_user\n @last_posted_at = Time.current\n end\n end", "def profile\n\t\t@user = User.find(current_user)\n\tend", "def show\n @my_posts = @good.good_posts.select{|p| p.user == current_user }\n end", "def show\n\n @posts = @user.posts #11/19 Mypostsを表示\n end", "def show\n @user = User.find_by_username( params[:id] )\n @data = {:type => \"profile_view\", :object_id => @user.id, :ip => request.remote_ip, :user => user_signed_in? ? current_user.id : \"\" }\n @view = View.track_view(@data)\n @company_count = @user.company\n if current_user.present?\n @blog_posts = @user.blog_posts\n @follow_status = UserFollower.where( :user_id => @user.id, :follow_user_id => current_user.id, :followed => 1).count\n @followed = CompanyFollower.followed_companies(@user.id,params)\n else\n @blog_posts = @user.blog_posts.where(:private => \"0\")\n end\n @followers = UserFollower.where(:user_id => @user.id, followed: 1).count\n @following = UserFollower.where(:follow_user_id => @user.id, followed: 1).count\n render layout: \"homepage\"\n end", "def index\n @posts = current_user.posts\n end", "def set_post_and_user\n @post = Post.find(params[:id])\n @user = @post.user\n end", "def show\n @post = Post.find(params[:id])\n @post_data = PostDecorator.new.show_post_data(@post, current_user)\n render :show_post\n end", "def show\n @is_connected = current_user\n\n if @is_connected\n @isadmin = (current_user.has_role? :admin)\n @is_author = (current_user.id == @eventpost.user_id)\n @is_event_author = (current_user.id == @eventpost.event.user_id) # user_id == id del autor\n @eventpostcomment = Eventpostcomment.new\n end\n\n @postuser = @eventpost.user\n @postusercount = @postuser.posts.count + @postuser.eventposts.count\n @postuserscore = @postuser.posts.sum(:cached_votes_score) + @postuser.eventposts.sum(:cached_votes_score)\n\n end", "def show\n kiss_record \"View blog post\"\n if admin_signed_in?\n @post = Post.find_by_title_for_url(params[:id])\n else\n @post = Post.where(:draft => false).find_by_title_for_url(params[:id])\n end\n if session[:comment].nil?\n @comment = @post.comments.new\n else\n @comment = session[:comment]\n end\n\t\t@comments = @post.comments.all.reverse\n end", "def show\n # @post = Post.find(params[:id])\n user = User.find(params[:user_id])\n @post = Post.find(params[:post_id], :conditions => { :user_id => user })\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end", "def show\n @post = current_user.posts.build\n @user = User.find(params[:id])\n @user_posts = @user.posts.paginate(page: params[:page]).order('created_at DESC')\n \n end", "def show\n @sites = current_user.sites\n @post = current_user.posts.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end", "def show\n @photos = @post.photos\n @likes = @post.likes.includes(:user)\n @bookmarks = @post.bookmarks.includes(:user)\n @comment = Comment.new\n @is_liked = @post.is_liked(current_user)\n @is_bookmarked = @post.is_bookmarked(current_user)\n end", "def profile\n\t\t\n\t\tif !current_user\n\t\t\tredirect_to root_url and return\n\t\tend\n\t\t\n\t\t@user = current_user\n\t\t\n\tend", "def index\n @posts = Post.where(:user_id => current_user.id).order(\"created_at DESC\")\n #@posts = Post.all.order(\"created_at DESC\")\n #this post also saves lives\n #https://stackoverflow.com/questions/25831594/devise-how-to-show-users-post\n \n end", "def show\n @post = params[:pid] ? Post.find_by_unique_id(params[:pid], :include => [:contest, :owner]) : nil\n @authorization_url = @post.get_fb_auth_url\n \n #@contest = Contest.find_by_id(@post.contest_id)\n @contest = @post.contest unless @post.nil?\n \n if params[:mid].nil?\n @match = Match.get_next_scheduled_match(@contest)\n @previous_match = Match.get_previous_match(@contest, @match)\n else\n @match = Match.find_by_unique_id(params[:mid])\n @previous_match = @match\n end\n @category = @match.category\n \n if @post \n if @readonlypost\n @last_viewed_at = Time.now\n #Case: If member clicked on an open invite link again to join, then simply redirect to show page\n if current_user && current_user.activated?\n #check if user is already a participant\n @eng = current_user.engagements.find_by_post_id(@post.id)\n redirect_to(@post.get_url_for(current_user, 'show')) && return unless @eng.nil?\n end\n unless @user.unique_id.nil?\n @eng = @user.engagements.find_by_post_id(@post.id)\n redirect_to(@post.get_url_for(@user, 'show')) && return unless @eng.nil?\n end \n else \n #Special case: If non-member joined a post and visiting the post for the first time\n #there would not be an engagement record. So fix this by creating eng. record\n @eng = @user.engagements.find_by_post_id(@post.id)\n if @eng.nil?\n sp_exists = SharedPost.find(:first, :conditions => ['post_id = ? and user_id = ?', @post.id, @user.id])\n if !sp_exists.nil?\n @eng = create_engagement(sp_exists)\n sp_exists.destroy\n else\n flash[:error] = \"It appears you have not joined this contest. Please join by clicking on your Open invitation link.\"\n render 'posts/404', :status => 404, :layout => false and return\n end\n end\n\n #display the count of unread records\n unread = @post.unread_comments_for(@user)\n #comment_notice = unread > 0 ? pluralize(unread, 'comment') : \"No new comments\"\n @comment_notice = unread.to_s + \" comments since your last visit\"\n @last_viewed_at = @post.last_viewed_at(@user)\n\n @engagement = Engagement.new\n @eng = @user.engagements.find_by_post_id(@post.id)\n @eng.update_attribute( :last_viewed_at, Time.now )\n end\n else\n flash[:error] = \"We could not locate this post. Please check the address and try again.\"\n render 'posts/404', :status => 404, :layout => false and return\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post }\n end\n end", "def show\n @post = Post.find(params[:id])\n if current_user.teenager\n @post_client=Client.find(@post.client_id).user_id\n end\n end", "def show\n @user_profile = UserProfile.find(params[:id])\n\n #refactor this code out also we can probably just\n #get the avatar url and put it into a hash to pass to the view will be faster\n #also need to load up the posts better\n @followed_users_profile_list = Array.new\n @followed_users_post_list = Array.new\n followed_users = @user_profile.user.all_follows\n followed_users.each do |followed|\n @followed_users_profile_list << User.find(followed.followable_id).user_profile\n posts = User.find(followed.followable_id).posts\n posts.each do |post|\n @followed_users_post_list << post\n end\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_profile }\n end\n end", "def user_post\n @posts = Post.where(user_id: current_user.id)\n\n if @posts.nil?\n render :json => {message: \"Cannot find post\" }\n end\n\n render :index\n end", "def set_post\n @profile = Profile.find(params[:id])\n end", "def index\n @posts = @current_user.posts\n end", "def index\n puts \"\\n******* post/index *******\"\n puts \"** session[:user_id], #{session[:user_id]}\"\n @user = User.where(id: session[:user_id]).first\n @posts = Post.where(user_id: session[:user_id])\n end", "def show\n @user = page_user\n @posts = @user.posts\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @user }\n format.json { render :json => @user }\n end\n end", "def profile\n # grab the username from the URL as :id\n @user = User.find(session[:user_id])\n #@followers = Relationship.all.where(\"followed_id = ?\", User.find_by_username(params[\"id\"]).id)\n #@following = Relationship.all.where(\"follower_id = ?\", User.find_by_username(params[\"id\"]).id)\n #@posts = Post.all.where(\"user_id = ?\", User.find_by_username(params[\"id\"]).id)\n end", "def show\n @user = current_user\n end", "def show\n @profile = current_user\n @projects = Project.all \n @user = current_user\n end", "def show\n @post = current_user.posts.find_by_id(params[:id])\n redirect_to root_path, :alert => 'An error has occured.' unless @post\n end", "def show\n @eg_post = EgPost.find(params[:id])\n authorize @eg_post\n end", "def show\n @user = User.find(params[:id]) \n @user_me = retrieve_authenticated_user\n end", "def show\n @user = User.find_by_slug(params[:user_id])\n @post = @user.posts.find(params[:id])\n @image = @post.image\n @comments = @post.comments.all\n\n @title = @post.created_at\n\n respond_with(@user, @post)\n\n end", "def show\r\n @profile = Profile.find(params[:id])\r\n @user = User.find(@profile.user_id)\r\n @posts_raw = Post.where(user_id: @user.id).order(created_at: :desc)\r\n @posts = Array.new\r\n @posts_raw.each do |post|\r\n if not post.is_in_dumpster?\r\n @posts << post\r\n end\r\n end\r\n @votes = Hash.new\r\n @comments = Hash.new\r\n @posts.each do |post|\r\n @votes[post.id] = post.get_votes\r\n @comments[post.id] = Comment.get_post_comments(post.id)\r\n end\r\n @new_post = Post.new\r\n if current_user\r\n @new_comment = Comment.new(user_id: current_user.id)\r\n end\r\n @shared_posts = Array.new\r\n @up_posts = Array.new\r\n @down_posts = Array.new\r\n @user_comments = Comment.get_posts_by_comments(@profile.user_id)\r\n\r\n all_shared_posts = SharedPost.all\r\n all_voted_posts = Validation.all\r\n\r\n\r\n if all_shared_posts.length > 0\r\n shared_post_first = all_shared_posts.where(user_id: @user.id).first\r\n end\r\n if shared_post_first\r\n @shared_posts = shared_post_first.get_shared_posts\r\n end\r\n\r\n if all_voted_posts.length > 0\r\n voted_post_first = all_voted_posts.where(user_id: @user.id).first\r\n end\r\n if voted_post_first\r\n @up_posts = voted_post_first.get_voted_posts['up']\r\n @down_posts = voted_post_first.get_voted_posts['down']\r\n end\r\n\r\n end", "def show\n @user = User.find(params[:user_id])\n @post = @user.posts.find(params[:id])\n\n render json: @post\n end", "def index\n @posts = Post.all\n @user = current_user\n end", "def show\n @user = current_user\n end", "def show\n @user = current_user\n end", "def show\n @user = current_user\n end", "def show\n @user = current_user\n end", "def show\n @user = current_user\n end", "def show\n @user = current_user\n end", "def show\n @user = current_user\n end", "def show\n @user = current_user\n end", "def show\n @user = current_user\n end", "def show\n @user = current_user\n end", "def show\n @user = current_user\n end", "def show\n @user = current_user\n end", "def show\n @user = current_user\n end", "def show\n @user = current_user\n end", "def show\n @user = current_user\n end", "def show\n @user = current_user\n end", "def show\n\n\t\t@current_profile = Profile.get_profile params[:id], \"asdf\"\n\n\t\tpretty_render \"api/public_user\"\t\n\n\tend", "def index\n @profiles = current_user\n end", "def profile\n #grab the username from user and url\n \n if (User.find_by_username(params[:id]))\n @username = params[:id]\n else\n redirect_to root_path, :notice => \"User Not found\"\n end\n@posts= Post.all.where(\"user_id = ?\",User.find_by_username(params[:id]))\n@newPost = Post.new\nend", "def show\n @profile = Profile.find(params[:id]) || current_user.profile\n end", "def show\n\t\t@post\n\tend", "def show \n\t\t@post = Post.find(params[:id]) \n\t\t@last_post = Post.last\n\tend", "def set_post\n @post = current_user.posts.find(params[:id])\n end" ]
[ "0.78440815", "0.779411", "0.76547605", "0.7480559", "0.7429356", "0.73974055", "0.7320419", "0.7287811", "0.72701865", "0.7260165", "0.7229102", "0.7225554", "0.72161406", "0.72145724", "0.7202835", "0.71353114", "0.71238047", "0.70719504", "0.7069117", "0.70279247", "0.70273006", "0.7002141", "0.7000673", "0.696792", "0.6964087", "0.69625443", "0.6922281", "0.69083846", "0.69025475", "0.688497", "0.6879543", "0.6878478", "0.6866994", "0.68525255", "0.6817147", "0.6814674", "0.681213", "0.67873245", "0.67855006", "0.67671406", "0.67640597", "0.6762836", "0.67622095", "0.6740085", "0.6735822", "0.6732473", "0.6726349", "0.67247415", "0.6706806", "0.67055386", "0.66915554", "0.66883594", "0.6682801", "0.667684", "0.6672463", "0.6672272", "0.6668425", "0.6667073", "0.66619444", "0.6654904", "0.6651967", "0.66418535", "0.66127187", "0.6605335", "0.6605252", "0.6602615", "0.6602254", "0.65888923", "0.65819824", "0.65812397", "0.6579412", "0.6579386", "0.6575203", "0.6572223", "0.65720004", "0.6571687", "0.6557022", "0.6556067", "0.6556067", "0.6556067", "0.6556067", "0.6556067", "0.6556067", "0.6556067", "0.6556067", "0.6556067", "0.6556067", "0.6556067", "0.6556067", "0.6556067", "0.6556067", "0.6555754", "0.6554959", "0.65547484", "0.65521455", "0.6539766", "0.6539606", "0.653424", "0.65296906", "0.6529029" ]
0.67613053
43
redefine your position_taken? method here, so that you can use it in the valid_move? method above.
def position_taken?(board, idx) ["X", "O"].include?(board[idx]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def position_taken?(board, position)\n return false if valid_move?(board, position)\n return true unless valid_move?(board, position)\nend", "def position_taken?\nend", "def valid_move?(board, index)\n if index.between?(0, 8)\n # re-define your #position_taken? method here, so that you can use it in the #valid_move? method above.\n def position_taken?(board, index)\n if board[index] == \" \"\n !false\n elsif board[index] == \"\"\n !false\n elsif board[index] == nil\n !false\n elsif board[index] == \"X\" || board[index] == \"O\"\n !true\n end\n end\n position_taken?(board, index)\nend\nend", "def valid_move?(board, index)\nif position_taken?(board, index) == false\n if between?(index) == true\n true\n else\n false\n end\nelse\n false\nend\nend", "def valid_move?(board, position)\n position = position.to_i\n return false if !valid_position?(position)\n return false if position_taken?(board, position)\n return true\nend", "def valid_move?(position)\n position.between?(0,8) && !position_taken?(position)\n end", "def valid_move?(board, index)\n\nif position_taken?(board,index) == true\n return false\nelsif index > -1 && index < 9\n return true\nelse\n return false\nend\n\nend", "def valid_move?(position)\r\n @index = position.to_i-1\r\n if @index.between?(0,8) && !position_taken?(@index)\r\n return true\r\n else\r\n return false\r\n end\r\n end", "def valid_move?(board,position)\n valid = nil\n if position >= 0 && position <=8\n case position_taken?(board,position)\n when true\n valid = false\n when false\n valid = true\n end\n end\n\n return valid\nend", "def valid_move?(position)\n if is_number?(position)\n if position.to_i.between?(0, 10)\n if position_taken?(position.to_i-1)\n false\n else\n true\n end\n else \n false\n end\n else\n false\n end\n end", "def valid_move?( board, index )\n if index >= 0 && index <= 8\n if position_taken?( board, index ) # this is the one\n return false\n else\n return true\n end\n else\n return false\n end\nend", "def valid_move?(fir, sec)\n if (sec < 0) || (sec > 8)\n return false\n elsif position_taken?(fir,sec)\n return false\n else\n return true\n end\nend", "def valid_move?(board,pos)\n if !position_taken?(board,pos.to_i-1) && pos.to_i.between?(1,9)\n return true\n elsif position_taken?(board,pos.to_i-1) && pos.to_i.between?(1,9)\n return false\n end\nend", "def valid_move?(board, ix)\n if position_taken?(board, ix) == false && move_val?(ix) == true\n return true\n else\n false\n end\nend", "def valid_move?(new_x, new_y)\n true\n end", "def valid_move?(board, new_index)\n if 8 < new_index || new_index < 0\n return false\n elsif position_taken?(board, new_index) == true\n return false\n else\n return true\n end\nend", "def valid_move?(position)\n !taken?(position) && position.to_i >0 && position.to_i <=9\n end", "def valid_move?(board,position)\n if position.to_i.between?(1,9) && !position_taken?(board,position.to_i-1)\n true\n else\n end\nend", "def valid_move?(board, position)\n # position = position.to_i \n position.to_i. between?(1, 9) && !position_taken?(board, position.to_i-1)\nend", "def valid_move?(board, indx)\n if position_taken?(board, indx)\n false \n elsif (indx < 0 || indx > 8)\n false\n else \n true \n end \nend", "def valid_move? (board, position)\n position = position.to_i - 1\n (position.between?(0,8)) && (position_taken?(board, position) == false)\nend", "def valid_move?(board, indx)\n if indx>=0 && indx<board.length && !position_taken?(board,indx)\n true\n else\n false\n end\nend", "def valid_move?(board, index)\n if position_taken?(board, index) == true\n false\n elsif index > 8 || index < 0\n false\n else\n true\n end\nend", "def valid_move?(board, position)\n position.to_i.between?(1,9) && !position_taken?(board, position.to_i-1)\nend", "def valid_move?(board, position)\n position_taken?(board, position) == false && position.between?(0, 8) ? true : false\nend", "def valid_move?(position)\n position = position.to_i - 1\n if position_taken?(position) == false && position.to_i.between?(0, 8)\n return true\nelsif position_taken?(position) == true\n return false\nelse \n return false\nend\nend", "def valid_move?(position)\n index=position.to_i - 1\n index.between?(0, 8) && !(position_taken?(index))\n end", "def valid_move?(board,index)\n if index > 9 || index < 0\n return false\n elsif position_taken?(board,index)\n return false\n else\n return true\n end\nend", "def position_taken?(board,position)\n return false if [\" \", \"\", nil].include?(board[position])\n return true if [\"X\", \"O\"].include?(board[position])\n raise \"#{board[position]} is not a valid move\"\nend", "def valid_move?(board, index)\n if position_taken?(board, index) or !(index >= 0 and index < 9)\n false\n else\n true\n end\nend", "def valid_move?(board, position)\n position.to_i.between?(1,9) && !position_taken?(board,position.to_i-1)\n\nend", "def valid_move?(board, position)\n position = position.to_i\n if(position.between?(1,9))\n position -=1\n if(position_taken?(board, position))\n false\n else\n true\n end\n end\nend", "def valid_move?(board,position)\n if !position.is_a?(Integer)\n position = position.to_i\n end\n if(position>=1 && position<=board.length && !position_taken?(board,position))\n return true\n end\n return false\nend", "def valid_move?(board, position)\n if !(position_taken?(board, position)) && position.between?(0, 8)\n return true\n else\n return false\n end\nend", "def valid_move?(board, position)\n position = position.to_i - 1\n if position_taken?(board, position) == false && position.to_i.between?(0, 8)\n return true\nelsif position_taken?(board, position) == true\n return false\nelse \n return false\nend\nend", "def valid_move?(board, index)\n if position_taken?(board, index)\n false\n elsif index > 8 || index < 0\n false\n else\n true\n end\nend", "def valid_move?(board, position)\n position = position.to_i - 1\n if position_taken?(board, position)\n return false\n else\n if position.between?(0,8) && (board[position] != \"X\" || board[position] != \"O\")\n return true\n else\n return false \n end\n end\nend", "def valid_move?(input_position)\n num = self.convert_to_i(input_position)\n num.between?(1, 9) && !self.taken?(num)\n end", "def valid_move?(board, position)\n if position.to_i>=1 && position.to_i<=9 && !position_taken?(board, position.to_i-1)\n return true\n else\n return false\n end\nend", "def valid_move?(board,position)\n position=position.to_i-1\n if position.between?(0,8) && !position_taken?(board, position)\n true\n else\n false\n end\nend", "def valid_move?(board, position)\n position.between?(0, 8) && !position_taken?(board, position)\nend", "def valid_move?(position)\n if !position_taken?(position) && position.between?(0,8)\n true\n else\n false\n end\n end", "def valid_move?(board, index)\n if index.between?(0, 8) && position_taken?(board, index) == false\n true\n else\n false\n end\nend", "def valid_move?(board, i)\n # check if position taken or 'out-of-bounds'\n if (position_taken?(board, i) == true) || (i > 8) || (i < 0)\n return false\n else \n return true\n end \nend", "def move_is_valid?(position)\n\t\tif @played_positions.index(position)\n\t\t\tresult = false\n\t\telse \n\t\t\t@played_positions << position \n\t\t\tresult = true\n\t\tend\n\t\tresult\n\tend", "def valid_move?(board, position)\n indexed_position = position.to_i - 1\n indexed_position.between?(0,8) && !position_taken?(board, indexed_position)\nend", "def valid_move?(board,index)\n if (index >= 0 && index <=8)\n if (position_taken?(board,index))\n return false\n else\n return true\n end\n else\n return false\n end\nend", "def valid_move?(board, position)\n position = (position.to_i - 1)\n\n if position.between?(0, 8) && !position_taken?(board, position)\n true\n else false\n end\nend", "def valid_move?(board, position)\n position = position.to_i - 1\n position_taken?(board, position) == false && position.between?(0,8) == true\nend", "def valid_move?(board, index)\n if index.between?(0, board.count - 1) && position_taken?(board, index) == false\n true\n else\n false\n end\nend", "def valid_move?(board, index)\n \nif position_taken?(board, index) === false && index.between?(0, 8)\n return true\nelse \n return false\nend\nend", "def valid_move?(position)\n if !position.is_a?(Integer)\n position = position.to_i\n end\n if(position>=1 && position<[email protected] && !position_taken?(position))\n return true\n end\n return false\n end", "def valid_move?(board, position)\n !position_taken?(board, position) && position.between?(0,8)\nend", "def valid_move?(board, position)\n position = position.to_i - 1\n if position.between?(0, 8) && !position_taken?(board, position)\n true\n end\nend", "def valid_move?(board,index)\n if position_taken?(board,index) == true\n return false\n elsif index > 8 or index < 0\n return false\n else\n return true\n end\n end", "def valid_move?(board, position)\n position = position.to_i\n \n if (position_taken?(board, position) ==false) && position.between?(1,9)\n return true\n else\n return false\n end\nend", "def valid_move?( board, index )\n\n if (index.between?(0,8) ) && ( position_taken?(board, index) == false )\n return true\n else\n return false\n end\n\nend", "def valid_move?(board, index)\n if board[index].nil? || position_taken?(board, index) || board[index] == \"X\" || board[index] == \"O\"\n false\n else\n true\n end\nend", "def valid_move? (board, index)\n if index.between?(0, 8) && !position_taken?(board, index)\n true \n end \nend", "def valid_move?(board, position)\n position = position.to_i\n \n if !(position_taken?(board, position-1)) && position.between?(1,9)\n return true\n else\n return false\n end\nend", "def valid_move?(board, index)\nif !(index.between?(0,8))\n return false\nelsif position_taken?(board, index)\n return false \nelse \n return true\n end\nend", "def valid_move?(a,i)\r\n if i.between?(0,8) && !position_taken?(a,i)\r\n true\r\n else\r\n false\r\n end\r\nend", "def valid_move?(board,index)\n if index < 0\n false\n else\n if index > 8\n false\n else\n !position_taken?(board,index)\n end\n end\nend", "def valid_move?(location)\n location.to_i.between?(1,9) && !position_taken?(location.to_i-1)\n end", "def valid_move?(board, index)\nif index.between?(0,8) && !position_taken?(board, index)\n true\nelse\n false\nend\nend", "def valid_move?(board, index)\n if index.between?(0, 8) && position_taken?(board, index) == false\n true\n else position_taken?(board, index) == true\n nil\n end\nend", "def position_taken?(board, position)\n if !(board[position.to_i - 1] == \"X\" || board[position.to_i - 1] == \"O\")\n return true\n else \n return false\n end\nend", "def valid_move?(board, idx)\n if position_taken?(board, idx) == false && idx.between?(0, 8)\n return true\n else\n return false\n end\nend", "def valid_move?(position) ### changed from index to position - ER 2017\n\n if (position > 9) || (position < 0) #if index (position on board entered by user) is greater than 9 or less than 0, return false\n false\n elsif position_taken?(position) ###otherwise, if position on board is taken, return false\n false\n else position.between?(0, 8) ###finally, if the position isn't taken, and the index (position on board entered by user) is between 0 and 8, return true\n true\n end # end if...elsif statements\n end", "def valid_move?(index)\n\t\tindex < 9 && !position_taken?(index) ? true : false\n\tend", "def position_taken?(board, index_to_validate)\n if (board[index_to_validate] == \"X\" || board[index_to_validate] == \"O\")\n return true\n end\n return false # NOTE: if we arrive here, the position is definitely not taken\nend", "def position_taken?(board, pos)\n if board[pos]==\"X\" || board[pos]==\"O\"\n taken = true\n else\n taken = false\n end\n taken\nend", "def valid_move?(board, position)\n if position_taken?(board, position) == false && position.to_i.between?(0,8)\n true\n else\n false\n end\n end", "def valid_move?(board,index)\n if index >= 0 && index <= 8\n if !position_taken?(board, index)\n return true\n else \n return false\n end\n else \n return false\n end\nend", "def valid_move?(board, index)\n if index.between?(0, 8) && (position_taken?(board, index) == false)\n true\n elsif (index.between?(0,8) == false) || (position_taken?(board, index) == true)\n false\n end\nend", "def valid_move?(move_index)\r\n #valid if position is NOT taken\r\n valid = !self.position_taken?(move_index)\r\n if valid == true\r\n if move_index.between?(0,8)\r\n valid = true\r\n else\r\n valid = false\r\n end\r\n end\r\n valid\r\n end", "def valid_move?(board,index)\n if position_taken?(board,index) == FALSE && index.between?(0, 8) == TRUE\n TRUE\n else\n FALSE\n end\nend", "def valid_move?(board, index)\nif position_taken?(board, index)\nreturn false\nelsif !index.between?(0, 8)\n return false\n else\n return true\n end\nend", "def valid_move?(board, index)\n index.between?(0, 8) && position_taken?(board, index) == false\n\nend", "def valid_move?(board,index)\n if index.between?(0,8) && !position_taken?(board,index)\n true\n else\n false\n end\n\nend", "def valid_move?(board,index)\n if index.between?(0, 8) && !(position_taken?(board, index))\n true\n else \n false\n end\nend", "def position_taken?(board, new_index)\n if board[new_index] == \"X\" || board[new_index] == \"O\"\n return true\n else\n return false\n end\nend", "def valid_move?(board, index)\n if !(index.between?(0,8))\n return false\n end\n if (position_taken?(board,index))\n return false\n end\n true\nend", "def valid_move?(board, index)\nif index.between?(0,8) && !position_taken?(board, index)\n true\n else\n false\n end\nend", "def valid_move?(board, index)\n if index.between?(0,8) && !position_taken?(board, index)\n puts \"this is a valid move\"\n return true\n else\n return false\n end\nend", "def valid_move?(board, index)\r\n if index.between?(0, 8) && ! position_taken?(board, index)\r\n return TRUE\r\n else \r\n return FALSE\r\n end\r\nend", "def valid_move?(board, index)\n if position_taken?(board, index) == false && index.between?(0, 8) == true\n true\n else\n false\nend\nend", "def position_taken?(move_index)\r\n if @board[move_index] == \" \"\r\n false\r\n else\r\n true\r\n end\r\n end", "def valid_move?(board,index)\n if !position_taken?(board,index) && index >= 0 && index <=8\n return true\n else \n return false\n end\nend", "def valid_move? (board, index)\n if (index).between?(0,8) == true && position_taken?(board, index) == false\n return true\n else\n return false\n end\nend", "def valid_move?(board,index)\n if index.between?(0,8) && position_taken?(board,index)\n true\n end\nend", "def position_taken?(board,move)\n if board[move]!=\" \"\n return false\n end\nreturn true\nend", "def position_taken?(board,pos)\n if board[pos.to_i]==\"X\" || board[pos.to_i] ==\"O\"\n return true\n else\n return false\n end\nend", "def position_taken?(board, position)\n return true if board[position - 1] == \"X\" || board[position - 1] == \"O\"\n false\nend", "def position_taken?(location)\n !(board[location] == \" \" || board[location].nil?)\nend", "def valid_move?(input)\n (0..8).include?(input) && !position_taken?(input)\n end", "def valid_move?( board, position )\n position_int = position.to_i\n position_ary = position_int - 1\n if !(position_taken?( board, position_ary )) && position_ary.between?( 0, 8 )\n true\n else\n false\n end\nend", "def valid_move?( board, position )\n position_int = position.to_i\n position_ary = position_int - 1\n if !(position_taken?( board, position_ary )) && position_ary.between?( 0, 8 )\n true\n else\n false\n end\nend", "def valid_move?(index)\n if position_taken?(index)\n false\n elsif index < 0 || index > 8\n false\n else\n true \n end\n end", "def valid_move?(board, position)\n index = position.to_i\n if position_taken?(board, index) == false && index.between?(0, 8)\n return true\n else\n return false\n end\nend", "def valid_move?(board, index)\n# binding.pry\n index.between?(0,8) && !position_taken?(board, index)\nend" ]
[ "0.84089375", "0.8162548", "0.80914116", "0.8028049", "0.8014509", "0.7898257", "0.78943205", "0.78863996", "0.78445494", "0.78427726", "0.78322136", "0.78148186", "0.78134465", "0.7810213", "0.7802794", "0.78019965", "0.78009653", "0.77892697", "0.7782964", "0.777476", "0.77740395", "0.7771367", "0.7767533", "0.7757887", "0.7755835", "0.7754798", "0.7750462", "0.77417445", "0.77400064", "0.77387905", "0.7727324", "0.7726927", "0.7726391", "0.7725737", "0.7722249", "0.77216715", "0.77188325", "0.7716459", "0.7715759", "0.7697509", "0.7692037", "0.7686372", "0.76802915", "0.7679141", "0.7674355", "0.76740724", "0.76725537", "0.7671101", "0.7662629", "0.765899", "0.76585126", "0.7643821", "0.7642699", "0.76426005", "0.7642", "0.7637012", "0.7633774", "0.76257694", "0.76238066", "0.762115", "0.76184845", "0.76145756", "0.7613178", "0.7609597", "0.7609532", "0.7602318", "0.7599159", "0.7595818", "0.75929064", "0.7592081", "0.7590335", "0.7578851", "0.7578171", "0.757784", "0.7575348", "0.7573866", "0.7566832", "0.756671", "0.7557961", "0.75540113", "0.75510806", "0.75506806", "0.7549246", "0.7549225", "0.7541533", "0.7539705", "0.75395393", "0.75394094", "0.753866", "0.7537366", "0.7535385", "0.7533926", "0.7532312", "0.753218", "0.7530084", "0.75300235", "0.7529606", "0.7529606", "0.7527527", "0.7526119", "0.7525708" ]
0.0
-1
Now extend the Array class to include my_select that takes a block and returns a new array containing only elements that satisfy the block. Use your my_each method!
def my_select(&prc) selection = [] i = 0 while i < self.length if prc.call(self[i]) selection << self[i] end i += 1 end return selection end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "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 my_select\n arr = []\n self.my_each {|x| arr << x if yield x}\n arr\n end", "def my_select(&block)\n result = []\n my_each do |elem|\n result << elem if block.call(elem) == true\n end\n result\n end", "def my_select\n if block_given?\n new_array = []\n self.my_each{|item| array_new << item if yield(self)}\n # This is the same as:\n # for i in 0..self.length-1\n # new_array << self[i] if yield(self[i])\n # end\n new_array\n end\n end", "def my_select\n\t\treturn_array = []\n\t\tself.my_each do |element|\n\t\t\tif yield(element) == true\n\t\t\t\treturn_array << element\n\t\t\tend\n\t\tend\n\t\treturn return_array\n\tend", "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 my_select\n return self unless block_given?\n new_arr = []\n self.my_each { |s| new_arr << s if yield(s) }\n return new_arr\n end", "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 my_select\n\n\t\tselect_array = []\n\t\t# call my each\n my_each do | num |\n \tif yield( num )\n \t\tselect_array << num\n \telse\n \t\tnext\n \tend\n\n\n end\n\n return select_array\n\n\tend", "def my_select(&prc)\n\t\tnew_array = []\n\n\t\tself.my_each do |ele|\n\t\t\tnew_array << ele if prc.call(ele)\t\t\t\t\n\t\tend\n\n\t\tnew_array\n\tend", "def my_select\n new_array = []\n each do |value|\n new_array << value if yield(value)\n end\n new_array\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 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_select(&prc)\n arr = []\n self.my_each { |el| arr << el if prc.call(el) }\n arr\n end", "def my_select(&prc)\n result_array = []\n self.my_each {|el| result_array << el if prc.call(el)}\n result_array\n end", "def filter(array, block)\n return array.select(&block) # Your code here\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 my_select(array)\n counter = 0\n new_array = []\n while counter < array.size\n if yield(array[counter])\n new_array << array[counter]\n else\n end\n counter += 1\n end\n return new_array\nend", "def filter(array, block)\n return array.select &block\nend", "def my_select(array)\n i = 0\n select = []\n while i < array.length\n if (yield(array[i]))\n select << array[i]\n end\n i+=1\n end\n select\nend", "def filter(array, block)\n return array.select(&block)\nend", "def filter(array, block)\n return array.select(&block)\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 select\n new_array = []\n @array.size.times do |index|\n value = @array[index]\n if yield(value)\n new_array << value\n end\n end\n\n new_array\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 my_select (collection)\n if block_given?\n i = 0 \n new_collection = []\n \n while i < collection.length \n if yield(collection[i]) \n new_collection << collection[i]\n end\n i += 1\n end\n \n else\n puts \"Hey! No block was given!\"\n end\n new_collection \nend", "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 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 select(array)\n counter = 0\n new_array = []\n while counter < array.size\n value = yield(array[counter])\n if value\n new_array << array[counter]\n end\n counter += 1\n end\n\n new_array\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 select(array)\n counter = 0\n ret_array = []\n while counter < array.size\n ret = yield(array[counter])\n ret_array << array[counter] if ret\n counter += 1\n end\n ret_array\nend", "def my_select\n return to_enum unless block_given?\n\n selected = []\n my_each { |i| selected << i if yield(i) }\n selected\n end", "def select(array)\n counter = 0\n result = []\n until counter == array.size do\n result << array[counter] if yield(array[counter])\n counter += 1\n end\n result\nend", "def my_select( proc_argument = nil )\n result = []\n\n my_each do |element|\n if block_given? \n result << element if yield(element)\n else\n result << element if proc_argument.call(element)\n end\n end\n result\n end", "def my_select\n if block_given?\n arr = Array.new\n self.my_each do |x|\n if yield x\n arr << x\n end\n end\n arr\n else\n self.to_enum\n end\n end", "def my_select\n return self unless block_given?\n\n result = self.class.new\n\n if is_a? Array\n my_each { |val| result.push(val) if yield(val) }\n elsif is_a? Hash\n my_each { |key, val| result[key] = val if yield(key, val) }\n else\n warn 'Incompatible type!'\n end\n result\n end", "def my_select\n return to_enum unless block_given?\n array = []\n to_a.my_each { |n| array << n if yield(n) }\n array\n end", "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 select\n out = []\n\n each { |e| out << e if yield(e) }\n\n out\n end", "def selecting(&blk)\n Enumerator.new do |yielder|\n each do |*item|\n yielder.yield *item if blk.call(*item)\n end\n end\n end", "def find_all(&block)\r\n copy_and_return(@records.select(&block))\r\n end", "def select\n a = []\n @set.each do |e,_|\n if yield(e)\n a << e\n end\n end\n a\n end", "def not_mutate(arr)\n # calls the '.select' method on the 'arr' parameter with a condition given\n arr.select { |i| i > 3 }\nend", "def select(&block)\n result = empty_copy\n values.select(&block).each{|mach| result << mach}\n result\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 filter!(&block)\n @rows.select!(&block)\n end", "def select(&block)\n ary = []\n self.class.members.each{|field|\n val = self[field]\n ary.push(val) if block.call(val)\n }\n ary\n end", "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 my_select(parameter = nil)\n arr = []\n if block_given?\n my_each { |value| arr.push(value) if yield(value) }\n elsif parameter.nil?\n return Enumerator.new(arr)\n else\n my_each { |value| arr.push(value) if parameter.call(value) }\n end\n arr\n end", "def select(&block)\n append(Filter.new(&block))\n end", "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 select(&block); end", "def select!(&block); end", "def select(&block)\n @select = block if block\n @select\n end", "def select(&block)\n alter do\n @lines = @lines.select(&block)\n end\n end", "def xnor_select(arr, proc_1, proc_2)\n new_arr = []\n arr.each do |ele|\n new_arr << ele if ( proc_1.call(ele) && proc_2.call(ele) ) || ( !proc_1.call(ele) && !proc_2.call(ele) )\n end\n new_arr\nend", "def select_nodes(&block)\n each_node.select &block\n end", "def non_mutate(arr)\n arr.select {|i| i > 3} # => 4, 5\nend", "def select( &block )\r\n\t\t\treturn @contents.select( &block )\r\n\t\tend", "def each(&block)\n @array.each(&block)\n end", "def select(&blk)\n alter do\n @lines = @lines.select(&blk)\n end\n end", "def find_a(array)\n new_a_array = []\n #binding.pry\n array.select do |item|\n if item[0]==\"a\"\n new_a_array<< item\n else\n puts \"nil\"\n end\n end\nnew_a_array\nend", "def test_array_select2\n a = [2, 5, 2, 2, 3]\n num = a.select {|n| n == 2}\n assert_equal([2, 2, 2], num)\n end", "def select(&block)\n self.class.new @members.select(&block)\n end", "def test_array_select\n a = [2, 5, 2, 2, 3]\n num = a.select {|n| n == 1}\n assert_equal([], num)\n end", "def each(&block)\n to_a.each(&block)\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 selectElements\n ([expression] + elements).compact if select\n end", "def select!(&block)\n #@file_list = FileList.all(*to_a.select{ |f| block.call(f) })\n @file_list = @file_list.select{ |f| block.call(f) }\n end", "def each(&block)\n array.each(&block)\n end", "def each(&block)\n @array.each(&block)\n end", "def each(&block)\n @array.each(&block)\n end", "def collect!(&block)\n unless block_given?\n return ArrayEnumerator.new(self, :collect! ) # for 1.8.7\n end\n i = 0\n sz = self.__size\n enum_res = self.each { | elem | # use self.each to handle break in block\n self.__at_put(i, block.call( elem ) )\n i += 1\n }\n if i < sz\n return enum_res\n end\n self\n end", "def my_collect(array)\n if block_given?\n i = 0\n collection = []\n while i < array.length\n collection << yield(array[i])\n i+=1\n end\n else\n puts \"Hey! No block given!\"\n end #block_given?\n collection\nend", "def select!(&block)\n block or return enum_for(__method__)\n n = size\n keep_if(&block)\n size == n ? nil : self\n end", "def selected_values &block\n ar = []\n selected_rows().each do |i|\n val = @list[i]\n if block_given?\n yield val\n else\n ar << val\n end\n end\n return ar unless block_given?\n end", "def my_each(array)\n\t\t#array = []\n\t\tindex = 0\n\t\twhile index < array.length\n\t\t\tyield(array[index])\n\t\t\tindex += 1\n\t\tend\n\t\treturn array\n\tend", "def each(&block)\n to_a.each(&block)\n end", "def my_each(array)\n if block_given?\n i = 0\n while i < array.length\n yield array[i]\n i = i + 1\n end\n array\n end\nend", "def my_each(array)\n if block_given?\n counter = 0\n while counter < array.length\n yield (array[counter])\n counter += 1\n end\n array\n else\n puts \"No block given\"\n end\nend", "def select!\n return enum_for(:select!) if not block_given?\n each { |n| remove(n) if not yield n }\n self\n end", "def filter(arr)\n # create new empty array to populate with filtered elements\n arr2 = []\n # for each element in array, check if it passes the test in the block, called by yield, and if it does add it to the new array\n arr.each { |x| arr2 << x if yield(x) }\n # return the new array, setting the original array to these new values\n arr2\nend", "def thread_select\n selection = Array.new\n thread_each do |e|\n selection << e if yield(e)\n end\n selection\n end", "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 each(&block)\r\n @arr.each &block\r\n end", "def each(&block)\r\n @arr.each &block\r\n end", "def select(numbers)\r\nreturn numbers.select { |x| x < 5 }\r\nend", "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 custom_each(array)\n i = 0\n while i < array.length\n yield array[i]\n i += 1\n end\nend", "def select(&block)\n @_componentable_container.select(&block)\n end", "def my_collect(array) # put argument(s) here\n # code here\n i = 0\n result = []\n\n while i < array.size\n\n result << yield(array[i])\n i += 1\n end\nresult\nend", "def filter(&block)\n result = yield\n return result.map { |o| filter { o } } if result.is_a?(Array)\n result\n end", "def select_arr(arr)\n # select and return all odd numbers from the Array variable `arr`\n arr.select {|a| a % 2 != 0}\nend", "def each(&block)\n to_a.each(&block)\n end", "def each(&block)\n to_a.each(&block)\n end", "def lselect(&blk)\n Enumerator.new do |out|\n self.each do |i|\n out.yield i if blk.call(i)\n end\n end\n end", "def my_each(array)\n if block_given?\n i = 0\n \n while i < array.length \n yield array[i] \n i = i + 1 \n end\n \n array\n else\n return \"Hey! No block was given!\"\n end\nend", "def array_select\n golf_scores=[75,76,78,77,79,74,72] # this is the orignal array\n golf_scores.select {|scores| scores<78 } #this example return all the scores from\n # golf_scores array that are less than 78\nend", "def each(&block)\n find_each(&block)\n end", "def my_select(collection)\n new_collection = [] #create new empty array\n i = 1 #counter variable i set to 1 (not 0, which is even)\n while i < collection.length #start while loop, execute code below as long as i is less than the length of the array\n (new_collection << i) if i.even? # each number gets appended to new_collection that is even\n i = i + 1 #increment value of i variable\n end #end do loop\n new_collection #return new_collection array\nend" ]
[ "0.84452134", "0.83266735", "0.8278081", "0.8233434", "0.81102276", "0.8094788", "0.8029384", "0.7981806", "0.7887911", "0.78706664", "0.7844753", "0.7842753", "0.77930135", "0.7710922", "0.77061504", "0.7697411", "0.7643738", "0.76163954", "0.7581148", "0.75727606", "0.7539117", "0.74296695", "0.74116987", "0.7377544", "0.73677504", "0.72720134", "0.7270406", "0.7256465", "0.72407746", "0.7217763", "0.71887404", "0.70997703", "0.70596033", "0.704774", "0.70185614", "0.6981216", "0.69467884", "0.687344", "0.6868449", "0.6816278", "0.6814137", "0.68026847", "0.67591274", "0.6652696", "0.6612395", "0.65644807", "0.65253127", "0.64861864", "0.644696", "0.6429755", "0.64160377", "0.64060366", "0.639316", "0.6347641", "0.6332227", "0.63021076", "0.62934643", "0.62828803", "0.62802047", "0.6267615", "0.6247519", "0.62179506", "0.6191046", "0.61848015", "0.6184523", "0.6163284", "0.61370534", "0.6133301", "0.61215955", "0.61160696", "0.6115176", "0.6115176", "0.6113734", "0.6110402", "0.61074257", "0.60945106", "0.60898715", "0.60827875", "0.6081396", "0.60748726", "0.60579413", "0.6054615", "0.60514414", "0.60505646", "0.6019794", "0.6019794", "0.6004718", "0.6002321", "0.59995043", "0.5996596", "0.5994316", "0.5989367", "0.5963654", "0.5955441", "0.5955441", "0.5949866", "0.59478545", "0.59352785", "0.5933909", "0.5932081" ]
0.6798151
42
Write my_reject to take a block and return a new array excluding elements that satisfy the block.
def my_reject(&prc) rejection = [] i = 0 while i < self.length if !prc.call(self[i]) rejection << self[i] end i += 1 end return rejection end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def my_reject(&prc)\n\t\tnew_array = []\n\n\t\tself.my_each do |ele|\n\t\t\tnew_array << ele if !prc.call(ele)\t\t\t\t\n\t\tend\n\n\t\tnew_array\n\tend", "def my_reject(&prc)\n arr = []\n self.my_each { |el| arr << el if !prc.call(el) }\n arr\n end", "def my_reject(arr,&prc)\n remainders = []\n arr.each {|el| remainders << el if prc.call(el)}\n remainders\nend", "def reject(&block)\n append(Filter.new { |value| ! block.call(value) })\n end", "def reject(list, &block)\n list.reject(&block)\nend", "def reject\n return enum_for(:reject) if not block_given?\n select { |item| !yield(item) }\n end", "def reject(&block)\n alter do\n @lines = @lines.reject(&block)\n end\n end", "def reject(&block)\n @reject = block if block\n @reject\n end", "def consume_each(&block)\r\n @arr = @arr.reject(&block)\r\n end", "def mutating_reject(array)\n i = 0\n loop do\n break if i == array.length\n\n if yield(array[i]) # if array[i] meets the condition checked by the block\n array.delete_at(i)\n else\n i += 1\n end\n end\n\n array\nend", "def reject(&block); end", "def lreject(&blk)\n Enumerator.new do |out|\n self.each do |i|\n out.yield i unless blk.call(i)\n end\n end\n end", "def reject\n C.curry.(->(f, xs) { xs - select.(f, xs) })\n end", "def reject(&blk); end", "def filter_out(arr, &blck)\n # arr.reject { |el| blck.call(el) }\n new_arr = []\n arr.each do |el|\n if !blck.call(el)\n new_arr << el\n end\n end\n return new_arr\nend", "def reject!(&block); end", "def reject(&block)\n return to_enum :reject unless block\n\n ary = []\n self.each{|*val|\n ary.push(val.__svalue) unless block.call(*val)\n }\n ary\n end", "def reject_item(array, item_to_reject)\n # Your code here\nend", "def reject(&block)\n raise \"Missing block\" unless block\n raise \"filter already called on this experiment\" if @request_filter_block\n\n @request_filter_block = block\n end", "def reject_arr(arr)\n arr.reject{|x| x % 3 == 0}\nend", "def reject_item(array, reject_item)\n output_array = []\n\n array.each do |item|\n if item == reject_item\n\n else\n output_array << item\n end\n end\n\n return output_array\nend", "def reject!( &block ) # :yields: key, value\n\t\trval = @data.reject!( &block )\n\t\treturn rval\n\tensure\n\t\t@modified = true if rval\n\tend", "def reject!\n return enum_for(:reject!) if not block_given?\n each { |n| remove(n) if yield n }\n self\n end", "def filter(array, block)\n return array.select(&block)\nend", "def filter(array, block)\n return array.select(&block)\nend", "def filter(array, block)\n return array.select &block\nend", "def reject!\n return Enumerator.new(self, :reject!) unless block_given?\n select! { |key, obj| !yield(key, obj) }\n end", "def reject!(&block)\n @parameters.reject!(&block)\n self\n end", "def my_reject(&prc)\n end", "def not_mutate(arr)\n # calls the '.select' method on the 'arr' parameter with a condition given\n arr.select { |i| i > 3 }\nend", "def reject_without_hooks!( & block )\n\n @without_hooks = true\n\n reject!( & block )\n \n @without_hooks = false\n\n return return_value\n\n end", "def reject!(&b)\n a = reject(&b)\n if a.size == size\n nil # no changes, return nil\n else\n replace(a)\n self\n end\n end", "def filter(array, block)\n return array.select(&block) # Your code here\nend", "def reject(*args, &blk) top.reject(*args, &blk) end", "def reject_arr(arr)\n # reject all elements which are divisible by 3\n arr.reject { |x| x%3 ==0 }\n end", "def filter_out(arr, &prc)\n new_arr = []\n arr.each do |ele| \n if !prc.call(ele)\n new_arr << ele\n end\n end\n new_arr\nend", "def reject_arr(arr)\n arr.delete_if{ |a| a%3 == 0 }\nend", "def filter_out(arr, &prc)\n new_arr = []\n\n arr.each do |ele|\n new_arr << ele if !prc.call(ele)\n end\n new_arr\nend", "def grep_v(pattern, &block)\n result = select { |item| !(pattern === item) }\n result = result.map(&block) if block_given?\n result\n end", "def filter_out!(arr, &prc)\n arr.delete_if { |ele| prc.call(ele)}\n arr\nend", "def reject!\n self.each do |key, value|\n self.delete[key] if yield(key, value)\n end\n return self\n end", "def reject!\n self.each do |key, value|\n self.delete[key] if yield(key, value)\n end\n return self\n end", "def reject!(&block)\n block or return enum_for(__method__)\n n = size\n delete_if(&block)\n size == n ? nil : self\n end", "def reject_with_list_arg!(list, &block)\n self = reject_with_list_arg(list, &block)\n end", "def filter(&block)\n result = yield\n return result.map { |o| filter { o } } if result.is_a?(Array)\n result\n end", "def test_reject\n assert_equal(%w[1 2 4 7 8 11 13 14],\n @kbb.reject { |res| res.include?('Bar') || res.include?('Baz') })\n end", "def reject_puppies(arr)\n arr.reject { |hash| hash[\"age\"] < 3 }\nend", "def filter(arr)\n # create new empty array to populate with filtered elements\n arr2 = []\n # for each element in array, check if it passes the test in the block, called by yield, and if it does add it to the new array\n arr.each { |x| arr2 << x if yield(x) }\n # return the new array, setting the original array to these new values\n arr2\nend", "def discard(a)\n clean = a.select {|x| x >= 5}\n print clean\n \nend", "def reject_num(numbers)\r\nreturn numbers.reject { |x| x < 5 }\r\nend", "def reject_puppies(arr)\n arr.reject{|hash| hash[\"age\"] <= 2}\nend", "def reject!(&block)\n block or return enum_for(__method__) { size }\n n = size\n delete_if(&block)\n self if size != n\n end", "def filter_out!(arr, &prc)\n i = 0\n while i < arr.length\n if prc.call(arr[i])\n arr.delete_at(i)\n else\n i += 1\n end\n end \n arr\nend", "def find_not_all(conditions={}, &block)\n all.reject { |item| match_all(item, conditions, &block) }\n end", "def reject!(&block)\n ensure_loaded\n ret = nil\n each do |key,value|\n if yield(key,value)\n ret = self\n delete(key)\n end\n end\n ret\n end", "def reject(&block)\n new_instance_with_inherited_permitted_status(@parameters.reject(&block))\n end", "def filter_out &block\n @@filter << Proc.new do |test| \n block.call(test) ? false : nil\n end\n end", "def test_0270_reject\n @@log.debug \"test_0270_reject starts\" if @@log.debug?\n assert_respond_to(@list, :reject, \"test_0270_reject_respond\")\n # List false returns\n ta = @list.reject {|obj| (obj.ndata % 2) == 0}\n assert_equal([@bsb, @dad], ta, \"test_0270_reject_eq01\")\n\n @@log.debug \"test_0270_reject ends\" if @@log.debug?\n end", "def filter_out\n result,i = [],0\n while(i < size)\n if yield(e = self.at(i))\n result << e\n delete_at(i)\n else\n i += 1\n end\n end\n result\n end", "def reject!(&b)\n keys = []\n self.each_key{|k|\n v = self[k]\n if b.call(k, v)\n keys.push(k)\n end\n }\n return nil if keys.size == 0\n keys.each{|k|\n self.delete(k)\n }\n self\n end", "def reject! &block\n stash.reject! &block\n end", "def array_diff(a, b)\n #your code here\n b.each do |value|\n a.reject! { |n| n == value }\n end\n return a\nend", "def non_mutate(arr)\n arr.select {|i| i > 3} # => 4, 5\nend", "def reject_inject(array)\n\n\n reject {|num| num <= 50}.inject(0) {|sum, number| sum + number}\n \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 reject(collection_of_people, num)\n result = []\n collection_of_people.map do |age|\n result << age if age % 2 != num\n end\n return result\nend", "def test_reject\n assert_equal(%w[1 2 4 7 8 11 13 14],\n @ab.reject { |res| res.include?('Assign') || res.include?('Buzz') })\n end", "def test_oposite_of_reject\n array = [\"hello\", 2, 3, \"there\", \"how\", 9, \"are you\"]\n array.keep_if{ |x| x.is_a?(String)}\n assert_equal [\"hello\", \"there\", \"how\", \"are you\"], array\n end", "def reject(*paths)\n match = []; traverse(*paths){|f| match << f unless yield f }; match\n end", "def drop_while(array)\n results = []\n array.each do |item|\n results << item if !yield(item)\n end\n results\nend", "def exclude_array(arr)\n\t\tfilter_two_arrays(self, arr, false)\n\tend", "def block_splitter(array)\n answer_array = []\n\n answer_array << array.select { |word| word.yield }\n answer_array << array.reject { |word| word.yield }\n\n return answer_aray\nend", "def my_array_deletion_method(source, thing_to_delete)\n source.reject!{ |x| x.to_s.include?(thing_to_delete) }\nend", "def reject_total(array)\n array.reject { |string| string == 'total' }\n end", "def filter(&blk)\n Rubylude.new ->() {\n while value = @generator.resume\n Fiber.yield value if blk.call(value)\n end\n }\n end", "def filter(items)\r\n\tnew_items = Array.new\r\n\titems.each { |item| new_items.push(item) unless should_ban(item) }\r\n\tnew_items\r\nend", "def filter(arr, &block)\n if arr.empty?\n []\n else\n head, *tail = arr\n if block.call(head) == true\n [head] + filter(tail, &block)\n else\n filter(tail, &block)\n end\n end\nend", "def reject(&b)\n h = {}\n self.each_key{|k|\n v = self[k]\n unless b.call(k, v)\n h[k] = v\n end\n }\n h\n end", "def reject\n hsh = ::Archetype::Hash.new\n self.each do |key, value|\n hsh[key] = value unless yield(key, value)\n end\n return hsh\n end", "def reject\n hsh = ::Archetype::Hash.new\n self.each do |key, value|\n hsh[key] = value unless yield(key, value)\n end\n return hsh\n end", "def extract!(array)\n out = []\n array.reject! do |e|\n next false unless yield e\n out << e\n true\n end\n out\n end", "def drop_while(arr)\n new_arr = []\n none_false = nil\n for el in arr\n next if (yield el) && none_false.nil?\n\n none_false ||= true\n new_arr << el\n end\n new_arr\nend", "def reject!\n n = size\n delete_if { |o| yield(o) }\n size == n ? nil : self\n end", "def reject_odds(array)\n\t\n\tnot_odds = array.reject { |num| num.odd?}\nend", "def my_select(&block)\n result = []\n my_each do |elem|\n result << elem if block.call(elem) == true\n end\n result\n end", "def exclude!(*cond, &block)\n exclude(nil, *cond, &block)\n end", "def eliminar(array, num)\n #for i in 0..((array.length) - 1)\n #if array.at(i) < num\n # puts \"debería de funcionar\"\n # #array.delete_at(1)\n #end\n #end\n array.reject!{ |x| x < num }\n puts \"El resultado es #{array}\"\nend", "def filter!(&block)\n @rows.select!(&block)\n end", "def exclude(arr, num)\n i = 0\n a = []\n while i < arr.length\n if arr[i] != num\n a << arr[i]\n end\n i += 1\n end\n return a\nend", "def lazy_reject\n lazify.call(S.reject)\n end", "def remove_possible_values_in_block(row_id, column_id, block_id, value_to_remove)\n get_block(block_id).reject { |square| row_id == square.row && column_id == square.column }.each do |square|\n square.possible_values.delete(value_to_remove)\n end\n end", "def delete_not_all(conditions={}, &block)\n @items.inject([]) do |items, (key, item)|\n items << @items.delete(key) if !match_all(item, conditions, &block)\n items\n end\n end", "def drop_while(array)\n array.each_with_index do |el, ind|\n return array[ind..] unless yield(el)\n end\n []\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.select! {|el| el.to_s.include?(thing_to_delete) == false}\nend", "def keep_arr(arr)\n # keep all non negative elements ( >= 0)\n arr.keep_if { |x| x >= 0 }\n end", "def test_filters_no_elements\n stream = FromArray.new([2, 4, 6, 8])\n collected = stream.filter { |num| num % 2 == 0 }.collect\n assert(stream.collect == collected)\n end", "def xnor_select(arr, prc1, prc2)\n arr.select {|el| !(prc1.call(el) ^ prc2.call(el))}\nend", "def array_diff(a, b)\n a.reject {|e| b.include? e}\nend", "def my_array_deletion_method!(source, thing_to_delete)\n source.reject! {|user_string| user_string.to_s.index(thing_to_delete) != nil}\n return source\nend", "def reduce_blocks(blks, filter = writable_mifare_blocks)\n if identify_2d_array(blks)\n hsh = blks.to_h\n filter.map { |x| hsh[x] }.compact.flatten\n else\n filter.map { |x| blks[x] }.compact.flatten\n end\n end" ]
[ "0.77882814", "0.75782925", "0.7383995", "0.72468245", "0.71466064", "0.7123806", "0.707463", "0.70282537", "0.6974494", "0.69211", "0.6898149", "0.682925", "0.67519176", "0.66831", "0.66273993", "0.66132087", "0.6562831", "0.6556095", "0.65476376", "0.65165865", "0.6472411", "0.644115", "0.63702756", "0.63135815", "0.62903464", "0.6235051", "0.6209885", "0.6158005", "0.61503047", "0.61437184", "0.61340487", "0.61338246", "0.6056693", "0.6045984", "0.60246146", "0.6001204", "0.59770983", "0.5972465", "0.5963215", "0.5962446", "0.59372103", "0.59372103", "0.59010726", "0.5858015", "0.5851469", "0.5810362", "0.57789266", "0.577296", "0.5764083", "0.576308", "0.5761105", "0.5743085", "0.5736441", "0.5695264", "0.56922746", "0.56791073", "0.56636816", "0.565654", "0.56434804", "0.5621333", "0.5614146", "0.55828625", "0.55796665", "0.5578941", "0.5551578", "0.55510616", "0.54722273", "0.53864974", "0.53738195", "0.53668237", "0.5361614", "0.53489214", "0.5341409", "0.53203434", "0.53168803", "0.53082365", "0.5295465", "0.5283019", "0.52709407", "0.52709407", "0.5248638", "0.524804", "0.52459335", "0.5244373", "0.5232041", "0.5231085", "0.5192752", "0.51841974", "0.5175473", "0.51604575", "0.51544106", "0.51375574", "0.5134057", "0.51331615", "0.51274246", "0.5126504", "0.51260054", "0.5125024", "0.51188874", "0.51105237" ]
0.71689457
4
Write my_any? to return true if any elements of the array satisfy the block and my_all? to return true only if all elements satisfy the block.
def my_any?(&prc) i = 0 while i < self.length if prc.call(self[i]) == true return true end i += 1 end return false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def my_any?\n all = false\n self.my_each do |x|\n if !block_given?\n if x || !x.nil?\n all = true\n end\n elsif yield x\n all = true\n end\n break if all == true\n end\n all\n end", "def my_any?(arr, &prc)\n arr.each do |ele|\n return true if prc.call(ele)\n end\n false\nend", "def my_any?(&block)\n return false unless block_given?\n\n # Return true on first instance\n my_each { |*args| return true if block.call(*args) }\n\n false\n end", "def my_any?(&prc)\n\t\tself.my_each do |ele|\n\t\t\treturn true if prc.call(ele)\n\t\tend\n\t\tfalse\n\tend", "def my_any?(&prc)\n self.my_each { |el| return true if prc.call(el) }\n false\n end", "def my_any?\n self.my_each {|x| return true if yield(x) == true}\n false\n end", "def my_any?(&block)\n counter = 0\n my_each do |elem|\n counter += 1 if block.call(elem) == true\n end\n return true if counter.positive?\n\n false\n end", "def my_any?\n return unless block_given?\n self.my_each do |ele|\n if yield ele then return true\n end\n end\n return false\n end", "def my_any?\n if block_given?\n self.my_each {|n| return true if yield(n) == true}\n return false\n else\n return false if self.size == 0\n self.my_each {|n| return true if n == true}\n return false\n end\n end", "def my_any?\n if block_given?\n self.my_each{|item| return true if yield(item)}\n # return false unless one is true\n false\n else\n # if no block given return true\n true\n end\n end", "def my_all?(&block)\n return true unless block_given?\n\n # Return false as early as possible\n my_each { |*args| return false unless block.call(*args) }\n\n true\n end", "def my_all?(main_param = nil)\n result = true\n my_each do |element|\n condition = my_all_any_none_helper(main_param, element) { |i| block_given? ? yield(i) : i }\n result &&= condition\n break if result == false\n end\n result\n end", "def any?(array)\n array.each do |element|\n return true if yield(element)\n end\n \n false\nend", "def 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 any1?(arr, &block)\n return false if arr.empty?\n block.call(arr.first) ? true : any?(arr.drop(1), &block)\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 any?(array)\n array.each do |el|\n return true if yield(el)\n end\n\n false\nend", "def my_all?(*args)\n arr = self\n is_all = true\n if !args[0].nil?\n arr.my_each do |x|\n if args[0].is_a?(Class)\n is_all = false unless x.is_a?(args[0])\n elsif args[0].is_a?(Regexp)\n is_all = false unless args[0].match?(x)\n else\n is_all = false unless args[0] == x\n end\n end\n elsif block_given?\n arr.my_each do |x|\n is_all = false unless yield(x)\n end\n else\n arr.my_each do |x|\n is_all = false unless x\n end\n end\n is_all\n end", "def my_all?(arr, &prc)\n arr.each do |ele|\n return false if !prc.call(ele)\n end\n true\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?( proc_argument = nil )\n result = []\n\n my_each do |element|\n if block_given? \n result << element if yield(element)\n else\n result << element if proc_argument.call(element)\n end\n end\n\n # If the new array has the same number of true elements as the original array, we know that all elements satisfied the condition\n self.size == result.size ? true : false\n end", "def my_any?(pattern = nil)\n test = false\n if(block_given?)\n self.my_each do |x|\n test = test || yield(x)\n end\n else\n if(pattern.nil?)\n self.my_each do |x|\n test = test || (x == true)\n end\n else\n self.my_each do |x|\n test = test || (x.match?(pattern))\n end\n end\n end\n return test\n end", "def my_all?(&prc)\n self.my_each do |el|\n return false if !prc.call(el)\n end\n\n true\n end", "def my_all?\n all = true\n self.my_each do |x|\n if !block_given?\n if !x || x.nil?\n all = false\n end\n elsif !yield x\n all = false\n end\n break if all == false\n end\n all\n end", "def some?(arr, &blk)\n #arr.any? { |el| blk.call(el) }\n arr.each do |el| \n if blk.call(el)\n return true\n end\n end\n return false\nend", "def any?(&block)\n if block\n self.each{|*val| return true if block.call(*val)}\n else\n self.each{|*val| return true if val.__svalue}\n end\n false\n end", "def my_all?\n\t\t#if any element is false return false\n\t\tmy_each do | element |\n\t\t\tif yield( element )\n\t\t\t\tnext\n\t\t\telse\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\n\t\t# returns true when all iterations pass\n\t\treturn true\n\n\tend", "def my_all?(&block)\n counter = 0\n my_each do |elem|\n counter += 1 if block.call(elem) == true\n end\n return true if counter == size\n\n false\n end", "def my_all?(&prc)\n self.my_each { |el| return false if !prc.call(el) }\n true\n end", "def my_all?\n return unless block_given?\n self.my_each do |ele|\n if not yield ele then return false\n end\n end\n return true\n end", "def my_all?\n if block_given?\n self.my_each{|item| return false if yield(item) == false }\n # return true unless one is false\n true\n else\n # if no block given return true\n true\n end\n end", "def my_all?\n\t\tvalue = true\n\t\tself.my_each do |element|\n\t\t\tif yield(element) != true\n\t\t\t\tvalue = false\n\t\t\tend\n\t\tend\n\t\treturn value\n\tend", "def 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 my_all?(arg = nil)\n all_matched = true\n my_each do |val|\n if block_given?\n all_matched = false unless yield(val)\n elsif arg.nil?\n all_matched = false unless val\n else\n all_matched = false unless arg === val\n end\n end\n all_matched\n end", "def my_any? (pattern = false)\n if block_given?\n self.my_each{|item| return true if yield item}\n elsif !!pattern == true\n self.my_each{|item| return true if pattern === item}\n else\n self.my_each{|item| return true if !!item}\n end\n false\n end", "def any?\n if block_given?\n to_a.any? { |*block_args| yield(*block_args) }\n else\n !empty?\n end\n end", "def every?(arr, &blck)\n # arr.all? { |el| blck.call(el) }\n arr.each do |el|\n if !blck.call(el)\n return false\n end\n end\n return true\nend", "def any?\n if block_given?\n to_a.any? { |*block_args| yield(*block_args) }\n else\n !empty?\n end\n end", "def my_any?\n\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_any? #iterates through and returns true if ANY iteration returns true\n if self.class == Array\n self.my_each do |value|\n if yield(value)\n return true\n end\n end\n elsif self.class == Hash\n self.my_each do |key, value|\n if yield(key, value) #if block yield is true then true is returned\n return true\n end\n end\n end\n false #this is the default setting\n end", "def my_all?(proc=nil)\n self.my_each do |item|\n if block_given?\n return false if !yield(item)\n else\n return false if !proc.call(item)\n end\n end\n true\n end", "def my_all?(proc=nil)\n self.my_each do |item|\n if block_given?\n return false if !yield(item)\n else\n return false if !proc.call(item)\n end\n end\n true\n end", "def my_all?(args = nil)\n result = true\n my_each do |value|\n if block_given?\n result = false unless yield(value)\n elsif args.nil?\n result = false unless value\n else\n result = false unless args === value\n end\n end\n result\n end", "def my_any?\n return self.to_enum unless block_given?\n for i in self\n return true if yield i\n end\n return false\n end", "def my_all?\n self.my_each {|x| return false if yield(x) != true}\n true\n end", "def my_all?\n return self unless block_given?\n for a in self\n if !yield(a)\n return false\n end\n end\n return true\n end", "def my_any? looking_for\n output = false\n self.my_each {|item| output = true if item == looking_for}\n output\n end", "def any?(collection)\n collection.each do |element|\n return true if yield(element)\n end\n false\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 all?(arr)\n arr.each { |el| return false if yield(el) == false}\n true\nend", "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_all?(var = nil)\n result = true\n my_each do |item|\n if block_given?\n result = false unless yield(item)\n elsif var.nil?\n result = false unless item\n else\n result = false unless var === item\n end\n end\n result\n end", "def my_all? \n\ti = true\n\tself.my_each do |a|\n\t\tunless yield (a)\n\t\t\ti = false\n\t\t\tbreak\n\t\tend\n\tend\n\ti\nend", "def any?(collection)\n return false if collection.empty?\n collection.each { |args| return true if yield(args) }\n false\nend", "def my_all?(pattern = nil)\n test = true\n if(block_given?)\n self.my_each do |x|\n test = test && yield(x)\n end \n else\n if(pattern.nil?)\n self.my_each do |x|\n test = test && (x==true)\n end\n else\n self.my_each do |x|\n test = test && (x.match?(pattern))\n end\n end\n end\n return test\n end", "def my_all?\n my_each do |i|\n if (!yield(i))\n return false\n end\n end\n true\n end", "def my_all?\n return my_all? { |n| n } unless block_given?\n array = []\n to_a.my_each { |n| array << n if yield(n) }\n array.size == size\n end", "def any?\n only_with('any?', 'Boolean')\n items.compact.any?\n end", "def every?(arr, &prc)\n\n arr.each do |ele|\n return false if !(prc.call(ele))\n end\n\n true\nend", "def my_all? (pattern = false)\n if block_given?\n self.my_each{|item| return false if !!(yield item) == false}\n elsif !!pattern == true\n self.my_each{|item| return false if (pattern === item) == false}\n else\n self.my_each{|item| return false if !!item == false}\n end\n true\n end", "def any\n C.curry.(\n ->(f, xs) {\n _f = ->(acc, x) {\n f.(x) ? true : acc\n }\n\n C.fold.(_f, xs, false)\n }\n )\n end", "def some?(array, &prc)\n array.each do |ele|\n return true if prc.call(ele)\n end\n false\nend", "def my_all?\n if self.class == Array\n my_each do |value|\n # stop if item is flagged\n return false unless yield(value)\n end\n elsif self.class == Hash\n my_each do |key, value|\n return false unless yield(key, value)\n end\n end\n true\n end", "def my_all?(arg = nil)\n resp = true\n return true if to_a.nil? || (self.class.to_s == 'Hash' && !block_given?)\n\n if block_given?\n to_a.my_each { |val| resp = false unless yield(val) }\n elsif arg.nil?\n to_a.my_each { |val| resp = false unless val }\n else\n case arg.class.to_s\n when 'Regexp'\n to_a.my_each { |val| resp = false unless arg.match? val.to_s }\n when 'Class'\n to_a.my_each { |val| resp = false unless val.is_a? arg }\n else\n to_a.my_each { |val| return resp = false unless val == arg }\n end\n end\n resp\n end", "def some?(arr, &prc)\n arr.each { |el| return true if prc.call(el)}\n false\nend", "def all?(&block)\n n = 0\n lim = size\n if block_given?\n while n < lim\n unless yield(self.__at(n)) ; return false ; end\n n = n + 1\n end\n else\n while n < lim\n unless self.__at(n) ; return false ; end\n n = n + 1\n end\n end\n true\n end", "def my_one?(array, &prc)\n results = array.select {|ele| prc.call(ele)}\n return 1 == results.length\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 array?(of: ANY)\n v = wrap(of)\n ->(o) { o.is_a? Array and o.map { |e| v.call(e) }.all? }\n end", "def any(opts, *rest)\n equality_to_function(\"ANY\", opts, rest)\n end", "def any_of(*args)\n [:any_of, args]\n end", "def my_all?(param = nil)\n if block_given?\n my_each { |i| return false unless yield(i) }\n elsif param.class == Class\n my_each { |i| return false unless i.class == param }\n elsif param.class == Regexp\n my_each { |i| return false unless i =~ param }\n elsif param.nil?\n my_each { |i| return false unless i }\n else\n my_each { |i| return false unless i == param }\n end\n true\n end", "def my_all?(collection)\n i = 0\n block_return_values = []\n while i < collection.length\n block_return_values.push(yield(collection[i]))\n #Three steps\n #First we add yield keyword to yield each element of the block\n #Second we, save the the return values to an array which we declare\n #before the while loop\n i = i + 1\n end\n #Third, we want the final to be true or false for each element in\n #our block_return_values as that is what all? returns\n if block_return_values.include?(false)\n false\n else\n true\n end\nend", "def some?(arr, &prc)\n\n arr.each do |ele|\n return true if prc.call(ele)\n end\nfalse\nend", "def my_all?\n status = true\n self.my_each do |item|\n if (yield item) != true\n status = false\n end\n end\n status\n end", "def all?(&block)\n if block\n self.each{|*val| return false unless block.call(*val)}\n else\n self.each{|*val| return false unless val.__svalue}\n end\n true\n end", "def my_none?\n all = true\n self.my_each do |x|\n if !block_given?\n if x\n all = false\n end\n elsif yield x\n all = false\n end\n break if all == false\n end\n all\n end", "def f_all\n C.curry.(\n ->(f, xs) {\n !any.(->(x) { x == false }, map.(f, xs))\n }\n )\n end", "def any?\n condition_operator == :any\n end", "def my_none?(arr, &prc)\n arr.each do |ele|\n return false if prc.call(ele)\n end\n true\nend", "def array_42(a)\n\ta.any?{|x| x == 42}\nend", "def any?\n required? || defaults? || splat? || block_arg?\n end", "def all?(array)\n i = 0\n score = 0\n\n while i < array.length\n if yield(array[i])\n score += 1\n end\n i += 1\n end\n\n score == array.length\nend", "def every?(arr, &prc)\n count = 0\n arr.each do |ele| \n if prc.call(ele)\n count += 1\n end\n end\n count == arr.length\nend", "def any?\n false\n end", "def any?\n [\"true\", \"1\", \"yes\"].include? @any.to_s\n end", "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 first_any(conditions={}, &block)\n all.detect { |item| match_any(item, conditions, &block) }\n end", "def any?\n !empty?\n end", "def any?\n !empty?\n end", "def my_all?(collection)\n i = 0\n return_value = []\n while i < collection.length\n return_value << yield(collection[i])\n i += 1\n end\n\n # check to see if the return values from yielding contains a false\n if return_value.include?(false)\n false\n else\n true\n end\n\nend", "def my_all?\n self.my_each do |word|\n return false if !yield(word)\n end\n return true\n end", "def any?\n @any == true || @any == \"true\" || @any == \"1\" || @any == \"yes\"\n end", "def every?(arr, &proc)\r\n count = 0\r\n arr.each { |el| count += 1 if proc.call(el) }\r\n count == arr.length\r\nend", "def match_all?\n self.class.array_matching == :all\n 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 all?(collection)\n collection.each_with_object(true) { |el| return false unless yield(el) }\nend", "def any?\n ! empty?\n end", "def some\r\n each do |value|\r\n result = yield(value)\r\n return true if result\r\n end\r\n return false\r\n end" ]
[ "0.7960906", "0.7924131", "0.78736955", "0.78420866", "0.7827809", "0.77741617", "0.77730644", "0.776643", "0.77654076", "0.7660904", "0.76324725", "0.7609725", "0.7607826", "0.76056004", "0.76056004", "0.75952685", "0.7568064", "0.7551117", "0.75151646", "0.74255055", "0.74110067", "0.73912066", "0.73707986", "0.73279035", "0.73274654", "0.7324141", "0.7300477", "0.7299285", "0.72801876", "0.7234956", "0.722323", "0.72213125", "0.71992373", "0.71933424", "0.717242", "0.7164956", "0.7123236", "0.71085036", "0.71034575", "0.7100681", "0.7096236", "0.7065951", "0.7065951", "0.70513296", "0.70340085", "0.700314", "0.7001086", "0.6989561", "0.6986197", "0.69827664", "0.69652295", "0.69460845", "0.69276416", "0.6891461", "0.6889987", "0.6863736", "0.684286", "0.68388355", "0.6798075", "0.6790798", "0.67834973", "0.67730075", "0.6731026", "0.6665934", "0.66528", "0.66379946", "0.6634628", "0.66247356", "0.66146374", "0.6574194", "0.65649766", "0.6549158", "0.6519982", "0.65118986", "0.649953", "0.6495548", "0.6488249", "0.646227", "0.64401096", "0.63996553", "0.6397305", "0.63528764", "0.6343986", "0.6331145", "0.6328486", "0.6312649", "0.6290643", "0.6285453", "0.62609804", "0.62384117", "0.62384117", "0.6198049", "0.61893845", "0.6176361", "0.61687577", "0.61646825", "0.6154686", "0.61514187", "0.614632", "0.6108123" ]
0.7635935
10
my_flatten should return all elements of the array into a new, onedimensional array. Hint: use recursion!
def my_flatten arr = [] i = 0 while i < self.length if self[i].is_a? Array arr += self[i].my_flatten else arr << self[i] end i += 1 end return arr end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def my_flatten\n flattened_array = []\n each do |item|\n if item.class != Array\n flattened_array << item\n else\n #recursevly call my flatten\n item.my_flatten.each { |sub_item| flattened_array << sub_item }\n end\n end\n flattened_array\n end", "def my_flatten\n flattened = []\n self.my_each do |el|\n if el.is_a? Array\n flattened += el.my_flatten\n else\n flattened << el\n end\n end\n flattened\n end", "def my_flatten\n flattened = []\n self.my_each do |el|\n el.is_a?(Array) ? flattened.concat(el.my_flatten) : flattened << el\n end\n flattened\n end", "def my_flatten\n flattened = []\n self.my_each do |el|\n el.is_a?(Array) ? flattened += el.my_flatten : flattened << el\n end\n flattened\n end", "def using_flatten(array)\n array.flatten()\nend", "def using_flatten(array)\n array.flatten\n end", "def my_flatten(array)\n print array.flatten\n end", "def my_flatten\n # return self unless self.is_a?(Array)\n new_arr = []\n self.each do |el|\n if el.is_a?(Array)\n new_arr += el.my_flatten\n else\n new_arr << el\n end\n end\n new_arr\n end", "def using_flatten (array)\n return array.flatten!\nend", "def using_flatten(array)\n array.flatten\nend", "def using_flatten(array)\n array.flatten\nend", "def using_flatten(array)\n \n array.flatten\n \nend", "def flatten\n\t\tmake_flat(@array)\n\tend", "def flatten(array)\n array.flatten(1)\nend", "def flatten(array)\n array.flatten(1)\nend", "def using_flatten(array)\n array.flatten\nend", "def using_flatten(array)\n array.flatten\nend", "def using_flatten(array)\n array.flatten\nend", "def using_flatten(array)\n array.flatten\nend", "def using_flatten(array)\n array.flatten\nend", "def using_flatten(array)\n array.flatten\nend", "def my_flatten_recursive \n results = []\n self.my_each do |ele|\n if ele.is_a? Array \n results.concat(ele.my_flatten_recursive)\n else \n results<< ele\n end\n end\n results\n\n end", "def using_flatten(arr)\n arr.flatten\nend", "def one_line_flatten(array, ret = [])\n array.each { |x| x.is_a?(Array) ? one_line_flatten(x, ret) : ret << x }; ret\nend", "def applying_flatten array_value\n return array_value.flatten!\n end", "def using_flatten(array)\n array.flatten\n \nend", "def flatten_array(arr)\n arr.flatten\nend", "def flatten!\n\t\t@array = make_flat(@array)\n\tend", "def my_flatten(arr, flattened_arr = [])\nend", "def recursive_flatten(incoming_array, new_flattened_array = [])\n incoming_array.each do |item|\n if item.class == Array\n # Recursion\n recursive_flatten(item, new_flattened_array)\n else\n new_flattened_array << item\n end\n end\n new_flattened_array\n end", "def flatten(array)\n new_array = []\n array.each do |x|\n if x.class == Array\n x.each {|y| new_array.push(y)}\n else\n new_array.push(x)\n end\n end\n new_array\nend", "def flatten(array)\n return [] if array.empty?\n\n res = []\n array.each do |el|\n if el.is_a? Array\n res += flatten(el)\n else\n res << el\n end\n end\n res\nend", "def flatten(array, result = [])\n array.each do |element|\n if element.is_a?(Array)\n flatten(element, result)\n else\n result << element\n end\n end\n result\nend", "def my_flatten!\n self.replace(my_flatten)\n end", "def flatten_array(array, result = [])\n array.each do |element|\n if element.is_a? Array\n flatten_array(element, result)\n else\n result << element\n end\n end\n result\nend", "def flatten_deeper(array)\n array.collect { |element| element.respond_to?(:flatten) ? element.flatten : element }.flatten\n end", "def flatten(array)\n a = []\n array.each do |n|\n if n.is_a? Array\n b = flatten(n)\n b.each { |x| a << x }\n else\n a << n\n end\n end\n a\nend", "def flatten(array)\n raise NonArrayError, 'argument must be an array' unless array.is_a? Array\n\n array.each_with_object([]) do |element, memo|\n if element.is_a?(Array)\n memo.push(*flatten(element))\n else\n memo.push(element)\n end\n end\nend", "def my_flatten(final_arr = []) \n self.my_each do |el|\n debugger\n if el.class == Integer\n final_arr << el\n else\n el.my_flatten(final_arr)\n end\n end\n result\n end", "def flatten(nested_array, result = [])\n nested_array.each do |integer|\n if integer.class == Array\n flatten(integer, result)\n else\n result << integer\n end\n end\n result\nend", "def my_controlled_flatten(n)\n flattened = []\n\n self.each do |el|\n depth = 0\n if el.is_a?(Array)\n depth += 1\n flattened += el.my_flatten\n else\n flattened << el\n end\n end\n flattened\n end", "def my_controlled_flatten(n)\n flattened = []\n self.my_each do |el|\n if n > 0 && el.is_a?(Array)\n flattened += el.my_controlled_flatten(n - 1)\n else\n flattened << el\n end\n end\n flattened\n end", "def flatten(array)\n container = []\n\n array.each do |element|\n if element.is_a?(Array)\n container += element\n else\n container << element\n end\n end\n\n container\nend", "def flatten!() end", "def _recursively_flatten_to!(array, out)\n array.each do |o|\n if NodeList === o\n _recursively_flatten_to!(o.nodes, out)\n elsif o.respond_to?(:to_ary)\n ary = Array === o ? o : o.to_ary\n _recursively_flatten_to!(ary, out)\n else\n out << o\n end\n end\n end", "def flatt(arr, flat_arr = [])\n arr.each do |element|\n if element.is_a?(Array)\n flatt(element, flat_arr)\n else\n flat_arr << element\n end\n end\n flat_arr\nend", "def my_controlled_flatten(level = nil)\n flattened = []\n\n self.each do |ele|\n if ele.is_a?(Array) && level != 0\n flattened += (level.nil? ? ele.my_controlled_flatten : ele.my_controlled_flatten(level - 1))\n else\n flattened << ele\n end\n end\n\n flattened\n end", "def my_controlled_flatten(level = nil)\n flattened = []\n\n self.each do |ele|\n if ele.is_a?(Array) && level != 0\n flattened += (level.nil? ? ele.my_controlled_flatten : ele.my_controlled_flatten(level - 1))\n else\n flattened << ele\n end\n end\n\n flattened\n end", "def my_controlled_flatten(n)\n return self if n < 1\n new_arr = []\n my_each {|el| new_arr += (el.is_a?(Array) ? el.my_controlled_flatten(n-1) : [el])}\n new_arr\n end", "def flatten() end", "def arr\n a = [1,2,[3,4,[5]]]\n return a.flatten\nend", "def flat(a)\n\tnew_arr = []\n\ta.each do |el|\n\t\tif el.is_a? Array\n\t\t\tel.each do |n|\n\t\t\t\tif el.is_a? Array\n\t\t\t\t\ta << n\n\t\t\t\telse\n\t\t\t\t\tnew_arr << n\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\tnew_arr << el\t\n\t\tend\n\tend\n\tp new_arr\nend", "def flatten_deeper(array)\n array.collect do |element|\n (element.respond_to?(:flatten) && !element.is_a?(Hash)) ? element.flatten : element\n end.flatten\n end", "def flatten(a, flat=[])\n if a.class != Array\n # base case\n flat << a\n else\n a.each {|v| flatten(v, flat)}\n end\n flat\nend", "def my_controlled_flatten(n)\n return self if n == 0\n new_arr = []\n self.each do |el|\n if el.is_a? (Array)\n new_arr += el.my_controlled_flatten(n-1)\n else\n new_arr << el\n end\n end\n new_arr\n end", "def flatten\n map {|item| item.respond_to?(:flatten) ? item.flatten : item }.flatten\n end", "def flatten_aoi_recursive(array)\n return nil if array.nil?\n result = []\n array.each do |element|\n if element.is_a?(Array)\n f_array = flatten_aoi_recursive(element)\n f_array.each do |f_element|\n result << f_element\n end\n else\n result << element\n end\n end\n result\nend", "def my_controlled_flatten(n)\n return self if n == 0\n result = []\n self.each do |el|\n result << el unless el.is_a? Array\n result += el.my_controlled_flatten(n - 1) if el.is_a? Array\n end\n result\n end", "def my_controlled_flatten(n)\n return self if n == 0\n result = []\n self.each do |el|\n result << el unless el.is_a? Array\n result += el.my_controlled_flatten(n - 1) if el.is_a? Array\n end\n result\n end", "def flatten(*args)\n new_array = []\n self.each do |v|\n if v.is_a?(Array)\n new_array.push( *(v.flatten(*args)) )\n else\n new_array << v\n end\n end\n new_array\n end", "def flatten!\n self.replace(flatten)\n end", "def flatten(arr)\n\n flat = []\n\n arr.each do |el|\n if el.class != Array\n flat << el \n else\n #flatten(el).each {|char| flat << char}\n flat.push(*flatten(el))\n end\n end\n flat \nend", "def recursively_flatten_finite(array, out, level)\n ret = nil\n if level <= 0\n out.concat(array)\n else\n array.each do |o|\n if ary = Backports.is_array?(o)\n recursively_flatten_finite(ary, out, level - 1)\n ret = self\n else\n out << o\n end\n end\n end\n ret\n end", "def recursively_flatten_finite(array, out, level)\n ret = nil\n if level <= 0\n out.concat(array)\n else\n array.each do |o|\n if ary = Backports.is_array?(o)\n recursively_flatten_finite(ary, out, level - 1)\n ret = self\n else\n out << o\n end\n end\n end\n ret\n end", "def flatten(depth = -1)\n to_a.flatten(depth)\n end", "def convert_1_level_deep(arr, result=[])\n arr.flatten.each_slice(3) { |ele| result.push(ele)}\n result\nend", "def unflatten(flat_array)\n result = []\n x = 0\n\n while x < flat_array.length do \n if flat_array[x] < 3 \n result.push flat_array[x]\n x += 1\n else\n temp = [*flat_array[x...x + flat_array[x]]]\n result.push temp \n x += flat_array[x]\n end\n end\n result \nend", "def my_controlled_flatten(n)\n\n end", "def my_controlled_flatten(n)\n\n end", "def flatten(array)\n return [] if array.empty? \n list = []\n head = array[0]\n rest = array[1..-1]\n if head.is_a? Array \n flatten(head) + flatten(rest)\n else \n list += [head] + flatten(rest)\n end \nend", "def my_controlled_flatten(n=1)\n #here\n return self if n < 1\n\n results = []\n self.each do |el|\n if el.class == Array\n #here\n results += el.my_controlled_flatten(n-1)\n else\n results << el\n end\n end\n\n results\n\n end", "def flatten(data, level = 0)\n return [data] unless data.is_a?(Array) \n flat = []\n data.each do |ele|\n if ele.is_a?(Array)\n flat += flatten(ele, level + 1)\n else\n flat << ele\n end\n end\n flat\nend", "def test_fix_nested_array\n array = [1, [2], [3, [4,[5]]], 6]\n array = array.flatten\n assert_equal [1,2,3,4,5,6], array\n end", "def flatten\n a=[]\n self.deep_each {|f| a << f}\n a\n end", "def my_controlled_flatten(n)\n return self if n == 0\n flattened = []\n\n self.each do |el|\n if el.is_a? Array\n next_val = n.nil? nil : n - 1\n flattened += el.my_controlled_flatten(next_val)\n else\n flattened += el\n end\n end\n\n flattened\n end", "def flatten\n dup\n end", "def flatten!\n nil\n end", "def flatten!\n # buggerit\n raise NotImplementedError\n end", "def flatten(list)\n list.flatten\nend", "def multi_dimensional_sum(array)\n\n puts \"With the built-in flatten method:\"\n puts array.flatten.inject { |acc, num| acc + num }\n\n puts \"With my flatten method:\"\n puts my_flatten(array).inject { |acc, num| acc + num}\n\n return \"----\"\n\nend", "def multi_dimensional_sum(array)\n array.flatten\nend", "def flatten_array(arr)\n arr.each_with_object([]) do |item, flat|\n if item.is_a? Integer\n flat << item\n else\n flatten_array(item).each do |num|\n flat << num\n end\n end\n end\nend", "def flatten\n self.class.new.flatten_merge(self)\n end", "def flatten\n self.class.new.flatten_merge(self)\n end", "def flatten\n # if any item is a Set or Java Collection, then convert those into arrays before recursively flattening the list\n if any? { |item| Set === item or Java::JavaUtil::Collection === item } then\n return map { |item| (Set === item or Java::JavaUtil::Collection === item) ? item.to_a : item }.flatten\n end\n base__flatten\n end", "def test_flatten_once\n ary = [1, [2, [3, 4]], [5]]\n flatter_ary = [1, 2, [3, 4], 5]\n assert_equal flatter_ary, OneLiner.flatten_once(ary)\n end", "def test_flatten_once\n ary = [1, [2, [3, 4]]]\n flatter_ary = [1, 2, [3, 4]]\n assert_equal flatter_ary, OneLiner.flatten_once(ary)\n end", "def to_flat_array\n ary = Array.new(self.size)\n self.each.with_index { |v,i| ary[i] = v }\n ary\n end", "def flatten_without_hooks!\n\n @without_hooks = true\n\n return_value = flatten!\n \n @without_hooks = false\n\n return return_value\n\n end", "def flatten(value, named=false) # :nodoc:\n # Passes through everything that isn't an array of things\n return value unless value.instance_of? Array\n\n # Extracts the s-expression tag\n tag, *tail = value\n\n # Merges arrays:\n result = tail.\n map { |e| flatten(e) } # first flatten each element\n \n case tag\n when :sequence\n return flatten_sequence(result)\n when :maybe\n return named ? result.first : result.first || ''\n when :repetition\n return flatten_repetition(result, named)\n end\n \n fail \"BUG: Unknown tag #{tag.inspect}.\"\n end", "def flattened_results\n\n f2 = results.flatten(2)\n f2.any? ? [ f2.shift ] + f2.flatten(2) : []\n end", "def flatten_a_o_a(aoa)\n aoa.flatten\nend", "def flatten_a_o_a(aoa)\n result = []\n x = 0\n while x < aoa.length do\n y = 0\n while y < aoa[x].length do\n result.push(aoa[x][y])\n y += 1\n end\n x += 1\n end\n return result\nend", "def deep_dup(arr)\n return [] if arr.length.zero?\n\n innerArr = []\n\n arr.each do |el|\n if el.is_a?(Array)\n innerArr << deep_dup(el)\n else\n innerArr << el\n end\n end\n\n innerArr\nend", "def deep_dup(array)\n\n final_array = []\n return final_array if array.empty?\n\n array.each do |item|\n if item.is_a?(Array)\n final_array << deep_dup(item)\n else\n final_array << item\n end\n end\n\n final_array\nend", "def flatten_with_optional_argument!(level=-1)\n level = Backports.coerce_to_int(level)\n return flatten_without_optional_argument! if level < 0\n\n out = []\n ret = recursively_flatten_finite(self, out, level)\n replace(out) if ret\n ret\n end", "def expand\n map { |p| p&.flatten || p }.flatten\n end", "def deep_dup(arr)\n ans = []\n arr.each do |elt| #can use map\n if elt.is_a?(Array)\n ans.concat([deep_dup(elt)])\n else\n ans << elt\n end\n end\n ans\nend", "def ensure_flat_array_value(value)\n if value.kind_of?(Array)\n value.flatten!\n else\n value = [value]\n end\n value\n end", "def deep_dup(arr)\n new_arr = []\n arr.each do |el|\n if el.is_a?(Array)\n new_arr << deep_dup(el)\n else\n new_arr << el\n end\n end\n new_arr\nend" ]
[ "0.81874835", "0.80982953", "0.8023162", "0.8021197", "0.7873731", "0.78402483", "0.779833", "0.77438736", "0.77373993", "0.7689893", "0.7689893", "0.7683187", "0.76608276", "0.76396793", "0.76396793", "0.76336336", "0.76336336", "0.76336336", "0.76336336", "0.76336336", "0.76336336", "0.76116145", "0.7602592", "0.75445515", "0.75192", "0.75089073", "0.746443", "0.7417879", "0.7403817", "0.73943347", "0.7390887", "0.73742193", "0.7334531", "0.73263735", "0.72862947", "0.7268197", "0.723132", "0.72275555", "0.7156524", "0.7069701", "0.6989038", "0.6975671", "0.69718915", "0.6971088", "0.69706845", "0.6926829", "0.6881039", "0.6881009", "0.6880557", "0.6863059", "0.6854111", "0.68311334", "0.6830933", "0.67507535", "0.67264974", "0.670981", "0.66948885", "0.66908693", "0.66908693", "0.6686312", "0.6660196", "0.66179484", "0.65978885", "0.65978885", "0.65767443", "0.6570163", "0.6567731", "0.65059024", "0.65059024", "0.6471431", "0.6469443", "0.645973", "0.6416437", "0.6389372", "0.6374333", "0.6354551", "0.6346117", "0.63219506", "0.6215623", "0.6215029", "0.621483", "0.62067777", "0.61639977", "0.61639977", "0.61418664", "0.60845864", "0.6003648", "0.59375846", "0.5872361", "0.5792022", "0.5767274", "0.5732375", "0.5645239", "0.5636031", "0.56251776", "0.55741745", "0.5573382", "0.5525849", "0.54945046", "0.54915565" ]
0.8041758
2
Write my_zip to take any number of arguments. It should return a new array containing self.length elements. Each element of the new array should be an array with a length of the input arguments + 1 and contain the merged elements at that index. If the size of any argument is less than self, nil is returned for that location.
def my_zip(*arrays) i = 0 zipped = [] while i < self.length nest = [self[i]] arrays.my_each do |arr| if i < arr.length nest << arr[i] else nest << nil end end zipped << nest i += 1 end return zipped end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def my_zip(*args)\n zipped = Array.new(self.length) {[]}\n\n self.each_with_index { |el, i_arr| zipped[i_arr] << el}\n args.each_with_index do |arg, i_arg|\n (zipped.length).times {|i_arg_el| zipped[i_arg_el] << arg[i_arg_el]}\n end\n zipped\n end", "def my_zip(*arrs)\n zipped = []\n self.each_with_index do |ele, i|\n sub = [ele]\n arrs.each do |arr|\n sub << arr[i]\n end\n zipped << sub\n end\n zipped\n end", "def my_zip(*given_arrays)\n result = []\n\n self.each_with_index do |el, idx|\n internal_array = [el]\n given_arrays.each { |given_array| internal_array << given_array[idx] }\n result << internal_array\n end\n\n result\n end", "def zip(*args)\n \n multi = Array.new(args[0].length) {[]}\n\n (0...args.length).each do |i|\n (0...args[0].length).each do |j|\n multi[j] << args[i][j]\n end\n end\n multi\nend", "def zany_zip(*args)\n length = args.map(&:length).max\n multi = Array.new(length) {[]}\n\n (0...args.length).each do |i|\n (0...length).each do |j|\n if j >= args[i].length\n multi[j] << nil\n else\n multi[j] << args[i][j]\n end\n end\n end\n multi\nend", "def my_zip(*arr)\n answer = Array.new([])\n each_with_index do |item, index|\n answer[index] = [item]\n arr.each do |elem|\n answer[index] << elem[index]\n end\n end\n answer\n end", "def zip_to_length(length, *arrays)\n (0...length).map do |i|\n arrays[-1].map { |array| array[i] }\n end\nend", "def zany_zip(*arr)\n max_length = 0\n arr.each do |x|\n if x.length > max_length\n max_length = x.length\n end\n end\n result = []\n i = 0\n while i < max_length\n temp = []\n arr.each do |subarray|\n temp << subarray[i]\n end\n result << temp\n i += 1\n end\n result\nend", "def zip(*rest) end", "def zip(*arr)\n (0...arr[0].length).map do |i|\n arr.map {|arr| arr[i]}\n end\nend", "def zip(*arr)\n new_arr = []\n i = 0\n while i < arr[0].length\n temp = []\n arr.each do |subarray|\n temp << subarray[i]\n end\n new_arr << temp\n i += 1\n end\n new_arr\nend", "def custom_zip (arr1, arr2)\n final = []\n arr1.each_with_index do |item, index|\n final << [item, arr2[index]]\n end\n final\nend", "def zip(arr1, arr2)\n Array.new(arr1.size) do |idx|\n [arr1[idx], arr2[idx]]\n end\nend", "def custom_zip(arr1, arr2)\n result = []\n arr1.each_with_index do |item, index|\n result << [arr1[index], arr2[index]]\n end\n result\nend", "def zip(*arrs)\n return [] if arrs.any?(&:empty?)\n [arrs.map(&:first)] + zip(arrs.first.drop(1), arrs.last.drop(1))\nend", "def custom_zip(arr1, arr2)\n final = []\n arr1.each_with_index do |value, index|\n final << [value, arr2[index]]\n end\n final\nend", "def zip(arr_1, arr_2)\n new_arr = []\n arr_1.size.times do |i|\n new_arr << [arr_1[i], arr_2[i]]\n end\n new_arr\nend", "def zip( *other_arrays, & block )\n\n load_parent_state\n \n return super\n \n end", "def zip(ar1, ar2)\n zip_rec = ->(ar1, ar2, result) do\n case [ar1, ar2]\n when [[], []]\n result\n else\n zip_rec.(ar1[1..-1], ar2[1..-1], result << [ar1[0], ar2[0]])\n end\n end\n zip_rec.(ar1, ar2, [])\nend", "def custom_zip(arr1, arr2)\n final=[]\n arr1.each_with_index do |item, index|\n nested_array= []\n arr2.each_with_index do |item2, index2|\n if index == index2\n nested_array << item\n nested_array << item2\n final << nested_array\n end\n end\n end\n final\nend", "def custom_zip(arr1, arr2)\n final = []\n arr1.each_with_index { |name, index| final << [name, arr2[index]] }\n final\nend", "def combine_zip(a, b)\n if a.length < b.length\n # fill in if a shorter than b\n a += Array.new(b.length - a.length)\n end\n a.zip(b).flatten!\nend", "def zip(arr1, arr2)\n index = 0\n zipped = []\n while index < arr1.length\n zipped << [arr1[index], arr2[index]]\n index += 1\n end\n zipped\nend", "def zipper(arr1, arr2)\n arr1.map.with_index { |val, idx| [val] << arr2[idx] }\nend", "def zip(array1, array2)\n iterations = array1.size\n results = []\n iterations.times do |index|\n results << [array1[index], array2[index]]\n end\n results\nend", "def zip(arr1, arr2)\n zipped = []\n arr1.each_with_index do |el, i|\n zipped << [el, arr2[i]]\n end\n zipped\nend", "def custom_zip(arr1, arr2, arr3)\n arr = []\n nest_arr = []\n arr1.each do |i|\n k = [] #initialize a temporary array\n k.push(i) #pushed first val\n k.push(arr2[arr1.index(i)]) #pushed 2nd val\n k.push(arr3[arr1.index(i)]) #pushed 3rd val\n nest_arr = k #assigned to nest_arr\n arr.push(nest_arr) # pushed nest_arr to arr in order to nest in\n end\n\n p arr\nend", "def zip(arr1, arr2)\n result = []\n idx = 0\n loop do\n result << [arr1[idx], arr2[idx]]\n idx += 1\n break if idx == arr1.size\n end\n result\nend", "def zip(arr1, arr2)\n zipped = []\n arr1.each_with_index { |ele, ind| zipped << [ele, arr2[ind]] }\n zipped\nend", "def zip(arr1, arr2)\n arr1.each_with_index.with_object([]) do |(el, i), z|\n z << [el, arr2[i]]\n end\nend", "def together_slice(*args)\n if_not_contain_array_rails_type_error\n reduce([]) { |ret, list|ret << list.slice(*args) }\n end", "def zip(first, second)\n first.zip(second)\nend", "def zip\n end", "def zipper(arr1, arr2)\n arr1.map.with_index { |elem, ndx| [elem, arr2[ndx]] }\nend", "def zip\n end", "def zip(arr1, arr2)\n arr1.each_with_index.with_object([]) do |(el, idx), arr|\n arr << [el, arr2[idx]]\n end\nend", "def to_args(arity)\n case arity\n when -1\n full_arguments\n when (min_argument_count..full_argument_count)\n full_arguments.slice(full_argument_count - arity, arity)\n else\n raise ArgumentError, \"Arity must be between #{min_argument_count} \"\\\n \"and #{full_argument_count}\"\n end\n end", "def to_args(arity)\n case arity\n when -1\n full_arguments\n when (min_argument_count..full_argument_count)\n full_arguments.slice(full_argument_count - arity, arity)\n else\n raise ArgumentError, \"Arity must be between #{min_argument_count} \"\\\n \"and #{full_argument_count}\"\n end\n end", "def zip(array1, array2)\n results = []\n array1.each_with_index do |current_element, current_index|\n results << [current_element, array2[current_index]]\n end\n results\nend", "def zip(first, second)\n first.zip(second).flatten\nend", "def zip_with(a, b, &op)\n result = []\n a.zip(b){ |aa,bb| result << op.call(aa,bb)}\n result\nend", "def custom_zip(arr1, arr2)\n new_nested = []\n arr1.each_with_index do | arr1_value, arr1_index |\n arr2.each_with_index do | arr2_value, arr2_index |\n if arr1_index == arr2_index\n arr3 = [arr1[arr1_index], arr2[arr2_index]]\n new_nested << arr3\n end # end of if\n end # end of do (array 2)\n end # end of do (array 1)\n new_nested\nend", "def interzip(array1, array2)\n array1.zip(array2).flatten\nend", "def zip_sum(array, array2)\n new_arr = []\n array.length.times do |index|\n new_arr.push(array[index] + array2[index])\n end\n new_arr\nend", "def zip(arr1, arr2)\n arr1.each_with_index.reduce([]) { |result, (el, idx)| result << [el, arr2[idx]] }\nend", "def array_align (arr, *data)\n arr.zip(*data)\nend", "def variable_length( *args )\n return args\nend", "def zip(*args, &result_selector)\n args.unshift(self)\n Observable.zip(*args, &result_selector)\n end", "def lecturer_zip(arr1,arr2)\n final = []\n arr1.each_with_index { |value, index| final << [value, arr2[index]] }\n final\nend", "def alternate\n return [] if size.zero?\n return [[self[0]]] if size == 1 \n populate_alternate_arrays\n end", "def zip(arr1, arr2)\n arr1.map.with_index { |el1, idx| [el1, arr2[idx]] }\nend", "def zip\n @zip\n end", "def zip first, second\n first.zip(second).flatten()\nend", "def zip_archive_zip_create(input_file1, opts = {})\n data, _status_code, _headers = zip_archive_zip_create_with_http_info(input_file1, opts)\n data\n end", "def interleave(*arrays)\n return [] if arrays.empty?\n inter_array = []\n\n arrays.max_by(&:length).size.times do |index|\n arrays.each { |array| inter_array << array[index] }\n end\n\n inter_array\nend", "def union(*arrys)\n\n united = []\n \n # For each argument passed, push it into a new flattened array\n # that is one dimensional. Making use of implied returns.\n arrys.each {|arg| united.push(arg) }.flatten\n\nend", "def zip first, second\n answer = Array.new\n first.each.with_index do |letter, index|\n answer << first[index]\n answer << second[index]\n end\n answer\nend", "def to_a(length=self.length)\n length == 0 ? [] : self[0, length]\n end", "def test_0300_zip\n @@log.debug \"test_0300_zip starts\" if @@log.debug?\n assert_respond_to(@list, :zip, \"test_0300_zip_respond\")\n # Basic example\n a = [1]\n b = [2,3]\n c = [4,5,6]\n ta = @list.zip(a, b, c)\n #\n te = [[@aen, 1, 2, 4], \n [@bsb, nil, 3, 5], \n [@cab, nil, nil, 6], \n [@dad, nil, nil, nil]]\n #\n assert_equal(te, ta, \"test_0300_zip_basic\")\n # TODO: A practical example ??? What could this possibly be used for??\n @@log.debug \"test_0300_zip ends\" if @@log.debug?\n end", "def combinations(*args)\n # initialize an array for the result\n array_new = []\n # combine the last two arguments (arrays)\n args[-2].each do |y|\n args[-1].each do |z|\n array_new.push(([y, z]).flatten)\n end\n end\n # get rid or last two arguments (arrays) that were combined above\n args.pop(2)\n # add the combined array (of last two elements) to args\n args.push(array_new)\n # if there are still more arguments to process call this function recursively\n if args.length > 1\n array_new = combinations(*args)\n end\n return array_new\nend", "def merge!(new_args); end", "def multiply_list_zip(array1,array2)\n array1.zip(array2).map {|element| element.reduce(:*)}\n # array 1's element would be spread out into three arrays, 3,5 and 7 being the first elements. Zip then iterates through the argument\n # and mergers these elements into array1 one by one. The documentation then states if a block is given it invoked for EACH ARRAY, so in this case\n # the combined arrays we have now created.\nend", "def ext_zip(values, options = {})\n zip_to_hash(self, values, options)\n end", "def zip(others)\n LazyList.new do\n next self if empty? && others.empty?\n Cons.new(Cons.new(head, Cons.new(others.head)), tail.zip(others.tail))\n end\n end", "def zip(*enums)\r\n r = block_given? ? nil : []\r\n len = enums.collect { |x| x.size }.max\r\n len.times do |i|\r\n val = enums.collect { |x| x[i] }\r\n if block_given?\r\n yield val\r\n else\r\n r << val\r\n end\r\n end\r\n r\r\nend", "def slice_args(out)\n out.shape.map {:*}\n end", "def mergeSort(ia)\n mergeSortHelper(ia, 0, ia.length-1)\nend", "def zip_contents; end", "def write_zip64_support=(_arg0); end", "def generate_zip\n o = [(0..9)].map{|i| i.to_a}.flatten\n zip = (0...5).map{ o[rand(o.length)] }.join\n end", "def bzpopmin(*args); end", "def union(ele1, ele2, *other_args)\n new = [ele1, ele2, *other_args]\n return new.flatten\nend", "def zipfile=(_arg0); end", "def interleave(arr1, arr2)\n # new_arr = []\n # arr1.size.times do |count|\n # new_arr << arr1[count] << arr2[count]\n # end\n # new_arr\n\n # using Array#zip and Array#flatten\n arr1.zip(arr2).flatten\nend", "def array_concat (*args)\n\t\tfull = Array.new\n\t\targs.each { |item|\n\t\t\tfull << item\n\t\t}\n\n\t\tfull.flatten!\n\t\tfull\n\tend", "def paralell_array(*enums)\n zip(*enums)\n end", "def combine(*args)\n if args.all? {|x| x.is_a? Array}\n para = args.shift\n args.each do |x|\n para = para.product(x)\n end\n para.map {|x| x.flatten(1)}\n else\n raise ArgumentError, 'All arguments must be Array'\n end\n end", "def my_each_with_index\n i = 0\n while i < self.to_a.length\n yield self.to_a[i], i\n i += 1\n end\n end", "def interleave(arr1, arr2)\n inter_arr = []\n idx = 0\n\n loop do\n inter_arr << arr1[idx]\n inter_arr << arr2[idx]\n \n idx += 1\n break if idx >= arr2.length\n end\n inter_arr\nend", "def my_each_with_index\n i = 0\n while i < self.length\n yield self[i], i\n i += 1\n end\n self\n end", "def flat(arr1=[],arr2=[],i=0)\n if i >= arr1.length\n return arr2\n else\n if arr1[i].kind_of?(Array)\n flat(arr1[i],arr2) \n else\n arr2.push(arr1[i])\n end\n return flat(arr1,arr2,i+1)\n end\nend", "def interleave(arr1, arr2)\n output_arr = []\n arr1.size.times do |idx|\n output_arr << arr1[idx]\n output_arr << arr2[idx]\n end\n output_arr\nend", "def alternate!\n return self if size.zero?\n first = self[0]\n return self.clear << [first] if size == 1\n ary1, ary2 = populate_alternate_arrays\n self.clear << ary1 << ary2\n end", "def zip(*lists)\n length = nil\n values = []\n lists.each do |list|\n array = list.to_a\n values << array.dup\n length = length.nil? ? array.length : [length, array.length].min\n end\n values.each do |value|\n value.slice!(length)\n end\n new_list_value = values.first.zip(*values[1..-1])\n list(new_list_value.map {|list| list(list, :space)}, :comma)\n end", "def interleave(arr1, arr2)\r\n combined_arr = []\r\n counter = 0\r\n arr1.size.times do\r\n combined_arr << arr1[counter]\r\n combined_arr << arr2[counter]\r\n counter += 1\r\n end\r\n combined_arr\r\nend", "def run_length_encode\n self.pack_consecutive_duplicates.inject([]) do |array, current|\n array << [current.size, current[0]]\n array \n end\n end", "def extract_build_args args # :nodoc:\n return [] unless offset = args.index('--')\n build_args = args.slice!(offset...args.length)\n build_args.shift\n build_args\n end", "def my_flatten\n arr = []\n i = 0\n while i < self.length\n if self[i].is_a? Array\n arr += self[i].my_flatten\n else\n arr << self[i]\n end\n i += 1\n end\n return arr\n end", "def interleave(arr1, arr2)\n return_array = []\n arr1.each_with_index do |element, index|\n return_array << element << arr2[index]\n end\nend", "def my_each_with_index\n i = 0\n while i < size\n yield(self[i], i)\n i += 1\n end\n self\n end", "def interleave(arr1, arr2)\n new_arr = []\n arr1.size.times{ |idx| new_arr << arr1[idx] << arr2[idx] }\n new_arr\nend", "def concat(another)\n case another\n when Array, ExternalArchive\n self[length, another.length] = another\n else \n raise TypeError.new(\"can't convert #{another.class} into ExternalArchive or Array\")\n end\n self\n end", "def interleave(arr1, arr2)\n return_array = arr1.zip(arr2).flatten\nend", "def merge_sort\n if self.length <= 1\n return self\n else\n mid = self.length/2\n return merge(self[0...mid].merge_sort, self[mid..-1].merge_sort)\n end\n end", "def interleave(arr1, arr2)\n index = 0\n results = []\n arr1.size.times do\n results << arr1[index] << arr2[index]\n index += 1\n end\n results\nend", "def merge_zip merged_build\n debug_msg \"Merging zip for #{merged_build}\"\n \n tmp = temp_dir\n \n title = merged_build.builds.map do |build| \n automation_by_name(build.name).name + \" v#{build.version}\"\n end.join(', ')\n names = merged_build.builds.map do |build| \n automation_by_name(build.name).short_name\n end.join(',')\n options = []\n options << \"-o\" << tmp\n options << '--title' << title\n options << '--names' << names\n merged_build.builds.each do |build|\n options << File.join(@public_dir, build.to_s)\n end\n SDoc::Merge.new.merge(options)\n \n prepare tmp\n \n tmp\n end", "def %(len) # {{{\n inject([]) do |array, x|\n # array << [] if [*array.last].nitems % len == 0\n array << [] if [*array.last].count{|x| !x.nil?} % len == 0\n array.last << x\n array\n end\n end", "def array_concat(array_1, array_2)\n array_2.each do |x|\n array_1[array_1.length] = x\n end\n return array_1\nend", "def merge_arrays (first, second)\n\nlarge_array = []\n\n 11.times do |i|\n smaller_array = []\n smaller_array << first[i]\n smaller_array << second[i]\n large_array << smaller_array\n end\n return large_array\n\nend", "def combine_arrays(nums, other_nums)\n \n return nums if other_nums.empty? # not necessary, but good to have\n return other_nums if nums.empty? # not necessary, but good to have\n \n res= []\n \n i, j = 0, 0\n \n while i < nums.length && j < other_nums.length\n a, b = nums[i], other_nums[j]\n \n if a <= b\n res << a\n i+= 1\n else\n res << b\n j+= 1\n end\n end\n \n if j == other_nums.length\n # other_nums was exhausted, but there still remain\n # elements in nums to process\n res.push( *nums[i..-1] )\n elsif i == nums.length\n # nums was exhausted, but there still remain\n # elements in nums to process\n res.push( *other_nums[j..-1] )\n end\n \n res\nend" ]
[ "0.7993346", "0.7171449", "0.6906811", "0.68743765", "0.6857708", "0.66011566", "0.65430564", "0.65390015", "0.6427724", "0.6289802", "0.61811864", "0.60137665", "0.6002802", "0.59019065", "0.5884806", "0.584799", "0.58433497", "0.5839005", "0.57678163", "0.57246906", "0.5706424", "0.56441516", "0.56425524", "0.5637954", "0.55308676", "0.55268043", "0.5470664", "0.543411", "0.54094124", "0.5400132", "0.5392805", "0.5373229", "0.53178537", "0.53120893", "0.5311099", "0.52711326", "0.52705157", "0.5270065", "0.52671427", "0.524909", "0.5198746", "0.51803374", "0.5114477", "0.51131713", "0.5109045", "0.5051116", "0.4968161", "0.49639958", "0.49566704", "0.4947134", "0.49008948", "0.49000803", "0.48988056", "0.48432", "0.4840228", "0.47865766", "0.47864538", "0.4769101", "0.47529992", "0.4675626", "0.4650642", "0.46390268", "0.46299642", "0.46290666", "0.46259192", "0.46229583", "0.45785996", "0.4571981", "0.45634538", "0.45467854", "0.45399052", "0.4509913", "0.45094913", "0.44974762", "0.4487856", "0.4485399", "0.4484996", "0.4472226", "0.44707423", "0.44437036", "0.44429904", "0.4439687", "0.44339994", "0.44236737", "0.44116902", "0.44024205", "0.44012856", "0.4397102", "0.4396874", "0.4389332", "0.438823", "0.4386835", "0.43852475", "0.4374861", "0.43727976", "0.43721333", "0.4371756", "0.43713707", "0.43682513", "0.4366348" ]
0.67384714
5
Write a method my_rotate that returns self rotated. By default, the array should rotate by one element. If a negative value is given, the array is rotated in the opposite direction.
def my_rotate(pos=1) pos.times do self.push(self.shift) end return self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def my_rotate(arr)\n print arr.rotate\n end", "def my_rotate!(array, amt)\n\nend", "def my_rotate(num = 1)\n num < 1 ? num.abs.times {self.unshift(self.pop)} : num.times {self.push(self.shift)}\n self\n end", "def my_rotate(num = 1)\n offset = num % self.length\n self.drop(offset) + self.take(offset)\n end", "def rotate(arr)\n\nend", "def my_rotate(num = 1)\n new_array = []\n \n new_array\nend", "def rotate_without_changing(arr)\n\nend", "def my_rotate(rotation = 1)\n # debugger\n answer = []\n each_with_index { |x, i| answer[i] = x }\n if rotation > 0\n rotation.times { answer.push(answer.shift) }\n elsif rotation == 0\n answer\n else\n rotation.abs.times { answer.unshift(answer.pop) }\n end\n answer\n end", "def array_rotation(arr, num)\n\tarr.rotate(num)\nend", "def rotate_array(ar)\n ar[1..-1] << ar[0]\nend", "def rotate_array(array)\narray[1..-1] + [array[0]]\nend", "def rotate_array(ary)\n ary[1..-1] + [ary[0]]\nend", "def rotate_array(ary)\n ary[1..-1] + [ary[0]]\nend", "def rotate_array(array)\n rotated = array[1..-1]\n first = array.first\n rotated.push(first)\nend", "def rotate_array(array)\n array[1..-1] + [array[0]] \nend", "def rotate_array(ary)\r\n return ary if ary.nil?\r\n ary[1..-1] << ary[0]\r\nend", "def rotate_array(array)\n array[1..-1] + [array[0]]\nend", "def rotate_array(array)\n array[1..-1] + [array[0]]\nend", "def rotate_array(array)\n array[1..-1] + [array[0]]\nend", "def rotate_array(array)\n array[1..-1] + [array[0]]\nend", "def rotate_array(array)\n array[1..-1] + [array[0]]\nend", "def rotate_array(array)\n array[1..-1] + [array[0]]\nend", "def rotate_array(array)\n array[1..-1] + [array[0]]\nend", "def rotate_array(array)\n array[1..-1] + [array[0]]\nend", "def rotate_array(array)\n array[1..-1] + [array[0]]\nend", "def rotate_array(array)\n array[1..-1] + [array[0]]\nend", "def rotate_array(array)\n array[1..-1] + [array[0]]\nend", "def rotate_array(array)\n array[1..-1] + [array[0]]\nend", "def rotate_array(array)\n array[1..-1] + [array[0]]\nend", "def rotate_array(array)\n array[1..-1] + array[0..0]\nend", "def rotate_array(arr)\n arr[1..-1] + [arr[0]]\nend", "def rotate_array(arr)\n arr[1..-1] + [arr[0]]\nend", "def rotate_array(arr)\n arr[1..-1] + [arr[0]]\nend", "def rotate_array(arr)\n arr[1..-1] + [arr[0]]\nend", "def rotate_array(arr)\n arr[1..-1] + [arr[0]]\nend", "def rotate_array(arr)\n arr[1..-1] + [arr[0]]\nend", "def rotate_array(arr)\n arr[1..-1] + [arr[0]]\nend", "def rotate_array(array)\n array[1..-1] << array[0]\nend", "def rotate_array(unrotated)\n unrotated[1..] + [unrotated.first]\nend", "def rotate_array(unrotated)\n unrotated[1..] + [unrotated.first]\nend", "def rotate_array(ary)\r\n ary[1..-1] << ary[0]\r\nend", "def rotate_array_alt(arr)\n arr[1..-1] + [arr[0]]\nend", "def rotate_array(array)\n array.values_at(1..-1, 0)\nend", "def rotate_array(array)\n array[1..-1] + [array[0]] # brackets added to array[0] to force it to an array from integer.\nend", "def rotate_array(array)\n array[1, array.size] << array[0]\nend", "def my_rotate(arr, offset=1)\n # your code goes here\n drop(offset) + take(offset)\n\nend", "def my_rotate(arr, offset=1)\n modOffset = offset % arr.length\n arr.drop(modOffset).concat(arr.take(modOffset))\nend", "def rotate_matrix(arr)\n\nend", "def rotate_array(arr)\n\narr_new = arr.clone\narr_new.push(arr_new[0]).shift\narr_new\nend", "def rotate_array(arr)\n arr[1...arr.size] + [arr[0]]\nend", "def rotate_array(arr)\n arr[1...arr.size] + [arr[0]]\nend", "def rotate_array(arr)\n rotated = arr.clone\n rotated.insert(-1, rotated.shift)\nend", "def rotate_array(ary)\n ary[1..-1] + [ary[0]] # need to concatenate 2 arrays\nend", "def rotate_matrix(array)\n\n\nend", "def rotate_array(arr)\narr.drop(1) + arr[0...1]\nend", "def rotate(input)\n input[1..-1] << input[0]\nend", "def rotate_array(arr)\n arr[1..(arr.size - 1)] << arr[0]\nend", "def rotate_array(arr)\n arr[1..(arr.size - 1)] << arr[0]\nend", "def rotate(array)\n array.map.with_index do |elem, index|\n if (index + 1) < array.size\n array[index + 1]\n else\n array[0]\n end\n end\nend", "def my_rotate(arr, offset = 1)\n arr.drop(offset % arr.length) + arr.take(offset % arr.length)\nend", "def my_rotate(arr, offset=1)\n # your code goes here\n shift = offset % arr.length\n arr.drop(shift) + arr.take(shift)\nend", "def rotate_array(arr)\n new_arr = arr.clone # avoid mutation\n first_element = new_arr.shift\n new_arr << first_element # could've called new_arr.shift here instead\n new_arr # later realized that this is redundant\nend", "def my_rotate(arr, offset=1)\n # your code goes here\n arr.drop(offset % arr.length) + arr.take(offset % arr.length)\nend", "def rotate_array(arr)\n arr.empty? ? arr : arr[1..-1] << arr[0]\nend", "def rotate_backwards(arr)\n\nend", "def rotate_array(numbers)\n numbers[1..-1] + [numbers[0]]\nend", "def rotate_array(numbers)\n numbers[1..-1] + [numbers[0]]\nend", "def my_rotate(arr, offset=1)\n unshifted = arr.pop(arr.length % offset)\n arr.push(popped)\nend", "def rotate_array(arr)\n [*arr[1..-1], *arr[0, 1]]\nend", "def rotate_array(aArray, off_x, off_y, rel_angle, change_in_place=false)\r\n # - - - - - - - - - - - - - - - - - - - - -\r\nend", "def my_rotate(arr, offset=1)\r\n # your code goes here\r\n # take first offset elements and append to end of array\r\n shift = offset % arr.length\r\n arr.drop(shift) + arr.take(shift)\r\nend", "def rotate_array(array)\n array.drop(1) + array.take(1)\nend", "def rotate_array(array)\n first_value = array.slice(0)\n other_values = array.slice(1..-1)\n other_values << first_value\nend", "def rotate_array(array)\n first_value = array.slice(0)\n other_values = array.slice(1..-1)\n other_values << first_value\nend", "def rotate\n push shift\n end", "def my_rotate(arr, offset=1)\n rotations = offset % arr.length\n arr.drop(rotations) + arr.take(rotations)\nend", "def rotate_array(arr)\n arr_copy = arr.dup\n rotated_element = arr_copy.shift\n arr_copy.push(rotated_element)\nend", "def rotate_array(array)\n arr2 = []\n arr2.concat(array[1..-1]) << array[0]\nend", "def rotate_array(arr)\n arr1 = arr.clone\n f = arr1.shift\n arr1 << f\nend", "def rotate_array1(arr)\n rotated_arr = arr.map { |element| element }\n rotated_arr.push(rotated_arr.shift)\n\n rotated_arr\nend", "def rotate!( angle_rad )\n self.angle += angle_rad\n self\n end", "def rotate(unrotated)\n return '' if unrotated.empty?\n unrotated[1..-1] + unrotated[0]\nend", "def rotate( angle_rad )\n dup.rotate!( angle_rad )\n end", "def rotate_array(array)\n result = []\n array.each_with_index do |value, index|\n result.push(value) if index > 0\n end\n result.push(array[0])\n result\nend", "def rotate! n = 1\n n %= size\n return self if n.zero?\n new_index = (@current_index - n) % size\n center_indices_at new_index\n @array.rotate! n\n end", "def rotate_array(arr)\n new_arr = arr.clone\n new_arr << new_arr.shift\n new_arr\nend", "def rotate_array(arr)\n rotated_arr = []\n if arr.length > 1\n arr.each_index do |index|\n next if index + 1 >= arr.length\n rotated_arr.push(arr[index + 1])\n end\n end\n rotated_arr.push(arr[0])\n rotated_arr\nend", "def rotate_array(arr)\n arr_copy = arr.dup\n arr_copy << arr_copy.shift\nend", "def rotate_array(input_array)\n return input_array if input_array.size <= 1\n new_array = []\n index_counter = 1\n loop do\n new_array << input_array[index_counter]\n index_counter += 1\n break if index_counter >= input_array.size\n end\n new_array << input_array[0]\n new_array\nend", "def my_rotate(turns = 1)\n arr = self.map { |el| el }\n\n if turns > 0\n turns.times do\n target_element = arr.shift\n arr << target_element\n end\n elsif turns < 0\n turns.abs.times do\n target_element = arr.pop\n arr.unshift(target_element)\n end\n end\n\n arr\n end", "def rotate_array(array)\n new_array = array.dup \n new_array << new_array.shift \nend", "def rotate_array(array_of_numbers)\n rotated_array = array_of_numbers.clone\n rotated_array << rotated_array.shift\n\n rotated_array\nend", "def rotate_array(array)\n arr_copy = array.clone\n return arr_copy if arr_copy.empty?\n arr_copy.push(arr_copy.shift)\nend", "def rotate_deg!( angle_deg )\n self.angle_deg += angle_deg\n self\n end", "def rotate_array(array)\n new_array = array.dup\n first_element = new_array.shift\n new_array.append(first_element)\n new_array\nend", "def rotate_array(arr)\n [arr[1..-1],arr[0]].flatten\nend", "def rotate_array(arr)\n arr2 = arr.dup\n first = arr2.shift\n arr2 << first\nend", "def rotate(array, i)\n i.times { array << array.shift }\n array\nend", "def rotate_array(arr)\n array = arr.dup\n array << array.shift\nend", "def rotate_arr(arr)\n result_arr = arr.map{|num| num}\n result_arr << result_arr[0]\n result_arr.shift\n result_arr\nend" ]
[ "0.7689837", "0.7450369", "0.7337929", "0.7266656", "0.7196517", "0.71069294", "0.7103364", "0.69522715", "0.692674", "0.6794971", "0.67792004", "0.6771717", "0.6771717", "0.6761561", "0.67435664", "0.6717796", "0.6708353", "0.6708353", "0.6708353", "0.6708353", "0.6708353", "0.6708353", "0.6708353", "0.6708353", "0.6708353", "0.6708353", "0.6708353", "0.6708353", "0.6708353", "0.66922367", "0.66900986", "0.66900986", "0.66900986", "0.66900986", "0.66900986", "0.66900986", "0.66900986", "0.668971", "0.66823596", "0.66823596", "0.6652115", "0.6631957", "0.6578693", "0.6558462", "0.6544744", "0.65260196", "0.65232474", "0.65161943", "0.6506856", "0.65023893", "0.65023893", "0.64996934", "0.64730424", "0.64668965", "0.6462237", "0.6455609", "0.64466566", "0.64466566", "0.6434112", "0.64268386", "0.6420788", "0.6399667", "0.6395067", "0.63950485", "0.63917184", "0.6375277", "0.6375277", "0.63689476", "0.63636786", "0.63580227", "0.6347337", "0.63274413", "0.63158786", "0.6315567", "0.63148177", "0.63069737", "0.625936", "0.62571543", "0.6245096", "0.62438375", "0.62258357", "0.62228906", "0.6216013", "0.6208201", "0.6204034", "0.6199513", "0.61665076", "0.61566806", "0.615101", "0.6144416", "0.61363536", "0.6119118", "0.6109234", "0.6089142", "0.60859466", "0.60788244", "0.6077718", "0.60734355", "0.60628116", "0.6057429" ]
0.72281665
4
my_join returns a single string containing all the elements of the array, separated by the given string separator. If no separator is given, an empty string is used.
def my_join(link="") str = "" i = 0 while i < self.length if i != 0 str += link end str += self[i].to_s i += 1 end return str end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def my_join(array, separator)\n\tarray_string = \" \"\n\tarray.each{ |a| array_string << a + separator }\n\treturn array_string\nend", "def my_join(arr, separator = \"\")\n str = \"\"\n arr.each_with_index { |el, i| str += el + separator}\n return str[0..separator.length*-1-1]\nend", "def my_join(arr, separator = \"\")\n join = \"\"\n idx = 0\n while idx < arr.length\n join = join + arr[idx]\n if idx != arr.length - 1 # Don't want to add the separator after the last element\n join = join + separator\n end\n idx = idx + 1\n end\n join\nend", "def my_join(arr, separator=\"\")\r\n # your code goes here\r\n my_join = \"\"\r\n\r\n i=0\r\n while i<arr.length\r\n if i < arr.length - 1\r\n my_join += arr[i] + separator\r\n else\r\n my_join += arr[i]\r\n end\r\n i+=1\r\n end\r\n my_join\r\nend", "def my_join(arr, separator = \"\")\n return \"\" if arr.empty?\n joined_str = \"\"\n arr[0...-1].each {|elem| joined_str << elem + separator}\n joined_str << arr[-1]\nend", "def my_join(arr, separator = \"\")\nr = \"\"\narr.each_with_index { |c, i| r += separator if i != 0; r += c.to_s }\nr\nend", "def custom_join(array, delimiter = \"\")\r\n array.join(delimiter)\r\nend", "def my_join(array, separator)\n\n string = ''\n array.each_with_index do |elem, index|\n if index < array.length - 1\n string << elem + separator\n else\n string << elem\n end\n end\n \n string\nend", "def my_join(arr, separator = \"\")\n result = \"\"\n arr.each_index do |index|\n if index != arr.length-1\n result += (arr[index] + separator)\n else\n result += arr[index]\n end\n end\n result\nend", "def my_join(arr, separator = \"\")\n result = \"\"\n (0...arr.length).each do |idx|\n if idx != arr.length - 1\n result << arr[idx] << separator\n else\n result << arr[idx]\n end\n end\n\n return result\n\nend", "def my_join(separator = '')\n out_str = ''\n each do |x|\n out_str << x\n out_str << separator\n end\n out_str[0..-1 * separator.length]\n end", "def my_join(arr, separator = \"\")\n result = \"\"\n arr.each_with_index do |ele, idx|\n idx < arr.size - 1 ? result += (ele + separator) : result += ele\n end\n result\nend", "def my_join(arr, separator = \"\")\n if arr.empty?\n return \"\"\n else\n new_str = ''\n arr[0..-2].each{|n| new_str+= (n+separator)}\n new_str + arr[-1]\n end\nend", "def my_join(sep='')\n str = ''\n self.each_with_index do |ele, i|\n if i == self.length-1\n str += ele \n else\n str += ele + sep\n end\n end\n str\n end", "def my_join(arr, separator = \"\")\n result = ''\n arr.each do |x|\n result << x.to_s\n result << separator unless x == arr[-1]\n end\n result\nend", "def my_join(separator = \"\")\n ret = \"\"\n each_with_index do |el, i|\n if i == count - 1\n ret << el\n else\n ret << el + separator\n end\n end\n ret\n end", "def custom_join(array, delimiter = \"\")\r\n string = \"\"\r\n last_index = array.length - 1\r\n array.each_with_index do |elem, index|\r\n string << elem\r\n string << delimiter unless index == last_index\r\n end\r\n string\r\nend", "def join(separator=nil)\n to_a.join(separator)\n end", "def join(array, delimiter = \"\")\n result = \"\"\n i = 1\n array.each do |item|\n result += item.to_s\n unless i == array.length\n result += delimiter\n end\n i += 1\n end\n result\nend", "def my_join(arr, separator = '')\n new_str = ''\n return new_str if arr.empty?\n\n arr.each do |c|\n new_str << c + separator unless c == arr.last\n end\n new_str + arr.last\nend", "def join(separator = $OFS)\n '' + _join(separator)\n end", "def my_join(arr, separator = \"\")\n output_str = arr[0].to_s\n arr.each do |el|\n if el != arr[0]\n output_str += (separator.to_s + el.to_s)\n end\n end\n\n output_str\nend", "def my_join(arg='')\n joined_str = ''\n self.my_each {|el| joined_str += el + arg}\n joined_str\n end", "def safe_join(array, sep = $OFS)\n helpers.safe_join(array, sep)\n end", "def join(sep = $,)\n map(&:to_s).join(sep)\n end", "def join(separator = $,)\n result = \"\"\n if separator\n each_with_index { |obj, i| result << separator if i > 0; result << obj.to_s }\n else\n each { |obj| result << obj.to_s }\n end\n result\n end", "def safe_join(array, sep = T.unsafe(nil)); end", "def join(separator = T.unsafe(nil)); end", "def join_split(arr=nil)\n\t\tarr.join.split(\"\") if not arr.nil? and arr.respond_to? :push\n\tend", "def fn_join(value)\n unless value.last.is_a?(Array)\n val = value.last.to_s.split(\",\")\n else\n val = value.last\n end\n val.join(value.first)\n end", "def join(sep=$,)\n self.to_a.join(sep)\n end", "def join\n a = []\n each{|s| a << s}\n a.join\n end", "def join(delimiter=' ')\n if rest\n first.to_s + delimiter + rest.join\n else\n first.to_s\n end\n end", "def join(s = Undefined)\n # this is mostly Rubinius code, but modified for our API\n # Put in delta since we need the recursion guard found in common.\n my_size = size\n return \"\" if my_size._equal?(0)\n if s._equal?(Undefined)\n sep = $,\n elsif s._equal?(nil)\n sep = nil\n else\n sep = s.to_str # let any NoMethodError be seen by caller\n end\n\n out = \"\"\n# out.taint if sep.tainted? or self.tainted?\n i = 0\n ts = Thread.__recursion_guard_set\n while (i < my_size)\n elem = at(i)\n out << sep unless (sep._equal?(nil) || i == 0)\n\n if elem._isArray\n\tadded = ts.__add_if_absent(self)\n\tbegin\n if ts.include?(elem)\n out << \"[...]\"\n else\n out << elem.join(sep)\n end\n\tensure\n if added\n\t ts.remove(self)\n\t end\n end\n else\n out << elem.to_s\n# out.taint if elem.tainted? and not out.tainted?\n end\n i += 1\n end\n out\n end", "def my_join(spacer = '')\n str = ''\n\n self.each_with_index do |char, idx|\n str += char\n str += spacer if idx != self.length - 1\n end\n\n str\n end", "def join(*args,sep)\n args.reject { |x| !x }.uniq.join(sep)\n end", "def join(delimiter); @args.join(delimiter) end", "def joiner(arr, delimiter = ', ', word = 'or')\n case arr.size\n when 0 then ''\n when 1 then arr.first\n when 2 then arr.join(\" #{word} \")\n else\n all_but_last = arr[0, arr.length - 1].join(delimiter)\n \"#{all_but_last}#{delimiter}#{word} #{arr[-1]}\"\n end\nend", "def __joinStrings\n # called from generated code\n str = ''\n n = 0\n siz = self.__size\n while n < siz\n str << self.__at(n).to_s\n n += 1\n end\n str\n end", "def join_split(array=nil, *rest)\n\tarray.join.split(//) if not array.nil? and array.respond_to? :join\nend", "def to_s\n join\n end", "def joinor(arr, separator = \", \", ending = \"or\")\n final_string = \"\"\n n = 0\n\n case arr.length()\n when 1\n final_string = arr[0].to_s\n when 2\n final_string = arr[0].to_s + \" \" + ending + \" \" + arr[1].to_s\n when 3..\n while n < (arr.length()-1)\n final_string += (arr[n].to_s) + separator\n n += 1\n end\n final_string += ending + \" \" + (arr[-1].to_s)\n end\nend", "def string(arr)\n arr.join(\" \")\nend", "def array_string(array, **opt)\n list_separator = opt[:list_separator] || LIST_SEPARATOR\n normalized_list(array, **opt).join(list_separator)\n end", "def to_joined_str (item)\n if (item.class == Array) then\n item.join(\", \")\n else\n item.to_s\n end\nend", "def joinor(arr, sep = \", \", art = \"or \")\n case arr.size\n when 0 then \"\"\n when 1 then arr.first\n when 2 then arr.join(\" #{art} \")\n else\n arr[-1] = \"#{art} #{arr.last}\"\n arr.join(sep)\n end\nend", "def joinor(array, separator = ', ', word = 'or')\n case array.size\n when 0, 1\n array.join\n when 2\n array.join(\" #{word} \")\n else\n last_element = array.pop.to_s\n array.join(separator) << last_element.prepend(\"#{separator}#{word} \")\n end\nend", "def join(array, separator)\n first = true\n array.each do |widget_or_text|\n if !first\n text separator\n end\n first = false\n text widget_or_text\n end\n end", "def joinor(arr, delimiter = ', ', conjunction = 'or')\n return '' if arr.empty?\n arr.map!(&:to_s)\n return arr[0] if arr.size == 1\n str = arr.size > 2 ? arr[0..-2].join(delimiter) + delimiter : arr[0] + ' '\n # str = arr[0..-2].join(delimiter)\n # str << (arr.size > 2 ? delimiter : ' ')\n str << conjunction + ' ' + arr[-1]\nend", "def concatenate_array_of_strings(array)\n array_of_strings_concatenated = array.join\nend", "def join(list, sep = '')\n return '' if list.length == 0\n first_word = list.shift\n list.each do |item|\n first_word << sep << item\n end\n\n first_word\n end", "def map_join(list, *opts, &block)\n options = opts.extract_options!\n if options[:nowrap]\n options[:surround] = [raw('<span style=\"white-space: nowrap;\">'), raw(''), raw('</span> ')]\n end\n separator = options[:separator] || opts[0] || raw(options[:surround] ? ',' : ', ')\n last_separator = options[:last_separator] || opts[1] || separator\n\n results = list.map &block\n case results.length\n when 0 then ''\n when 1 then results[0]\n else\n # Array#join doesn't support html_safe => concatenate with inject\n if options[:surround]\n s1,s2,s3 = options[:surround]\n s1 + results[0..-2].inject { |a,b| a.to_s + s2 + separator + s3 + s1 + b.to_s } +\n s2 + last_separator + s3 + results.last\n else\n results[0..-2].inject {|a,b| a.to_s + separator + b.to_s } + last_separator + results.last\n end\n end\n end", "def to_s\n self.join\n end", "def list_join(*args)\n args.count == 1 ? \" #{args[0]}\" : \"#{$/}* #{args.join(\"#{$/}* \")}\"\n end", "def _eval_join(*args)\n args = args.compact\n args.delete_if &:empty?\n args.slice(1, args.size).to_a.inject(args.first) do |memo, item|\n if item.start_with?(\"[\")\n memo += item\n else\n memo += \".#{item}\"\n end\n end\n end", "def comma_join(data)\n if data.is_a?(Array)\n data.join(',')\n else\n data || ''\n end\n end", "def join(args, joiner=nil)\n raise Error, 'argument to Sequel.join must be an array' unless args.is_a?(Array)\n if joiner\n args = args.zip([joiner]*args.length).flatten\n args.pop\n end\n\n return SQL::StringExpression.new(:NOOP, '') if args.empty?\n\n args = args.map do |a|\n case a\n when Symbol, ::Sequel::SQL::Expression, ::Sequel::LiteralString, TrueClass, FalseClass, NilClass\n a\n else\n a.to_s\n end\n end\n SQL::StringExpression.new(:'||', *args)\n end", "def array_method(string)\n string.join(\" \")\nend", "def join_strings_reject_empty(display_array, separator = \" ,\")\n display_array = display_array.reject { |display| display.empty? }\n return display_array.join(separator).html_safe\n\n end", "def join\n str = @feedback.join(@separator)\n str << @separator.strip if @trailing_separator\n str\n end", "def join(array, separator)\n first = true\n array.each do |item|\n if !first\n if separator.is_a? Widget\n widget separator\n else\n text separator\n end\n end\n first = false\n if item.is_a? Widget\n widget item\n else\n text item\n end\n end\n end", "def try_join_arr(val)\n val.join(\"\\n\") rescue val\n end", "def main_thing(arr, delimiter = \"\")\n\njoin_word = \"\"\n\narr.each do |i|\n if arr.index(i) > 0\n join_word += delimiter\n end\n join_word += i\n end\n p join_word\n end", "def join(x, sep = \",\")\n y = []\n x.each do |element|\n y.push element.text\n end\n y.join(sep)\n end", "def joinor(arr, delimiter=', ', word='or')\n case arr.size\n when 0 then ''\n when 1 then arr.first\n when 2 then arr.join(\" #{word} \")\n else\n arr[-1] = \"#{word} #{arr.last}\"\n arr.join(delimiter)\n end\nend", "def joinor(arr, str1 = ', ', str2 = 'or')\n case arr.size\n when 0 then ''\n when 1 then arr.first\n when 2 then arr.join(\" #{str2} \")\n else\n arr[-1] = \"#{str2} #{arr.last}\"\n arr.join(str1)\n end\nend", "def concatenate_array\n\tarr = [\"this is my string\", \"where I concatenate\", \"everything together\"]\n\tstring_arr = arr.join(\" \")\nend", "def array_joiner( *arr)\n p arr\n array = [] \n array << arr\n array.flatten.flatten\n\nend", "def joinor(arr, delimiter=', ', word='or')\n arr[-1] = \"#{word} #{arr.last}\" if arr.size > 1\n arr.join(delimiter)\nend", "def english_join(conjunction = 'and', separator = ', ', oxford_comma = true)\n len = length\n # Return empty string for empty array\n return '' if len == 0\n # Return only element as string if length is 1\n return self[0].to_s if len == 1\n # Return comma-less conjunction of elements if length is 2\n return \"#{self[0]} #{conjunction} #{self[1]}\" if len == 2\n # Return comma joined conjunction of elemements\n join_str = ''\n each_with_index{|ele, i|\n str = if !oxford_comma && i == len - 2\n \"#{ele} #{conjunction} \" # rubocop:disable Layout/IndentationWidth\n elsif i == len - 2\n \"#{ele}#{separator}#{conjunction} \"\n elsif i == len - 1\n ele.to_s\n else\n \"#{ele}#{separator}\"\n end\n join_str << str\n }\n join_str\n end", "def join_domain( arr )\n arr.map {|i|\n if /\\A\\[.*\\]\\z/ === i\n i\n else\n quote_atom(i)\n end\n }.join('.')\n end", "def join(*rest) end", "def encode_array(arr)\n arr.join ','\n end", "def join(strings, seperator)\n result = strings.first.clone\n strings[1..-1].each do |str|\n result << seperator\n result << str\n end\n\n return result\nend", "def joinor(array, delimiter = ', ', word = 'or')\n if array.size == 2\n array.join(\" #{word} \")\n else\n array[-1] = \"#{word} #{array.last}\"\n array.join(delimiter)\n end\nend", "def join(input, glue = T.unsafe(nil)); end", "def back_to_s(array)\n array.join(\"\")\nend", "def join_with str = nil\n @join_with = str if str\n @join_with || ', '\n end", "def combine(str, arr)\n out = ''\n arr.each do |el|\n out += el\n end\n out + str\nend", "def joinor(ary, punc=', ', conj='or')\n if ary.size <= 1\n ary.first.to_s\n elsif ary.size == 2\n ary.join(\" #{conj} \")\n else\n \"#{ary[0..-2].join(punc)}#{punc + conj} #{ary.last}\"\n end\nend", "def to_s\n self.join \" \"\n end", "def joinor(elements, separator = ', ', conjunction = 'or')\n temp = []\n elements.each.with_index do |element, index|\n if index == elements.size - 1\n if elements.size > 1\n temp << \" #{conjunction} #{element}\"\n else\n temp << \"#{element}\"\n end\n else\n if elements.size > 2\n temp << \"#{element}#{separator}\"\n else\n temp << \"#{element}\"\n end\n end\n end\n temp.join.gsub(' ', ' ')\nend", "def human_string(array)\n length = array.length\n \n new_string = array[0...-1].join(\", \")\n new_string << \" and #{array[-1]}\"\n \n return new_string\nend", "def joinor(ary, delimiter = ', ', last_word = 'or')\n return ary.first if ary.size == 1\n return \"#{ary.first} #{last_word} #{ary.last}\" if ary.size == 2\n\n last_element = ary.pop\n ary << ''\n\n \"#{ary.join(delimiter)}\"\\\n \"#{last_word} \"\\\n \"#{last_element}\"\n end", "def join_strings(a, b)\n a + \" \" + b\nend", "def array_to_string(arr)\n arr.map { |e| \"'#{sanitize(e)}'\" }.join(\",\")\n end", "def joinor(ary, delimiter = ', ', final_word = 'or')\n result = ''\n count = 0\n\n case ary.size\n when 0 then ''\n when 1 then ary[0].to_s\n when 2 then \"#{ary[0]} #{final_word} #{ary[1]}\"\n else\n while count <= ary.length - 2\n result += ary[count].to_s + delimiter\n count += 1\n end\n\n result + final_word + ' ' + ary[-1].to_s\n end\nend", "def to_s\n to_a.join(SEPARATOR)\n end", "def joinlines(lines)\n lines.is_a?(Array) ? lines.join : lines\n end", "def to_s\n @items.join( _separator )\n end", "def name(arr)\n\tarr.join(' ')\nend", "def join_list(delim, list) { :'Fn::Join' => [ delim, list ] } end", "def strjoin strs, before = \"\", after = \"\", joiner = ',', line_end=' '\n if strs.keep_if { |str| !str.blank? }.size > 0\n last = strs.pop\n liststr = strs.join (joiner+line_end)\n liststr += \" and#{line_end}\" unless liststr.blank?\n before+liststr+last+after\n else\n \"\"\n end\nend", "def to_s\n return super unless elements\n elements.map(&:to_s).join(\" \")\n end", "def joinor(array, symbol = ', ', symbol_2 = 'or')\n if array.size == 2\n array.join(' ').insert(-2, 'or ')\n elsif array.size == 1\n array.join\n else\n array.join(\"#{symbol}\").insert(-2, \"#{symbol_2} \")\n end\nend", "def join_nested_strings(array)\n string_array = []\n count = 0\n while count < array.length do\n\n inner_count = 0\n while inner_count < array[count].length do\n if array[count][inner_count].class == String\n string_array << array[count][inner_count]\n else\n string_array = string_array\n end\n inner_count += 1\n\n end\n count += 1\n end\n string_array.join(\" \")\nend", "def join_strings(string_1, string_2)\n \"#{string_1} #{string_2}\"\nend", "def to_s\n buf = []\n each { |part| buf << part }\n buf.join\n end", "def oxford_comma(array)\n case array.length \nwhen 1\n \"#{array[0]}\"\nwhen 2\n array[0..1].join(\" and \")\nelse \n array[0...-1].join(\", \") << \", and #{array[-1]}\"\nend \nend", "def format(arr, opts={})\n # if seperator is an array, it is using different seperators for inner arrays\n seperator = opts[:seperator] || ' '\n #indicates if it should return nil if one of arr's elements is nil\n ignore = opts.has_key?(:ignore) ? opts[:ignore] : false\n format = opts[:format] || '%s'\n\n # determine if there empty elements in the array\n def has_empty?(a)\n if a.instance_of? Array\n ret = false\n a.each { |x| ret = true if has_empty?(x) }\n ret\n else\n not a or a.empty?\n end\n end\n includes_empty = has_empty? arr\n\n # arrays to string using the seperators\n seperator = [seperator] if not seperator.kind_of? Array\n def visit(ar, lvl, seperator)\n sep = seperator[lvl]\n sep = seperator.first if not sep\n s = ar.map do |element|\n if element.kind_of? Array\n visit(element, lvl + 1, seperator)\n else\n element\n end\n end\n s.reject! { |x| not x or x.empty? } # remove empty/nil elements\n s.join(sep) \n end\n str = visit(arr, 0, seperator)\n\n if includes_empty and ignore\n nil\n else\n format % [str]\n end\n end" ]
[ "0.88390476", "0.86078805", "0.8597715", "0.85454005", "0.8535866", "0.85291773", "0.84992737", "0.8493449", "0.8485974", "0.84780633", "0.8409516", "0.83667535", "0.8319346", "0.8314559", "0.8275135", "0.81557107", "0.812804", "0.8122665", "0.8086827", "0.8085121", "0.8082976", "0.7960929", "0.7940267", "0.79058504", "0.78970903", "0.7836105", "0.78211087", "0.7696768", "0.7579506", "0.7492984", "0.74824786", "0.7281965", "0.7270707", "0.72435313", "0.7191009", "0.7159195", "0.71359205", "0.7085211", "0.7075133", "0.703821", "0.70215917", "0.7018258", "0.6932497", "0.6931583", "0.692464", "0.6883768", "0.6854536", "0.68347764", "0.68208134", "0.6800118", "0.6760534", "0.6757575", "0.6757481", "0.672313", "0.66980976", "0.6690215", "0.66696626", "0.66625977", "0.66461504", "0.66406524", "0.65952975", "0.6592196", "0.6573134", "0.6547161", "0.6543165", "0.65199673", "0.6503297", "0.6470437", "0.64458704", "0.6399173", "0.6384514", "0.63575006", "0.63490057", "0.6345966", "0.63416624", "0.62921816", "0.62884086", "0.62039655", "0.6185762", "0.61652076", "0.61085874", "0.61027914", "0.6102606", "0.6094157", "0.6093053", "0.6088722", "0.60498637", "0.6047473", "0.6038362", "0.6018645", "0.60158956", "0.60140383", "0.5985757", "0.5981931", "0.59780633", "0.59737253", "0.5963233", "0.59487134", "0.59340876", "0.593067" ]
0.7110448
37
Write a method that returns a new array containing all the elements of the original array in reverse order.
def my_reverse reverse = [] i = self.length - 1 while i >= 0 reverse << self[i] i -= 1 end return reverse end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reverse_array(array_new)\n array_new.reverse \n end", "def reverse(array)\n result_array = []\n array.reverse_each { |element| result_array << element }\n result_array\nend", "def reverse(array)\n result_array = []\n array.reverse_each { |element| result_array << element }\n result_array\nend", "def my_reverse(arr)\n new_array = arr.reverse\n return new_array\n end", "def reverse(array)\n new_array = []\n \n array.reverse_each { |element| new_array << element }\n \n new_array\nend", "def reverse_array (array) \n return array.reverse\nend", "def my_reverse\n new_arr = []\n i = self.length-1\n while i >= 0\n new_arr << self[i]\n i -= 1\n end\n new_arr\n end", "def reverse_array(array)\n array.reverse\nend", "def reverse_array(array)\n array.reverse \nend", "def reverse_array(array)\n array.reverse!\n array\nend", "def reverse_array(arr)\n arr.reverse\nend", "def reverse_array(array)\n array.reverse\nend", "def reverse_array(array)\n array.reverse\nend", "def reverse_array(array)\n array.reverse\nend", "def reverse_array(array)\n array.reverse\nend", "def reverse_array(array)\n array.reverse\nend", "def reverse_array(array)\n array.reverse\nend", "def reverse_array(array)\n array.reverse\nend", "def reverse_array(array)\n array.reverse\nend", "def reverse_array(array)\n array.reverse\nend", "def reverse_array(array)\n array.reverse\nend", "def reverse_array(array)\n array.reverse\nend", "def reverse_array(array)\n array.reverse\nend", "def reverse_array(array)\n array.reverse\nend", "def reverse_array(array)\n array.reverse\nend", "def reverse_array(array)\n array.reverse\nend", "def reverse_array(array)\n array.reverse\nend", "def reverse_array(array)\n array.reverse\nend", "def reverse_array(array)\n array.reverse\nend", "def reverse_array(array)\n array.reverse\nend", "def reverse_array(array)\n array.reverse\nend", "def reverse_array(array)\n array.reverse\nend", "def reverse_array(array)\narray.reverse\nend", "def reverse_array(array)\narray.reverse\nend", "def reverse_array(array)\narray.reverse\nend", "def reverse_every_element_in_array(array)\n new_array = Array.new\n array.each {|element|\n new_array << element.reverse\n } \n new_array\nend", "def reverse_array(array)\n\tarray.reverse\nend", "def reverse(array)\n results = []\n array.reverse_each{ |x| results << x }\n results\nend", "def reverse_array(arr_rev)\n arr_rev.reverse\nend", "def reverse_array(arry)\n arry.reverse\n\nend", "def reverse_array(array)\n array.reverse!\nend", "def reverse_array(array)\n array.reverse!\nend", "def reverse(array)\r\n new_array = []\r\narray.reverse_each do |element|\r\n new_array << element\r\nend\r\nnew_array\r\nend", "def reverse_array(array)\n new_array = []\n index = -1\n while index * (-1) <= array.length\n new_array << array[index]\n index -= 1\n end\n new_array\nend", "def reverse!(old_array)\n new_array = []\n while old_array.length > 0\n new_array << old_array.pop\n end\n while new_array.length > 0\n old_array << new_array.shift\n end\n old_array\nend", "def my_reverse\n arr = []\n\n idx = self.length - 1\n while idx >= 0\n arr << self[idx]\n idx -= 1\n end\n\n arr\n end", "def my_reverse(arr)\n result = []\n for i in (0..arr.length-1).reverse_each #maybe this is cheating?\n result << arr[i]\n end\n result\nend", "def reverseArray(array)\n tmp_array = Array.new(array.length)\n index = array.length - 1\n\n for i in 0...array.length\n tmp_array[index] = array[i]\n index -= 1\n # puts \"#{i} = #{array[i]}\"\n end\n\n return tmp_array\nend", "def reverse_array(array)\n reversed_arr = []\n (array.size - 1).downto(0) do |index|\n reversed_arr << array[index]\n end\n\n reversed_arr\nend", "def reverse(arr)\n output = []\n arr.reverse_each {|x| output.push x}\n output\nend", "def reverse(array)\n new_array = []\n array.length.times do \n new_array << array.pop\n end\n new_array\nend", "def reverse_array(i)\r\n i.reverse!\r\nend", "def reverse_array(array)\n output = []\n (array.length).times do |_|\n output << array.pop \n end\n output\nend", "def reverse(a)\n new = []\n (0...a.size).each { |i| new << a[a.size - i - 1] }\n new\nend", "def reverse_array(a)\n a.reverse{|b| b}\nend", "def reverse(an_array)\n\tlen = an_array.length\n\tnew_arr = Array.new(an_array.length)\n\twhile len > 0 do\n\t\tnew_arr[len-1] = an_array[an_array.length - len]\n\t\tlen -= 1\n\tend\n\tnew_arr\nend", "def reverse_array(array)\n flipped = []\n array.each{ |el| flipped.unshift(el) }\n flipped\nend", "def reverse(array)\n result_array = []\n array.each { |element| result_array.unshift(element) }\n result_array\nend", "def reverse!(array)\n copy = array.clone\n index = -1\n\n copy.each do |element|\n array[index] = element\n index -= 1\n end\n\n array\nend", "def reversearray arr\n len = arr.length\n idx = len - 1 \n arr2 = []\n while idx >= 0 \n arr2.push arr[idx] \n idx = idx - 1\n end\n return arr2\nend", "def reverse!(array)\n copy_array = array.dup\n array.map! { |_| copy_array.pop }\nend", "def reverse_array(integers)\n integers.reverse \nend", "def reverse_array(integers)\n integers.reverse\nend", "def reverse_array(int_array)\n int_array.reverse\nend", "def reverse_each(array)\n new_array = []\n array.each do |el|\n new_array.push(el.reverse)\n end\n return new_array\nend", "def reverse_array(arr)\n new_arr = []\n arr.length.times do |i|\n new_arr = new_arr.unshift(arr[i])\n end\n new_arr\nend", "def my_reverse(arr)\n len = arr.length - 1\n new_arr = []\n while len >= 0\n new_arr << arr[len]\n len -= 1\n end\n new_arr\nend", "def reverse(array)\n new_array = []\n array.reverse.each do |outer|\n new_inner = []\n outer.reverse.each do |inner|\n new_inner << inner\n end\n new_array << new_inner\n end\n return new_array\nend", "def reverse_array(array_i)\n array_i = array_i.reverse\nend", "def reverse(array)\n new_array = array.dup\n counter, finish, max = 0, -1, (array.length)\n while counter < max\n new_array[finish] = array[counter]\n counter += 1\n finish -= 1\n end\n new_array\nend", "def using_reverse(array)\n reversed_array=array.reverse\nend", "def reverse!(arr)\n copy = []\n cp_index = arr.size-1\n (0...arr.size).each do |arr_index|\n copy[arr_index] = arr[cp_index]\n cp_index -= 1\n end\n copy.each_with_index do |el, index|\n arr[index] = el\n end\n arr\nend", "def reverse(arr)\n new_arr = []\n arr.each do |element|\n new_arr.prepend(element)\n end\n new_arr\nend", "def reverse_array(array)\n reversed = []\n while array != []\n reversed << array.last\n array = array[0..-2]\n end\n reversed\nend", "def reverse!(arr)\n values = arr.dup\n arr.each.with_index do |_, index|\n arr[index] = values[-index - 1]\n end\nend", "def reverse_array(array)\n return nil if array.class != Array\n local_stack = Stack.new()\n array.each do |element|\n local_stack.push(element)\n end\n array.size.times do |i|\n array[i] = local_stack.pop()\n end\n array\nend", "def reverse_array(array)\nreversed_array = []\nindex = array.length - 1\n while index >= 0\n reversed_array.push(array[index])\n index -= 1\n end\nreversed_array\nend", "def reverse_every_element_in_array(array)\n array.map(&:reverse)\nend", "def reverse_array(array_int)\n array_int.reverse!\nend", "def reverse!(arr)\n arr_orignal = arr.map{ |element| element }\n index = 0\n loop do\n break if index == arr.size\n arr[index] = arr_orignal[-(index+1)]\n index +=1\n end\n arr\nend", "def reverse!(array)\n reversed_array = []\n array.size.times { reversed_array << array.pop }\n reversed_array.size.times { array << reversed_array.shift }\n array\nend", "def reverse(array)\n final = []\n i = array.length - 1\n loop do\n break if i < 0\n\n final << array[i]\n i -= 1\n end\n final\nend", "def reverse_every_element_in_array(array)\n array.map!{|element|element.reverse}\nend", "def reverse_array(array)\n reverse_arr = []\n array.each_with_index do |val, index|\n reverse_arr[array.size - 1 - index] = val\n end\n reverse_arr\nend", "def reverse(array)\n result = []\n array.each do |item|\n result.prepend(item)\n end\n result\nend", "def reverse(arr)\n new_arr = []\n arr.each { |elem| new_arr.unshift(elem) }\n new_arr\nend", "def using_reverse(array)\narray.reverse\nend", "def using_reverse(array)\narray.reverse\nend", "def my_reverse(arr)\n idx = arr.length - 1\n rev = []\n while idx >= 0\n rev.push(arr[idx])\n idx -= 1\n end\n rev\nend", "def reverse!(arr)\n temp = arr.dup\n arr.map!.with_index(1) { |_, i| p temp[-i] }\nend", "def reverse(arr)\n temp = arr.dup\n result = []\n result << temp.pop until temp.empty?\n result\nend", "def reverse_array(array)\n reversed_array = []\n array.each {|e| reversed_array.unshift(e)}\n reversed_array\n\n #could just use #reverse but don't think that's what the lab was asking for\n # reversed_array = array.reverse\nend", "def reverse_arr(arr)\n return_arr = []\n arr.each do |item|\n return_arr.unshift(item)\n end \n return_arr\nend", "def reverse(arr)\n\nnew_arr = []\n\n arr.each do |element|\n new_arr.unshift(element)\n end\n new_arr\n\nend", "def using_reverse(array)\n array.reverse \nend", "def my_reverse(arr)\n\tarr.reverse\nend", "def reverse(array)\n reversed_array = []\n array.each { |item| reversed_array.unshift(item) }\n reversed_array\nend", "def my_reverse(arr)\n new_arr = []\n arr.each {|i| new_arr.unshift(i) }\n new_arr\nend", "def flip\n arr = Array.new(self.length)\n (0..self.length / 2).each do |index|\n arr[index] = self[self.length - 1 - index]\n arr[self.length - 1 - index] = self[index]\n end\n arr\n end", "def reverseArray1(a)\n reverse_a = []\n i = a.length() - 1\n\n while i >= 0\n reverse_a.push(a[i])\n i -= 1\n end\n\n return reverse_a\nend" ]
[ "0.8644121", "0.8546132", "0.8546132", "0.8522452", "0.84845865", "0.845157", "0.8442636", "0.8401113", "0.8393306", "0.8382579", "0.83584803", "0.83541095", "0.83541095", "0.83541095", "0.83541095", "0.83541095", "0.83541095", "0.83541095", "0.83541095", "0.83541095", "0.83541095", "0.83541095", "0.83541095", "0.83541095", "0.83541095", "0.83541095", "0.83541095", "0.83541095", "0.83541095", "0.83541095", "0.83541095", "0.83541095", "0.8323955", "0.8323955", "0.8323955", "0.83007467", "0.8292405", "0.8292005", "0.8289652", "0.8287869", "0.8276964", "0.8276964", "0.82584417", "0.82553697", "0.8247296", "0.8219906", "0.8183273", "0.8181007", "0.8114386", "0.8101122", "0.8092999", "0.80827", "0.80789304", "0.8076316", "0.8074069", "0.80666864", "0.80652916", "0.80650795", "0.80522287", "0.80496407", "0.8044911", "0.80335724", "0.801717", "0.8000442", "0.79678524", "0.7967119", "0.7967088", "0.79472077", "0.7944357", "0.7937877", "0.79197794", "0.7916915", "0.7911707", "0.78999937", "0.78972447", "0.78918046", "0.78786516", "0.7878187", "0.7878185", "0.7870435", "0.7858884", "0.78541285", "0.7853628", "0.7853307", "0.7825215", "0.78246146", "0.7818815", "0.7818815", "0.78086233", "0.7806291", "0.77992606", "0.7788631", "0.7786503", "0.7771592", "0.77421683", "0.7741483", "0.77400017", "0.77044594", "0.7701771", "0.76972413" ]
0.7941648
69
you can say except or only
def index #to store cookies, see how many visitors, etc. sessions is a cookie. # if session[:count] == nil # session[:count] = 0 # end # session[:count] +=1 # @counter = session[:count] @purses = Purse.all sort_attribute = params[:sort] order_attribute = params[:sort_order] discount_amount = params[:discount] category_sort = params[:category_id] search_term = params[:search_term] if category_sort @purses = Category.find_by(id: category_sort).purses end if discount_amount @purses = @purses.where("price < ?", discount_amount) end if sort_attribute && order_attribute @purses = @purses.order({sort_attribute => order_attribute}) #this makes it more dynamic, lets you type whatever value i.e, desc or asc into the order_attribute search bar, or any sort_attribute . have to break it apart into the hash rocket syntax, otherwise it won't work, as a symbol elsif sort_attribute @purses = @purses.order(sort_attribute) end if search_term @purses = @purses.where("name iLIKE ? OR description iLIKE ?", "%#{search_term}%" , "%#{search_term}%" ) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def excluded; end", "def exclude; end", "def ignores; end", "def ignore; end", "def ignore(*args); end", "def unless_condition; end", "def ignored?()\n #This is a stub, used for indexing\n end", "def exclude=(_arg0); end", "def allows_not_action\n @statements.select { |statement| !statement.not_actions.empty? && statement.effect == 'Allow' }\n end", "def ignore_me\nend", "def skipped; end", "def skip?\n false \n end", "def allowed?; true end", "def never?; end", "def regardless(&block)\n yield\nrescue\nend", "def skips; end", "def ignore_if(&block)\n @@ignores << block\n end", "def validate_exclusion_of(attr); end", "def skip_value?(value); end", "def skip?\n !value_of(entity.only_if)\n end", "def skipped!; end", "def ignore?\n @should_ignore\n end", "def ignore &block\n begin; block.call; rescue; end\n end", "def ignore!\n @should_ignore = true\n end", "def prohibit_all(except: [])\n set_all :prohibited, except: { exceptions: except, status: :allowed }\n end", "def miss_reason; end", "def possibly_include_hidden?; end", "def irregular?\n false\n end", "def ignore\n @ignore = true\n end", "def exclude_end?() end", "def not_lichen?\n lifeform.exclude?(\" lichen \")\n end", "def skipped?; end", "def skipped?; end", "def skipped?; end", "def skipped?; end", "def not( arg ); { $not => arg } end", "def i_dont_see(what)\n assert !i_see?(what), __last_because + \" (actually see #{what})\"\n end", "def skip_method(a,b,c)\nend", "def is_not(&block)\n [:is_not, block]\n end", "def is_not(&block)\n [:is_not, block]\n end", "def skip?\n raise NotImplementedError\n end", "def semact?; false; end", "def does_not_contain(&block)\n [:does_not_contain, block]\n end", "def does_not_contain(&block)\n [:does_not_contain, block]\n end", "def deny(condition)\n # a simple transformation to increase readability IMO\n assert !condition\n end", "def deny(condition)\n # a simple transformation to increase readability IMO\n assert !condition\n end", "def deny(condition)\n # a simple transformation to increase readability IMO\n assert !condition\n end", "def ignore?\n !!@ignore\n end", "def foo(bar)\n unless allowed?(bar)\n raise \"bad bar: #{bar.inspect}\"\n end\nend", "def supports_intersect_except?\n false\n end", "def supports_intersect_except?\n false\n end", "def ignore\n @ignore = true\n end", "def test_no_raise\n\n r = Ruote.filter(\n [ { 'field' => 'x', 't' => 'hash', 'has' => 'a' } ],\n { 'x' => %w[ a b c ] },\n :no_raise => true)\n\n assert_equal(\n [ [ { \"has\" => \"a\", \"field\" => \"x\", \"t\" => \"hash\"}, \"x\", [ \"a\", \"b\", \"c\" ] ] ],\n r)\n end", "def false a\n # catch cuts\n catch :rubylog_cut do\n a.prove { return }\n end\n yield\n end", "def ignore *node\n end", "def exclusive!\n @inclusive = false\n end", "def not\n require_relative './not'\n \n NRSER::Types.not self\n end", "def ignore_nonmulti?(task)\n ignore_by_type?(task, :nonmulti)\n end", "def negative?; end", "def not _args\n \"not _args;\" \n end", "def skip_include_blank?; end", "def except(*args)\n reject { |k, _v| args.include?(k) }\n end", "def masking?; false; end", "def deny(condition, msg=\"\")\n assert !condition, msg\n end", "def ignore_parent_exclusion?; end", "def miss_reason=(_arg0); end", "def ignore(*ids); end", "def disabled_all?; end", "def conditionally(*) end", "def conditionally(*) end", "def exclude\n all - methods\n end", "def invalid; end", "def dont_care\n each(&:dont_care)\n myself\n end", "def except *filter_list\n filter.except filter_list\n self\n end", "def skip_during; end", "def skip_during; end", "def ignore?(buf); end", "def deny(condition, message='')\n assert !condition, message\n end", "def missed?; end", "def skip_actions; end", "def excepted?(method)\n is_ignored?(method.file) ||\n except_methods.any? { |except_method| Exceptable.matches method, except_method }\n end", "def not *a\n return self if guard *a\n s = ':not('\n self + s + (a.flatten.join ')' + s) + ')'\n end", "def exclude!(*cond, &block)\n exclude(nil, *cond, &block)\n end", "def skip_name?(control, name)\n if control.has_key?(:exclude) and control[:exclude].include? name\n true\n elsif control.has_key?(:include) and not control[:include].include? name\n true\n end\n end", "def not\n self.class.not(self)\n end", "def skip\n end", "def skip\n end", "def assert_missing_delimitation!\n end", "def ignore\n\t\t\treturn @data['ignore']\n\t\tend", "def unknown?; false; end", "def unknown?; false; end", "def except(*methods)\r\n with_options(except: methods)\r\n end", "def not(e)\n ((1 << 64) - 1) & (~eval_ex(e))\n end", "def maybe; end", "def skips_around\n @skips_around\n end", "def one_gradable_ex_only\n end", "def forbidden?\n @forbidden\n end", "def exclude\n [exceptions, self.class.exclude_always, foreign_key, polymorphic_type].flatten.uniq\n end", "def ignored?\n marking == \"IGNORED\"\n end", "def skip_unless(eng, bt: caller)\n skip_msg = case eng\n when :darwin then \"Skip unless darwin\" unless RUBY_PLATFORM[/darwin/]\n when :jruby then \"Skip unless JRuby\" unless Puma.jruby?\n when :windows then \"Skip unless Windows\" unless Puma.windows?\n when :mri then \"Skip unless MRI\" unless Puma.mri?\n else false\n end\n skip skip_msg, bt if skip_msg\n end", "def not(condition)\n {\"Fn::Not\" => [condition]}\n end" ]
[ "0.7294366", "0.7203189", "0.7167285", "0.7010639", "0.67544496", "0.64616525", "0.64294875", "0.6279929", "0.62302715", "0.62144935", "0.6206721", "0.61943483", "0.61906326", "0.6182039", "0.61771625", "0.6165924", "0.6165761", "0.6162465", "0.6162464", "0.6152767", "0.6150681", "0.6145717", "0.613492", "0.6133166", "0.61233824", "0.61199963", "0.61156064", "0.6092623", "0.60441154", "0.60350716", "0.60266155", "0.6016988", "0.6016988", "0.6016988", "0.6016988", "0.5956241", "0.59531593", "0.59424263", "0.59292114", "0.59292114", "0.59231925", "0.590753", "0.58960074", "0.58960074", "0.5895232", "0.5895232", "0.5894077", "0.58938867", "0.58926654", "0.58814114", "0.58814114", "0.58774114", "0.58701646", "0.5857808", "0.58493936", "0.5848095", "0.5847035", "0.5845569", "0.5830837", "0.5819412", "0.58151996", "0.58135116", "0.58055997", "0.5803336", "0.580271", "0.5801896", "0.579997", "0.5798668", "0.5798172", "0.5798172", "0.57943106", "0.5792325", "0.57918733", "0.57896113", "0.57865936", "0.57865936", "0.5785235", "0.5783481", "0.57831204", "0.577765", "0.57756644", "0.5764133", "0.57640404", "0.57611704", "0.5759112", "0.5755735", "0.5755735", "0.5754704", "0.57513213", "0.5739902", "0.5739902", "0.573898", "0.57361954", "0.5729292", "0.5724572", "0.57216585", "0.57196254", "0.57119906", "0.57097954", "0.57093686", "0.57075346" ]
0.0
-1
this is for checkboxes which give us a param of 'on' on the params hash
def normalize replacements = { 'on' => true, '' => nil} normalized = {} self.each_pair do |key,val| normalized[key] = replacements.has_key?(val) ? replacements[val] : val end normalized end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def checkboxes_for(method,vals,options={})\n \n end", "def checkboxes; end", "def checkbox_checked\n return 'checked=checked' if show\n\n ''\n end", "def check_box; end", "def build_check_box_without_hidden_field(options); end", "def switch_params\n params.permit(:is_on)\n end", "def build_hidden_field_for_checkbox; end", "def true?(param)\n params[param] == 'on'\n end", "def check_box_toggle(name, checked, elt, ifchecked, ifnotchecked)\n check_box_tag name, 1, checked, :onchange => %Q{$('##{elt}').text($(this).is(':checked') ? '#{escape_javascript ifchecked}' : '#{escape_javascript ifnotchecked}')}\n end", "def checkbox(criteria = T.unsafe(nil)); end", "def checkbox(key)\n field_type = @form.getFieldType(key.to_s)\n return unless field_type == @acrofields.FIELD_TYPE_CHECKBOX\n\n all_states = @form.getAppearanceStates(key.to_s)\n yes_state = all_states.reject{|x| x == \"Off\"}\n \n \n @form.setField(key.to_s, yes_state.first) unless (yes_state.size == 0)\n end", "def toggle_field(attrs = {})\n if attrs.has_key?(:checked)\n if attrs[:checked]\n attrs[:checked] = \"checked\"\n else\n attrs.delete(:checked)\n end\n end\n \n check_box(attrs)\n end", "def checkbox(key)\n field_type = @form.getFieldType(key.to_s)\n return unless is_checkbox(field_type)\n\n all_states = @form.getAppearanceStates(key.to_s)\n yes_state = all_states.reject{|x| x == \"Off\"}\n \n \n @form.setField(key.to_s, yes_state.first) unless (yes_state.size == 0)\n end", "def check_box_tag(name, value = T.unsafe(nil), checked = T.unsafe(nil), options = T.unsafe(nil)); end", "def event_switch_checkbox(event, attribute, conference_id)\n check_box_tag(\n conference_id,\n event.id,\n event.send(attribute),\n url: admin_conference_program_event_path(\n conference_id,\n event,\n event: { attribute => nil }\n ),\n class: 'switch-checkbox'\n )\n end", "def collection_check_boxes(method, collection, value_method, text_method, options = T.unsafe(nil), html_options = T.unsafe(nil), &block); end", "def checked; end", "def check_box_tag(name, value = \"1\", checked = false, options = {}) \n\t\toptions = check_options(options)\n\t\toptions[:class] << 'check_box'\n\t\tsuper(name, value, checked, options)\n\tend", "def build_check_box(unchecked_value, options); end", "def wrt_checkbox(chkbox, state,loc = nil, ret = nil)\n if loc \n loc.click \n edit.click\n chkbox.send state \n save.click_no_wait\n jsClick(\"OK\")\n sleep 1\n ret.click \n else\n chkbox.send state\n end\n end", "def data_com_checked!\n update_attributes(data_com_checked_c: true)\n end", "def todo_list_params\n params.require(:todo_list).permit(:is_checked)\n end", "def mailing_mails_status_checkbox(status, count)\n checked = (session[:filter_by_mailing_mail_status] ? session[:filter_by_mailing_mail_status].split(\",\").include?(status.to_s) : count.to_i > 0)\n check_box_tag(\"status[]\", status, checked, :onclick => remote_function(:url => filter_mailing_path(@mailing), :with => %Q/\"status=\" + $$(\"input[name='status[]']\").findAll(function (el) { return el.checked }).pluck(\"value\")/))\n end", "def input_checkbox(name)\n field = field_content(name)\n option_item(field, field_id(name), name)\n end", "def identity_tag_attributes\n [:checked, :disabled, :selected, :multiple]\n end", "def checkbox(item)\n name_li(item).checkbox\n end", "def click_checkbox(button, value)\n append_to_script \"click_checkbox \\\"#{button}\\\" \\\"#{value}\\\"\"\n end", "def lead_status_checkbox(status, count)\n entity_filter_checkbox(:status, status, count)\n end", "def check!\n update_attribute :checked, true\n end", "def format_checkbox\n @attr[:disabled] = :disabled\n @opts[:no_hidden] = true unless @opts.has_key?(:no_hidden)\n super\n end", "def labeled_checkbox( text, checked, object, property )\n tag_id = object.to_s.gsub(/[\\[,\\]]/, \"_\") + \"_\" + property.to_s\n adds = \"checked='checked'\" if checked\n\n str = \"<input type='checkbox' name='#{object+\"[\"+property.to_s+\"]\"}' value='#{property}' id='#{tag_id}' #{adds} />&nbsp;\"\n str += \"<label for='#{tag_id}'><a class='hidden_link' style='display: inline' href=\\\"javascript:toggleCheckBox('#{tag_id}')\\\">#{h(text)}</a></label>\\n\" \n\n return str\n end", "def format_checkbox\n @attr[:type] = :checkbox\n @attr[:checked] = :checked if @opts[:checked]\n if @attr[:name] && !@opts[:no_hidden]\n attr = {:type=>:hidden}\n unless attr[:value] = @opts[:hidden_value]\n attr[:value] = CHECKBOX_MAP[@attr[:value]]\n end\n attr[:id] = \"#{@attr[:id]}_hidden\" if @attr[:id]\n attr[:name] = @attr[:name]\n [tag(:input, attr), tag(:input)]\n else\n tag(:input)\n end\n end", "def checkbox_do( effnum, updateId, updateId2, checkboxId, effect, url = {}, urloptions = {})\n \n mycount = 0\n pars = ''\n theRealnumer = countTheArray(urloptions)\n # Build the url options\n urloptions.each_pair do |key,value|\n mycount += 1\n if key != ''\n if mycount == theRealnumer\n pars += %{#{key}:'#{value}'}\n else\n pars += %{#{key}:'#{value}',}\n end\n end\n end\n \n url[:controller].nil? ? controller = '' : controller = '/' + url[:controller]\n url[:action].nil? ? action = 'index' : action = url[:action]\n url[:id].nil? ? id = '' : id = '/' + url[:id]\n controller == '' ? slash = '' : slash = '/'\n \n theRequestUrl = controller + slash + action + id\n \n if effnum == 'two'\n twoeffects = effect.split(\"=\")\n theEffect1 = twoeffects[0].capitalize\n theEffect2 = twoeffects[1].capitalize\n \n # Effect list below, you may add others if you like\n theEffect1 == 'Blindup' ? theEffect1 = 'BlindUp' : theEffect1 = theEffect1\n theEffect1 == 'Dropout' ? theEffect1 = 'DropOut' : theEffect1 = theEffect1\n theEffect1 == 'Blinddown' ? theEffect1 = 'BlindDown' : theEffect1 = theEffect1\n \n theEffect2 == 'Blindup' ? theEffect2 = 'BlindUp' : theEffect2 = theEffect2\n theEffect2 == 'Dropout' ? theEffect2 = 'DropOut' : theEffect2 = theEffect2\n theEffect2 == 'Blinddown' ? theEffect2 = 'BlindDown' : theEffect2 = theEffect2\n # End Effect list\n \n theRequestCode = \"new Ajax.Request('#{theRequestUrl}', {method: 'get', onSuccess: new Effect.#{theEffect1}('#{updateId}'), parameters: {#{pars}} });\"\n buildeffect2 = \" new Effect.#{theEffect2}('#{updateId2}');\"\n # Return the checkbox to the view.\n return %{<input type=\"checkbox\" id=\"#{checkboxId}\" onclick=\"#{theRequestCode}#{buildeffect2}\" />}\n else\n theEffect = effect.capitalize\n # Effect list below, you may add others if you like\n theEffect == 'Blindup' ? theEffect = 'BlindUp' : theEffect = theEffect\n theEffect == 'Dropout' ? theEffect = 'DropOut' : theEffect = theEffect\n \n # End Effect list\n \n theRequestCode = \"new Ajax.Request('#{theRequestUrl}', {method: 'get', onSuccess: new Effect.#{theEffect}('#{updateId}'), parameters: {#{pars}} });\"\n # Return the checkbox to the view.\n return %{<input type=\"checkbox\" id=\"#{checkboxId}\" onclick=\"#{theRequestCode}\" />}\n end\n \n end", "def modal_opt_in_checkbox\n $tracer.trace(format_method(__method__))\n return ToolTag.new(@tag.find.input.className(create_ats_regex_string(\"ats-optinbox\")), format_method(__method__))\n end", "def toggle_link\n new_params = toggle_params\n\n if enabled\n h.link_to(h.search_path(new_params)) do\n h.check_box_tag(\"category_#{to_param}\", '1', true, disabled: true) +\n h.html_escape(name)\n end\n else\n h.link_to(h.search_path(new_params)) do\n h.check_box_tag(\"category_#{to_param}\", '1', false, disabled: true) +\n h.html_escape(name)\n end\n end\n end", "def switch_paddle(attr, options = {})\n @inside_switch_paddle = true\n output_html = check_box attr, options\n @inside_switch_paddle = false\n\n output_html\n end", "def checkbox(box)\n if box.checked?\n 'set'\n else\n 'clear'\n end\n end", "def boolean(param_name, **args)\n validation_builder(:to_s, param_name, **args)\n parameters_to_filter << param_name if args[:submit] == false\n end", "def check_box_options\n [:tag_ids, Tag.order(:name), :id, :name]\n end", "def check_all\n frm.checkbox(:id=>\"selectall\").set\n end", "def checkbox(&block)\n @template.form_checkbox(&block)\n end", "def checkbox(name, value=nil, options={})\n selected = ''\n selected = \" checked='1'\" if value\n attrs = options.map { |(k, v)| \" #{h k}='#{h v}'\" }.join('')\n\n [ \"<input type='hidden' name='#{name}' value='0'>\" +\n \"<input#{attrs} type='checkbox' name='#{name}' value='1'#{selected}>\"\n ].join(\"\\n\")\n end", "def checkbox(name, value=nil, options={})\n selected = ''\n selected = \" checked='1'\" if value\n attrs = options.map { |(k, v)| \" #{h k}='#{h v}'\" }.join('')\n\n [ \"<input type='hidden' name='#{name}' value='0'>\" +\n \"<input#{attrs} type='checkbox' name='#{name}' value='1'#{selected}>\"\n ].join(\"\\n\")\n end", "def text_or_checkbox(options)\r\n value = options.delete(:value)\r\n if(options.delete(:editable))\r\n options[:type] = \"checkbox\"\r\n options[:value] = \"true\"\r\n options[:checked] = \"true\" if value\r\n tag(\"input\", options)\r\n else\r\n value ? \"on\" : \"off\"\r\n end\r\n end", "def booleans!\n @boolean_params.each do |param|\n key = (param.is_a?(Array) ? param.first : param)\n verify_boolean_param(key)\n end\n end", "def setCheckBox ( name , value , newState , formName = \"\" , frameName = \"\" )\n\n fname = getFunctionName()\n log fname + \" Starting. Trying to set checkbox: #{name.to_s} (#{value.to_s}) to \" + getDescriptionOfState(newState )if $debuglevel >=0\n container = getObjectContainer( name , formName , frameName )\n\n thisCheckBox = nil\n\n # does it exist\n #o = container.all[ name.to_s ]\n # another one of those hacky frame things...\n container.all.each do |box|\n next unless thisCheckBox == nil\n begin\n if box.name == name.to_s and thisCheckBox== nil\n # do we have a value as well?\n if value != \"\"\n if box.value == value\n thisCheckBox = box\n end\n else\n thisCheckBox = box\n end\n end\n rescue\n # probably doesnt have a name\n end\n\n end\n\n if thisCheckBox== nil\n return false, [ OBJECTNOTFOUND ]\n end\n setBackGround(thisCheckBox)\n\n # we now have a reference to the checkbox we want!\n\n if thisCheckBox.disabled\n clearBackground\n return false, [ OBJECTDISABLED ] \n end \n\n if thisCheckBox.checked == true\n currentState = CHECKBOX_CHECKED\n toggleState = false\n else\n currentState = CHECKBOX_UNCHECKED\n toggleState = true\n end\n state = getDescriptionOfState(currentState)\n log fname + \" Found Checkbox #{name.to_s} (#{value.to_s}). Its Current value is: \" + state + \" Setting to: \" + getDescriptionOfState(newState )if $debuglevel >=0\n\n # now set the new state\n \n case newState \n when CHECKBOX_CHECKED\n if currentState == CHECKBOX_CHECKED\n # we dont need to do anything!\n else\n a, messages = setCheckBoxState( thisCheckBox , true )\n if !a\n clearBackground\n return false, [ fname + \" Problem setting checkbox (1)\"]\n end\n end \n when CHECKBOX_UNCHECKED\n if currentState == CHECKBOX_CHECKED\n a, messages = setCheckBoxState( thisCheckBox , false )\n if !a \n clearBackground\n return false, [ fname + \" Problem setting checkbox (2)\"]\n end\n else\n # we dont need to do anything\n end \n when CHECKBOX_TOGGLE\n a, messages = setCheckBoxState( thisCheckBox , toggleState )\n if !a\n clearBackground\n return false, [ fname + \" Problem setting checkbox (3)\" ]\n end\n end\n clearBackground\n return true, [ \"\" ]\n\n end", "def toggle_use_filters\n @service_learning_course = ServiceLearningCourse.find(params[:id])\n @service_learning_course.no_filters = ((params[:checked] == \"true\") ? true : false)\n @service_learning_course.save\n \n unless @service_learning_course.no_filters\n @pipeline_course_filter = PipelineCourseFilter.find_or_create_by_service_learning_course_id params[:id]\n @filters = @pipeline_course_filter.filters.nil? ? {} : @pipeline_course_filter.filters\n \n filter_search\n end\n \n \n respond_to do |format|\n format.js\n end\n end", "def lbIsSelected _obj, _args\n \"_obj lbIsSelected _args;\" \n end", "def checkbox_value\n show\n # return 'true' if show\n # 'false'\n end", "def setCheckBoxState ( o , state )\n\n # dont call this directly - use setCheckBox\n\n o.fireEvent(\"onMouseOver\")\n if !waitForIE(NOWAITFORIE)\n return false, [fname + \" problem loading the page\"]\n end\n\n o.focus()\n\n if !waitForIE(NOWAITFORIE)\n return false, [fname + \" problem loading the page\"]\n end\n\n o.checked = state\n\n if !waitForIE(NOWAITFORIE)\n return false, [fname + \" problem loading the page\"]\n end\n\n o.fireEvent(\"onClick\")\n if !waitForIE(NOWAITFORIE)\n return false, [fname + \" problem loading the page\"]\n end\n\n\n # if the page has reloaded we dont want to fire more events on this object\n if !@pageHasReloaded\n\n o.fireEvent(\"onChange\")\n if !waitForIE(NOWAITFORIE)\n return false, [fname + \" problem loading the page\"]\n end\n end\n\n if !@pageHasReloaded\n\n o.fireEvent(\"onMouseOut\")\n if !waitForIE(NOWAITFORIE)\n return false, [fname + \" problem loading the page\"]\n end\n end\n\n return true, []\n end", "def toggle_value(obj)\n remote_function(\n :url => url_for(obj),\n :method => :put ,\n :before => \"Element.show('spinner-#{object.id}'\",\n :after => \"Element.hide('spinner-#{object.id}'\",\n :with => \"this.name + '=' + this.checked\"\n )\n end", "def format_checkbox\n @opts[:no_hidden] = true unless @opts.has_key?(:no_hidden)\n super\n end", "def notify?; params_for_save[:Notify] == true end", "def notify?; params_for_save[:Notify] == true end", "def notify?; params_for_save[:Notify] == true end", "def assert_checkbox_selected(checkbox_name)\n assert_togglebutton_selected checkbox_name\n end", "def check_assignment(id) #FIXME to use name instead of id.\n frm.checkbox(:value, /#{id}/).set\n end", "def store_checkboxes_setup(store_name, attrs)\n define_method(\"#{store_name}_keys\") do\n list = [];\n attrs.each do |attr|\n if send(attr) == true\n list.push(attr)\n end\n end\n list\n end\n define_method(\"#{store_name}_options\") do\n @i18n_base_scope = [:activerecord, :options, self.class.name.underscore, store_name]\n list = [];\n attrs.each do |attr|\n if send(attr) == true\n list.push(I18n.t(\"#{attr}\", scope: @i18n_base_scope, :default => attr.to_s.humanize))\n end\n end\n list\n end\n end", "def update\n @todo.update_attributes(checked: todo_params['checked'])\n end", "def build_hidden_field_for_checkbox\n @builder.hidden_field(attribute_name, :value => unchecked_value, :id => nil,\n :disabled => input_html_options[:disabled],\n :name => input_html_options[:name])\n end", "def test_direct_deseriaziation\n \n cf = StHtml::Ruing::Factory.get \"check\", \"myname\"\n \n # HTML checked checkboxes are post in this way: the key is the \n # name of the control, the value is \"on\"\n cf.serializer.value_from_params cf, { 'myname' => 'on' }\n \n assert cf.value, 'Wrond de-serialization'\n \n cf.serializer.value_from_params cf, { 'myname' => 'off' } # this is not real, is only to demostarte tha if not on the false\n assert !cf.value, 'Wrond de-serialization'\n cf.serializer.value_from_params cf, { 'other_key1_but_myname' => 'on', \n 'other_key2_but_myname' => 'on' }\n assert !cf.value, 'Wrond de-serialization'\n \n end", "def tag_checkbox(article, tags)\n html = \"\"\n return html if tags == nil || tags.empty?\n tags.each do |tag|\n checked = \"\"\n if tag.selected?(article)\n checked = \" checked\"\n end\n html << <<-HTML\n <label for=\"tag_#{tag.id}\" class=\"checkbox inline tagcheck\">\n <input type=\"checkbox\" id=\"tag_#{tag.id}\" value=\"#{tag.name}\" class=\"tagCheck\"#{checked}>#{tag.name}</input>\n </label>\n HTML\n end\n html.html_safe\n end", "def build_check_box(unchecked_value = unchecked_value())\n @builder.check_box(attribute_name, input_html_options, checked_value, unchecked_value)\n end", "def description\n 'Choose multiple values using checkbox'\n end", "def checked?\n state == :on\n end", "def check_box(method, orig_options = {}, checked_value = '1',\n unchecked_value = '0')\n options = decorate_opts_with_disabled(orig_options)\n div_wrapper do\n @template.content_tag :div, class: 'checkbox' do\n label_control(method) do\n orig_check_box(method, options, checked_value, unchecked_value) +\n method.to_s.humanize\n end\n end\n end\n end", "def get_field_edit_rptl\n '<input type=\"hidden\" id=\"' + @id + '-hidden\" name=\"' + @name + '\" value=\"false\" />\n <input type=\"checkbox\" id=\"' + @id + '\" name=\"' + @name + '\" class=\"' + @class_txt + '\" value=\"true\" {%=' + @model_name + '[:' + @name + '_checked]%}\" />\n '\n end", "def build_check_box_without_hidden_field\n build_check_box(nil)\n end", "def checkbox_name\n \"mail[#{name}_check]\"\n end", "def html_label\n check_box_tag(input_name(:fields, true, nil), name, active, :id => dom_id(:active), :onclick => js_active_toggle) + h(label)\n end", "def checked=(value)\n `#{@el}.checked = #{value}`\n end", "def ctrlChecked _args\n \"ctrlChecked _args;\" \n end", "def checklist_item_params\n params.require(:checklist_item).permit(:content, :is_checked)\n end", "def checkboxes_for coll, &blok\n \n @checkbox ||= Class.new do \n \n def initialize &blok\n instance_eval(&blok)\n end\n \n def text txt\n @text = txt\n end\n \n def value txt\n @value = txt\n end\n \n def name txt\n @name = txt\n end\n \n def props\n [ \n @text, \n { :name => @name, \n :type => 'checkbox', \n :value => @value \n } \n ]\n end\n \n end\n \n span_txt, attrs = @checkbox.new(&blok).props\n ele_id = \"checkbox_#{rand(1000)}_#{attrs[:value]}\"\n s_ele_id = \"selected_checkbox_#{rand(1000)}_#{attrs[:value]}\"\n \n text(capture {\n loop coll do\n \n show_if 'selected?' do\n div.box.selected {\n input( {:checked=>'checked', :id=>s_ele_id}.update attrs )\n label span_txt, :for=>s_ele_id\n }\n end\n \n if_not 'selected?' do\n div.box {\n input( {:id=>ele_id}.update attrs )\n label span_txt, :for=>ele_id\n }\n end\n \n end # === loop\n })\n\n end", "def convert_boolean(key)\n @params[key] = _boolinze(@params[key]) if _is_bool?(get_default(key))\n end", "def onCheckedChanged(_, checked_or_id)\n @callback.call(checked_or_id) if @callback\n end", "def checked_value?\n self[:value] ||= {}\n is_checked?(/checked/)\n end", "def toggle_value(object,field) # = 'boh' )\n logga(\"toggle_value(#{object})\")\n remote_function(:url => url_for(object), \n :method => :put, \n :before => \"Element.show('spinner-#{field}-#{object.id}')\", \n :complete => \"Element.hide('spinner-#{field}-#{object.id}')\",\n :with => \"this.name + '=' + this.checked\")\n end", "def get_field_edit_html\n # if([email protected]? && (@value == '1' || @value == 1)) then\n if ([email protected]? && @value == true) then\n checked = 'checked=\"true\"'\n else\n checked = ''\n end\n '<input type=\"checkbox\" id=\"' + @id + '\" name=\"' + @name + '\" value=\"1\" class=\"' + @class_txt + '\" ' + @checked + ' />'\n end", "def set_status_from_buttons(params, draft_check=false)\r\n if(draft_check and params['savedraft.x'])\r\n self.draft = true\r\n elsif params['publish.x'] || params[:clicked_button] == 'publish' || params['makepublic.x']\r\n self.priv = false\r\n self.draft = false\r\n elsif params['unpublish.x'] || params[:clicked_button] == 'unpublish'\r\n self.priv = true\r\n self.draft = false\r\n else\r\n # nothing\r\n end\r\n end", "def check_box_field_select(value)\n control = @field.all(:css, 'input[type=\"checkbox\"][id$=\"__Data\"]').first[:id]\n if value.to_s.downcase == 'true'\n check(control)\n else\n uncheck(control)\n end\n end", "def checkbox_to_function(checked = true, *args, &block)\n\t\thtml_options = args.extract_options!\n\t\tfunction = args[0] || ''\n\n\t\thtml_options.symbolize_keys!\n\t\tfunction = update_page(&block) if block_given?\n\t\ttag(\"input\",\n\t\thtml_options.merge({\n\t\t\t:type => \"checkbox\",\n\t\t\t:checked => (\"checked\" if checked),\n\t\t\t# FIXME-cpg: href should not be needed? :href => html_options[:href] || \"#\",\n\t\t\t:onclick => (html_options[:onclick] ? \"#{html_options[:onclick]}; \" : \"\") + \"#{function}; return false;\"\n\t\t})\n\t\t)\n\tend", "def checklist_item_params\n\t\t\tparams.require(:checklist_item).permit(\n\t\t\t\t:description,\n\t\t\t\t:checked\n\t\t\t\t)\n\t\tend", "def bool_checked(field)\n filename = field ? \"check.png\" : \"blank.gif\"\n image_tag(filename, :alt => \"yes\", :size => \"16x16\") \n end", "def display_check_box( value )\n html = String.new\n html += \"<input type=\\\"checkbox\\\" readonly disabled\"\n html += \" checked\" if value\n html += \"/>\"\n html.html_safe\n end", "def render_item_checkbox(item)\n %(<input type=\"checkbox\"\n class=\"task-list-item-checkbox\"\n #{'checked=\"checked\"' if item.complete?}\n disabled=\"disabled\"\n />)\n end", "def boolean_input(method, options)\n html_options = options.delete(:input_html) || {}\n checked = options.key?(:checked) ? options[:checked] : options[:selected]\n html_options[:checked] = checked == true if [:selected, :checked].any? { |k| options.key?(k) }\n\n input = self.check_box(method, strip_formtastic_options(options).merge(html_options),\n options.delete(:checked_value) || '1', options.delete(:unchecked_value) || '0')\n options = options_for_label(options)\n\n # the label() method will insert this nested input into the label at the last minute\n options[:label_prefix_for_nested_input] = input\n\n self.label(method, options)\n end", "def save_selected\n session[:pizarras] ||= Hash.new\n id_chk = params[:id_chk]\n chk_estado = (params[:estado] == \"false\") ? false : true\n session[:pizarras][id_chk] = chk_estado\n render :nothing => true \n end", "def nested_boolean_choice_field(form, name, attribute, opts = {})\n on_change = (attribute.new_record? ? \"nestedCheckboxChanged(this)\" : nil)\n class_name = (attribute.new_record? ? \"nested_checkbox\" : nil)\n\n if opts[:onchange] and on_change\n on_change += \"; #{ opts[:onchange] }\"\n end\n\n opts[:class] = \"#{ opts[:class] } #{ class_name }\"\n\n options = opts.merge({ :onchange => on_change, :index => attribute.id })\n return form.check_box(name, options)\n end", "def checked\n `!!#{@el}.checked`\n end", "def actions(m, params)\n case params[:toggle]\n when 'on'\n @registry[m.sourcenick + \"_actions\"] = true\n m.okay\n when 'off'\n @registry.delete(m.sourcenick + \"_actions\")\n m.okay\n else\n if @registry[m.sourcenick + \"_actions\"]\n m.reply _(\"actions will be twitted\")\n else\n m.reply _(\"actions will not be twitted\")\n end\n end\n end", "def ctrlSetChecked _obj, _args\n \"_obj ctrlSetChecked _args;\" \n end", "def check_beginning\n frm.checkbox(:id=>\"use_start_date\").set\n end", "def run_set_bool(args, default=true)\n set_val = args.size < 2 ? 'on' : args[1]\n setting = @name.gsub(/^(set|show)/,'')\n begin\n settings[setting.to_sym] = @proc.get_onoff(set_val)\n run_show_bool(string_in_show)\n rescue NameError, TypeError\n end\n end", "def in_kwarg; end", "def bool_sheet(bool)\n \nend", "def tag_in_params?(tag_name)\n params[:t] and params[:t][tag_name] and params[:t][tag_name] == '✓'\n end", "def on?; self.refresh!['state']['on']; end", "def wiki_checkbox\n adding_field do |f|\n output = \"\".html_safe\n output << f.label(:wiki, \"Wiki\")\n output << f.check_box(:wiki)\n output\n end\n end", "def on?\n state[\"on\"]\n end", "def checkbox(name = \"\", value = nil, checked = nil)\n attributes = if name.kind_of?(String)\n { \"TYPE\" => \"checkbox\", \"NAME\" => name,\n \"VALUE\" => value, \"CHECKED\" => checked }\n else\n name[\"TYPE\"] = \"checkbox\"\n name\n end\n input(attributes)\n end" ]
[ "0.7102771", "0.6825558", "0.6421961", "0.63545877", "0.63206977", "0.63136536", "0.62110454", "0.6167114", "0.61328566", "0.6076351", "0.59995955", "0.59494317", "0.593552", "0.59340125", "0.59145343", "0.58546746", "0.5833506", "0.5805612", "0.579222", "0.5789278", "0.5765186", "0.57072467", "0.5701892", "0.5635807", "0.56027126", "0.5602378", "0.5594073", "0.5590286", "0.5571766", "0.55594414", "0.5556104", "0.5552002", "0.5531303", "0.5508342", "0.5494819", "0.5484789", "0.5465507", "0.546352", "0.54558593", "0.54434806", "0.5436573", "0.5435862", "0.5435862", "0.5415147", "0.5408493", "0.53914124", "0.5380378", "0.5370901", "0.53662294", "0.5362657", "0.53612614", "0.53576285", "0.5352825", "0.5352825", "0.5352825", "0.5350522", "0.53371704", "0.5331256", "0.5325891", "0.53257495", "0.5321285", "0.5317194", "0.53139883", "0.5302826", "0.5290008", "0.5284753", "0.5273596", "0.52705264", "0.5244146", "0.523397", "0.5232816", "0.52319026", "0.52172333", "0.5214744", "0.5197003", "0.5190665", "0.51845586", "0.51842546", "0.5178858", "0.5170118", "0.5166402", "0.51634943", "0.5161612", "0.51582617", "0.51411253", "0.514039", "0.5133007", "0.5132031", "0.51207745", "0.509476", "0.5094014", "0.50905126", "0.50749344", "0.507087", "0.5068198", "0.50581837", "0.5048241", "0.5044198", "0.50379324", "0.5033576", "0.50318265" ]
0.0
-1
Returns all policy instances
def get_all_policies @command = :get_all_policies raise ProjectHanlon::Error::Slice::SliceCommandParsingFailed, "Unexpected arguments found in command #{@command} -> #{@command_array.inspect}" if @command_array.length > 0 # get the policies from the RESTful API (as an array of objects) uri = URI.parse @uri_string result = hnl_http_get(uri) unless result.blank? # convert it to a sorted array of objects (from an array of hashes) sort_fieldname = 'line_number' result = hash_array_to_obj_array(expand_response_with_uris(result), sort_fieldname) end # and print the result print_object_array(result, "Policies:", :style => :table) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def policies\n @policies = Policy.all\n end", "def find_all_resources options\n policy_scope(resource_class)\n end", "def index\n @policies = Policy.all\n end", "def index\n @priv_policies = PrivPolicy.all\n end", "def policy_classes\n fetch_policies! unless @fetched\n @policy_classes\n end", "def index\n @policy_templates = PolicyTemplate.all\n end", "def instances()\n return @instances\n end", "def index\n @privacy_policies = PrivacyPolicy.all\n end", "def index\n @permission_policies = PermissionPolicy.all\n end", "def policies_with_access\n #### TODO -- Memoize this and put it in the session?\n user_access_filters = []\n user_access_filters += apply_policy_group_permissions(discovery_permissions)\n user_access_filters += apply_policy_user_permissions(discovery_permissions)\n where = user_access_filters.join(' OR ')\n result = policy_class.search_with_conditions(where,\n fl: 'id',\n rows: policy_class.count)\n logger.debug \"get policies: #{result}\\n\\n\"\n result.map { |h| h['id'] }\n end", "def instances\n @instances ||= []\n end", "def index\n @client_policies = ClientPolicy.all\n end", "def index\n @profiles = policy_scope(Profile)\n end", "def all(*policies)\n clazz = Class.new(Walruz::Policy) do # :nodoc:\n extend PolicyCompositionHelper\n \n def authorized?(actor, subject) # :nodoc:\n acum = [true, self.params || {}]\n self.class.policies.each do |policy|\n break unless acum[0]\n result = policy.new.set_params(acum[1]).safe_authorized?(actor, subject)\n acum[0] &&= result[0]\n acum[1].merge!(result[1])\n end\n acum[0] ? acum : acum[0]\n end\n \n def self.policy_keyword # :nodoc:\n (self.policies.map { |p| p.policy_keyword.to_s[0..-2] }.join('_and_') + \"?\").to_sym\n end\n \n end\n clazz.policies = policies\n clazz\n end", "def instances\n instances = []\n JSON.parse(resource['/instances'].get)[\"instances\"].each do |i|\n instances << Instance.new(i)\n end\n return instances\n end", "def index\n @users = policy_scope(User)\n end", "def index\n @form_submissions = policy_scope(FormSubmission)\n end", "def index\n @clients = policy_scope(Client)\n end", "def index\n @users = policy_scope(User).page(params.fetch(:page, 1)).per(params.fetch(:per, 25))\n end", "def index\n @policy_valuations = PolicyValuation.all\n end", "def instances\n Egi::Fedcloud::Vmhound::Log.info \"[#{self.class}] Retrieving active instances\"\n fetch_instances\n end", "def index\n @policy_divisions = PolicyDivision.all\n end", "def instances\n @instances ||= init_instances.reject(&:terminated?)\n end", "def execute\n policies_with_hbx_enrollment = Family.all.flat_map(&:active_household).compact.flat_map(&:hbx_enrollments).map(&:policy_id).uniq\n Policy.where(:id.nin => policies_with_hbx_enrollment).pluck(:id).to_a\n end", "def instances_list\n return [] unless configured?\n\n @service.fetch_all do |token|\n @service.list_instances(@gcp_config['project'], @gcp_config['zone'], page_token: token)\n end.map(&:name)\n end", "def all\n PaginatedResource.new(self)\n end", "def all\n PaginatedResource.new(self)\n end", "def all\n PaginatedResource.new(self)\n end", "def all\n PaginatedResource.new(self)\n end", "def all\n PaginatedResource.new(self)\n end", "def all\n PaginatedResource.new(self)\n end", "def all\n PaginatedResource.new(self)\n end", "def all\n PaginatedResource.new(self)\n end", "def all\n PaginatedResource.new(self)\n end", "def all\n PaginatedResource.new(self)\n end", "def index\n @market_offerings = policy_scope(MarketOffering)\n end", "def all\n @pool\n end", "def policy\n ensure_service!\n grpc = service.get_instance_policy path\n policy = Policy.from_grpc grpc\n return policy unless block_given?\n yield policy\n update_policy policy\n end", "def instances\n end", "def index\n @bookings = policy_scope(Booking).order(created_at: :desc)\n @bookings = Booking.all\n end", "def instances\n\t\tAlgorithm.each_ancestor_singleton(self) do |a|\n\t\t\tif a.respond_to?(:instances) && a.instances\n\t\t\t\treturn a.instances.dup\n\t\t\tend\n\t\tend\n\n\t\traise \"No method 'instances' found in any ancestor for '#{self}' (class: #{self.class})\"\n\tend", "def get_instances\n all_instances = Array.new()\n @groups.values.each do |instances|\n instances.each do |instance|\n all_instances << instance\n end\n end\n all_instances\n end", "def getPAYGInstances\n self.class.get('/v1/payAsYouGo/bareMetals/instances', @options)\n end", "def group_policies\r\n GroupPoliciesController.instance\r\n end", "def index\n iterations = policy_scope(Iteration)\n render json: iterations\n end", "def index\n @grants = policy_scope(Grant.all)\n end", "def all\n self.class.all\n end", "def all\n ::ActiveRecord::Base.connection_pool.with_connection do\n execute(:all).to_a\n end\n end", "def list_policies\n nessus_rest_get('policies')['policies']\n end", "def index\n\t\t@posts = policy_scope(Post)\n\t\t@posts = Post.all.order(\"created_at desc\")\n\t\t@post = Post.new\n\tend", "def instances #:nodoc:\n r = []\n ObjectSpace.each_object(self) { |mod| r << mod }\n r\n end", "def index\n @bookings = policy_scope(Booking.where(user_id: current_user.id))\n end", "def instances\n @instances ||= begin\n h = {}\n PPStore::new(app.pstore_new_sujets).each_root(except: :last_id) do |ps, art_id|\n h.merge! art_id => new( art_id )\n end\n h\n end\n end", "def list_policies\n http_get(:uri=>\"/policies\", :fields=>x_cookie)\n end", "def cache_instances\n [*Pages.all_instances, *([BlogArticle, Industry, Team].map{|p| p.all })]\n end", "def fetch_policies!\n @fetched = true\n @policy_classes = @policies.map do |pol|\n result = case pol\n when String\n Merb::Authorization._policy_from_string(pol)\n when Symbol\n Merb::Authorization._policies_from_scope(pol, scope)\n end\n end\n @policy_classes = @policy_classes.flatten.compact\n end", "def all\n id_list = redis.zrange \"#{klass}:all\", 0, -1\n\n obj_list = []\n id_list.each do |obj_id|\n obj = self.new\n obj.send(:id=, obj_id.to_i)\n obj_list << obj\n end\n\n obj_list\n end", "def index\n @groups = policy_scope(Group)\n end", "def index\n @products = policy_scope(Product).order(created_at: :desc)\n @products = Product.where(availability: true)\n end", "def index\n if Policy.all.empty?\n redirect_to new_policy_path\n else\n redirect_to policy_path(Policy.first)\n end\n end", "def get_policy_templates\n @command = :get_policy_templates\n # get the policy templates from the RESTful API (as an array of objects)\n uri = URI.parse @uri_string + '/templates'\n result = hnl_http_get(uri)\n unless result.blank?\n # convert it to a sorted array of objects (from an array of hashes)\n sort_fieldname = 'template'\n result = hash_array_to_obj_array(expand_response_with_uris(result), sort_fieldname)\n end\n # and print the result\n print_object_array(result, \"Policy Templates:\", :style => :table)\n end", "def index\n @instances = Instance.all\n end", "def index\n @instances = Instance.all\n end", "def index\n @roles = policy_scope(Role).page(pagination[:page]).per(pagination[:per])\n end", "def each_instance( limit = %w[ all ])\n limit = [ limit ].flatten\n every = (limit.first == \"all\")\n\n instances.keys.sort.each do |name|\n if every or limit.include?( name ) then\n yield instances[name]\n end\n end\n end", "def index\n @galaxies = policy_scope(Galaxy)\n end", "def all\n _register_class_observer\n if _class_fetch_states.has_key?(:all) && 'fi'.include?(_class_fetch_states[:all]) # if f_etched or i_n progress of fetching\n collection = HyperRecord::Collection.new\n _record_cache.each_value { |record| collection.push(record) }\n return collection\n end\n promise_all\n HyperRecord::Collection.new\n end", "def get_posts_for_user\n @posts = policy_scope(Post)\n end", "def index\n @bookings = policy_scope(current_user.bookings)\n authorize @bookings\n @experiences = policy_scope(current_user.experiences)\n authorize @experiences\n end", "def init_instances\n instances = []\n next_token = nil\n all_records_retrieved = false\n\n until all_records_retrieved\n response = @@client.describe_instances({\n next_token: next_token\n })\n next_token = response.next_token\n all_records_retrieved = next_token.nil? || next_token.empty?\n instances << response.reservations.map { |r| r.instances }\n end\n\n instances.flatten\n end", "def all_objectives\n Objective.all\n end", "def index\n @samples = policy_scope(Sample.all)\n authorize Sample\n end", "def accumulate_instances\n self.repository = Hash.new { |h,k| h[k] = new(*k) }\n\n begin\n yield\n return repository.values\n ensure\n self.repository = nil\n end\n end", "def policies; end", "def get_pvm_instances\n pvm_instances = get(\"cloud-instances/#{guid}/pvm-instances\")[\"pvmInstances\"] || []\n\n pvm_instances.map do |pvm_instance|\n get_pvm_instance(pvm_instance[\"pvmInstanceID\"])\n end\n end", "def populate_policies\n end", "def policy_list_hash\n\t\t\tpost= { \"token\" => @token }\n\t\t\tdocxml = nil\n\t\t\tdocxml=nessus_request('scan/list', post)\n\t\t\tif docxml.nil?\n\t\t\t\treturn\n\t\t\tend\n\t\t\tpolicies=Array.new\n\t\t\tdocxml.elements.each('/reply/contents/policies/policies/policy') { |policy|\n\t\t\t\tentry=Hash.new\n\t\t\t\tentry['id']=policy.elements['policyID'].text if policy.elements['policyID']\n\t\t\t\tentry['name']=policy.elements['policyName'].text if policy.elements['policyName']\n\t\t\t\tentry['comment']=policy.elements['policyComments'].text if policy.elements['policyComments']\n\t\t\t\tpolicies.push(entry)\n\t\t\t}\n\t\t\treturn policies\n\t\tend", "def fetch_instances(allow_states = nil, reject_states = nil)\n Egi::Fedcloud::Vmhound::Log.debug \"[#{self.class}] Retrieving instances: \" \\\n \"allow_states=#{allow_states.inspect} & \" \\\n \"reject_states=#{reject_states.inspect}\"\n return if allow_states && allow_states.empty?\n reject_states ||= []\n\n @vm_pool_ary ||= fetch_instances_batch_pool(@vm_pool)\n @vm_pool_ary.collect { |vm| fetch_instances_vm(vm, allow_states, reject_states) }.compact\n end", "def index\n @rentals = policy_scope(Rental).order(created_at: :desc)\n end", "def index\n #@members = member.all\n #@members = member.with_restricted_access_access\n @members = policy_scope(Member)\n end", "def schedule_periods\n\t\t@periods = Period.all\n\tend", "def index\n authorize Authentication, :index?\n @authentications = policy_scope(Authentication)\n end", "def managed_app_policies\n return @managed_app_policies\n end", "def index\n authorize Job\n #\n @jobs = policy_scope(Job)\n end", "def instances; end", "def instances; end", "def index\n @app_instances = AppInstance.all\n end", "def policy_role_policies\n @policy_role_policies ||= Array.new.tap do |uris|\n filters = current_ability.agents.map do |agent|\n \"#{Ddr::Index::Fields::POLICY_ROLE}:\\\"#{agent}\\\"\"\n end.join(\" OR \")\n query = \"#{Ddr::Index::Fields::ACTIVE_FEDORA_MODEL}:Collection AND (#{filters})\"\n results = ActiveFedora::SolrService.query(query, rows: Collection.count, fl: Ddr::Index::Fields::INTERNAL_URI)\n results.each_with_object(uris) { |r, memo| memo << r[Ddr::Index::Fields::INTERNAL_URI] }\n end\n end", "def index\n @spaces = policy_scope(Space.order('name ASC'))\n end", "def index\n # @wikis = Wiki.all\n @user = current_user\n @wikis = policy_scope(Wiki)\n end", "def active_instances; end", "def index\n users = policy_scope(User)\n render json: { users: users }\n end", "def get_all(provider = :aws)\n @@_rule_set_registry.fetch(provider, {}).values\n end", "def index\n @profiles = Profile.all\n #authorize Profile\n #@profiles = policy_scope(Profile)\n end", "def policy\n ensure_service!\n grpc = service.get_table_policy instance_id, name\n policy = Policy.from_grpc grpc\n return policy unless block_given?\n yield policy\n update_policy policy\n end", "def all\n table_name = self.to_s.pluralize.underscore\n results = DATABASE.execute(\"SELECT * FROM #{table_name}\")\n \n results_as_objects = []\n \n results.each do |result_hash|\n results_as_objects << self.new(result_hash)\n end\n return results_as_objects\n end", "def all\n self.all\n end", "def all\n result = @dealing_platform.session.get('accounts').fetch :accounts\n\n @dealing_platform.instantiate_models Account, result\n end", "def all\n super | entities | action_instances\n end", "def all\n # Figure out the table's name from the class we're calling the method on.\n table_name = self.to_s.pluralize.underscore\n \n results = QUIZ.execute(\"SELECT * FROM #{table_name}\")\n results_as_objects = []\n \n results.each do |result_hash|\n results_as_objects << self.new(result_hash)\n end\n return results_as_objects\n end" ]
[ "0.7464853", "0.6737194", "0.6611847", "0.6559259", "0.64755905", "0.6422424", "0.6364494", "0.63396394", "0.6315466", "0.62616324", "0.62502855", "0.6196983", "0.61888546", "0.6140078", "0.6123789", "0.6118178", "0.6107066", "0.6078124", "0.60427094", "0.6039749", "0.60091597", "0.5996068", "0.59558225", "0.59460294", "0.59385073", "0.59288806", "0.59288806", "0.59288806", "0.59288806", "0.59288806", "0.59288806", "0.59288806", "0.59288806", "0.59288806", "0.59288806", "0.5879571", "0.58794665", "0.5867692", "0.58630675", "0.5862594", "0.585335", "0.5833298", "0.58317274", "0.5797077", "0.5794604", "0.5776257", "0.57725275", "0.5766381", "0.57480526", "0.57364595", "0.5715462", "0.5708763", "0.5703459", "0.5691469", "0.5662188", "0.5646633", "0.5645434", "0.56432104", "0.5629828", "0.5611213", "0.5579853", "0.5572622", "0.5572622", "0.55665827", "0.55435497", "0.55402076", "0.55367607", "0.5519234", "0.5512928", "0.5508627", "0.55079716", "0.5492434", "0.54724824", "0.54701763", "0.54647934", "0.5460631", "0.54589194", "0.5454318", "0.54525757", "0.54523367", "0.54499114", "0.5440004", "0.5435412", "0.5432888", "0.54290324", "0.54290324", "0.5413914", "0.5411231", "0.540813", "0.5405122", "0.54015064", "0.5378491", "0.53761125", "0.5370396", "0.5367866", "0.53673214", "0.53626424", "0.5359772", "0.5356109", "0.53523934" ]
0.5910806
35
Returns the policy templates available
def get_policy_templates @command = :get_policy_templates # get the policy templates from the RESTful API (as an array of objects) uri = URI.parse @uri_string + '/templates' result = hnl_http_get(uri) unless result.blank? # convert it to a sorted array of objects (from an array of hashes) sort_fieldname = 'template' result = hash_array_to_obj_array(expand_response_with_uris(result), sort_fieldname) end # and print the result print_object_array(result, "Policy Templates:", :style => :table) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @policy_templates = PolicyTemplate.all\n end", "def templates\n response = get 'templates'\n response.map{|item| Hashie::Mash.new(item)}\n end", "def templates\n @templates ||= (\n list = []\n list.concat templates_from_project\n list.concat templates_from_remotes\n list.concat templates_from_plugins\n list.sort_by{ |t| t.name }\n )\n end", "def templates\n state(metrics: \"metadata\").dig(\"metadata\", \"templates\")\n end", "def templates\n @instruments_templates ||= lambda do\n args = ['xctrace', 'list', 'templates']\n\n hash = xcrun.run_command_in_context(args, log_cmd: true)\n hash[:out].chomp.split(\"\\n\").map do |elm|\n stripped = elm.strip.tr('\"', '')\n if stripped == '' || stripped == 'Known Templates:'\n nil\n else\n stripped\n end\n end.compact\n end.call\n end", "def get_resource_templates\n @model.get.mixins.select { |mixin| mixin.related.select { |rel| rel.end_with? 'resource_tpl' }.any? }\n end", "def supported_templates\n [\n double_opt_in_template,\n admin_forgot_password_template,\n user_forgot_password_template,\n kyc_issue_template,\n admin_invite_template,\n test_webhook_result_template,\n\n # kyc_data_mismatch_template,\n # kyc_document_id_issue_template,\n # kyc_selfie_image_issue_template,\n # kyc_residency_image_issue_template,\n\n kyc_approved_template,\n kyc_denied_template,\n purchase_confirmation,\n altdrop_sent,\n contact_us_template,\n low_whitelister_balance_template,\n manual_review_needed_template,\n billing_plan_notification_template,\n update_ethereum_request_outcome_template,\n open_case_request_outcome_template,\n contact_us_ost_partner_autoresponder_template,\n contact_us_ost_kyc_autoresponder_template,\n kyc_report_download_template,\n low_balance_whitelisting_suspended_template,\n contract_address_update_template\n ]\n end", "def templates\n @conn.templates\n end", "def available_page_templates\n dirname = Rails.root.join('app/' + Option.theme_full_dir)\n templates = []\n Dir.foreach(dirname) do |filename|\n if filename.length > 19 + 1 && filename.slice(0, 9) == 'template_' && filename.slice(-10, 10) == '.html.haml'\n templates << filename.slice(9, filename.length - 19)\n end\n end\n templates\n end", "def templates\n file_list '{templates,puppet}/**/*.{erb,epp}'\n end", "def get_driver_templates\n @client.raw('get', '/content/email-templates/driver/templates')\n end", "def get_available_template_types\n\t\tskin = @params['from']\n\t\tskin_dir = File.join(THEMES, skin)\n\t\toptions = []\n\t\tif File.exists? File.join(skin_dir, \"templates\", \"skin.liquid\")\n\t\t\toptions << create_checkbox(\"functions\", \"rooms\", \"Rooms\", \"validate-one-required\")\n\t\tend\n\t\tif File.exists? File.join(skin_dir, \"templates\", \"tickets\")\n\t\t\toptions << create_checkbox(\"functions\", \"events\", \"Events\", \"validate-one-required\")\n\t\tend\n\t\tif File.exists? File.join(skin_dir, \"templates\", \"vouchers\")\n\t\t options << create_checkbox(\"functions\", \"vouchers\", \"Vouchers\", \"validate-one-required\")\n\t\tend\n\t\toptions = options.join(\"<br />\")\n\t\trender :text => options\n\tend", "def list_policies\n nessus_rest_get('policies')['policies']\n end", "def published_templates\n\t\treturn templates.where(\"published = ?\", true)\n\tend", "def list\n @client.call(method: :get, path: 'templates')\n end", "def templates\n response = get \"storage/template\"\n data = JSON.parse response.body\n data\n end", "def public_templates\n Template.includes(org: :identifiers)\n .joins(:org)\n .published\n .publicly_visible\n .where(customization_of: nil)\n .order(:title)\n end", "def possible_templates\n\t\tif !params[:funder].nil? && params[:funder] != \"\" && params[:funder] != \"undefined\" then\n\t\t\tfunder = Organisation.find(params[:funder])\n\t\telse\n\t\t\tfunder = nil\n\t\tend\n\t\tif !params[:institution].nil? && params[:institution] != \"\" && params[:institution] != \"undefined\" then\n\t\t\tinstitution = Organisation.find(params[:institution])\n\t\telse\n\t\t\tinstitution = nil\n\t\tend\n\t\ttemplates = {}\n\t\tunless funder.nil? then\n\t\t\tfunder.published_templates.each do |t|\n\t\t\t\ttemplates[t.id] = t.title\n\t\t\tend\n\t\tend\n\t\tif templates.count == 0 && !institution.nil? then\n\t\t\tinstitution.published_templates.each do |t|\n\t\t\t\ttemplates[t.id] = t.title\n\t\t\tend\n\t\t\tinstitution.children.each do |o|\n\t\t\t\to.published_templates.each do |t|\n\t\t\t\t\ttemplates[t.id] = t.title\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\trespond_to do |format|\n\t\t\tformat.json { render json: templates.to_json }\n\t\tend\n\tend", "def templates\n # Some cheap memoiziation\n @templates ||= begin\n files = Dir.glob(template_glob)\n # Check to see what mode we are in, that'll define how we parse the file names\n if Gluttonberg.localized? or Gluttonberg.translated?\n # Figure out what regex we need\n matcher, mode = if Gluttonberg.localized?\n [/\\/#{filename}.(\\w+).([a-z-]+).(\\w+).(erb|mab|haml)/, :localized]\n elsif Gluttonberg.translated?\n [/\\/#{filename}.([a-z-]+).(\\w+).(erb|mab|haml)/, :translated]\n end\n files.inject({}) do |memo, file|\n match = file.match(matcher)\n extract_template_details(memo, mode, match) if match\n memo\n end\n else\n # For the non-localized/dialect mode, just collect the various formats\n files.inject([]) do |memo, file|\n match = file.match(/#{filename}.(\\w+).(erb|mab|haml)/)\n memo << match[1] if match\n memo\n end\n end\n end\n end", "def policies\n @policies = Policy.all\n end", "def templates\n wayfinder.decorated_templates\n end", "def index\n @q = policy_scope(ServiceTemplate).ransack params[:q]\n @service_templates = @q.result.order(\"updated_at DESC\").page params[:page]\n end", "def get_templates(opts={})\n path = '/template/list'\n opts[:query] = create_search_string(opts[:query]) if opts[:query]\n query = create_query_string(opts, [:page, :page_size, :query])\n path += query\n HelloSign::Resource::ResourceArray.new get(path, opts), 'templates', HelloSign::Resource::Template\n end", "def get_os_templates\n @model.get.mixins.select { |mixin| mixin.related.select { |rel| rel.end_with? 'os_tpl' }.any? }\n end", "def templates\n return self.class.get('/templates').parsed_response.map do |template|\n Template.new(template['template_id'], template['name'])\n end\n end", "def init_template_statements\n @templates.map do |template|\n Loader.template_policy(template[\"template\"], template[\"vars\"])\n end.flatten\n end", "def list\n @client.make_request :get, templates_path\n end", "def templates\n Dir.glob(::Webby.path('examples') / '*').sort\n end", "def templates\n @templates ||= TemplateFinder.new(path, types)\n end", "def get_templates(type)\n Dir[get_template_location << type << '/*']\n end", "def index\n authorize @organization, :show_templates?\n @survey_templates = @organization.survey_templates\n end", "def filtered_widgets_templates\n if MnoEnterprise.widgets_templates_listing\n return self.widgets_templates.select do |t|\n MnoEnterprise.widgets_templates_listing.include?(t[:path])\n end\n else\n return self.widgets_templates\n end\n end", "def filtered_widgets_templates\n if MnoEnterprise.widgets_templates_listing\n return self.widgets_templates.select do |t|\n MnoEnterprise.widgets_templates_listing.include?(t[:path])\n end\n else\n return self.widgets_templates\n end\n end", "def result_templates\n return @result_templates\n end", "def resource_templates_by_name\n @resource_templates_by_name ||= resource_templates.all_by_name\n end", "def org_templates(templates: [])\n org_templates = Template.latest_version_per_org(@client.user.org).published\n custs = Template.latest_customized_version_per_org(@client.user.org).published\n return (templates + org_templates).sort_by(&:title) unless custs.any?\n\n # Remove any templates that were customized by the org, we will use their customization\n templates.reject { |t| custs.map(&:customization_of).include?(t.family_id) }\n\n (org_templates + custs + templates).sort_by(&:title)\n end", "def templates\n Dir.glob(File.join(gem_path, 'templates', '*'))\n end", "def index\n authorize! :manage, :all\n @question_templates = QuestionTemplate.all\n end", "def templates\n @templates ||= EbanqApi::Templates.new(self)\n end", "def policy_list_names\r\n\t\tpost= { \"token\" => @token } \r\n\t\tdocxml=nessus_request('policy/list', post)\r\n\t\tlist = Array.new\r\n\t\tdocxml.root.elements['contents'].elements['policies'].each_element('//policy') {|policy|\r\n\t\t\t\tlist.push policy.elements['policyName'].text\r\n\t\t}\r\n\t\treturn list\r\n\tend", "def policy_list_names\n\t\t\tpost= { \"token\" => @token }\n\t\t\tdocxml = nil\n\t\t\tdocxml=nessus_request('policy/list', post)\n\t\t\tif docxml.nil?\n\t\t\t\treturn\n\t\t\tend\n\t\t\tlist = Array.new\n\t\t\tdocxml.root.elements['contents'].elements['policies'].each_element('//policy') {|policy|\n\t\t\t\tlist.push policy.elements['policyName'].text\n\t\t\t}\n\t\t\treturn list\n\t\tend", "def policy_tags\n names = @gapi.policy_tags&.names\n names.to_a if names && !names.empty?\n end", "def applied_policies\n return @applied_policies\n end", "def mcget_templates\n # setup_mcapi.folders.list(\"template\")\n setup_mcapi.templates.list({user: true},{include_drag_and_drop: true})\n end", "def templates\n @template_paths ||= Tilt.mappings.map do |ext, engines|\n Dir.glob(@root+\"/**/*.#{ext}\") if engines.map(&:default_mime_type).include?('text/html')\n end.flatten.compact\n end", "def template_types_for_view\n\t\ttt = {}\n\t\tif File.exists?(theme_template_path + '/skin.liquid')\n\t\t\ttt[:rooms] = 'Rooms-Templates'\n\t\tend\n\t\tif File.exists?(theme_template_path + '/tickets')\n\t\t\ttt[:events] = 'Events-Templates'\n\t\tend\n\t\tif File.exists?(theme_template_path + '/vouchers')\n tt[:vouchers] = 'Voucher-Templates'\n end\n\t\treturn tt\n\tend", "def policy_classes\n fetch_policies! unless @fetched\n @policy_classes\n end", "def list_templates(type)\n res = http_get(:uri=>\"/editor/#{type}/templates\", :fields=>x_cookie)\n end", "def verification_templates(main_only: false)\n templates = raw_template\n templates = [templates.detect { |t| Kubernetes::RoleConfigFile.primary?(t) } || templates.first] if main_only\n templates.each_with_index.map { |c, i| Kubernetes::TemplateFiller.new(self, c, index: i) }\n end", "def shared_templates\n manifest[:shared_templates]\n end", "def plugin_templates(type: :export)\n type = valid_type(type)\n templates = []\n plugs = plugins[type].clone\n plugs.delete_if { |_t, o| o[:templates].nil? }.each do |_, options|\n options[:templates].each do |t|\n out = t[:name]\n out += \" (#{t[:format]})\" if t.key?(:format)\n templates << out\n end\n end\n\n templates.sort.uniq\n end", "def index\n @priv_policies = PrivPolicy.all\n end", "def plans_templates_index\n @user = User.find_by_id(session[:user_id])\n \n # If an institutional user, return the templates that the instition has used to make plans\n if user_role_in?(:dmp_admin)\n @plans = Plan.includes(:requirements_template).order(id: :asc)\n \n @plans\n \n elsif user_role_in?(:institutional_admin, :institutional_reviewer, :resource_editor, :template_editor)\n @plans = Plan.joins(:users).where(\"users.institution_id IN (?)\", @user.institution.id).\n includes(:requirements_template).order(id: :asc)\n @plans\n else\n render_unauthorized\n end\n end", "def list_sslpolicies(headers = {})\n get!(\"sslpolicies\", {}, headers)\n end", "def list_policies\n http_get(:uri=>\"/policies\", :fields=>x_cookie)\n end", "def templates; end", "def find_templates(name, prefix, partial, details)\n conditions = {\n path: normalize_path(name, prefix),\n locale: normalize_array(details[:locale]).first,\n format: normalize_array(details[:formats]).first,\n handler: normalize_array(details[:handlers]),\n partial: partial || false\n }\n\n ::Page.visible(user_sign_in_status).where(conditions).map do |record|\n initialize_template(record)\n end\n end", "def policies_for_widget widget, options\n widget = widget.is_a?(Widget) ? widget : Widget.find(widget)\n policies = UbiquoDesign::CachePolicies.get(options[:policy_context])[widget.key]\n [widget, policies]\n end", "def hardCodedPolicies()\n\n return [\"Ice time rates are subject to change.\",\n \"Booking total is subject to change depending on activity at the discretion of the \" + long_name + \".\",\n \"Ice schedules are subject to change and Playogo does not guarantee that the timeslot is available until it is confirmed by the \" + long_name + \".\",\n \"Once your booking request has been confirmed by the \" + long_name + \", the price of the booking will be charged to your credit card.\",\n \"Your ice contract will be with the \" + long_name + \".\",\n \"Refer to all terms and conditions of your contract with the \" + long_name + \".\",\n \"Playogo is a non-affiliated third party, who simply makes it easier to find available ice time across a number of markets.\",\n \"There are no additional fees to book ice time through Playogo.\"\n ]\n end", "def policies; end", "def select_template\n templatelist = []\n templatelist\n end", "def list_templates(args = {})\n filter = args[:filter] || 'featured'\n params = {\n 'command' => 'listTemplates',\n 'templateFilter' => filter\n }\n params['projectid'] = args[:project_id] if args[:project_id]\n params['zoneid'] = args[:zone_id] if args[:zone_id]\n \n json = send_request(params)\n json['template'] || []\n end", "def template\n possible_templates.find {|t| File.exists? \"#{t}.html\"}\n end", "def template_options(org_id, funder_id)\n @templates = []\n\n if org_id.present? || funder_id.present?\n if funder_id.blank?\n # Load the org's template(s)\n if org_id.present?\n org = Org.find(org_id)\n @templates = Template.valid.where(published: true, org: org, customization_of: nil).to_a\n @msg = _(\"We found multiple DMP templates corresponding to the research organisation.\") if @templates.count > 1\n end\n\n else\n funder = Org.find(funder_id)\n # Load the funder's template(s)\n @templates = Template.valid.where(published: true, org: funder).to_a\n\n if org_id.present?\n org = Org.find(org_id)\n\n # Swap out any organisational cusotmizations of a funder template\n @templates.each do |tmplt|\n customization = Template.valid.find_by(published: true, org: org, customization_of: tmplt.dmptemplate_id)\n if customization.present? && tmplt.updated_at < customization.created_at\n @templates.delete(tmplt)\n @templates << customization\n end\n end\n end\n\n @msg = _(\"We found multiple DMP templates corresponding to the funder.\") if @templates.count > 1\n end\n end\n\n # If no templates were available use the generic templates\n if @templates.empty?\n @msg = _(\"Using the generic Data Management Plan\")\n @templates << Template.default\n end\n\n @templates = @templates.sort{|x,y| x.title <=> y.title } if @templates.count > 1\n end", "def policy_scopes; end", "def node_policy_tags\n policy_tags = []\n if @policy_tags_enabled\n if @node.respond_to?('policy_group') && [email protected]_group.nil?\n policy_tags << \"#{@scope_prefix}policy_group:#{@node.policy_group}\"\n end\n if @node.respond_to?('policy_name') && [email protected]_name.nil?\n policy_tags << \"#{@scope_prefix}policy_name:#{@node.policy_name}\"\n end\n end\n policy_tags\n end", "def template_extensions\n EXTENSIONS.keys\n end", "def owt_list\n @client.make_request :get, templates_path('owt')\n end", "def files\n templates.map(&:filename)\n end", "def scan_templates\r\n @templates = Dir.glob(File.join(path, \"*\")).inject([]) do |list, file_path|\r\n log.debug \"Checking if #{file_path} is a recognised template file.\"\r\n if File.file?(file_path)\r\n file_name = File.basename(file_path)\r\n log.debug \"#{file_path} is a template file.\" if !(Tilt[file_name]).nil?\r\n list << file_path if !(Tilt[file_name]).nil?\r\n end\r\n list\r\n end\r\n end", "def virtual_machine_templates\n kubevirt_client.get_virtual_machine_templates(namespace: @namespace)\n end", "def find_all_resources options\n policy_scope(resource_class)\n end", "def _mg_templates\n @_mg_templates ||= ModelGrinder.templates\n end", "def templates\n GitWiki.template_cache ||= Dir[\"#{ settings.views[0] }/*.liquid\"].map do |f|\n name = File.basename(f, '.liquid')\n {\n \"name\" => name,\n \"examples\" => Page.get_template(name).examples\n }\n end\n end", "def templates() = templates_path.glob('**/*.erb')", "def intended_policies\n return @intended_policies\n end", "def form_templates\n FormTemplate.where(lecturer_id: @id)\n end", "def policy\n if resource[:plist]\n return File.readlines(resource[:plist]).to_s\n end \n resource[:content]\n end", "def template_files\r\n \t[].concat(@templates)\r\n end", "def config_templates\r\n ConfigTemplatesController.instance\r\n end", "def index\n authorize Template\n templates = Template.latest_version.where(customization_of: nil)\n published = templates.count { |t| t.published? || t.draft? }\n\n @orgs = Org.includes(identifiers: :identifier_scheme).managed\n @title = _('All Templates')\n @templates = templates.includes(:org).page(1)\n @query_params = { sort_field: 'templates.title', sort_direction: 'asc' }\n @all_count = templates.length\n @published_count = (published.presence || 0)\n @unpublished_count = if published.present?\n (templates.length - published)\n else\n templates.length\n end\n render :index\n end", "def list_resource_tpl\n @resource_tpl\n end", "def templates(params = {})\n @api.get(\"#{@api.path}/List/#{@id}/Templates\", params: params)\n end", "def auth_policies\n []\n end", "def get_templates_in_page(title, limit = @query_limit_default)\n params = {\n prop: 'templates',\n titles: title,\n tllimit: get_limited(limit)\n }\n\n query(params) do |return_val, query|\n pageid = query['pages'].keys.find { |id| id != '-1' }\n return unless pageid\n templates = query['pages'][pageid].fetch('templates', [])\n return_val.concat(templates.collect { |template| template['title'] })\n end\n end", "def policy_list_hash\n\t\t\tpost= { \"token\" => @token }\n\t\t\tdocxml = nil\n\t\t\tdocxml=nessus_request('scan/list', post)\n\t\t\tif docxml.nil?\n\t\t\t\treturn\n\t\t\tend\n\t\t\tpolicies=Array.new\n\t\t\tdocxml.elements.each('/reply/contents/policies/policies/policy') { |policy|\n\t\t\t\tentry=Hash.new\n\t\t\t\tentry['id']=policy.elements['policyID'].text if policy.elements['policyID']\n\t\t\t\tentry['name']=policy.elements['policyName'].text if policy.elements['policyName']\n\t\t\t\tentry['comment']=policy.elements['policyComments'].text if policy.elements['policyComments']\n\t\t\t\tpolicies.push(entry)\n\t\t\t}\n\t\t\treturn policies\n\t\tend", "def policy_get_first\n\t\t\tpost= { \"token\" => @token }\n\t\t\tdocxml = nil\n\t\t\tdocxml=nessus_request('policy/list', post)\n\t\t\tif docxml.nil?\n\t\t\t\treturn\n\t\t\tend\n\t\t\tdocxml.root.elements['contents'].elements['policies'].each_element('//policy') {|policy|\n\t\t\t\treturn policy.elements['policyID'].text, policy.elements['policyName'].text\n\t\t\t}\n\t\tend", "def retrieve_all_template_info\n puts \"Retrieving all template ids and names for #{@primary_username} ...\"\n puts\n\n uri = URI(@config['endpoint'])\n\n # Retrieve templates\n http = Net::HTTP.new( uri.host,uri.port )\n http.use_ssl = true\n request = Net::HTTP::Get.new( uri.request_uri )\n request.basic_auth(@primary_username, @primary_password)\n\n response = http.request( request )\n templates = JSON.parse( response.body )\n\n # Create template_id array\n @template_array = Array.new\n\n # Create a template hash w/ name and id for each template found\n templates['templates'].each do |t|\n @template_array.push({:id => t['id'], :name => t['name']})\n end\n\n # Return constructed temmplate array\n return template_array\n end", "def get_course_templates_schema\n path = \"/d2l/api/lp/#{$lp_ver}/coursetemplates/schema\"\n _get(path)\n # This action returns a JSON array of SchemaElement blocks.\nend", "def get_os_templates(authInfo, options)\n\n @logger.debug(\"Getting OS templates ...\")\n \n os_templates = nil\n\n # If the authentication information is not specified in the Vagrantfile return a failure status\n if(authInfo.nil? || authInfo.url.nil? || authInfo.applicationKey.nil? || authInfo.sharedSecret.nil?)\n @env.ui.error(I18n.t('secured_cloud_vagrant.errors.unspecified_auth', :resource_type => \"OS templates\"))\n return os_templates\n end\n\n begin\n\n # Create a Secured Cloud Connection instance to connect to the SecuredCloud API\n sc_connection = SecuredCloudConnection.new(authInfo.url, authInfo.applicationKey, authInfo.sharedSecret)\n\n # Get the OS templates for the specified details\n os_templates_urls = SecuredCloudRestClient.getOsTemplatesAvailable(sc_connection, options[:orgResource], options[:nodeResource])\n\n if !os_templates_urls.nil?\n\n # Create an array to hold the os templates details\n os_templates = Hash.new\n\n # Get the details for each retrieved os template resource URL and add it to the list\n os_templates_urls.each do |os_template_url|\n os_templates[os_template_url] = SecuredCloudRestClient.getOsTemplateDetails(sc_connection, os_template_url)\n end\n\n @logger.debug(\"Found #{os_templates.length} OS templates for organization '#{options[:orgResource]}' on node '#{options[:nodeResource]}'\")\n\n else\n\n @logger.debug(\"No OS templates available for organization '#{options[:orgResource]}' on node '#{options[:nodeResource]}'\")\n\n end\n\n rescue Errno::ETIMEDOUT\n @env.ui.error(I18n.t(\"secured_cloud_vagrant.errors.request_timed_out\", :request => \"get the OS templates details\"))\n rescue Exception => e\n @env.ui.error(I18n.t(\"secured_cloud_vagrant.errors.generic_error\", :error_message => e.message))\n end\n\n return os_templates\n\n end", "def templates_path\n @templates_path\n end", "def find_templates(path)\n templates = []\n Find.find(path) do |path|\n templates << path if template?(path)\n end\n templates\n end", "def get_all_policies\n @command = :get_all_policies\n raise ProjectHanlon::Error::Slice::SliceCommandParsingFailed,\n \"Unexpected arguments found in command #{@command} -> #{@command_array.inspect}\" if @command_array.length > 0\n # get the policies from the RESTful API (as an array of objects)\n uri = URI.parse @uri_string\n result = hnl_http_get(uri)\n unless result.blank?\n # convert it to a sorted array of objects (from an array of hashes)\n sort_fieldname = 'line_number'\n result = hash_array_to_obj_array(expand_response_with_uris(result), sort_fieldname)\n end\n # and print the result\n print_object_array(result, \"Policies:\", :style => :table)\n end", "def notifier_templates\n @notifier_templates || []\n end", "def templates_from_plugins\n list = []\n dirs = ::Find.data_path(File.join('quarry', '*/'))\n dirs = dirs.uniq.map{ |d| d.chomp('/') }\n dirs.each do |dir|\n i = dir.rindex('quarry/')\n name = dir[i+7..-1]\n list << Template.new(name, dir, :type=>:plugin)\n end\n list\n end", "def populate_policies\n end", "def retrieve_policies( resource_name, access_token, realm_uuid, resource_server )\n if resource_name && access_token\n request_policies(\n resource_name,\n access_token,\n realm_uuid,\n resource_server\n )\n else\n nil\n end\n end", "def index\n @permission_policies = PermissionPolicy.all\n end", "def template_paths(name)\r\n \[email protected]([]) do |list, path|\r\n \t\tfile_name = File.basename(path)\r\n \t\tfile_name[0, name.length] == name.to_s ? list << path : list\r\n \tend\r\n end", "def get_template(matching_options_hash, matching_tags_hash)\n log(:info, \"Processing get_template...\", true)\n\n template_search_by_guid = matching_options_hash[:guid] rescue nil\n template_search_by_name = matching_options_hash[:name] || matching_options_hash[:template] rescue nil\n template_search_by_product = matching_options_hash[:os] rescue nil\n templates = []\n\n unless template_search_by_guid.nil?\n # Search for templates tagged with 'prov_scope' => 'all' & match the guid from option_?_guid\n if templates.empty?\n log(:info, \"Searching for templates tagged with 'prov_scope' => 'all' that match guid: #{template_search_by_guid}\")\n templates = $evm.vmdb('miq_template').all.select do |template|\n template.ext_management_system && template.tagged_with?('prov_scope', 'all') && template.guid == template_search_by_guid\n end\n end\n end\n unless template_search_by_name.nil?\n # Search for templates that tagged with 'prov_scope' => 'all' & match the name from option_?_template || option_?_name - then load balance them across different providers based on vm count\n if templates.empty?\n log(:info, \"Searching for templates tagged with 'prov_scope' => 'all' that are named: #{template_search_by_name}\")\n templates = $evm.vmdb('miq_template').all.select do |template|\n template.ext_management_system && template.tagged_with?('prov_scope', 'all') && template.name == template_search_by_name\n end.sort { |template1, template2| template1.ext_management_system.vms.count <=> template2.ext_management_system.vms.count }\n end\n end\n unless template_search_by_product.nil?\n # Search for templates tagged with 'prov_scope' => 'all' & product_name include option_?_os (I.e. 'windows', red hat') - then load balance them across different providers based on vm count\n if templates.empty?\n log(:info, \"Searching for templates tagged with 'prov_scope' => 'all' that inlcude product: #{template_search_by_product}\")\n templates = $evm.vmdb('miq_template').all.select do |template|\n template.ext_management_system && template.tagged_with?('prov_scope', 'all') && template.operating_system[:product_name].downcase.include?(template_search_by_product)\n end.sort { |template1, template2| template1.ext_management_system.vms.count <=> template2.ext_management_system.vms.count }\n end\n end\n raise \"No templates found\" if templates.empty?\n\n # get the first template in the list\n template = templates.first\n log(:info, \"Found template: #{template.name} product: #{template.operating_system[:product_name].downcase rescue 'unknown'} guid: #{template.guid} on provider: #{template.ext_management_system.name}\")\n matching_options_hash[:name] = template.name\n matching_options_hash[:guid] = template.guid\n log(:info, \"Processing get_template...Complete\", true)\n end" ]
[ "0.7061667", "0.6666429", "0.665107", "0.6640467", "0.65752417", "0.6467771", "0.6467769", "0.6442301", "0.6428483", "0.64229816", "0.6392251", "0.6387849", "0.6347757", "0.62990326", "0.6283147", "0.62463605", "0.6222771", "0.62059665", "0.61889166", "0.617958", "0.6176009", "0.6166934", "0.61263657", "0.60888827", "0.6087091", "0.60844284", "0.6055995", "0.60317594", "0.6020545", "0.60154533", "0.6003541", "0.5937151", "0.5937151", "0.59266496", "0.592263", "0.5913901", "0.58987665", "0.589862", "0.588397", "0.5877941", "0.58702904", "0.5867401", "0.5829849", "0.5821981", "0.5816848", "0.5814791", "0.58137846", "0.58080584", "0.5788032", "0.57861334", "0.5782106", "0.576998", "0.57611424", "0.5755406", "0.57368225", "0.5722299", "0.5718622", "0.5714701", "0.57118464", "0.5708551", "0.57080656", "0.57018435", "0.56919265", "0.5682907", "0.5682055", "0.5680531", "0.5672092", "0.5649364", "0.5646211", "0.5642657", "0.564246", "0.56319684", "0.5626741", "0.56192493", "0.56150085", "0.5613193", "0.56006455", "0.55875266", "0.55837196", "0.5570752", "0.55671465", "0.55632895", "0.5553549", "0.5538536", "0.5523061", "0.55155385", "0.55154485", "0.5514238", "0.5513711", "0.5502581", "0.5498499", "0.5491215", "0.547998", "0.5476737", "0.5472162", "0.54613113", "0.54611284", "0.5456984", "0.5453114", "0.54484403" ]
0.82029665
0
This method is the inverse of Base::initialize. Instead of assigning instance variables from a hash, it iterates over an object's instance_variables to build a hash representation of them. Ruby prepends
def reload_obj(dirty_obj) persisted_obj = dirty_obj.class.find_one(dirty_obj.id) dirty_obj.instance_variable.each do |instance_variable| dirty_obj.instance_variable_set(instance_variable, persisted_obj.instance_variable_get(instance_variable)) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(hash={})\n # assign the attributes here (???)\n hash.each do |k, v| # name = id, name, etc.\n self.send(\"#{k}=\", v)\n # self.k = v # there's no '.k' method\n #binding.pry\n end\n end", "def initialize(params={})\n\t\t\t\tparams.each_pair do |k,v|\n\t\t\t\t\tinstance_variable_set(\"@#{k}\", v)\n\t\t\t\tend\n\t\t\tend", "def initialize(attr_hash = nil)\n if attr_hash\n attr_hash.each do |k, v|\n instance_variable_set \"@#{k}\", v\n end\n end\n end", "def initialize(hash={})\n self.init_attrs_from_hash(hash)\n end", "def initialize(initial_hash = {})\n # convert String keys to Symbol\n @object = {}\n initial_hash.each_pair do | key, value |\n if key.is_a?(String)\n @object[key.to_sym] = value\n else\n @object[key] = value\n end\n end\n end", "def initialize(attrs={})\n from_hash(attrs)\n end", "def initialize(**attrs)\n prune(attrs).each { |name, value| instance_variable_set(:\"@#{name}\", value) }\n end", "def initialize(params = {})\n raise 'Wrong data provided' unless params.is_a? Hash\n\n params = params.to_h.stringify_keys\n set_instance_variable_params(params)\n set_instance_variable_columns(params)\n end", "def initialize(*args)\n args.each do |arg|\n if arg.kind_of? Hash\n arg.each do |k,v|\n self.send(\"#{k}=\", v)\n end\n end\n end\n end", "def initialize(hash={})\n self.class.fields.each do |field|\n self.singleton_class.send(:attr_accessor, field)\n end\n\n # initialize values of fields\n self.set_attributes(hash)\n\n # initialize internal variables\n self._errors = {}\n self._old_values = {}\n\n self.run_hook :after_initialize\n end", "def initialize(attributes_hash)\n attributes_hash.each {|k, v| self.send((\"#{k}=\"), v) if self.respond_to? (\"#{k}=\")}\n self.save\n end", "def initialize(params)\n params.each do |key, value|\n instance_variable_set(\"@#{key}\", value) if respond_to?(key)\n end\n end", "def initialize(params={})\n params.each do |k, v|\n self.instance_variable_set(\"@#{k}\", v)\n end\n end", "def initialize(attributes = {})\n defaults.merge!(attributes).each do |key, value|\n instance_variable_set(\"@#{key}\", value)\n end\n end", "def initialize(attributes = {})\n defaults.merge!(attributes).each do |key, value|\n instance_variable_set(\"@#{key}\", value)\n end\n end", "def initialize(attributes = {})\n defaults.merge!(attributes).each do |key, value|\n instance_variable_set(\"@#{key}\", value)\n end\n end", "def initialize(attributes = {})\n defaults.merge!(attributes).each do |key, value|\n instance_variable_set(\"@#{key}\", value)\n end\n end", "def initialize(dog_hash) #from Mass Assignment & Metaprogramming Lab\n dog_hash.each do |key, value|\n self.send((\"#{key}=\"), value)\n end\n end", "def initialize(hash)\n hash.each do |key, value|\n attribute = ATTRIBUTE_MAP[key.to_s]\n send(\"#{attribute}=\", value) if respond_to?(attribute)\n end\n end", "def initialize(props)\n props.each do |key, value|\n self.instance_variable_set('@' + key.to_s, value)\n end\n end", "def initialize(attr_hash = nil)\n if ! attr_hash.nil?\n attr_hash.keys.each do |k|\n self.send(\"#{k}=\", attr_hash[k])\n end\n end\n end", "def initialize(obj)\n @obj = obj\n @overrides = @@empty_hash\n end", "def initialize(args)\n args.each {|key, value|\n instance_variable_set \"@#{key}\", value if self.class.props.member?(key.to_sym)\n } if args.is_a? Hash\n end", "def initialize(attributes = nil)\n if attributes.is_a? Hash\n attributes.each do |key, value|\n self.send(key.to_s + \"=\", value)\n end\n end\n end", "def initialize(attributes = {})\n @attributes = defaults.merge!(attributes)\n\n @attributes.each do |key, value|\n instance_variable_set(\"@#{key}\", value)\n end\n end", "def initialize(attributes = {})\n @attributes = defaults.merge!(attributes)\n\n @attributes.each do |key, value|\n instance_variable_set(\"@#{key}\", value)\n end\n end", "def initialize(attributes = {})\n @attributes = defaults.merge!(attributes)\n\n @attributes.each do |key, value|\n instance_variable_set(\"@#{key}\", value)\n end\n end", "def initialize(attributes = nil)\n if attributes.is_a? Hash\n attributes.each do |key, value|\n self.send(key.to_s + \"=\", value)\n end\n end\n end", "def initialize(hash)\n super(hash)\n end", "def assign_instance_variables_from_hash(hash)\n hash.each { |key, value| public_send(\"#{key}=\", value) }\n end", "def initialize(args)\n args.each do |k, v|\n instance_variable_set(\"@#{k}\", v)\n end\n end", "def initialize(attrs={})\n attrs.each {|k,v| send(\"#{k}=\", v)}\n end", "def initialize(args = {})\n super()\n convert_hash_keys(args).each { |k, v| public_send(\"#{k}=\", v) }\n end", "def initialize new_attributes = {}\n _assign_attributes new_attributes\n end", "def initialize(attributes)\n attributes.each do |key, value|\n instance_variable_set(\"@#{key}\", value)\n end\n end", "def initialize(attrs = {})\n super nil\n attrs.each_pair do |field, value|\n self[field] = value\n end\n end", "def initialize(attributes={})\n attributes.each {|key, value| self.send(\"#{key}=\", value)}\n end", "def initialize(*args)\n @hash = HashWithIndifferentAccess.new(*args)\n end", "def initialize(attributes = {})\n defaults.merge!(attributes).each do |key, value|\n instance_variable_set(\"@#{key}\", value || defaults.fetch(key))\n end\n end", "def initialize(attributes={})\n attributes.each do |key, value|\n self.send(\"#{key}=\", value)\n end\n @attributes = attributes\n end", "def initialize(attributes = {})\n defaults.merge!(attributes).each do |key, value|\n instance_variable_set(\"@#{key}\", value || defaults.fetch(key))\n end\n end", "def initialize(hash)\r\n hash.each { |k, v|\r\n # Create getters and setters\r\n self.class.attr_accessor(k)\r\n # Set value for created variable\r\n self.send(\"#{k}=\", v)\r\n }\r\n self.class.all.push(self)\r\n end", "def initialize(hash={})\n self.attributes = hash\n end", "def initialize(hash)\n \n hash.each do |key,value|\n # if this attribute has a custom setter, use that otherwise set to the value\n if PERSON_DEFINITION[key][:setter]\n instance_variable_set(\"@#{key}\", PERSON_DEFINITION[key][:setter].call(value))\n else\n instance_variable_set(\"@#{key}\", value)\n end\n end\n\n # We're going to keep a list of all this persons guests and activities\n @guests = Array.new\n @activities = Array.new\n \n # NOTE: last_name and first_name attributes must be defined in the configuration file\n # The search name is formatted the same way as the guest of column that iModules spits\n # out\n @search_name = \"#{@last_name}, #{@first_name}\"\n \n # New reporting puts guest of in row for the registrant, making it look like they are\n # a guest of themselves - this fixes that\n @guest_of = nil if guest_of.eql?(@search_name)\n end", "def initialize(attrs)\n attrs = {} unless attrs\n attrs.each do |key, value|\n send(\"#{key}=\", value) if self.respond_to?(\"#{key}=\")\n end\n end", "def initialize(*args)\n params = args[0]\n attribute_keys.each { |k| self.__send__(\"#{k}=\", params[k]) if params.key?(k) } if params\n end", "def initialize(params={})super(params)\n # Define accessor and query methods for each attribute.\n attrs.each do |attribute|\n self.class.send :attr_accessor, attribute\n define_attr_query attribute\n end\n\n # Set instance variables and initialize @attributes with any\n # attribute values that were passed in the params hash.\n @attributes = {}\n params.each do |k,v|\n if attrs.include? k.to_s\n send(\"#{k}=\", v)\n @attributes[k] = v\n end\n end\n end", "def initialize(*attrs)\n options = attrs.empty? ? {} : attrs.first\n options = self.class.defaults.merge(options)\n set_instance_variables options\n end", "def initialize(hash=nil)\n @attributes = hash\n @attributes ||= {}\n end", "def initialize(input = {})\n input.each_pair do |key, value|\n instance_variable_set(self.class.send(:instance_variable_name, key), value)\n end\n end", "def initialize(*args)\n set_instance_variables args\n end", "def initialize( attrs = {} )\n @attributes = self.class.__properties.merge( attrs ).with_indifferent_access\n end", "def initialize(*attrs)\n # Sets all attributes as instance variables from the params (note this could also be done easily by using an OpenStruct)\n ATTRS.each do |key|\n instance_variable_set(\"@#{key}\", attrs.first[key])\n end\n end", "def initialize(attributes = {})\n @attributes = defaults.merge!(attributes)\n\n @attributes.each { |key, value| instance_variable_set(\"@#{key}\", value) }\n end", "def initialize(attributes)\n attributes.each {|key, value| self.send(\"#{key}=\", value)}\n end", "def initialize(params={})\n params.each_key do |item|\n self.class.send(:attr_accessor, item)\n self.send(\"#{item}=\", params[item])\n end\n end", "def initialize(options = {})\n @params = HashWithIndifferentAccess.new\n\n options.each do |key, value|\n send(\"#{key}=\", value)\n end\n end", "def initialize(params={})\n params.each do |attribute, value|\n if @@object_attributes.include? attribute\n objs = []\n value.each do |sub_val|\n objs << Ottoman.const_get(self.get_object_name(attribute)).new(sub_val)\n end if value\n self.public_send(\"#{attribute}=\", objs)\n elsif @@object_attribute.include? attribute\n self.public_send(\"#{attribute}=\", Object::const_get(self.get_object_name(attribute)).new(value)) if value\n else\n self.public_send(\"#{attribute}=\", value)\n end\n end if params\n\n super()\n end", "def initialize *args\n if respond_to? :before_init\n warn 'before_init is deprecated. please define process_init_args class method'\n else\n hash = self.class.process_init_args(*args)\n end\n\n unless hash && hash.kind_of?(Hash)\n raise ArgumentError, \"#{hash.inspect} was wrong as arguments. please specify kind of Hash instance\"\n end\n\n # allow String or Symbol for key\n tmp_hash = {}\n hash.each do |key,val|\n tmp_hash[key.to_s] = val\n end\n hash = tmp_hash\n\n hash.each do |key, val|\n if attribute_of[key]\n attribute_of[key].set val\n end\n end\n\n attribute_of.each do |key, val|\n next if val.class.lazy?\n raise AttrRequiredError, \"param: :#{key} is required to #{hash.inspect}\" if !val.class.optional? && !val.get\n end\n\n after_init\n end", "def initialize(attributes = {})\n @attributes = defaults.merge!(attributes)\n\n @attributes.each do |key, value|\n instance_variable_set(\"@#{key}\", value || defaults.fetch(key))\n end\n end", "def initialize(attrs = {})\n @attrs = attrs || {}\n @attrs.each do |key, value|\n self.class.class_eval { attr_reader key }\n instance_variable_set(\"@#{key}\", value)\n end\n end", "def initialize(*args)\n @attributes = HashWithIndifferentAccess[ self.class.attribute_names.zip([]) ]\n @attributes_cache = HashWithIndifferentAccess.new\n @previously_changed = HashWithIndifferentAccess.new\n @changed_attributes = HashWithIndifferentAccess.new\n super()\n end", "def preinitialize(attrs = nil)\n @attributes = {}\n end", "def initialize(initial_values = {})\n initial_values.each do |name, value|\n self.send(\"#{name}=\", value)\n end\n end", "def initialize(*args)\n super\n # hash = {}\n end", "def initialize(params)\n params.each do |key, value| \n instance_variable_set(\"@#{key}\", value) if Filing.instance_methods.include? key\n end\n end", "def initialize(attributes)\n attributes.each do |k,v|\n send(\"#{k}=\", v)\n end\n end", "def initialize(attributes)\n attributes.each do |k,v|\n send(\"#{k}=\", v)\n end\n end", "def initialize(attrs = {})\n attrs.each_pair do |attr, value|\n self.instance_variable_set(\"@#{attr}\", value)\n end\n end", "def initialize (hash)\n hash.each {|key, value|\n self.class.attr_accessor(key)\n self.send((\"#{key}=\"), value)\n }\n @@all << self\n end", "def initialize(attributes)\n attributes.each do |k,v|\n send(\"#{k}=\", v) if respond_to?(\"#{k}=\")\n end\n end", "def initialize(value_hash) # :title, :artist, :year, :genre\n me = self\n record = value_hash\n record.each_pair do |key, value|\n me.instance_variable_set(\"@#{key}\", value)\n me.class.send(\"attr_accessor\", key) \n end\n end", "def initialize(attrs)\n @attributes = {}\n attrs.each { |k, v| self[k] = v }\n end", "def initialize(object, vars = {})\n @object = object\n vars.each do |key, value|\n instance_variable_set \"@#{key}\", value\n end\n end", "def initialize(params)\n params.each do |key, value| \n instance_variable_set(\"@#{key}\", value) if Legislator.instance_methods.include? key\n end\n end", "def initialize(attrs = { })\n if attrs.present?\n attrs.each do |k, v|\n self.send(:\"#{k}=\", v)\n end\n end\n end", "def initialize attributes = {}\n @attributes = {}\n attributes.each { |attribute, value| set attribute, value }\n end", "def initialize(asteroid_hash)\n asteroid_hash.each {|key, value|\n self.class.attr_accessor(key)\n self.send(\"#{key}=\", value)\n }\n save\n end", "def initialize(attr_hash)\n if !attr_hash[:uuid]\n attr_hash[:uuid] = Util.generate_short_uid()\n end\n if !attr_hash[:start_time]\n attr_hash[:start_time] = TimeStamp.now.to_i\n end\n if !attr_hash[:machine_id]\n attr_hash[:machine_id] = Util.get_machine_id()\n end\n super(attr_hash)\n end", "def build_from_hash(hash)\n instance = self.new\n\n # Add the instance attributes dynamically from the hash. If the attribute\n # does not already exist, then don't re-add the attribute class and\n # variable, just set it with the value from the hash\n hash.keys.each do |key|\n class_eval { attr_accessor key } unless instance.methods.include?(key.to_sym)\n instance.instance_variable_set \"@#{key}\", hash[key]\n end\n\n instance\n end", "def initialize(attributes)\n attributes.each {|key, value| self.send((\"#{key}=\"), value)}\n end", "def initialize(attrs = {})\n return if attrs.blank?\n\n attrs = attrs.with_indifferent_access\n\n self.class.properties.each do |prop|\n write_attribute(prop.name, attrs[prop.name]) if attrs.key?(prop.name)\n end\n end", "def initialize() #method\n @variables = {}\n end", "def initialize(hash)\n hash.each do |k, v|\n self.send(\"#{k}=\", v) if self.respond_to?(\"#{k}=\")\n end\n @id = hash[\"id\"]\n end", "def initialize(objects = {}) #pass in a hash \n objects.each do |key,value|\n self.send(\"#{key}=\",value)\n end\n end", "def initialize(attributes)\n attributes.each do |key, value|\n eval(\"@#{key} = #{format_ruby(key, value)}\")\n end\n end", "def initialize(cont_info_hash)\n cont_info_hash.each do |key, value|\n next if key.eql?('Obj Reference')\n attribute = Utility.convert_to_underscore(key)\n string_to_evaluate = \"@#{attribute} = '#{value}'\"\n eval(string_to_evaluate)\n end\n end", "def initialize_attributes(attributes)\n @_properties = {}\n @_properties_before_type_cast={}\n self.attributes = attributes if attributes\n end", "def initialize(params)\n params.each do |key, value| \n instance_variable_set(\"@#{key}\", value) if Lobbyist.instance_methods.include? key\n end\n end", "def init_property_hash\n # make super()-safe so we can make liberal use of mixins\n end", "def initialize(params = {})\n params.each do |key, value|\n attribute?(key) && send(\"#{key}=\", value)\n end\n end", "def initialize(attributes = {})\n attributes.each do |key, value|\n send \"#{key}=\", value\n end\n end", "def initialize(**attributes)\n attributes.map { |(k, v)| public_send(\"#{k}=\", v) }\n end", "def initialize (attributes)\n attributes.each do |key, value|\n self.send((\"#{key}=\"), value)\n end\n end", "def initialize(attributes = {})\n attributes = HashWithIndifferentAccess.new(attributes)\n attributes.each_pair do |key, value|\n send(\"#{key}=\", value) if respond_to?(\"#{key}=\")\n end\n end", "def initialize( session_id=nil, initial_values={} )\n\t\t@hash = Hash.new {|h,k| h[k] = {} }\n\t\[email protected]!( initial_values )\n\n\t\t@namespace = nil\n\n\t\tsuper\n\tend", "def initialize(params = {})\n params.each_pair do |attr, value|\n send(\"#{attr}=\", value) if respond_to?(\"#{attr}=\", true)\n end unless params.blank?\n end", "def initialize(opts = {})\n [:klass, :id, :name, :accessor, :type, :object].each do |iv|\n instance_variable_set(\"@#{iv}\", opts[iv])\n end\n end", "def initialize(attributes = {})\n attributes.each_pair do |k, v|\n send(\"#{k}=\", v) if PARAMETER_MAPPING.key?(k)\n end\n end", "def initialize_attributes(attributes); end", "def initialize(attrs = nil)\n attrs ||= {}\n raise ArgumentError, \"Hash object is expected\" unless attrs.is_a?(Hash)\n\n @new_record = true\n @attributes ||= {}\n process_attributes(attrs)\n apply_defaults\n self.id = BSON::ObjectId.new unless self.id\n run_callbacks(:initialize) unless _initialize_callbacks.empty?\n end" ]
[ "0.7096979", "0.7075312", "0.69795835", "0.6931437", "0.68107194", "0.67872137", "0.6784826", "0.67669857", "0.6739661", "0.6735136", "0.67014766", "0.669997", "0.66953355", "0.6694159", "0.6694159", "0.6694159", "0.6694159", "0.66543823", "0.6610087", "0.66006804", "0.6599506", "0.6599139", "0.6593224", "0.6573405", "0.65443397", "0.65443397", "0.65443397", "0.65323025", "0.65088075", "0.65002143", "0.6495471", "0.64926636", "0.6484317", "0.6481752", "0.64768547", "0.6473706", "0.6452926", "0.6449752", "0.6448874", "0.6447957", "0.6447601", "0.6440658", "0.643619", "0.6433267", "0.6429235", "0.64229125", "0.64142674", "0.64048237", "0.63965887", "0.6395284", "0.63913256", "0.63849616", "0.63722", "0.6368592", "0.63682413", "0.6356787", "0.63558817", "0.6353419", "0.6330168", "0.63285846", "0.6325103", "0.6324421", "0.63226527", "0.63223106", "0.6315257", "0.63082606", "0.63044804", "0.63044804", "0.62990826", "0.62964433", "0.6295944", "0.6295307", "0.62874955", "0.62870693", "0.6286868", "0.6281316", "0.6278074", "0.62776005", "0.62649465", "0.62461334", "0.62423444", "0.6239368", "0.6236159", "0.62346786", "0.6234544", "0.62323546", "0.6229431", "0.6224661", "0.6224637", "0.62233764", "0.6220549", "0.6219207", "0.6218371", "0.6208994", "0.62063074", "0.6203585", "0.62019753", "0.6198274", "0.61966056", "0.6196119", "0.61958665" ]
0.0
-1
by Hany for pundit end by hany for Devise layout start
def layout_by_resource if devise_controller? "devise_layout" else "application" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n render layout: 'devise_layout' if current_user.present? && current_user.admin?\n end", "def layout_by_resource\n if devise_controller? && action_name == \"new\"\n \"sinmenu\"\n end\n end", "def layout_by_resource\n if user_signed_in?\n # \"admin\"\n #else\n \"application\"\n end\n end", "def layout_by_resource\n if devise_controller?\n 'integral/login'\n else\n 'integral/backend'\n end\n end", "def layout_by_resource\n if devise_controller?\n 'integral/login'\n else\n 'integral/backend'\n end\n end", "def devise_controller?; end", "def pundit_user\n \tcurrent_usuario\n end", "def layout\n \t#is_a?(RegistrationsController)\n if is_a?(Devise::SessionsController) || is_a?(Devise::ConfirmationsController) || is_a?(Devise::PasswordsController)\n \"login\"\n #elsif is_a?(AuthenticationsController)\n #\"first_time\"\n else\n \"application\"\n end\n end", "def layout_by_resource\n if devise_controller?\n \"integral/login\"\n else\n \"integral/backend\"\n end\n end", "def set_layout\n if devise_controller? #&& resource_class == Admin\n if params[:controller] == 'devise/registrations' and params[:action] == 'edit'\n \"application\"\n else\n \"devise_layout\"\n end\n end\n end", "def user_layout\n if user_signed_in?\n # If user is admin, set admin flag\n if current_user.admin?\n @admin = true\n end\n # set users fullname for display\n @user_name = current_user.name\n @user = current_user\n end\n \n end", "def take_password\n\t\tif is_admin?\n\t\t\trender :layout=>ADMIN_LAYOUT\n\t\telse\n\t\trender :layout=>EMPLOYEE_LAYOUT\n\t\tend\t\n\tend", "def layout_by_resource\n if devise_controller?\n \"new_login\"\n else\n \"application\"\n end\n end", "def pundit_user\n \t\tcurrent_admin # current_user to Pundit\n \tend", "def layout_by_resource\n if devise_controller? && !current_user.blank?\n \"admin\"\n else\n \"application\"\n end\n end", "def show\n if not ( paziente_signed_in? or administrator_signed_in?)\n redirect_to root_path and return\n end\n end", "def layout_by_resource\n if devise_controller?\n 'admin'\n else\n 'application'\n end\n end", "def layout_by_resource\n if devise_controllerf?\n 'devise'\n else\n 'application'\n end\n end", "def skip_pundit?\n devise_controller?\n end", "def layout_by_resource\n if devise_controller?\n 'devise'\n else\n 'application'\n end\n end", "def user_layout_setup\n @tab = :user\n end", "def set_layout\n devise_controller? ? 'admin' : 'application'\n end", "def layout_by_resource\n if devise_controller?\n \"admin\"\n else\n \"application\"\n end\n end", "def layout_by_resource\n if devise_controller?\n \"landing\"\n else\n \"application\"\n end\n end", "def layout_by_resource\n if devise_controller?\n \"login\"\n else\n 'application'\n end\n end", "def layout_by_resource\n if user_signed_in?\n # \"admin\"\n #else\n \"application\"\n end\n end", "def show\n # authorize Admin\n end", "def layout_by_resource\n if devise_controller?\n \"login\"\n else\n \"application\"\n end\n end", "def user_template\n super\n end", "def kopal_layout_before_page_header\n\n end", "def devise_modules_hook!; end", "def specify_layout\n if devise_controller?\n if !(current_user.nil?)\n \"application\"\n else\n \"sign_in\"\n end\n else\n \"application\"\n end\n end", "def layout_by_resource\n if user_signed_in?\n \"application\"\n else\n \"password\"\n end\n end", "def login\n layout 'sign_in'\n end", "def layout_by_resource\n if devise_controller? && resource_name == :client\n 'public'\n else\n 'lims'\n end\n end", "def after_sign_in_path_for(resource)\n #if resource.is_a?(User)\n #if User.count == 1\n # resource.add_role 'admin'\n #end\n #resource\n #end\n root_path\n end", "def home\n if user_signed_in?\n current_user.update_attribute(:login_status, true) if current_user # update login status for logged in user\n if !current_user.is_super_admin? && current_user.sign_in_count == 1 && current_user.created_by != 0 #User records which are created by super admin or dept admin has to change the password while they are logged in first time\n redirect_to :controller => \"registrations\", :action => \"privacy_setting\"\n else\n redirect_to :controller => \"dashboard\", :action => \"index\"\n end\n else\n redirect_to new_user_session_path\n end\n end", "def layout\n # only turn it off for login pages:\n # is_a?(Devise::SessionsController) ? \"sign_in_up\" : \"application\"\n # or turn layout off for every devise controller:\n #devise_controller? && \"application\"\n @categories ||= Category.ordered.with_memories \n\n if devise_controller? && params[:controller] == \"sessions\" || params[:controller] == \"registrations\" && params[:action] == \"new\" || \n params[:controller] == \"registrations\" && params[:action] == \"create\" || params[:controller] == \"passwords\" && params[:action] == \"new\" ||\n params[:controller] == \"confirmations\" && params[:action] == \"show\" \n \"sign_in_up\"\n else\n \"application\"\n end\n \n \n end", "def devise_mappings; end", "def admin_view_hours_prep\n return if current_user.roles.include?(Role.admin_role)\n\n redirect_to root_path\n end", "def layout_by_resource\n if user_signed_in?\n \"application\"\n else\n \"unauthorized\"\n end\n end", "def layout_for\n if devise_controller?\n 'full_page'\n else\n 'application'\n end\n end", "def show\n render layout: \"sin_menu\" unless user_signed_in? \n end", "def authorization; end", "def kopal_layout_after_page_header\n\n end", "def kopal_layout_before_page_front\n\n end", "def after_sign_up_path_for(resource)\n # binding.irb\n super\n # super(resource) do\n edit_user_registration_path\n # end\n # binding.irb\n # if resource[:role] == 'guest'\n # new_guest_path\n # else\n # new_host_path\n # end\n end", "def after_sign_in_path_for(resource)\n \t\t case resource\n \t\t \twhen Admin\n \t\t \t\t flash[:notice] = \"サインインしました\"\n \t\t\tadmins_end_users_path\n \t\t\twhen EndUser\n \t\t\t\t flash[:notice] = \"サインインしました\"\n \t\t\tproducts_path\n \t\t end\n\tend", "def after_sign_in_path_for(resource)\n #resource refers to user being signed in\n if resource.role == \"company\" then #if the user is company user\n #if it is first time after sign up go to new page of company else go to show page\n if resource.company.nil? then \n new_user_company_path(resource)\n \n else\n ([resource,resource.company])\n \n end\n elsif resource.role== \"applicant\" then # if user is applicant user\n #if it is first time after sign up go to new page of company else go to show page\n if resource.applicant.nil? then\n new_user_applicant_path(resource)\n else\n ([resource,resource.applicant])\n end \n else#if admin go to admin show path\n user_admin_path(resource,resource.admin)\n end\n end", "def devise_scope(scope); end", "def layout_by_resource\n if devise_controller? # Devise helper that returns true if the Controller it's a Devise\n \"backoffice_devise\"\n else\n \"application\"\n end\n end", "def kopal_layout_before_page_sidebar\n\n end", "def kopal_layout_before_page_meta\n\n end", "def skip_pundit?\n devise_controller? || params[:controller] =~ /(^(rails_)?admin)|(^pages$)/\n end", "def admin_logic\n end", "def kopal_layout_after_page_front\n\n end", "def pundit_user\n current_identity\n end", "def pundit_user\n # if action_name == \"new\"\n # current_user\n # else\n current_user || current_company\n # end\n end", "def set_layout\n\t \treturn \"landing\" if action_name == \"unregistered\"\n\t \tsuper\n\t end", "def index\n #@event_users = EventUser.where(event: @event)\n #@event_users = EventUserPolicy::Scope.new(current_user, [:admin, EventUser]).resolve\n @event_users = policy_scope(EventUser.where(event: @event))\n authorize @event_users\n\n add_breadcrumb \"#{@event.code}\", :admin_event_path\n add_breadcrumb \"Usuários\", :admin_event_users_path\n end", "def show\n if user_signed_in?\n else\n redirect_to root_path\n end\n end", "def kopal_layout_before_page_footer\n\n end", "def admin_layout \n @admin_layout\n end", "def layout_by_resource\n devise_controller? ? 'devise' : 'application'\n end", "def layout_by_resource\n devise_controller? ? 'devise' : 'application'\n end", "def layout_chooser(current_user)\n unless current_user.nil?\n if current_user.role==\"applicant\" then\n @applicant=current_user.applicant\n layout=\"applicants\"\n elsif current_user.role==\"company\" then\n @company=current_user.company\n layout=\"companies\"\n else\n layout=\"admin\" \n end\n \n else\n layout=\"welcome\"\n end\n layout\n end", "def show\n\t\tauthorize! :show, AsignacionFuncion\n end", "def after_sign_up_path_for(resource)\n #super(resource)\n\n #'/pages/monprofil'\n\n if(session[:page_id].present?)\n cours_show_path(session[:page_id])\n else\n '/users/sign_up' \n end\n end", "def after_sign_up_path_for(resource)\n super(resource)\n end", "def after_sign_up_path_for(resource)\n super(resource)\n end", "def after_sign_up_path_for(resource)\n super(resource)\n end", "def decideur_show\n @user = Admin.where(role_id: 2).order(name: :asc)\n add_breadcrumb 'utilisateur', parametre_admin_path\n add_breadcrumb 'decideurs', parametre_decideurs_path\n render layout: 'fylo'\n end", "def show\n authorize Section\n end", "def show\n if !current_user.isAdmin? and current_user.id != @user.id\n redirect_to user_path(current_user.id)\n end\n end", "def kopal_layout_after_page_sidebar\n\n end", "def serviceShow\n render layout: 'template/login2'\n end", "def choose_layout\n\t\tuser_profile_signed_in? ? (current_user_profile.first_time? ? 'first_time' : 'authed') : 'no_auth'\n\tend", "def layout_by_resource\n if devise_controller? && resource_class == Pilot\n \"pilot_devise\"\n elsif devise_controller? && resource_class == Operator\n \"operator_devise\"\n else\n \"application\"\n end\nend", "def after_sign_in_path_for(resoruce)\r\n \r\n if resource.is_a?(User)\r\n if User.count == 1\r\n resource.add_role 'admin'\r\n end\r\n resource\r\n end\r\n root_path\r\n end", "def admin_layout\n self.class.layout \"admin\" if current_user && admin?(current_user)\n end", "def pundit_user\n current_admin\n end", "def set_parent_view\n\n if current_user.role_id == 1\n \n else \n redirect_to unauthorised_path()\n end\n end", "def show\n authorize! :ver, @usuario_prestamo\n end", "def new\n @partner_sign_in = true\n render layout: 'sign_pages'\n end", "def admin_show\n @user = Admin.where(role_id: 1).order(name: :asc)\n add_breadcrumb 'utilisateurs', :parametre_admin_path\n add_breadcrumb 'administrateurs & décideurs', :parametre_admins_admin_show_path\n #render layout: 'fylo'\n render layout: 'views/index'\n end", "def show\n authorize! :create, Administrator\n end", "def authorize\n if current_user.nil?\n redirect_to login_url, alert: \"Please Log in or Sign Up to comment!\"\n \tend\n end", "def authorize_admin\n redirect_to root_path unless current.user.immortal?\n end", "def show\n\t\tauthorize! :show, EstadoPresupuesto\n end", "def show\n authorize @development\n end", "def authenticate_admin_hr\n unless current_user && (get_loging_permission !=1 || get_loging_permission !=2)\n redirect_to sign_in_path\n return \n end\n end", "def show\n set_administrator\n end", "def index\n @background_images = BackgroundImage.all\n render layout: 'devise_layout' \n end", "def pundit_user\n current_staff\n end", "def show\n admin_only do\n end\n end", "def display_resource(admin)\r\n admin.login\r\n end", "def authorize\n if current_user.nil? || current_user.tipo_usuario == \"Empleado\"\n redirect_to login_url, notice: \"No esta autorizado para ver esto. Por favor ingrese al sistema o reingrese como administrador.\"\n end\n end", "def layout_by_resource\n\t\tif devise_controller?\n\t\t\t\"dashboard\"\n\t\telse\n\t\t\t\"application\"\n\t\tend\n\tend", "def show\n authorize! :show, HoursRegistration\n end", "def after_sign_up_path_for(resource)\n super\n end" ]
[ "0.6884638", "0.65894437", "0.6556364", "0.64938176", "0.64938176", "0.64740324", "0.6425371", "0.64141256", "0.63951206", "0.6379952", "0.62374645", "0.62321883", "0.6229712", "0.62176514", "0.6207268", "0.6200789", "0.61983806", "0.61698556", "0.61664987", "0.6147479", "0.6144529", "0.6130176", "0.6124902", "0.6121982", "0.6101802", "0.60923254", "0.6070857", "0.6069938", "0.60423654", "0.60068804", "0.6006128", "0.60011756", "0.5997567", "0.5995478", "0.5989657", "0.59889716", "0.59868306", "0.59488446", "0.5932858", "0.5928594", "0.59178877", "0.5909901", "0.5892809", "0.58910775", "0.5883381", "0.58829784", "0.58507586", "0.584984", "0.58488977", "0.58456427", "0.58387357", "0.581945", "0.5814586", "0.5805269", "0.5797014", "0.5779697", "0.57787526", "0.5776995", "0.57745105", "0.5771366", "0.57601756", "0.5752813", "0.5742316", "0.5725316", "0.5725316", "0.57250965", "0.57188857", "0.57114685", "0.57055223", "0.57055223", "0.5705434", "0.5699296", "0.56979525", "0.5695109", "0.56869984", "0.56844825", "0.5681731", "0.56812215", "0.5675858", "0.567407", "0.5669804", "0.5665777", "0.56629896", "0.5659313", "0.56519294", "0.5650734", "0.5644411", "0.5642651", "0.56275094", "0.56247944", "0.5623761", "0.5619811", "0.5612992", "0.5612679", "0.5610642", "0.5607429", "0.56074274", "0.5607049", "0.5606913", "0.56022733" ]
0.57981974
54
GET /periods/1 GET /periods/1.xml
def show @period = Period.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @period } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @period = Period.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @period.to_xml }\n end\n end", "def index\n @authorization_periods = AuthorizationPeriod.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @authorization_periods }\n end\n end", "def index\n @periods = Period.all\n end", "def get_periods(id, starts: nil, ends: nil, threshold:, operation:)\n params = {:start => starts, :end => ends, :threshold => threshold, :op => operation}\n params.delete_if { |k, v| v.nil? }\n @client.http_get(\"/#{@resource}/#{id}/periods?\"+URI.encode_www_form(params))\n end", "def period(period, options = {})\n get(\"periods/#{period}\", options).pop\n end", "def show\n @period = Period.find(params[:id])\n\n render json: @period\n end", "def show\n @authorization_period = AuthorizationPeriod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @authorization_period }\n end\n end", "def show\n @periodista = Periodista.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @periodista }\n end\n end", "def show\n @pay_period = PayPeriod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @pay_period }\n end\n end", "def index\n @api_v1_frequency_periods = Api::V1::FrequencyPeriod.all\n end", "def new\n @period = Period.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @period }\n end\n end", "def index\n @periods = @organism.periods.order(:close_date)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @periods } \n end\n end", "def index\n @time_periods = TimePeriod.all\n end", "def show\n @title = \"Show Resources Periods\"\n @resource_period = ResourcePeriod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @resource_period }\n end\n end", "def show\n @workperiod = Workperiod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @workperiod }\n end\n end", "def show\n @tb_period = TbPeriod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tb_period }\n end\n end", "def get_periods\n @periods = current_user.periods.all.order(created_at: :desc)\n render json: @periods\n end", "def show\n period = current_user.school.periods.find(params[:id])\n render json: period\n end", "def index\r\n @product_periods = ProductPeriod.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @product_periods }\r\n end\r\n end", "def index\n periods = current_user.school.periods.all\n\n render json: periods\n end", "def show\n @period_list = [['7 days',7],['14 days',14],['31 days',30],['3 months',90],['6 months',180]]\n\n # get description data\n @transaction_group = TransactionGroup.find(params[:id])\n @transaction_group.transaction_group_items.all\n \n # get the period, default is 7 days\n @period_curr = params[:period].to_i\n @period_curr = 180 if @period_curr.nil? || @period_curr == 0\n\n mgr = GraphTransactionGroup.new\n mgr.getData(@transaction_group, @period_curr)\n @google_url = mgr.write\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @transaction_group }\n end\n end", "def periods\n @periods ||= @data['properties']['periods'].map { |row|\n ::WeatherSage::Weather::Period.new(@ctx, row)\n }\n end", "def show\n @sleep = Sleep.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sleep }\n end\n end", "def index\n @pay_periods = PayPeriod.all\n end", "def index\n @pay_periods = PayPeriod.all\n end", "def index\n @receipt_periods = ReceiptPeriod.all\n end", "def show\n @sleep = Sleep.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sleep }\n end\n end", "def index\n @registration_periods = RegistrationPeriod.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @registration_periods }\n end\n end", "def destroy\n @period = Period.find(params[:id])\n @period.destroy\n\n respond_to do |format|\n format.html { redirect_to(periods_url) }\n format.xml { head :ok }\n end\n end", "def api_url(period)\n %r{https://api.meetup.com/2/events.*status=#{period}}\nend", "def new\n @period = @cursus.periods.build\n\n respond_to do |format|\n format.html { render :layout => false }\n format.xml { render :xml => @period }\n end\n end", "def periods( num )\n @ma.fetch_periods( num )\n end", "def timeline\n @bookings = Booking.find_waiting_pickup\n respond_to do |format|\n format.xml\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 show\n @periodismo = Periodismo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @periodismo }\n end\n end", "def index\n @periods = Period.find(:all, :include => { :talks => :users })\n @periods_by_time_and_scene = Hash.new\n for p in @periods\n @periods_by_time_and_scene[p.time_id] ||= Hash.new\n @periods_by_time_and_scene[p.time_id][p.scene_id] = p \n end\n\n @time_ids = @periods.collect { |p| p.time_id }.sort.uniq\n \n @edit = params[:edit] && admin?\n @all_talks = Talk.all_pending_and_approved if @edit\n @all_talks.sort!{|t1,t2|t1.id <=> t2.id}\n\n respond_to do |format|\n format.html {render :layout => 'plain' }# index.html.erb\n format.xml { render :xml => @periods }\n end\n end", "def get(days,start_cep,end_cep)\n self.class.get(\"/api/v1/quote/available_scheduling_dates/#{days}/#{start_cep}/#{end_cep}\")\n end", "def get_listings_xml(url)\n @client.get_content(url)\n end", "def schedule_periods\n\t\t@periods = Period.all\n\tend", "def index\n @commission_days = CommissionDay.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @commission_days }\n end\n end", "def show\r\n @product_period = ProductPeriod.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @product_period }\r\n end\r\n end", "def show\n @ponto = Ponto.find(params[:id])\n @range_dias = @[email protected]_end_of_month\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ponto }\n end\n end", "def show\n @sleep_log = SleepLog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @sleep_log }\n end\n end", "def index\n @discipline = Discipline[params[\"discipline\"]]\n @discipline_names = Discipline.names\n @calculations = Calculations::V3::Calculation.where(year: @year).includes(:event)\n\n respond_to do |format|\n format.html\n format.xml do\n fresh_when RacingAssociation.current, public: true\n all_events\n end\n end\n end", "def index\n @vacation_periods = VacationPeriod.all\n end", "def destroy\n @period = Period.find(params[:id])\n @period.destroy\n\n respond_to do |format|\n format.html { redirect_to periods_url }\n format.xml { head :ok }\n end\n end", "def period\n return @period\n end", "def index\n @countdowns = Countdown.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @countdowns }\n end\n end", "def changes\n respond_to do |format|\n format.xml do\n raise ::AbstractController::ActionNotFound if params[:interval].blank?\n @changes = Node.all_including_deleted(:conditions => ['updated_at > ?', Time.now - params[:interval].to_i], :order => 'updated_at DESC')\n end\n format.any(:rss, :atom) do\n @nodes = @node.last_changes(:all, { :limit => 25 })\n render :template => '/shared/changes', :layout => false\n end\n end\n end", "def show\n @ayudastemporal = Ayudastemporal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ayudastemporal }\n end\n end", "def show\n @holiday_song_period = HolidaySongPeriod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @holiday_song_period }\n end\n end", "def show\n @chart = Chart.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @chart }\n end\n end", "def show\n @chart = Chart.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @chart }\n end\n end", "def index\n @periodistas = Periodista.listado(params[:page],params[:buscar], params[:departamento],params[:tipo_medio_id] , params[:institucion_periodistica_id])\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @periodistas }\n format.print{ @periodistas = Periodista.find(:all, :order => \"idDepartamento, nombre\"); render :layout => 'imprimir' }\n end\n end", "def set_period\n @period = Period.find(params[:id])\n end", "def set_period\n @period = Period.find(params[:id])\n end", "def set_period\n @period = Period.find(params[:id])\n end", "def show\n @deadline = Deadline.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @deadline }\n end\n end", "def retrieve_date_range\n\t\t@free_period = false\n\t\t@from, @to = nil, nil\n\t\tperiod_type = params[:period_type]\n\t\tperiod = params[:period]\n\t\tfromdate = params[:from]\n\t\ttodate = params[:to]\n\n\t\tif (period_type == '1' || (period_type.nil? && !period.nil?)) \n\t\t case period.to_s\n\t\t when 'current_month'\n\t\t\t@from = Date.civil(Date.today.year, Date.today.month, 1)\n\t\t\t@to = (@from >> 1) - 1\n\t\t when 'last_month'\n\t\t\t@from = Date.civil(Date.today.year, Date.today.month, 1) << 1\n\t\t\t@to = (@from >> 1) - 1\n\t\t end\n\t\telsif period_type == '2' || (period_type.nil? && (!fromdate.nil? || !todate.nil?))\n\t\t begin; @from = Date.civil((fromdate.to_s.to_date).year,(fromdate.to_s.to_date).month, 1) unless fromdate.blank?; rescue; end\n\t\t begin; @to = (@from >> 1) - 1 unless @from.blank?; rescue; end\n\t\t if @from.blank?\n\t\t\t@from = Date.civil(Date.today.year, Date.today.month, 1)\n\t\t\t@to = (@from >> 1) - 1\n\t\t end\n\t\t @free_period = true\n\t\telse\n\t\t # default\n\t\t # 'current_month'\t\t\n\t\t\t@from = Date.civil(Date.today.year, Date.today.month, 1)\n\t\t\t@to = (@from >> 1) - 1\n\t\tend \n\t\t\n\t\t@from, @to = @to, @from if @from && @to && @from > @to\n\n\t end", "def get_inactive_periods\n @periods = current_user.periods.where(is_active: false).order(created_at: :desc)\n render json: @periods\n end", "def show\n respond_with DisDoseperiod.find(params[:id])\n end", "def index\n @work_periods = WorkPeriod.all\n end", "def read(id=nil)\r\n request = Net::HTTP.new(@uri.host, @uri.port)\r\n if id.nil?\r\n response = request.get(\"#{@uri.path}.xml\") \r\n else\r\n response = request.get(\"#{@uri.path}/#{id}.xml\") \r\n end\r\n response.body\r\n end", "def show\n @interval = Interval.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @interval }\n end\n end", "def new\n @authorization_period = AuthorizationPeriod.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @authorization_period }\n end\n end", "def show\n @timing = Timing.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @timing }\n end\n end", "def intervals\n rest.get instrument_path('activeIntervals')\n end", "def show\n @daily_grr = DailyGrr.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @daily_grr }\n end\n end", "def get(options = {})\n @response_xml = options[:cache_file] ? File.read(options[:cache_file]) : http_get(options)\n response = Response.parse(response_xml, options) do | inner_response, elements |\n parse_reports(inner_response, elements)\n end\n response.response_items.first # there is is only one\n end", "def retrieve_date_range\n @free_period = false\n @from, @to = nil, nil\n\n if params[:period_type] == '1' || (params[:period_type].nil? && !params[:period].nil?)\n case params[:period].to_s\n when 'today'\n @from = @to = Date.today\n when 'yesterday'\n @from = @to = Date.today - 1\n when 'current_week'\n @from = Date.today - (Date.today.cwday - 1)%7\n @to = @from + 6\n when 'last_week'\n @from = Date.today - 7 - (Date.today.cwday - 1)%7\n @to = @from + 6\n when '7_days'\n @from = Date.today - 7\n @to = Date.today\n when 'current_month'\n @from = Date.civil(Date.today.year, Date.today.month, 1)\n @to = (@from >> 1) - 1\n when 'last_month'\n @from = Date.civil(Date.today.year, Date.today.month, 1) << 1\n @to = (@from >> 1) - 1\n when '30_days'\n @from = Date.today - 30\n @to = Date.today\n when 'current_year'\n @from = Date.civil(Date.today.year, 1, 1)\n @to = Date.civil(Date.today.year, 12, 31)\n end\n elsif params[:period_type] == '2' || (params[:period_type].nil? && (!params[:from].nil? || !params[:to].nil?))\n begin; @from = params[:from].to_s.to_date unless params[:from].blank?; rescue; end\n begin; @to = params[:to].to_s.to_date unless params[:to].blank?; rescue; end\n @free_period = true\n else\n # default\n end\n \n @from, @to = @to, @from if @from && @to && @from > @to\n\n end", "def index\n @teaching_periods = TeachingPeriod.all\n end", "def get_response( date )\r\n date_range = [parse_date( date ), parse_date( date.next_month )]\r\n puts \"Getting records modified from #{date_range.join(' to ')} ...\"\r\n \r\n response = ERP::ERPAgent.post(\r\n :url => AppConfig.SOAP_CU_SERV,\r\n :body => ERP::Customer.generate_xml( \"find_entity_key_list_customers\", :operator => \"Range\", :value1 => date_range.first, :value2 => date_range.last )\r\n )\r\nend", "def update\n @period = Period.find(params[:id])\n\n respond_to do |format|\n if @period.update_attributes(params[:period])\n flash[:notice] = 'Period was successfully updated.'\n format.html { redirect_to(@period) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @period.errors, :status => :unprocessable_entity }\n end\n end\n end", "def xml(id)\n http.get(\"/nfse/#{id}/xml\") do |response|\n response.headers.fetch(\"Location\") { \"\" }\n end\n end", "def new\n @periodista = Periodista.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @periodista }\n end\n end", "def get_active_period\n # puts 'ejecutando get_active_period'\n @active_period = current_user.periods.active\n # puts 'get_active_period ejecutado'\n end", "def index\n @savings = @advance.savings\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @savings }\n end\n end", "def index\n @breadcrumbs = [[t(:wage_periods), wage_periods_path],\n [@wage_period.name, wage_period_path(@wage_period.id)],\n [t(:wages)]]\n @wage_periods = current_organization.wage_periods.order('id')\n if !params[:wage_period_id] && @wage_periods.count > 0\n params[:wage_period_id] = @wage_periods.first.id\n end\n @wages = current_organization.wages.where('wage_period_id=?', params[:wage_period_id])\n @wages = @wages.page(params[:page]).decorate\n end", "def index\n @scholarship_periods = ScholarshipPeriod.all\n end", "def index\n @child_development_periods = ChildDevelopmentPeriod.all\n end", "def create\n @period = Period.new(params[:period])\n\n respond_to do |format|\n if @period.save\n flash[:notice] = _('%s was successfully created.', Period.human_name)\n format.html { redirect_to period_url(@period) }\n format.xml { head :created, :location => period_url(@period) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @period.errors.to_xml }\n end\n end\n end", "def new\n @pay_period = PayPeriod.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pay_period }\n end\n end", "def create\n @period = Period.new(params[:period])\n\n respond_to do |format|\n if @period.save\n flash[:notice] = 'Period was successfully created.'\n format.html { redirect_to(@period) }\n format.xml { render :xml => @period, :status => :created, :location => @period }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @period.errors, :status => :unprocessable_entity }\n end\n end\n end", "def show\n @rate_change_history = RateChangeHistory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @rate_change_history }\n end\n end", "def visits(period)\n stat = self.stats.where(:period => period).first\n return stat.visits\n end", "def returns(periodKey)\n self.class.get(url(\"liabilities\"), headers: @headers, query: @query )\n end", "def rss\n @event = Event.find_by_key(params['id'])\n @histories = @event.histories(:order => 'created_at DESC')\n render :layout => false\n response.headers[\"Content-Type\"] = \"application/xml; charset=utf-8\"\n end", "def index\n @dis_doseperiods = DisDoseperiod.all\n end", "def show\r\n Connection.switch_data(params[:connection], \"daily\")\r\n @connections = Connection.find(params[:id])\r\n respond_to do |format|\r\n format.html #show.html.erb\r\n format.xml { render :xml => @connections.to_xml(:root => 'records', :children => 'record', :dasherize => false) }\r\n end\r\n end", "def show\n @stat = Stat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @stat }\n end\n end", "def show\n @stat = Stat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @stat }\n end\n end", "def show\n @tso = Tso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tso.to_xml(:except => [ :created_at, :updated_at ]) }\n end\n end", "def show\n @savings = Savings.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @savings }\n end\n end", "def show\n Interval.find(params[:id])\n end", "def take_two\n response.headers[\"Content-Type\"] = 'text/xml'\n\n take_two = Program.find_by_slug!('take-two')\n @segments = take_two.episodes.published.first.segments.first(2)\n render template: 'feeds/take_two.xml.builder', format: :xml\n end", "def retrieve_date_range\n\t\t@free_period = false\n\t\t@from, @to = nil, nil\n\t\tperiod_type = session[controller_name][:period_type]\n\t\tperiod = session[controller_name][:period]\n\t\tfromdate = session[controller_name][:from]\n\t\ttodate = session[controller_name][:to]\n\t\t\n\t\tif (period_type == '1' || (period_type.nil? && !period.nil?)) \n\t\t case period.to_s\n\t\t\t when 'today'\n\t\t\t\t@from = @to = Date.today\n\t\t\t when 'yesterday'\n\t\t\t\t@from = @to = Date.today - 1\n\t\t\t when 'current_week'\n\t\t\t\t@from = getStartDay(Date.today - (Date.today.cwday - 1)%7)\n\t\t\t\t@to = @from + 6\n\t\t\t when 'last_week'\n\t\t\t\t@from =getStartDay(Date.today - 7 - (Date.today.cwday - 1)%7)\n\t\t\t\t@to = @from + 6\n\t\t\t when '7_days'\n\t\t\t\t@from = Date.today - 7\n\t\t\t\t@to = Date.today\n\t\t\t when 'current_month'\n\t\t\t\t@from = Date.civil(Date.today.year, Date.today.month, 1)\n\t\t\t\t@to = (@from >> 1) - 1\n\t\t\t when 'last_month'\n\t\t\t\t@from = Date.civil(Date.today.year, Date.today.month, 1) << 1\n\t\t\t\t@to = (@from >> 1) - 1\n\t\t\t when '30_days'\n\t\t\t\t@from = Date.today - 30\n\t\t\t\t@to = Date.today\n\t\t\t when 'current_year'\n\t\t\t\t@from = Date.civil(Date.today.year, 1, 1)\n\t\t\t\t@to = Date.civil(Date.today.year, 12, 31)\n\t end\n\t\telsif period_type == '2' || (period_type.nil? && (!fromdate.nil? || !todate.nil?))\n\t\t begin; @from = fromdate.to_s.to_date unless fromdate.blank?; rescue; end\n\t\t begin; @to = todate.to_s.to_date unless todate.blank?; rescue; end\n\t\t @free_period = true\n\t\telse\n\t\t # default\n\t\t # 'current_month'\t\t\n\t\t\t@from = Date.civil(Date.today.year, Date.today.month, 1)\n\t\t\t@to = (@from >> 1) - 1\n\t end \n\t\t\n\t\t@from, @to = @to, @from if @from && @to && @from > @to\n\n\tend", "def retrieve_date_range\n\t\t@free_period = false\n\t\t@from, @to = nil, nil\n\t\tperiod_type = session[controller_name][:period_type]\n\t\tperiod = session[controller_name][:period]\n\t\tfromdate = session[controller_name][:from]\n\t\ttodate = session[controller_name][:to]\n\t\t\n\t\tif (period_type == '1' || (period_type.nil? && !period.nil?)) \n\t\t case period.to_s\n\t\t\t when 'today'\n\t\t\t\t@from = @to = Date.today\n\t\t\t when 'yesterday'\n\t\t\t\t@from = @to = Date.today - 1\n\t\t\t when 'current_week'\n\t\t\t\t@from = getStartDay(Date.today - (Date.today.cwday - 1)%7)\n\t\t\t\t@to = @from + 6\n\t\t\t when 'last_week'\n\t\t\t\t@from =getStartDay(Date.today - 7 - (Date.today.cwday - 1)%7)\n\t\t\t\t@to = @from + 6\n\t\t\t when '7_days'\n\t\t\t\t@from = Date.today - 7\n\t\t\t\t@to = Date.today\n\t\t\t when 'current_month'\n\t\t\t\t@from = Date.civil(Date.today.year, Date.today.month, 1)\n\t\t\t\t@to = (@from >> 1) - 1\n\t\t\t when 'last_month'\n\t\t\t\t@from = Date.civil(Date.today.year, Date.today.month, 1) << 1\n\t\t\t\t@to = (@from >> 1) - 1\n\t\t\t when '30_days'\n\t\t\t\t@from = Date.today - 30\n\t\t\t\t@to = Date.today\n\t\t\t when 'current_year'\n\t\t\t\t@from = Date.civil(Date.today.year, 1, 1)\n\t\t\t\t@to = Date.civil(Date.today.year, 12, 31)\n\t end\n\t\telsif period_type == '2' || (period_type.nil? && (!fromdate.nil? || !todate.nil?))\n\t\t begin; @from = fromdate.to_s.to_date unless fromdate.blank?; rescue; end\n\t\t begin; @to = todate.to_s.to_date unless todate.blank?; rescue; end\n\t\t @free_period = true\n\t\telse\n\t\t # default\n\t\t # 'current_month'\t\t\n\t\t\t@from = Date.civil(Date.today.year, Date.today.month, 1)\n\t\t\t@to = (@from >> 1) - 1\n\t end \n\t\t\n\t\t@from, @to = @to, @from if @from && @to && @from > @to\n\n\tend", "def show\n\t\t@directory = Directory.find(params[:id])\n\t\t@days = params[:days].blank? ? 31 : params[:days].to_i\t\t\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.xml\t{ render :xml => @directory }\n\t\tend\n\tend", "def period\n\t\t\t\t5\n\t\t\tend" ]
[ "0.697887", "0.65344566", "0.6490071", "0.64261526", "0.6294119", "0.6250508", "0.6213859", "0.60953885", "0.60344595", "0.6013452", "0.59467125", "0.59323853", "0.590008", "0.588166", "0.58558226", "0.57800007", "0.5765523", "0.57490605", "0.5737154", "0.57222354", "0.5683859", "0.55700654", "0.5541241", "0.55249494", "0.55249494", "0.5524339", "0.5495365", "0.5489656", "0.5483582", "0.5481152", "0.54752785", "0.54709727", "0.5459912", "0.54388976", "0.54315513", "0.54200447", "0.5419219", "0.541196", "0.54091865", "0.5397484", "0.5395695", "0.5388603", "0.53740436", "0.53621644", "0.536134", "0.5359168", "0.5342715", "0.53318447", "0.53086746", "0.5299829", "0.5299293", "0.5297791", "0.5297791", "0.5293511", "0.52932626", "0.52932626", "0.52932626", "0.5289229", "0.52836937", "0.5281289", "0.5274622", "0.52699", "0.5269007", "0.5263573", "0.5253507", "0.5244699", "0.52431136", "0.52390146", "0.52277344", "0.52180386", "0.52151644", "0.5213673", "0.52130514", "0.52075624", "0.52060735", "0.520597", "0.5200599", "0.51949054", "0.5192077", "0.519198", "0.5189431", "0.5188546", "0.5180977", "0.51707804", "0.5170126", "0.51659673", "0.515998", "0.5157426", "0.5155593", "0.5153709", "0.5153709", "0.51530516", "0.51501226", "0.51401985", "0.51383835", "0.5135969", "0.5135969", "0.5135924", "0.513583" ]
0.697724
2
GET /periods/new GET /periods/new.xml
def new @period = @cursus.periods.build respond_to do |format| format.html { render :layout => false } format.xml { render :xml => @period } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @period = Period.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @period }\n end\n end", "def new\n @title = \"New Resources Periods\"\n @resource_period = ResourcePeriod.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @resource_period }\n end\n end", "def new\n @periodista = Periodista.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @periodista }\n end\n end", "def new\n @periodos = Periodo.all.collect{|p|[\"#{t p.inicio.strftime(\"%B\")} - #{t p.fim.strftime(\"%B\")}\",p.id]}\n @requisicao = Requisicao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @requisicao }\n end\n end", "def new\n @authorization_period = AuthorizationPeriod.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @authorization_period }\n end\n end", "def new\n @pay_period = PayPeriod.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pay_period }\n end\n end", "def new\n @workperiod = Workperiod.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @workperiod }\n end\n end", "def create\n @period = Period.new(params[:period])\n\n respond_to do |format|\n if @period.save\n flash[:notice] = _('%s was successfully created.', Period.human_name)\n format.html { redirect_to period_url(@period) }\n format.xml { head :created, :location => period_url(@period) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @period.errors.to_xml }\n end\n end\n end", "def create\n @period = Period.new(params[:period])\n\n respond_to do |format|\n if @period.save\n flash[:notice] = 'Period was successfully created.'\n format.html { redirect_to(@period) }\n format.xml { render :xml => @period, :status => :created, :location => @period }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @period.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @workday = Workday.new\n 2.times do\n @workday.periods.build\n end\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @workday }\n end\n end", "def new\n @tb_period = TbPeriod.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tb_period }\n end\n end", "def new\n @savings = Savings.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @savings }\n end\n end", "def new\n @sleep_log = SleepLog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sleep_log }\n end\n end", "def new\n @periodismo = Periodismo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @periodismo }\n end\n end", "def new\n @delay = Delay.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @delay }\n end\n end", "def new\n respond_to do |format|\n format.xml { render :xml => @schedule }\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 respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end", "def new\n @interval = Interval.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interval }\n end\n end", "def show\n @period = Period.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @period }\n end\n end", "def show\n @period = Period.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @period }\n end\n end", "def new\n @p_stat = PStat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @p_stat }\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 show\n @period = Period.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @period.to_xml }\n end\n end", "def new\n @polling_station = PollingStation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @polling_station }\n end\n end", "def new\n @tstat = Tstat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tstat }\n end\n end", "def new\n @timeline = Timeline.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @timeline }\n end\n end", "def new\n @timing = Timing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @timing }\n end\n end", "def new\n @lease = Lease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lease }\n end\n end", "def new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @registration_period }\n end\n end", "def new\n @status = Status.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @status }\n end\n end", "def new\n @status = Status.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @status }\n end\n end", "def new\n @status = Status.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @status }\n end\n end", "def new\n @commission_day = CommissionDay.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @commission_day }\n end\n end", "def create\n @period = Period.new(params[:period])\n\n if @period.save\n render json: @period, status: :created, location: @period\n else\n render json: @period.errors, status: :unprocessable_entity\n end\n end", "def new\n @deadline = Deadline.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @deadline }\n end\n end", "def new\n @modulo = Modulo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @modulo }\n end\n end", "def new\n @series = Series.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @series }\n end\n end", "def new\n @cohort = Cohort.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @cohort }\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 @sleep = Sleep.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @sleep }\n end\n end", "def new\n @schedule = Schedule.new\n @apps = App.find(:all)\n @tags = Contact.get_tags\n\n respond_to do |format|\n format.html # new.haml\n format.xml { render :xml => @schedule }\n end\n end", "def new\n @countdown = Countdown.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @countdown }\n end\n end", "def new\n @ptschedule = Ptschedule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ptschedule }\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 @spend = Spend.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @spend }\n end\n end", "def new_rest\n @instrument_version = InstrumentVersion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instrument_version }\n end\n end", "def new\n @prd_etc = PrdEtc.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @prd_etc }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @chronopay_link }\n end\n end", "def new\n @tso = Tso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tso }\n end\n end", "def new\n @today_activity = TodayActivity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @today_activity }\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 new\n @events_by_year = EventsByYear.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @events_by_year }\n end\n end", "def new\n @domain = Domain.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @domain }\n end\n end", "def new\n @poll = Poll.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @poll }\n end\n end", "def new\n @payment_history = PaymentHistory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @payment_history }\n end\n end", "def new\n @ayudastemporal = Ayudastemporal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ayudastemporal }\n end\n end", "def new\n @deposit_threshold = DepositThreshold.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @deposit_threshold }\n end\n end", "def get_all_new\n uri = [@@base_uri, 'all', 'getAllNew'].join('/')\n return get(uri)\n end", "def new\n @outcome_timepoint = OutcomeTimepoint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @outcome_timepoint }\n end\n end", "def new\n @lookup_cohort = LookupCohort.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_cohort }\n end\n end", "def new\n @range_specification = RangeSpecification.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @range_specification }\n end\n end", "def new\n @daily_grr = DailyGrr.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @daily_grr }\n end\n end", "def new\n @slice = Slice.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @slice }\n end\n end", "def new\n @newtype = params[:newtype]\n @ptbudget = Ptbudget.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ptbudget }\n end\n end", "def new\n @atom = Atom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @atom }\n end\n end", "def new\n @ptbudget = Ptbudget.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ptbudget }\n end\n end", "def new\n @derivative = Derivative.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @derivative }\n end\n end", "def new\n @holiday_song_period = HolidaySongPeriod.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @holiday_song_period }\n end\n end", "def new\n @datetime = Datetime.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @datetime }\n end\n end", "def new\n @page = Page.new(:status => params[:from])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end", "def new\n @fixed_deposit = FixedDeposit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @fixed_deposit }\n end\n end", "def new\n @withdrawal = Withdrawal.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @withdrawal }\n end\n end", "def new\n @patron = Patron.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @patron }\n end\n end", "def new\n @when_factor = WhenFactor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @when_factor }\n end\n end", "def new\n @add_on = AddOn.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @add_on }\n end\n end", "def new\n @issued = Issued.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @issued }\n end\n end", "def new\n @sleep = Sleep.new\n @user = User.find(session[:user_id])\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sleep }\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 @pool = Pool.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pool }\n end\n end", "def new\n @namespace = Namespace.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @namespace }\n end\n end", "def new_rest\n @entry_instrument = EntryInstrument.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry_instrument }\n end\n end", "def new\n @old_point_tag = OldPointTag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @old_point_tag }\n end\n end", "def new\n @sprint = Sprint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sprint }\n end\n end", "def new\n @sprint = Sprint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sprint }\n end\n end", "def new\n @loan = Loan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @loan }\n end\n end", "def new\n head :status => 405\n return\n \n @participant = Participant.new\n\n respond_to do |format|\n format.html # new.html.erb\n #format.xml { render :xml => @participant }\n end\n end", "def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stock }\n end\n end", "def new\n @rate_change_history = RateChangeHistory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rate_change_history }\n end\n end", "def new\n @pending_month = PendingMonth.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pending_month }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @fund_request }\n end\n end", "def new\n @available_off = AvailableOff.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @available_off }\n end\n end", "def new\n @task = Task.new(:expires => true, :time => -1, :start_date => Time.now.at_beginning_of_day, :end_date => Time.now.at_beginning_of_day)\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task }\n end\n end", "def new\n @part = Part.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @part }\n end\n end", "def new\n @schedule = Schedule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @schedule }\n end\n end", "def new\n @hpt_history = HptHistory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @hpt_history }\n end\n end", "def new\n @want = Want.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @want }\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 @chart = Chart.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @chart }\n end\n end" ]
[ "0.74897796", "0.6755607", "0.67438114", "0.6645171", "0.6644948", "0.6642514", "0.65834355", "0.64631915", "0.64355683", "0.6409539", "0.6383805", "0.61706525", "0.61404735", "0.6138096", "0.6121987", "0.6121013", "0.612042", "0.612042", "0.6105411", "0.606518", "0.60650456", "0.60650456", "0.603853", "0.6034219", "0.60237306", "0.6019786", "0.60169256", "0.6009936", "0.5962607", "0.5938267", "0.59287965", "0.5914165", "0.5914165", "0.5914165", "0.591384", "0.59068125", "0.59014827", "0.58957577", "0.5890725", "0.58894914", "0.58872783", "0.5883118", "0.5881272", "0.5878082", "0.5875361", "0.5874595", "0.58708966", "0.58650357", "0.58618087", "0.586102", "0.586031", "0.58582765", "0.58551556", "0.5846323", "0.58444047", "0.5832516", "0.58319026", "0.58298874", "0.5823451", "0.58204323", "0.5819693", "0.58194363", "0.5818316", "0.5809395", "0.58040804", "0.58038914", "0.57958066", "0.5794727", "0.57899487", "0.5776008", "0.57757074", "0.5775284", "0.5770748", "0.5763023", "0.57629794", "0.576131", "0.5759331", "0.57579833", "0.57565963", "0.575606", "0.57557195", "0.5749385", "0.57493806", "0.57435465", "0.57414687", "0.57414687", "0.5738502", "0.5737597", "0.57331836", "0.5733097", "0.5731765", "0.5730453", "0.572621", "0.5722872", "0.5722207", "0.5721691", "0.5716762", "0.5711871", "0.5708326", "0.5707187" ]
0.690532
1
POST /periods POST /periods.xml
def create @period = @cursus.periods.build(params[:period]) respond_to do |format| if @period.save format.html { redirect_to( cursus_periods_path(@cursus) ) } format.xml { render :xml => @period, :status => :created, :location => @period } else format.js do render :status => 500, :partial => "error_partial" end format.xml { render :xml => @period.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def periods_params\n params.require(:period).permit(:name, :comment, :start_date, :end_date, :budget_id)\n end", "def create\n @period = Period.new(params[:period])\n\n if @period.save\n render json: @period, status: :created, location: @period\n else\n render json: @period.errors, status: :unprocessable_entity\n end\n end", "def period_params\n params.require(:period).permit(:name, :start_at, :end_at, :school_id)\n end", "def create\n @period = Period.new(params[:period])\n\n respond_to do |format|\n if @period.save\n flash[:notice] = 'Period was successfully created.'\n format.html { redirect_to(@period) }\n format.xml { render :xml => @period, :status => :created, :location => @period }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @period.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @period = Period.new(params[:period])\n\n respond_to do |format|\n if @period.save\n flash[:notice] = _('%s was successfully created.', Period.human_name)\n format.html { redirect_to period_url(@period) }\n format.xml { head :created, :location => period_url(@period) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @period.errors.to_xml }\n end\n end\n end", "def period_params\n params.require(:period).permit(:number, :code, :explanation, :start_date, :end_date)\n end", "def create_period\n periods_checked = current_user.periods.active.count\n puts \"The user has #{periods_checked} active periods, trying to create a #{params[:nduration].to_i} days period\"\n if periods_checked == 0\n puts \"The user hasn't active periods\"\n @period = current_user.periods.new(is_active: true, is_updated: false, duration: params[:nduration].to_i, start_date: Date.today.to_s, end_date: (Date.today+params[:nduration].to_i).to_s)\n puts @period\n if @period.save\n render json: @period, status: :created, location: @period\n else\n render json: @period.errors, status: :unprocessable_entity\n end\n else\n puts \"The user has active periods\"\n # render json: @period.errors, status: :unprocessable_entity\n render json: { status: 'ERROR', message: \"The user has an active period\"}, status: :unprocessable_entity\n end\n end", "def period_params\n params.require(:period).permit(:first_day, :last_day, :holiday_id, :periodable_id, :periodable_type)\n end", "def period_params\n params.require(:period).permit(:start, :end, :buget, :activ, :nr_stud, :min_salary)\n end", "def create\n period = current_user.school.periods.create(period_params)\n\n if period.save\n render json: period, status: :created, location: period\n else\n render json: {errors: period.errors}, status: :unprocessable_entity\n end\n end", "def period_params\n params.require(:period).permit(:is_active, :is_updated, :duration, :start_date, :end_date)\n end", "def period_params\n params.require(:period).permit(:start_date, :end_date, :user_id)\n end", "def create\n @period = Period.new(period_params)\n\n respond_to do |format|\n if @period.save\n format.html { redirect_to periods_path, notice: 'Periode Telah Dibuat.' }\n format.json { render :show, status: :created, location: @period }\n else\n format.html { render :new }\n format.json { render json: @period.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @time_period = TimePeriod.new(time_period_params)\n\n if @time_period.save\n render :show, status: :created, location: @time_period\n else\n render json: @time_period.errors, status: :unprocessable_entity\n end\n end", "def expense_period_params\n params.require(:expense_period).permit(:start, :finish, :name)\n end", "def periodo_params\n params.require(:periodo).permit(:numero, :inicio, :termino)\n end", "def period_params\n params.require(:period).permit(:bulan, :tahun)\n end", "def create_period(season, options = {})\n post(\"seasons/#{season}/periods\", periods: [options]).pop\n end", "def get_periods(id, starts: nil, ends: nil, threshold:, operation:)\n params = {:start => starts, :end => ends, :threshold => threshold, :op => operation}\n params.delete_if { |k, v| v.nil? }\n @client.http_get(\"/#{@resource}/#{id}/periods?\"+URI.encode_www_form(params))\n end", "def pay_period_params\n params.require(:pay_period).permit(:start, :end)\n end", "def create\n @resource_period = ResourcePeriod.new(params[:resource_period])\n\n respond_to do |format|\n if @resource_period.save\n format.html { redirect_to(@resource_period, :notice => 'Resource period was successfully created.') }\n format.json { render :json => @resource_period, :status => :created, :location => @resource_period }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @resource_period.errors, :status => :unprocessable_entity }\n end\n end\n end", "def time_period_params\n params.require(:time_period).permit(:start_date, :end_date)\n end", "def create\n @authorization_period = AuthorizationPeriod.new(params[:authorization_period])\n\n respond_to do |format|\n if @authorization_period.save\n format.html { redirect_to(@authorization_period, :notice => 'AuthorizationPeriod was successfully created.') }\n format.xml { render :xml => @authorization_period, :status => :created, :location => @authorization_period }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @authorization_period.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @tb_period = TbPeriod.new(params[:tb_period])\n\n respond_to do |format|\n if @tb_period.save\n format.html { redirect_to @tb_period, notice: 'Tb period was successfully created.' }\n format.json { render json: @tb_period, status: :created, location: @tb_period }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tb_period.errors, status: :unprocessable_entity }\n end\n end\n end", "def scholarship_period_params\n params.require(:scholarship_period).permit(:begin, :end)\n end", "def new\n @period = @cursus.periods.build\n\n respond_to do |format|\n format.html { render :layout => false }\n format.xml { render :xml => @period }\n end\n end", "def pay_period_params\n params.require(:pay_period).permit(:start_date, :end_date, :is_open, :phase)\n end", "def index\n @periods = Period.all\n end", "def create\n @pay_period = PayPeriod.new(params[:pay_period])\n\n respond_to do |format|\n if @pay_period.save\n format.html { redirect_to(@pay_period, :notice => 'PayPeriod was successfully created.') }\n format.xml { render :xml => @pay_period, :status => :created, :location => @pay_period }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @pay_period.errors, :status => :unprocessable_entity }\n end\n end\n end", "def receipt_period_params\n params.require(:receipt_period).permit(:start_date, :end_date, :accompliched, :user_id)\n end", "def new\n @period = Period.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @period }\n end\n end", "def period_discipline_params\n params.require(:period_discipline).permit(:graduation_semester_id, :discipline_id, :instructor_id, period: [:start, :end])\n end", "def create\n @requisicao = Requisicao.new(params[:requisicao])\n @periodos = Periodo.all.collect{|p|[\"#{t p.inicio.strftime(\"%B\")} - #{t p.fim.strftime(\"%B\")}\",p.id]}\n respond_to do |format|\n if @requisicao.save\n format.html { redirect_to(@requisicao, :notice => 'Requisicao cadastrado com sucesso.') }\n format.xml { render :xml => @requisicao, :status => :created, :location => @requisicao }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @requisicao.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @periods_group = PeriodsGroup.new(periods_group_params)\n\n respond_to do |format|\n if @periods_group.save\n format.html { redirect_to company_periods_group_path(@company, @periods_group), notice: 'Periods group was successfully created.' }\n format.json { render :show, status: :created, location: @periods_group }\n else\n format.html { render :new }\n format.json { render json: @periods_group.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @workday = Workday.new\n 2.times do\n @workday.periods.build\n end\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @workday }\n end\n end", "def schedule_periods\n\t\t@periods = Period.all\n\tend", "def tracker_params\n params.require(:tracker).permit(:period)\n end", "def create\n @api_v1_frequency_period = Api::V1::FrequencyPeriod.new(api_v1_frequency_period_params)\n\n respond_to do |format|\n if @api_v1_frequency_period.save\n format.html { redirect_to @api_v1_frequency_period, notice: 'Frequency period was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_frequency_period }\n else\n format.html { render :new }\n format.json { render json: @api_v1_frequency_period.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @period = Period.new(period_params)\n\n respond_to do |format|\n if @period.save\n format.html { redirect_to @period.school, notice: 'Period was successfully created.' }\n format.json { render :show, status: :created, location: @period.school }\n else\n format.html { render :new }\n format.json { render json: @period.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @periodista = Periodista.new(params[:periodista])\n\n respond_to do |format|\n if @periodista.save\n flash[:notice] = 'Periodista se ha creado con exito.'\n format.html { redirect_to(admin_periodistas_url) }\n format.xml { render :xml => @periodista, :status => :created, :location => @periodista }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @periodista.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @authorization_periods = AuthorizationPeriod.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @authorization_periods }\n end\n end", "def create_new_period(period)\n JSON.generate(period)\n File.open(\"./files/periods/#{period[:name]}.json\", \"w\") do |f|\n f.write(period.to_json)\n end\nend", "def create\n @period = Period.new(period_params)\n\n # if @period.start < @period.end\n\n respond_to do |format|\n verify_activ = Period.find_by(:activ => 't')\n if not verify_activ.nil?\n flash[:error] = \"Exista deja o perioada activa!\"\n format.html { redirect_to \"/periods/new\", error: 'Exista deja o perioada activa!' }\n else\n if @period.save\n # create a news when a period is started\n @news = News.new()\n @news.title = \"Sesiune noua de burse\"\n @news.content = \"A fost deschisa o sesiune noua de aplicare la burse. Perioada incepe la #{@period.start} si se termina la #{@period.end}\"\n @news.post_date = Time.now\n @news.published = true\n @news.user_id = @current_user.id\n\n username = @current_user.last_name\n @mailing_list = Array.new\n\n @students = JSON.parse RestClient.get \"http://193.226.51.30/get_students?oauth_token=#{@current_user.token}\", {:accept => :json}\n # incerc sa prelucrez studentii si sa scot emailurile intr-un array\n @students.each do |year|\n year[1].each do |cycle|\n cycle[1].each do |group|\n group[1].each do |student| \n @mailing_list << student[\"email\"]\n end\n end\n end\n end\n\n NewsMailer.news_created(@news, username, @mailing_list).deliver_now\n @news.save()\n format.html { redirect_to \"/periods\", notice: 'Period was successfully created.' }\n format.json { render :show, status: :created, location: @period }\n else\n format.html { render :new }\n format.json { render json: @period.errors, status: :unprocessable_entity }\n end\n end\n end\n # else\n # flash[:error] = \"Data de inceput trebuie sa fie precedenta datei de sfarsit!\"\n # respond_to do |format|\n # format.html { render :new }\n # format.json { render json: @period.errors, status: :unprocessable_entity }\n # end\n # end\n\n end", "def destroy\n @period = Period.find(params[:id])\n @period.destroy\n\n respond_to do |format|\n format.html { redirect_to(periods_url) }\n format.xml { head :ok }\n end\n end", "def vat_period_params\n params.require(:vat_period).permit(:name, :vat_from, :vat_to, :accounting_period_id, :deadline,\n :supplier_id)\n end", "def set_period\n @period = Period.find(params[:id])\n end", "def set_period\n @period = Period.find(params[:id])\n end", "def set_period\n @period = Period.find(params[:id])\n end", "def create\n @receipt_period = ReceiptPeriod.new(receipt_period_params)\n\n respond_to do |format|\n if @receipt_period.save\n format.html { redirect_to @receipt_period, notice: 'Receipt period was successfully created.' }\n format.json { render :show, status: :created, location: @receipt_period }\n else\n format.html { render :new }\n format.json { render json: @receipt_period.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n period = current_user.school.periods.find(params[:id])\n\n if period.update(period_params)\n render json: period, status: :accepted\n else\n render json: {errors: period.errors}, status: :unprocessable_entity\n end\n end", "def create\n @pay_period = PayPeriod.new(pay_period_params)\n\n respond_to do |format|\n if @pay_period.save\n format.html { redirect_to @pay_period, notice: 'Pay period was successfully created.' }\n format.json { render :show, status: :created, location: @pay_period }\n else\n format.html { render :new }\n format.json { render json: @pay_period.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_grading_periods(interval, year, ed_org_id)\n grading_periods = []\n grading_periods << {\"type\" => :END_OF_YEAR, \"year\" => year, \"interval\" => interval, \"ed_org_id\" => ed_org_id}\n grading_periods\n end", "def periods_group_params\n params.require(:periods_group).permit(:period_type, :main_company_periods => [], :competitive_companies => [])\n end", "def periodic_params\n params.require(:periodic).permit(:name, :description, :qualis, :knowledgement_area, :issn, :selected_knowledgement_area, :selected_qualis)\n end", "def create\n @doseperiod = DisDoseperiod.new(doseperiod_params)\n\n\n if @doseperiod.save\n flash[:notice] = \"Task was successfully created.\"\n respond_with(@doseperiod)\n else\n flash[:notice] = \"Task was not created.\"\n end\n end", "def create\n @scholarship_period = ScholarshipPeriod.new(scholarship_period_params)\n\n respond_to do |format|\n if @scholarship_period.save\n format.html { redirect_to @scholarship_period, notice: 'Период степендии успешно создан.' }\n format.json { render :show, status: :created, location: @scholarship_period }\n else\n format.html { render :new }\n format.json { render json: @scholarship_period.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_periods\n @periods = current_user.periods.all.order(created_at: :desc)\n render json: @periods\n end", "def vacation_period_params\n params.require(:vacation_period).permit(:start_date, :end_date, :vacation_periodable_type, :vacation_periodable_id, :vacation_type_id, :description, :state)\n end", "def create\r\n @machine = Machine.new(params[:machine])\r\n @periods = Period.all\r\n\r\n\r\n respond_to do |format|\r\n if @machine.save\r\n @periods.each { |pe|\r\n MachinePeriod.create(machine_id: @machine.id, period_id: pe.id, capacity: 0, overtime: 0)\r\n }\r\n\r\n format.html { redirect_to @machine, notice: 'Produkt wurde erfolgreich angelegt!' }\r\n format.json { render json: @machine, status: :created, location: @machine }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @machine.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def accounting_period_params\n params.require(:accounting_period).permit(:name, :accounting_from, :accounting_to, :active, :vat_period_type, :accounting_plan, :accounting_plan_id)\n end", "def create\n @workperiod = Workperiod.new(params[:workperiod])\n\n respond_to do |format|\n if @workperiod.save\n flash[:notice] = 'Workperiod was successfully created.'\n format.html { redirect_to(@workperiod) }\n format.xml { render :xml => @workperiod, :status => :created, :location => @workperiod }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @workperiod.errors, :status => :unprocessable_entity }\n end\n end\n end", "def periods\n @periods ||= @data['properties']['periods'].map { |row|\n ::WeatherSage::Weather::Period.new(@ctx, row)\n }\n end", "def index\n @periods = @organism.periods.order(:close_date)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @periods } \n end\n end", "def destroy\n @period = Period.find(params[:id])\n @period.destroy\n\n respond_to do |format|\n format.html { redirect_to periods_url }\n format.xml { head :ok }\n end\n end", "def interval_params\n params.require(:interval).permit(:numerator, :denominator, :description, :name)\n end", "def doseperiod_params\n params.require(:doseperiod).permit(:name, :is_common, :abbrev, :status_id, :datasource_id)\n end", "def reporting_period_params\n params.require(:reporting_period).permit(:date, :base_rate, :aasm_state)\n end", "def create\n @teaching_period = TeachingPeriod.new(teaching_period_params)\n\n respond_to do |format|\n if @teaching_period.save\n format.html { redirect_to @teaching_period, notice: 'Teaching period was successfully created.' }\n format.json { render :show, status: :created, location: @teaching_period }\n else\n format.html { render :new }\n format.json { render json: @teaching_period.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @period = Period.find(params[:id])\n\n respond_to do |format|\n if @period.update_attributes(params[:period])\n flash[:notice] = 'Period was successfully updated.'\n format.html { redirect_to(@period) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @period.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @dis_doseperiod = DisDoseperiod.new(dis_doseperiod_params)\n\n respond_to do |format|\n if @dis_doseperiod.save\n format.html { redirect_to @dis_doseperiod, notice: 'Dis doseperiod was successfully created.' }\n format.json { render :show, status: :created, location: @dis_doseperiod }\n else\n format.html { render :new }\n format.json { render json: @dis_doseperiod.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @time_periods = TimePeriod.all\n end", "def index\n @registration_periods = RegistrationPeriod.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @registration_periods }\n end\n end", "def update\n @period = Period.find(params[:id])\n\n if @period.update(params[:period])\n head :no_content\n else\n render json: @period.errors, status: :unprocessable_entity\n end\n end", "def set_and_authorize_period\n @period = Period.find(params[:id])\n authorize @period, \"#{action_name}?\".to_sym\n end", "def period=(value)\n @period = value\n end", "def create\n @vacation_period = VacationPeriod.new(vacation_period_params)\n\n respond_to do |format|\n if @vacation_period.save\n format.html { redirect_to @vacation_period, notice: 'Vacation period was successfully created.' }\n format.json { render action: 'show', status: :created, location: @vacation_period }\n else\n format.html { render action: 'new' }\n format.json { render json: @vacation_period.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n data = reload(get_series('sleep'), str(Date.strptime(params[:sleep].values.join(\"-\"))))\n saved = false\n get_series('sleep').each do |s|\n data[s].each do |day|\n logger.debug \"data=#{day} date=#{day['dateTime']} value=#{day['value']}\"\n @sleep = for_date(day['dateTime'])\n\t# get variable name from last part of series\n @sleep.send(s.rpartition('/')[2] + '=', day['value'])\n saved = @sleep.save\n if not saved\n flash[:error] = @sleep.errors\n end\n end\n end\n \n respond_to do |format|\n flash[:success] = 'Sleep was successfully created.'\n format.html { redirect_to sleeps_path }\n format.json { render :json => sleeps_path, :status => :created, :location => sleeps_path }\n end\n end", "def periodicity_params\n params.require(:periodicity).permit(:name, :num_months, :user_id)\n end", "def new\n @periodos = Periodo.all.collect{|p|[\"#{t p.inicio.strftime(\"%B\")} - #{t p.fim.strftime(\"%B\")}\",p.id]}\n @requisicao = Requisicao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @requisicao }\n end\n end", "def create\n\n respond_to do |format|\n if @registration_period.save\n format.html { redirect_to @registration_period, notice: 'Registration period was successfully created.' }\n format.json { render json: @registration_period, status: :created, location: @registration_period }\n else\n format.html { render action: \"new\" }\n format.json { render json: @registration_period.errors, status: :unprocessable_entity }\n end\n end\n end", "def mezosoic_era_params\n params.require(:mezosoic_era).permit(:period)\n end", "def postEntityOpening_times( entity_id, monday, tuesday, wednesday, thursday, friday, saturday, sunday, closed, closed_public_holidays)\n params = Hash.new\n params['entity_id'] = entity_id\n params['monday'] = monday\n params['tuesday'] = tuesday\n params['wednesday'] = wednesday\n params['thursday'] = thursday\n params['friday'] = friday\n params['saturday'] = saturday\n params['sunday'] = sunday\n params['closed'] = closed\n params['closed_public_holidays'] = closed_public_holidays\n return doCurl(\"post\",\"/entity/opening_times\",params)\n end", "def destroy\n @time_period.destroy\n format.json { head :no_content }\n end", "def schedule(subperiod,year,gs,expiry_date)\n #URL della servlet\n url = URI.parse(CONFIG['servlet']['address'])\n #impostazione del metodo POST\n req = Net::HTTP::Post.new(url.path)\n #parametri di autenticazione\n #req.basic_auth 'jack', 'pass'\n #dati da inviare op = ScheduleJob\n if expiry_date\n data = expiry_date.date\n day = data.day.to_i\n if day < 10\n day = \"0\" + day.to_s\n else\n day = day.to_s\n end\n month = data.mon.to_i\n if month < 10\n month = \"0\" + month.to_s\n else\n month = month.to_s\n end\n date = day + \"-\" + month + \"-\" + data.year.to_s\n req.set_form_data({'op'=>'sj', 'graduate_course' => gs.id.to_s,\n 'year' => year,\n 'subperiod' => subperiod.to_s,\n 'date'=> date\n }, '&')\n else\n req.set_form_data({'op'=>'sj', 'graduate_course' => gs.id.to_s,\n 'year' => year,\n 'subperiod' => subperiod.to_s\n }, '&')\n #connessione alla servlet\n end\n res = Net::HTTP.new(url.host, url.port).start {\n |http| http.request(req)\n }\n #controllo del codice di errore\n case res\n when Net::HTTPSuccess, Net::HTTPRedirection\n # OK\n return true\n when Net::HTTPNotAcceptable\n #parametri non corretti.. riportare alla form\n return false\n else\n #errore connessione.. riprovare\n return false\n end\n end", "def class_period_params\n params.require(:class_period).permit(:subject, :user_id, :period, :level, :max)\n end", "def employee_work_period_params\n params.require(:employee_work_period).permit(:since, :until, :employee_id, :cancel_url, :redirect_url)\n end", "def schedule_cohort_period_params\n params.require(:schedule_cohort_period).permit(:schedule_id, :cohort_period_id)\n end", "def update_service_periods\n if self.purchase_order\n payments = self.purchase_order.payments.recurring.find(:all, :order => \"payments.id ASC\")\n unless payments.empty?\n self.update_attributes(:service_period_start_on => self.service_period_start_on,\n :service_period_end_on => self.service_period_end_on)\n end\n end\n end", "def create\n\t\turi = URI.parse(Counter::Application.config.simplyurl)\n\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\t\n\t\trequest = Net::HTTP::Post.new('/offsets.json')\n\t\tputs params\n\t\tputs params.slice(*['custids','acctids','itemids'])\n\t\t\n\t\t# ok, this join stuff is bogus - it encodes properly, but the other side only sees the last element and loses the array type - it's just string\n\t\t# this way, i 'split' it at the other side to recover my array\n\t\t# it should work without the join/split crap, but it doesn't\n\t\trequest.set_form_data({:custids => ( params['custids'] || []).join(','), :acctids => ( params['acctids'] || []).join(','), :itemids => ( params['itemids'] || []).join(','), :amount => params['amount'], :type => params['type']})\n\t\t\n\t\tputs request.body\n\t\t\n\t\tresponse = http.request(request)\n\t\tputs response.body\n\n respond_to do |format|\n format.html { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n format.json { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n end\n end", "def create\n @periodismo = Periodismo.new(params[:periodismo])\n\n respond_to do |format|\n if @periodismo.save\n format.html { redirect_to @periodismo, notice: 'Periodismo was successfully created.' }\n format.json { render json: @periodismo, status: :created, location: @periodismo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @periodismo.errors, status: :unprocessable_entity }\n end\n end\n end", "def api_v1_frequency_period_params\n params.fetch(:api_v1_frequency_period, {})\n end", "def period(period, options = {})\n get(\"periods/#{period}\", options).pop\n end", "def update\n @period = Period.find(params[:id])\n\n respond_to do |format|\n if @period.update_attributes(params[:period])\n flash[:notice] = _('%s was successfully updated.', Period.human_name)\n format.html { redirect_to period_url(@period) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @period.errors.to_xml }\n end\n end\n end", "def index\n periods = current_user.school.periods.all\n\n render json: periods\n end", "def create\n @holiday_song_period = HolidaySongPeriod.new(params[:holiday_song_period])\n\n respond_to do |format|\n if @holiday_song_period.save\n format.html { redirect_to @holiday_song_period, :notice => 'Holiday song period was successfully created.' }\n format.json { render :json => @holiday_song_period, :status => :created, :location => @holiday_song_period }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @holiday_song_period.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_request_period(period)\n\t\t@object_builder.set_request_period(period)\n\tend", "def create\n @klass = Klass.new(klass_params)\n respond_to do |format|\n if @klass.save\n format.html { redirect_to management_klasses_path }\n format.json { render :json => @klass.to_json(include: :period), status: :created }\n else\n format.html { render :new }\n format.json { render json: @klass.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @period = @cursus.periods.find(params[:id])\n\n respond_to do |format|\n if @period.update_attributes(params[:period])\n flash[:notice] = 'Period was successfully updated.'\n format.html { redirect_to( cursus_periods_path(@cursus) ) }\n format.xml { head :ok }\n else\n format.js do\n render :status => 500, :partial => \"error_partial\"\n end\n format.xml { render :xml => @period.errors, :status => :unprocessable_entity }\n end\n end\n end", "def destroy\n @tb_period = TbPeriod.find(params[:id])\n @tb_period.destroy\n\n respond_to do |format|\n format.html { redirect_to tb_periods_url }\n format.json { head :no_content }\n end\n end", "def create\n #@equity.customer_id = params[:customer_id]\n @equity = Equity.new(equity_params)\n @equity.equity_period = (Date.current - 20.years)..(Date.current + 25.years)\n #@equity.equity_period = \"1997-01-01,2030-01-01\"\n\n respond_to do |format|\n if @equity.save\n format.html { redirect_to admin_risk_equities_path(@equity.risk_id), notice: 'Equity was successfully created.' }\n format.json { render :show, status: :created, location: @equity }\n else\n format.html { render :new }\n format.json { render json: risk_equities_path(@equity.errors), status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.64246845", "0.6290774", "0.62859964", "0.6228496", "0.62185895", "0.61328846", "0.6081976", "0.6059283", "0.6030935", "0.60249627", "0.6019644", "0.5990538", "0.59542876", "0.5898787", "0.57986146", "0.57839024", "0.5770097", "0.5746094", "0.5743232", "0.5741344", "0.57139486", "0.57051086", "0.56993866", "0.5679567", "0.563988", "0.5585433", "0.55569285", "0.55417323", "0.55294156", "0.546479", "0.54569834", "0.54553163", "0.5447452", "0.5444351", "0.542037", "0.5391541", "0.5381156", "0.5373213", "0.53492355", "0.53472006", "0.5329236", "0.53027225", "0.52901334", "0.5289341", "0.5284539", "0.52588874", "0.52588874", "0.52588874", "0.5256586", "0.5252379", "0.52470887", "0.52467996", "0.5237079", "0.5235318", "0.520555", "0.5204134", "0.52028435", "0.5200919", "0.51960707", "0.5187045", "0.5184408", "0.51757914", "0.5175145", "0.51702076", "0.51363945", "0.51153004", "0.5104636", "0.5104621", "0.50996184", "0.50963396", "0.50846046", "0.5081667", "0.50768006", "0.50704676", "0.5065113", "0.5051683", "0.5051598", "0.50510967", "0.50498235", "0.5043714", "0.50300103", "0.5022297", "0.5020431", "0.5015604", "0.50123036", "0.5009816", "0.5009032", "0.5008198", "0.5002709", "0.50000954", "0.4994788", "0.49908662", "0.498472", "0.49771488", "0.49535498", "0.4951093", "0.4947782", "0.49449626", "0.49389246", "0.49384853" ]
0.58366454
14
PUT /periods/1 PUT /periods/1.xml
def update @period = @cursus.periods.find(params[:id]) respond_to do |format| if @period.update_attributes(params[:period]) flash[:notice] = 'Period was successfully updated.' format.html { redirect_to( cursus_periods_path(@cursus) ) } format.xml { head :ok } else format.js do render :status => 500, :partial => "error_partial" end format.xml { render :xml => @period.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @period = Period.find(params[:id])\n\n respond_to do |format|\n if @period.update_attributes(params[:period])\n flash[:notice] = 'Period was successfully updated.'\n format.html { redirect_to(@period) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @period.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @period = Period.find(params[:id])\n\n if @period.update(params[:period])\n head :no_content\n else\n render json: @period.errors, status: :unprocessable_entity\n end\n end", "def update\n @period = Period.find(params[:id])\n\n respond_to do |format|\n if @period.update_attributes(params[:period])\n flash[:notice] = _('%s was successfully updated.', Period.human_name)\n format.html { redirect_to period_url(@period) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @period.errors.to_xml }\n end\n end\n end", "def update!(**args)\n @periods = args[:periods] if args.key?(:periods)\n end", "def update!(**args)\n @periods = args[:periods] if args.key?(:periods)\n end", "def update!(**args)\n @periods = args[:periods] if args.key?(:periods)\n end", "def update!(**args)\n @periods = args[:periods] if args.key?(:periods)\n end", "def update\n period = current_user.school.periods.find(params[:id])\n\n if period.update(period_params)\n render json: period, status: :accepted\n else\n render json: {errors: period.errors}, status: :unprocessable_entity\n end\n end", "def update\n @resource_period = ResourcePeriod.find(params[:id])\n\n respond_to do |format|\n if @resource_period.update_attributes(params[:resource_period])\n format.html { redirect_to(@resource_period, :notice => 'Resource period was successfully updated.') }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @resource_period.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @period.update(period_params)\n format.html { redirect_to @period, notice: 'Period was successfully updated.' }\n format.json { render :show, status: :ok, location: @period }\n else\n format.html { render :edit }\n format.json { render json: @period.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tb_period = TbPeriod.find(params[:id])\n\n respond_to do |format|\n if @tb_period.update_attributes(params[:tb_period])\n format.html { redirect_to @tb_period, notice: 'Tb period was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tb_period.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_frequency_period.update(api_v1_frequency_period_params)\n format.html { redirect_to @api_v1_frequency_period, notice: 'Frequency period was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_frequency_period }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_frequency_period.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @authorization_period = AuthorizationPeriod.find(params[:id])\n\n respond_to do |format|\n if @authorization_period.update_attributes(params[:authorization_period])\n format.html { redirect_to(@authorization_period, :notice => 'AuthorizationPeriod was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @authorization_period.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @periodista = Periodista.find(params[:id])\n\n respond_to do |format|\n if @periodista.update_attributes(params[:periodista])\n flash[:notice] = 'Periodista se ha actualizado con exito.'\n format.html { redirect_to(admin_periodistas_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @periodista.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n if @time_period.update(time_period_params)\n render :show, status: :ok, location: @time_period\n else\n render json: @time_period.errors, status: :unprocessable_entity\n end\n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def update\n @requisicao = Requisicao.find(params[:id])\n @periodos = Periodo.all.collect{|p|[\"#{t p.inicio.strftime(\"%B\")} - #{t p.fim.strftime(\"%B\")}\",p.id]}\n respond_to do |format|\n if @requisicao.update_attributes(params[:requisicao])\n format.html { redirect_to(@requisicao, :notice => 'Requisicao atualizado com sucesso.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @requisicao.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @bill = Bill.find(params[:id])\n\n respond_to do |format|\n if @bill.update_attributes(params[:period])\n format.html { redirect_to @bill, notice: t('activerecord.attributes.bill.successfully') }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @pay_period = PayPeriod.find(params[:id])\n\n respond_to do |format|\n if @pay_period.update_attributes(params[:pay_period])\n format.html { redirect_to(@pay_period, :notice => 'PayPeriod was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @pay_period.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @period.update(period_params)\n format.html { redirect_to periods_path, notice: 'Periode Telah Diperbarui.' }\n format.json { render :show, status: :ok, location: @period }\n else\n format.html { render :edit }\n format.json { render json: @period.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @holiday_song_period = HolidaySongPeriod.find(params[:id])\n\n respond_to do |format|\n if @holiday_song_period.update_attributes(params[:holiday_song_period])\n format.html { redirect_to @holiday_song_period, :notice => 'Holiday song period was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @holiday_song_period.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_period\n @period = Period.find(params[:id])\n end", "def set_period\n @period = Period.find(params[:id])\n end", "def set_period\n @period = Period.find(params[:id])\n end", "def destroy\n @period = Period.find(params[:id])\n @period.destroy\n\n respond_to do |format|\n format.html { redirect_to(periods_url) }\n format.xml { head :ok }\n end\n end", "def update\n respond_to do |format|\n if @period.update(period_params)\n format.html { redirect_to school_period_path(@period.school, @period), notice: 'Period was successfully updated.' }\n format.json { render :show, status: :ok, location: school_period_path(@period.school, @period) }\n else\n format.html { render :edit }\n format.json { render json: @period.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @quantile_period = QuantilePeriod.find(params[:id])\n\n respond_to do |format|\n if @quantile_period.update_attributes(params[:quantile_period])\n format.html { redirect_to @quantile_period, notice: 'Quantile period was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quantile_period.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @workperiod = Workperiod.find(params[:id])\n\n respond_to do |format|\n if @workperiod.update_attributes(params[:workperiod])\n flash[:notice] = 'Workperiod was successfully updated.'\n format.html { redirect_to(@workperiod) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @workperiod.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @periodic.update(periodic_params)\n format.html { redirect_to @periodic, notice: 'Periodic was successfully updated.' }\n format.json { render :show, status: :ok, location: @periodic }\n else\n format.html { render :edit }\n format.json { render json: @periodic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n\n format.json { render json: Axis.find(params[:id]).update( name: params[:name]) }\n end\n\n # end\n end", "def set_api_v1_frequency_period\n @api_v1_frequency_period = Api::V1::FrequencyPeriod.find(params[:id])\n end", "def destroy\n @period = Period.find(params[:id])\n @period.destroy\n\n respond_to do |format|\n format.html { redirect_to periods_url }\n format.xml { head :ok }\n end\n end", "def update\n @step = TaskrequestsStep.find(params[:taskrequests_step_id])\n @absence_request = @step.absence_requests.find(params[:id])\n\n respond_to do |format|\n if @absence_request.update_attributes(params[:absence_request])\n format.html { redirect_to(@absence_request, :notice => 'Absence request was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @absence_request.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @periodic.update(periodic_params)\n format.html { redirect_to @periodic, notice: 'Periódico atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @periodic }\n else\n format.html { render :edit }\n format.json { render json: @periodic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n update_helper(@pay_period, 'Pay period', pay_period_params)\n end", "def update\n @timing = Timing.find(params[:id])\n if @timing.update_attributes(params[:timing].slice(:start, :stop, :days, :active))\n render json: @timing\n else\n render json: { error: 'error: could not update timing' }\n end\n end", "def update\n @interval = Interval.find(params[:id])\n\n respond_to do |format|\n if @interval.update_attributes(params[:interval])\n format.html { redirect_to @interval, notice: 'Interval was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @interval.errors, status: :unprocessable_entity }\n end\n end\n end", "def period_params\n params.require(:period).permit(:name, :start_at, :end_at, :school_id)\n end", "def update(id, name=\"Updated Name\", age=\"55\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <id type='integer'>#{id}</id>\r\n <name>#{name}</name>\r\n <age>#{age}</age> \r\n </person>\"\r\n request = Net::HTTP::Put.new(\"#{@url}/#{id}.xml\")\r\n request.add_field \"Content-Type\", \"application/xml\"\r\n request.body = xml_req\r\n http = Net::HTTP.new(@uri.host, @uri.port)\r\n response = http.request(request)\r\n # no response body will be returned\r\n case response\r\n when Net::HTTPSuccess\r\n return \"#{response.code} OK\"\r\n else\r\n return \"#{response.code} ERROR\"\r\n end\r\n end", "def update\n respond_to do |format|\n if @schedule_cohort_period.update(schedule_cohort_period_params)\n format.html { redirect_to @schedule_cohort_period}\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @schedule_cohort_period.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @vacation_period.update(vacation_period_params)\n format.html { redirect_to @vacation_period, notice: 'Vacation period was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @vacation_period.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @timeline = Timeline.find(params[:id])\n\n respond_to do |format|\n if @timeline.update_attributes(params[:timeline])\n flash[:notice] = 'Timeline was successfully updated.'\n format.html { redirect_to([:admin, @timeline]) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @timeline.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @periodismo = Periodismo.find(params[:id])\n\n respond_to do |format|\n if @periodismo.update_attributes(params[:periodismo])\n format.html { redirect_to @periodismo, notice: 'Periodismo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @periodismo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @quarter = Quarter.find(params[:id])\n\n respond_to do |format|\n if @quarter.update_attributes(params[:quarter])\n format.html { redirect_to(@quarter, :notice => 'Quarter was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @quarter.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update!(**args)\n @hours_type_id = args[:hours_type_id] if args.key?(:hours_type_id)\n @periods = args[:periods] if args.key?(:periods)\n end", "def update\n resource.update(deposit_contract_params)\n respond_with client, resource\n end", "def update\n @league = League.find(params[:id])\n starts_at = Time.parse(params[:starts_at])\n finishes_at = Time.parse(params[:finishes_at])\n respond_to do |format|\n if @league.update_attributes(params[:league].merge(:starts_at => starts_at, :finishes_at => finishes_at))\n flash[:notice] = 'Liga bola úspešne zmenená.'\n format.html { redirect_to(@league) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @league.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @periods_group.update(periods_group_params)\n format.html { redirect_to company_periods_group_path(@company, @periods_group), notice: 'Periods group was successfully updated.' }\n format.json { render :show, status: :ok, location: @periods_group }\n else\n format.html { render :edit }\n format.json { render json: @periods_group.errors, status: :unprocessable_entity }\n end\n end\n end", "def periods_params\n params.require(:period).permit(:name, :comment, :start_date, :end_date, :budget_id)\n end", "def update\n @periodo_academico = PeriodoAcademico.find(params[:id])\n\n if @periodo_academico.update(params[:periodo_academico])\n head :no_content\n else\n render json: @periodo_academico.errors, status: :unprocessable_entity\n end\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def update\n @outcome_timepoint = OutcomeTimepoint.find(params[:id])\n\n respond_to do |format|\n if @outcome_timepoint.update_attributes(params[:outcome_timepoint])\n format.html { redirect_to(@outcome_timepoint, :notice => 'Outcome timepoint was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @outcome_timepoint.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @ayudastemporal = Ayudastemporal.find(params[:id])\n\n respond_to do |format|\n if @ayudastemporal.update_attributes(params[:ayudastemporal])\n flash[:notice] = 'Ayudastemporal was successfully updated.'\n format.html { redirect_to(@ayudastemporal) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ayudastemporal.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_update_volumes(username, token, workset_name, volume_ids)\n\n #<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n #<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">\n # <volume>\n # <id>9999999</id>\n # </volume>\n # <volume>\n # <id>3333333</id>\n # </volume>\n # </volumes>\n volumes_xml =\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\" +\n \"<volumes xmlns=\\\"http://registry.htrc.i3.illinois.edu/entities/workset\\\">\";\n\n for id in volume_ids\n volumes_xml += \"<volume><id>#{id}</id></volume>\"\n end\n volumes_xml += \"</volumes>\"\n\n\n # curl -v --data @new_volumes.xml -X PUT \\\n # -H \"Content-Type: application/vnd.htrc-volume+xml\" \\\n # -H \"Accept: application/vnd.htrc-volume+xml\" \\\n # http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred\n\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Put.new(url.path)\n request[\"Content-Type\"] = \"application/vnd.htrc-volume+xml\"\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n\n request.body = volumes_xml\n response = http.request(request)\n\n #xml = response.body\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error retrieving worksets (HTTP #{response.code})\")\n end\n end", "def update\n respond_to do |format|\n if @scholarship_period.update(scholarship_period_params)\n format.html { redirect_to @scholarship_period, notice: 'Период степендии успешно отредактирован.' }\n format.json { render :show, status: :ok, location: @scholarship_period }\n else\n format.html { render :edit }\n format.json { render json: @scholarship_period.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @chart = Chart.find(params[:id])\n\n respond_to do |format|\n if @chart.update_attributes(params[:chart])\n format.html { redirect_to(@chart, :notice => 'Chart was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @chart.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @chart = Chart.find(params[:id])\n\n respond_to do |format|\n if @chart.update_attributes(params[:chart])\n format.html { redirect_to(@chart, :notice => 'Chart was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @chart.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @chart = Chart.find(params[:id])\n\n respond_to do |format|\n if @chart.update_attributes(params[:chart])\n format.html { redirect_to(@chart, :notice => 'Chart was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @chart.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 @range_specification = RangeSpecification.find(params[:id])\n\n respond_to do |format|\n if @range_specification.update_attributes(params[:range_specification])\n format.html { redirect_to(@range_specification, :notice => 'Range specification was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @range_specification.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n study_period_params.permit!\n @study_period.study_year = @year\n respond_to do |format|\n if @study_period.update(study_period_params)\n format.html { redirect_to study_year_study_periods_path(current_user.current_year), notice: 'Учебный отрезок успешно обновлен.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @study_period.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @stock_interval.update(stock_interval_params)\n format.html { redirect_to @stock_interval, notice: 'Stock interval was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @stock_interval.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_volumes(username, token, workset_name, volume_ids)\n\n #<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n #<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">\n # <volume>\n # <id>9999999</id>\n # </volume>\n # <volume>\n # <id>3333333</id>\n # </volume>\n # </volumes>\n volumes_xml =\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\" +\n \"<volumes xmlns=\\\"http://registry.htrc.i3.illinois.edu/entities/workset\\\">\";\n\n for id in volume_ids\n volumes_xml += \"<volume><id>#{id}</id></volume>\"\n end\n volumes_xml += \"</volumes>\"\n\n\n # curl -v --data @new_volumes.xml -X PUT \\\n # -H \"Content-Type: application/vnd.htrc-volume+xml\" \\\n # -H \"Accept: application/vnd.htrc-volume+xml\" \\\n # http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred\n\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}/volumes\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Put.new(url.request_uri)\n request[\"Content-Type\"] = \"application/vnd.htrc-volume+xml\"\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n\n request.body = volumes_xml\n response = http.request(request)\n\n #xml = response.body\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error retrieving worksets (HTTP #{response.code})\")\n end\n\n end", "def 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 respond_with Expense.update(params[:id], expense_params), status: 204\n end", "def set_period\n redirect_to @school, :alert => \"That period does not exist.\" unless @period = @school.periods.find_by_id(params[:id])\n end", "def update\n\n respond_to do |format|\n if @registration_period.update_attributes(registration_period_params)\n format.html { redirect_to @registration_period, notice: 'Registration period was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @registration_period.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @period = Period.new(params[:period])\n\n if @period.save\n render json: @period, status: :created, location: @period\n else\n render json: @period.errors, status: :unprocessable_entity\n end\n end", "def update\n @person = Person.find(params[:id])\n\n respond_to do |format|\n if @person.update_attributes(params[:person])\n updated = params[:availabilities].keys.map(&:to_i)\n #existing = @person.availabilities.map(&:timeslot_id)\n #new = updated - existing\n #deleted = existing - updated\n #@person.availabilities.delete(deleted.map{|d| @person.availabilities.find_by_timeslot_id(d)})\n @person.availabilities=(updated.map{|t| @person.availabilities.find_or_create_by_timeslot_id(t)})\n flash[:notice] = 'Person was successfully updated.'\n format.html { redirect_to(@person) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @person.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_periodic\n @periodic = Periodic.find(params[:id])\n end", "def set_periodic\n @periodic = Periodic.find(params[:id])\n end", "def test_put_expenses_1_xml\n @parameters = {:expense => {:description => 'NewDescription'}}\n if ActiveRecord::VERSION::MAJOR < 4\n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/expenses/1.xml',\n {:expense => {:description => 'NewDescription'}},\n {:success_code => :ok})\n end\n\n assert_no_difference('Expense.count') do\n put '/expenses/1.xml', @parameters, credentials('admin')\n end\n\n expense = Expense.find(1)\n assert_equal \"NewDescription\", expense.description\n end", "def update\n @arrival_range = ArrivalRange.find(params[:id])\n\n respond_to do |format|\n if @arrival_range.update_attributes(params[:arrival_range])\n format.html { redirect_to @arrival_range, notice: 'Arrival range was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @arrival_range.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @dept = Dept.find(params[:id])\n \n #comando para transformar as \"/\" para \".\" pois o sistema nao le datas com \"/\"\n params[:dept][:started_at].gsub!(\"/\",\".\")\n params[:dept][:finished_at].gsub!(\"/\",\".\")\n\n respond_to do |format|\n if @dept.update_attributes(params[:dept])\n format.html { redirect_to @dept, :notice => 'Departamento atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @dept.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_time_period\n @time_period = TimePeriod.find(params[:id])\n rescue ActiveRecord::RecordNotFound => e\n render json: e.message.to_json, status: :not_found\n end", "def update\n respond_to do |format|\n if @receipt_period.update(receipt_period_params)\n format.html { redirect_to @receipt_period, notice: 'Receipt period was successfully updated.' }\n format.json { render :show, status: :ok, location: @receipt_period }\n else\n format.html { render :edit }\n format.json { render json: @receipt_period.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @deadline = Deadline.find(params[:id])\n respond_to do |format|\n if @deadline.update_attributes(params[:deadline])\n format.html { redirect_to(@deadline, :notice => 'Question was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @deadline.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put_datastream(pid, dsID, xml)\n uri = URI.parse(@fedora + '/objects/' + pid + '/datastreams/' + dsID ) \n RestClient.put(uri.to_s, xml, :content_type => \"application/xml\")\n rescue => e\n e.response \n end", "def update\n respond_to do |format|\n if @pay_period.update(pay_period_params)\n format.html { redirect_to @pay_period, notice: 'Pay period was successfully updated.' }\n format.json { render :show, status: :ok, location: @pay_period }\n else\n format.html { render :edit }\n format.json { render json: @pay_period.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @service_period = args[:service_period] if args.key?(:service_period)\n end", "def create\n @period = Period.new(params[:period])\n\n respond_to do |format|\n if @period.save\n flash[:notice] = 'Period was successfully created.'\n format.html { redirect_to(@period) }\n format.xml { render :xml => @period, :status => :created, :location => @period }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @period.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_tenant_maintenance_window(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/maintenance/{tenantId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def update\n @historical = Historical.find(params[:id])\n\n respond_to do |format|\n if @historical.update_attributes(params[:historical])\n format.html { redirect_to @historical, notice: 'Historical was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @historical.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @appointment = person.appointments.find(params[:id])\n respond_to do |format|\n if @appointment.update_attributes(params[:appointment])\n format.html { redirect_to([person, @appointment], :notice => 'Appointment was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @appointment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def destroy\n @time_period.destroy\n format.json { head :no_content }\n end", "def update\n @page_title = \"Data Points\"\n @data_point = DataPoint.find(params[:id])\n\n respond_to do |format|\n if @data_point.update_attributes(params[:data_point])\n flash[:notice] = 'DataPoint was successfully updated.'\n format.html { redirect_to(@data_point) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @data_point.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @outcome_timepoint = OutcomeTimepoint.find(params[:id])\n\t@outcome_timepoint.update_attributes(params[:outcome_timepoint])\n end", "def update\n @tso = Tso.find(params[:id])\n\n respond_to do |format|\n if @tso.update_attributes(params[:tso])\n flash[:notice] = 'Tso was successfully updated.'\n format.html { redirect_to(@tso) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tso.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @timechart = Timechart.find(params[:id])\n\n respond_to do |format|\n if @timechart.update_attributes(params[:timechart])\n format.html { redirect_to @timechart, notice: 'Timechart was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @timechart.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @klass.update(klass_params)\n format.html { redirect_to management_klasses_path }\n format.json { render :json => @klass.to_json(include: :period), status: :ok }\n else\n format.html { render :edit }\n format.json { render json: @klass.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @segment = Segment.find(params[:id])\n\n respond_to do |format|\n if @segment.update_attributes(params[:segment])\n flash[:notice] = 'Segment was successfully updated.'\n format.html { redirect_to(@segment) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @segment.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_rest\n @instrument_version = InstrumentVersion.find(params[:id])\n\n respond_to do |format|\n if @instrument_version.update_attributes(params[:instrument_version])\n flash[:notice] = 'InstrumentVersion was successfully updated.'\n format.html { redirect_to(@instrument_version) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @instrument_version.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @period = Period.new(params[:period])\n\n respond_to do |format|\n if @period.save\n flash[:notice] = _('%s was successfully created.', Period.human_name)\n format.html { redirect_to period_url(@period) }\n format.xml { head :created, :location => period_url(@period) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @period.errors.to_xml }\n end\n end\n end", "def update\n @absence = Absence.find(params[:id])\n\n respond_to do |format|\n if @absence.update_attributes(params[:absence])\n format.html { redirect_to @absence, notice: 'Absence was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @absence.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @timing = Timing.find(params[:id])\n\n respond_to do |format|\n if @timing.update_attributes(params[:timing])\n flash[:notice] = 'Timing was successfully updated.'\n format.html { redirect_to(@timing) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @timing.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @live_stream_series = LiveStreamSeries.find(params[:id])\n\n respond_to do |format|\n if @live_stream_series.update_attributes(params[:live_stream_series])\n format.html { redirect_to(@live_stream_series, :notice => 'Live stream series was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @live_stream_series.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @time_slot = TimeSlot.find(params[:id])\n\n respond_to do |format|\n if @time_slot.update_attributes(params[:time_slot])\n flash[:notice] = 'TimeSlot was successfully updated.'\n format.html { redirect_to(@time_slot) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @time_slot.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @spent_point = SpentPoint.find(params[:id])\n\n respond_to do |format|\n if @spent_point.update_attributes(params[:spent_point])\n format.html { redirect_to(@spent_point, :notice => 'SpentPoint was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @spent_point.errors, :status => :unprocessable_entity }\n end\n end\n end", "def destroy\n @period = Period.find(params[:id])\n @period.destroy\n\n head :no_content\n end" ]
[ "0.6484507", "0.6446026", "0.63587046", "0.624536", "0.624536", "0.624536", "0.624536", "0.61596715", "0.5921498", "0.58854413", "0.5867411", "0.58646244", "0.5809602", "0.5785171", "0.5784812", "0.57740974", "0.572615", "0.5706911", "0.56858677", "0.56444556", "0.5569123", "0.5536889", "0.5536889", "0.5536889", "0.5501124", "0.5483893", "0.5458094", "0.544204", "0.54149085", "0.5412448", "0.54118204", "0.5401915", "0.53983206", "0.5374025", "0.5329453", "0.5323855", "0.5304056", "0.5299036", "0.528788", "0.5281249", "0.52770835", "0.5276668", "0.52762127", "0.5254321", "0.5249712", "0.5247094", "0.52438074", "0.5242013", "0.5241838", "0.5241201", "0.52391815", "0.52308863", "0.5209859", "0.5205563", "0.5203524", "0.5201857", "0.5199941", "0.5199941", "0.5199941", "0.5197524", "0.51844543", "0.51812047", "0.51811063", "0.51554185", "0.5149657", "0.51476854", "0.51323813", "0.5127803", "0.51215744", "0.5109244", "0.51078707", "0.51078707", "0.51073927", "0.5099049", "0.5096959", "0.50942594", "0.5092658", "0.50900245", "0.50878143", "0.50872034", "0.5085248", "0.50851095", "0.50836486", "0.50681186", "0.5055642", "0.5052654", "0.505138", "0.5043536", "0.5043447", "0.5037336", "0.50372136", "0.5033346", "0.5031667", "0.50313544", "0.5024489", "0.5022434", "0.50174797", "0.5015574", "0.50146466", "0.501328" ]
0.6023743
8
DELETE /periods/1 DELETE /periods/1.xml
def destroy @period = Period.find(params[:id]) @period.destroy respond_to do |format| format.html { redirect_to( cursus_periods_path(@cursus) ) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @period = Period.find(params[:id])\n @period.destroy\n\n respond_to do |format|\n format.html { redirect_to(periods_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @period = Period.find(params[:id])\n @period.destroy\n\n respond_to do |format|\n format.html { redirect_to periods_url }\n format.xml { head :ok }\n end\n end", "def destroy\n @period.destroy\n\n head :no_content\n end", "def destroy\n @period = Period.find(params[:id])\n @period.destroy\n\n head :no_content\n end", "def destroy\n @pay_period = PayPeriod.find(params[:id])\n @pay_period.destroy\n\n respond_to do |format|\n format.html { redirect_to(pay_periods_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @periodista = Periodista.find(params[:id])\n @periodista.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_periodistas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @time_period.destroy\n format.json { head :no_content }\n end", "def destroy\n @tb_period = TbPeriod.find(params[:id])\n @tb_period.destroy\n\n respond_to do |format|\n format.html { redirect_to tb_periods_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @period.destroy\n respond_to do |format|\n format.html { redirect_to periods_url, notice: 'Periode Telah Dihapus.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @resource_period = ResourcePeriod.find(params[:id])\n @resource_period.destroy\n\n respond_to do |format|\n format.html { redirect_to(resource_periods_url) }\n format.json { 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 destroy\n @workperiod = Workperiod.find(params[:id])\n @workperiod.destroy\n\n respond_to do |format|\n format.html { redirect_to(workperiods_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @api_v1_frequency_period.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_frequency_periods_url, notice: 'Frequency period was successfully destroyed.' }\n format.json { head :no_content }\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 destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end", "def destroy\n @absence_request = AbsenceRequest.find(params[:id])\n @absence_request.destroy\n\n respond_to do |format|\n format.html { redirect_to(absence_requests_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @datetime.destroy\n\n respond_to do |format|\n format.html { redirect_to request.env['HTTP_REFERER'] }\n format.xml { head :ok }\n end\n end", "def destroy\n @periodic.destroy\n respond_to do |format|\n format.html { redirect_to periodics_url, notice: 'Periódico excluido com sucesso.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @periodismo = Periodismo.find(params[:id])\n @periodismo.destroy\n\n respond_to do |format|\n format.html { redirect_to periodismos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sleep_log = SleepLog.find(params[:id])\n @sleep_log.destroy\n\n respond_to do |format|\n format.html { redirect_to(sleep_logs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @period.destroy\n respond_to do |format|\n format.html { redirect_to @period.school, notice: 'Period was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @bare_start = BareStart.find(params[:id])\n @bare_start.destroy\n\n respond_to do |format|\n format.html { redirect_to(bare_starts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @deposit_threshold = DepositThreshold.find(params[:id])\n @deposit_threshold.destroy\n\n respond_to do |format|\n format.html { redirect_to(deposit_thresholds_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @estacion = Estacion.find(params[:id])\n @estacion.destroy\n\n respond_to do |format|\n format.html { redirect_to(estaciones_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @quartz = Quartz.find(params[:id])\n @quartz.destroy\n\n respond_to do |format|\n format.html { redirect_to(quartzs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @period = Period.find(params[:id])\n if @period.destroy\n session[:period] = @organism.periods.any? ? @organism.periods.order(:close_date).last.id : nil\n flash[:notice] = 'L\\'exercice a été détruit ; vous avez changé d\\'exercice'\n end\n respond_to do |format|\n format.html do\n redirect_to admin_organism_periods_url(@organism)\n end\n format.json { head :ok }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @prd_etc = PrdEtc.find(params[:id])\n @prd_etc.destroy\n\n respond_to do |format|\n format.html { redirect_to(prd_etcs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @vacation_period.destroy\n respond_to do |format|\n format.html { redirect_to vacation_periods_url }\n format.json { head :no_content }\n end\n end", "def delete(id)\n request = Net::HTTP::Delete.new(\"#{@url}/#{id}.xml\")\n http = Net::HTTP.new(@uri.host, @uri.port)\n response = http.request(request)\n\n # no response body will be returned\n case response\n when Net::HTTPSuccess\n return \"#{response.code} OK\"\n else\n return \"#{response.code} ERROR\"\n end\n end", "def destroy\n client = Connection::MarkLogic.new.client\n client.send_corona_request(\"/v1/documents?uri=/amandments/amandment_#{@amandment.id}.xml\", :delete)\n @amandment.destroy\n respond_to do |format|\n format.html { redirect_to home_meeting_path, notice: 'Amandman was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @periodic.destroy\n respond_to do |format|\n format.html { redirect_to periodics_url, notice: 'Periodic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @estatu = Estatu.find(params[:id])\n @estatu.destroy\n\n respond_to do |format|\n format.html { redirect_to(estatus_url) }\n format.xml { head :ok }\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 @periodo_academico = PeriodoAcademico.find(params[:id])\n @periodo_academico.destroy\n\n head :no_content\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 @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 @periods_group.destroy\n respond_to do |format|\n format.html { redirect_to company_periods_groups_path(@company), notice: 'Periods group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @dbs_deposit = DbsDeposit.find(params[:id])\n @dbs_deposit.destroy\n\n respond_to do |format|\n format.html { redirect_to(dbs_deposits_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n destroy_helper(@pay_period, pay_periods_url, \"Pay period\")\n end", "def delete\n Iterable.request(conf, base_path).delete\n end", "def destroy\n @evactivity = Evactivity.find(params[:id])\n @evactivity.destroy\n\n respond_to do |format|\n format.html { redirect_to(evactivities_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @activity = Activity.find(params[:id])\n @activity.destroy\n\n respond_to do |format|\n format.html { redirect_to :action => :plan_chart }\n format.xml { head :ok }\n end\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 @appointment_request = AppointmentRequest.find(params[:id])\n @appointment_request.destroy\n\n respond_to do |format|\n format.html { redirect_to(appointment_requests_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @duration.destroy\n\n head :no_content\n end", "def delete\n request(:delete)\n end", "def destroy\n @doseperiod.destroy\n respond_to do |format|\n format.html { redirect_to doseperiods_url, notice: 'Combination dose was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def destroy\n @audit_log = AuditLog.find(params[:id])\n @audit_log.destroy\n\n respond_to do |format|\n format.html { redirect_to(audit_logs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @quantile_period = QuantilePeriod.find(params[:id])\n @quantile_period.destroy\n\n respond_to do |format|\n format.html { redirect_to quantile_periods_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @today_activity = TodayActivity.find(params[:id])\n @today_activity.destroy\n\n respond_to do |format|\n format.html { redirect_to(today_activities_url) }\n format.xml { head :ok }\n end\n end", "def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end", "def deletepublish\n @question = Publishquiz.find(:all, :conditions=>\"question_id=\"+params[:question]+\" and quiz_id=\"+session[:quizid])\n @question[0].destroy\n\n respond_to do |format|\n format.html { redirect_to(questions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @dis_doseperiod.destroy\n respond_to do |format|\n format.html { redirect_to dis_doseperiods_url, notice: 'Dis doseperiod was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @aplicacion = Aplicacion.find(params[:id])\n @aplicacion.destroy\n\n respond_to do |format|\n format.html { redirect_to(aplicacions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @t1 = T1.find(params[:id])\n @t1.destroy\n\n respond_to do |format|\n format.html { redirect_to(t1s_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @study_period.destroy\n respond_to do |format|\n format.html { redirect_to study_year_study_periods_path(current_user.current_year) }\n format.json { head :no_content }\n end\n end", "def destroy\n @schedule_cohort_period.destroy\n respond_to do |format|\n format.html { redirect_to schedule_cohort_periods_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @applicant_status = ApplicantStatus.find(params[:id])\n @applicant_status.destroy\n\n respond_to do |format|\n format.html { redirect_to(applicant_statuses_url) }\n format.xml { head :ok }\n end\n end", "def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end", "def delete_data\n response = WebPay.client.delete([path, 'data'].join('/'))\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", "def destroy\n @scholarship_period.destroy\n respond_to do |format|\n format.html { redirect_to scholarship_periods_url, notice: 'Период степендии успешно удален.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @authorization_period = AuthorizationPeriod.find(params[:id])\n#check if there are any visits with this patient before deleting\n\t\t@visit = Visit.find_all_by_authorization_id(@authorization_period)\n\t\tif @visit.empty?\n \t@authorization_period.destroy\n\t\telse\n\t\t\tflash[:notice] = \"This Authorization Period is associated with a visit.It cannot be destroyed.\"\n\t\tend\n\n respond_to do |format|\n format.html { redirect_to(authorization_periods_url) }\n format.xml { head :ok }\n end\n end", "def delete_by_id id, opts = {}\n update opts.merge(:data => xml.delete_by_id(id))\n end", "def destroy\n @pay_period.destroy\n respond_to do |format|\n format.html { redirect_to pay_periods_url, notice: 'Pay period was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @deadline = Deadline.find(params[:id])\n @deadline.destroy\n respond_to do |format|\n format.html { redirect_to(deadlines_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @data_set.destroy\n\n respond_to do |format|\n format.html { redirect_to(data_sets_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @recurring.destroy\n respond_to do |format|\n format.html { redirect_to(account_recurrings_path(@account)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @derivative = Derivative.find(params[:id])\n @derivative.destroy\n\n respond_to do |format|\n format.html { redirect_to(derivatives_url) }\n format.xml { head :ok }\n end\n end", "def delete(slide)\n # ./_rels/presentation.xml.rels\n # Update Relationship ids\n # Insert a new one slideRef\n @doc.edit_xml @doc.presentation.rels.path do |xml|\n # Calucate the next id\n # next_id = xml.xpath('//xmlns:Relationship[@Id]').map{ |n| n['Id'] }.sort.last.succ\n # TODO - Figure out how to make this more MS idiomatic up 9->10 instead of incrementing\n # the character....\n # Insert that into the slide and crakc open the presentation.xml file\n\n target = slide.path.relative_path_from(@doc.presentation.path.dirname)\n relationship = xml.at_xpath(\"/xmlns:Relationships/xmlns:Relationship[@Type='#{Slide::REL_TYPE}' and @Target='#{target}']\")\n # ./presentation.xml\n # Update attr\n # p:notesMasterId\n # Insert attr\n # p:sldId, increment, etc.\n @doc.edit_xml '/ppt/presentation.xml' do |xml|\n xml.at_xpath(\"/p:presentation/p:sldIdLst/p:sldId[@r:id='#{relationship['Id']}']\").remove\n end\n relationship.remove\n end\n\n # Delete slide link and slideNotes link from ./[Content-Types].xml \n @doc.edit_xml @doc.content_types.path do |xml|\n xml.at_xpath(\"/xmlns:Types/xmlns:Override[@ContentType='#{Slide::CONTENT_TYPE}' and @PartName='#{slide.path}']\").remove\n xml.at_xpath(\"/xmlns:Types/xmlns:Override[@ContentType='#{Notes::CONTENT_TYPE}' and @PartName='#{slide.notes.path}']\").remove\n end\n\n # Update ./ppt\n # !!! DESTROY !!!\n # ./slides\n # Delete files\n # ./_rels/notesSlide(\\d+).xml.rels\n @doc.delete slide.notes.rels.path\n # ./notesSlide(\\d+).xml file\n @doc.delete slide.notes.path\n # ./_rels/slide(\\d+).xml.rels\n @doc.delete slide.rels.path\n # ./slide(\\d+).xml file\n @doc.delete slide.path\n # ./notesSlides\n # Delete files\n\n # Hooray! We're done! Ummm, what should we return though? can't be the slide since\n # its destroyed and there's no practical way to keep it around in memory.\n end", "def delete\n period = Period.find(params[:per_id])\n\n if period.activ == false\n flash[:notice] = \"Sesiunea a fost stearsa cu succes\"\n period.destroy\n redirect_to '/periods'\n else\n flash[:notice] = \"Sesiunea este activa in momentul de fata si nu poate fi stearsa\"\n redirect_to '/periods'\n end\n end", "def destroy\n @appointment = Appointment.find(params[:id])\n @appointment.destroy\n\n respond_to do |format|\n format.html { redirect_to(appointments_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @appointment = Appointment.find(params[:id])\n @appointment.destroy\n\n respond_to do |format|\n format.html { redirect_to(appointments_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @appointment = Appointment.find(params[:id])\n @appointment.destroy\n\n respond_to do |format|\n format.html { redirect_to(appointments_url) }\n format.xml { head :ok }\n end\n end", "def delete\n start { |connection| connection.request http :Delete }\n end", "def destroy\n @decision = Decision.find(params[:id])\n @decision.destroy\n\n respond_to do |format|\n format.html { redirect_to(decisions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @receipt_period.destroy\n respond_to do |format|\n format.html { redirect_to receipt_periods_url, notice: 'Receipt period was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @chart = Chart.find(params[:id])\n @chart.destroy\n\n respond_to do |format|\n format.html { redirect_to(charts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n Audit.find(params[:id]).destroy\n head :no_content\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 destroy\n @chart = Chart.find(params[:id])\n @chart.destroy\n\n respond_to do |format|\n format.html { redirect_to(:controller => \"charts\", :action => \"area_chart\") }\n format.xml { head :ok }\n end\n end", "def destroy\n @registration_period.destroy\n\n respond_to do |format|\n format.html { redirect_to registration_periods_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @appointment = person.appointments.find(params[:id])\n @appointment.destroy\n respond_to do |format|\n format.html { redirect_to(patient_appointments_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @docent = Docent.find(params[:id])\n @docent.destroy\n\n respond_to do |format|\n format.html { redirect_to(docents_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @dataset = Dataset.find(params[:id])\n @dataset.destroy\n\n respond_to do |format|\n format.html { redirect_to datasets_url }\n format.xml { head :ok }\n end\n end", "def destroy\n @holiday_song_period = HolidaySongPeriod.find(params[:id])\n @holiday_song_period.destroy\n\n respond_to do |format|\n format.html { redirect_to holiday_song_periods_url }\n format.json { head :ok }\n end\n end", "def destroy\n @page_title = \"Data Points\"\n @data_point = DataPoint.find(params[:id])\n @data_point.destroy\n\n respond_to do |format|\n format.html { redirect_to(data_points_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @withdrawal = Withdrawal.find(params[:id])\n @withdrawal.destroy\n\n respond_to do |format|\n format.html { redirect_to(withdrawals_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @ayudastemporal = Ayudastemporal.find(params[:id])\n @ayudastemporal.destroy\n\n respond_to do |format|\n format.html { redirect_to(ayudastemporales_url) }\n format.xml { head :ok }\n end\n end", "def delete(id)\r\n connection.delete(\"/#{@doctype}[@ino:id=#{id}]\")\r\n end", "def destroy\n @adjunto = Adjunto.find(params[:id])\n @adjunto.destroy\n\n respond_to do |format|\n format.html { redirect_to(adjuntos_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 destroy\n @draft_investment = DraftInvestment.find(params[:id])\n @draft_investment.destroy\n\n respond_to do |format|\n\n format.xml { head :ok }\n end\n end", "def delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end", "def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end" ]
[ "0.7264833", "0.71584725", "0.7007135", "0.6955837", "0.66590405", "0.66505784", "0.664139", "0.64905083", "0.63941115", "0.63855994", "0.63625205", "0.63281256", "0.62490964", "0.62490135", "0.6228565", "0.62008375", "0.617587", "0.6149636", "0.6128786", "0.6108364", "0.6105144", "0.6082308", "0.6073539", "0.6072066", "0.6059854", "0.60566276", "0.6053341", "0.6047894", "0.6036558", "0.6035743", "0.60349834", "0.6024962", "0.6022626", "0.60085326", "0.6007177", "0.5994901", "0.5994177", "0.599016", "0.59878176", "0.5986119", "0.5972634", "0.59693265", "0.59615785", "0.59541404", "0.5945578", "0.5938212", "0.59343", "0.5925797", "0.59199977", "0.59199977", "0.59199977", "0.59199977", "0.5909881", "0.59066856", "0.5903726", "0.5902186", "0.5901676", "0.5901665", "0.5901297", "0.59008074", "0.59005696", "0.58987653", "0.58958", "0.589447", "0.5891634", "0.58868617", "0.5884745", "0.5881667", "0.5880798", "0.5879813", "0.58774513", "0.5875753", "0.5874094", "0.5873414", "0.58728856", "0.5872584", "0.5868504", "0.5868504", "0.5868504", "0.58663523", "0.5864738", "0.5863758", "0.5863413", "0.58586615", "0.5851545", "0.58514833", "0.5848633", "0.58436805", "0.5841883", "0.58416945", "0.58416015", "0.58412415", "0.58388466", "0.58386546", "0.58322346", "0.58320713", "0.5829659", "0.5829131", "0.5828363", "0.5827926" ]
0.67554444
4
The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... Let us list the factors of the first seven triangle numbers: 1: 1 3: 1,3 6: 1,2,3,6 10: 1,2,5,10 15: 1,3,5,15 21: 1,3,7,21 28: 1,2,4,7,14,28 We can see that 28 is the first triangle number to have over five divisors. What is the value of the first triangle number to have over five hundred divisors? From StackOverflow: Hints: what is the formula for nth triangular number? n and n+1 have no common factors (except 1). Question: given number of factors in n and n+1 how to calculate number of factors in n(n+1)? What about n/2 and (n+1) (or n and (n+1)/2)? if you know all prime factors of n how to calculate number of divisors of n?
def sieve(x) s = (0..x.to_i).to_a s[0] = s[1] = nil s.each{ |p| # Perform the block for each entry in the array. next unless p # Iterate on next array value if entry is nil break if p * p > x # Cease iteration if p*p > max_value (p*p).step(x, p) { |m| s[m] = nil } # Starting at p*p, set every p-th value to "nil" until max_value } s = s.compact end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def triangle_divisors(n)\n count = 2\n triangle = 1\n \n while\n triangle += count\n puts \"triangle is #{triangle}\"\n if number_of_factors(triangle) > n\n return triangle\n end\n count += 1\n end\nend", "def triangle_divisor(divisor)\r\n\tstep = 1\r\n\ttriangle = 0\r\n\tcount = 0\r\n\r\n\twhile count < divisor\r\n\t\tcount = 0\r\n\t\ttriangle += step\r\n\t\t#Start counting factors for triangle\r\n\t\t#Only need to go up to sqrt of triangle for factors\r\n\t\t(1..Math.sqrt(triangle)).each do |n|\r\n\t\t\t#If a factor set, increase count by 2\r\n\t\t\tif triangle%n == 0\r\n\t\t\t\tunless n**2 == triangle\r\n\t\t\t\t\tcount += 2\r\n\t\t\t\t#If a perfect square, only increase count by 1\r\n\t\t\t\telse\r\n\t\t\t\t\tcount +=1\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\tend\r\n\t\tstep += 1\r\n\tend\r\n\tputs triangle\r\nend", "def triangle_number_with_gt_n_divisors(n)\n triangle_number = 1\n num_to_add = 2\n while divisors(triangle_number) <= n\n triangle_number = triangle_number + num_to_add\n num_to_add += 1\n end\n triangle_number\nend", "def first_triangle_number_with_divisors_of(num)\n\tcount = 0\n\ti = 0\n\tsum = 0\n\tuntil count >= num do\n\t\ti += 1\n\t\tsum += i\n\t\tcount = divisor_number_of(sum)\n\tend\n\tsum\nend", "def triangle_num\n\ndivisors = 0\nn = 2\n\nuntil divisors > 500\n\tsum = 0\n\t(1..n).to_a.each do |x| sum += x end\n\t(1..sum - 1).to_a.each do |y|\n\t\tif sum % y == 0\n\t\t\tdivisors += 1\n\t\t\tif divisors > 500 \n\t\t\t\treturn sum\n\t\t\tend\n\t\tend\n\tend\ndivisors = 0\nn += 1\nend\nend", "def generate_triangle_number(n)\n triangle_number = 0\n i = n\n until i == 0 \n triangle_number += i\n i -= 1\n end\n evaluate_divisors(triangle_number)\nend", "def triangle_num\n num = 0\n i = 1\n while (num_of_divisors num) < 500\n # get triangle number\n num += i\n i += 1\n end\n num\nend", "def triangle_number_of(number)\n # Using the standard formula for the sum of the first n integers\n number * (number + 1) / 2\nend", "def find_factors\n 1.upto(@triangle_number / 2) do |possible_factor|\n @factors.push(possible_factor) if @triangle_number % possible_factor == 0\n end\nend", "def triangular_number_with_n_divisitors(num)\r\n\trunner = 0\r\n\ti = 2\r\n\twhile runner < num do\r\n\t\ti += 1\r\n\t\trunner = triangular_number_of_divisitors(i)\r\n\tend\r\nend", "def factors(number)\n divisors = []\n # 1 is always a divisor\n divisors << 1\n if number > 1\n # target number is also always a divisor\n divisors << number\n # start looking for other divisors from 2 on up.\n i = 2\n while (i <= Math.sqrt(number).to_i)\n # if number is evenly divisible by i, then retain i, and possibly also\n # the division of number/i.\n if (number % i == 0)\n divisors << i\n divisors << number/i if (i != number/i)\n end\n i += 1\n end\n divisors.sort!\n end\n divisors\nend", "def factors(noriginal) # gives n's proper divisors\n factors = [1] # 1 is always a factor. Exclude n to get \"proper divisors\"\n f = 2\n\n begin\n n = noriginal\n\n while f * f <= n # Only check up to sqrt(n)\n if n % f == 0\n factors << f << n / f \n n /= f\n else\n\n f += 1\n if noriginal % f == 0 # catches divisors you missed with n < noriginal\n factors << f << noriginal / f\n end\n end\n end \n\n f += 1\n end until f * f > noriginal # Overall, only check up to sqrt(noriginal)\n\n factors.uniq.sort # sort and remove duplicates\nend", "def nth_triangle_number(n)\n n * (n + 1) / 2\nend", "def triangularNumber n\n # closed-form expression for the sum of the first \"n\" counting numbers\n # i.e. 1+2+...+n\n thisNum = (n * (n + 1) / 2)\n return thisNum\nend", "def evaluate_divisors(triangle_number)\n i = 1 \n divisors = [] \n # Make use of the pairs that multiplied together equal the triangle number. \n # Take 100. 1x100, 2x50, 4X25, 5x20, 10x10\n # This way, only have to iterate up to the square root of triangle number. \n until i > Math.sqrt(triangle_number)\n if triangle_number % i == 0 \n divisors << i\n temp = triangle_number / i \n # Prevent dups. Example 10x10 = 100.\n unless temp == i \n divisors << temp\n end \n end\n i += 1\n end \n \n if divisors.count > 500\n puts \"#{triangle_number} is the first triangle number with more than 500 divisors.\"\n puts \"Divisors count: #{divisors.count}\"\n @solved = true \n end \n \nend", "def euler012\n each_triangle_number do |n, index|\n return n if n.factors.size > 500\n end\nend", "def findFiveHundred(numberOfFactors)\n count = 1\n triangleNumber = 0\n factors = 0;\n while(factors <= numberOfFactors)\n triangleNumber = triangleNumber + count\n factors = countFactors(triangleNumber)\n\n if(factors > numberOfFactors)\n return triangleNumber\n end\n count += 1\n end\n\n\nend", "def solution(n)\n factors = 0\n (1..Math.sqrt(n)).each do |i|\n if n % i == 0\n factors += i == Math.sqrt(n) ? 1 : 2\n end\n end\n factors\nend", "def factors3(number)\n factors = []\n for n in 1..number do\n factors << number / n if number % n == 0\n end \n factors\nend", "def prime_factors\n n = self\n factors = Hash.new(0)\n\n # Pull out twos manually\n while n % 2 == 0 do\n factors[2] += 1\n n /= 2\n end\n\n # Then use Fermat's method\n a = Math.sqrt(n).ceil\n b2 = a**2 - n\n until (b2**0.5).round**2 == b2 do\n a += 1\n b2 = a**2 - n\n end\n\n candidates = [(a - Math.sqrt(b2)).round, (a + Math.sqrt(b2)).round]\n candidates.each do |candidate|\n next if candidate == 1\n if candidate == n\n factors[n] += 1\n else\n candidate_factors = candidate.prime_factors\n if candidate_factors.length == 1\n factors[candidate_factors.first] += 1\n else\n candidates.concat candidate_factors\n end\n end\n end\n \n expanded = []\n factors.each do |prime, count|\n count.times { expanded << prime }\n end\n expanded.sort\n end", "def factors( n )\n p = Primer.ld( n )\n return n if p == n\n factors n.div( p )\nend", "def factors_of(number)\n\t\tprimes, powers = number.prime_division.transpose\n\t\texponents = powers.map{|i| (0..i).to_a}\n\t\tdivisors = exponents.shift.product(*exponents).map do |powers|\n\t\t\tprimes.zip(powers).map{|prime, power| prime ** power}.inject(:*)\n\t\tend\n\t\tdivisors.sort.map{|div| [div, number / div]}\n\tend", "def factors(number)\n fs = [1,number]\n (2..Math.sqrt(number).to_i).each do |i|\n if number % i == 0\n fs << i\n fs << number/i unless number/i == i\n end\n end\n fs.sort\n end", "def counting_the_divisor\n i = 12370\n count = 0\n triagular_factor = 0\n loop do\n triagular_factor = triangular_number_logic(i)\n p triagular_factor\n count = divisors(triagular_factor)\n break if count > 500\n\n p count\n i += 1\n end\n p triagular_factor\n p count\nend", "def triangleNumber(n)\n n * (n + 1) / 2\nend", "def factors(number)\n divisor = number\n factors = []\n #begin\n\twhile divisor > 0\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n #end until divisor == 1\n\tend\n factors\nend", "def factors_of(n)\n result = []\n (1..n/2).each do |x|\n quotient, remainder = n.divmod x\n if remainder.zero?\n result << quotient\n result << x\n end\n end\n result.uniq\nend", "def factors_of(n)\n\tfactors = []\n\tsqrt = (Math.sqrt(n)).floor\n\t(1..sqrt).each do |f|\n\t\tif n % f == 0\n\t\t\tfactors << f\n\t\t\tfactors << n / f if (n / f) != f\n\t\tend\n\tend\n\tfactors.sort\nend", "def find_factors!\n (1..number).each do |n|\n break if @factors.include?(n)\n if number % n == 0\n @factors << n << (number / n)\n end\n end\n # handle any perfect squares\n\n @factors.uniq!\n end", "def sum_of_factors_of(number)\n \n require 'mathn'\t\n\n primes, powers = number.prime_division.transpose\n \n #converts the \"prime_division\" of variable \"number,\" which is a series of arrays\n #of arrays of the form (prime factor, powers), to two new arrays, primes and powers, \n #which is a tranposition of the rows and columns of prime_division (i.e., 1,1 is the \n #first prime factor and 1,2 is the first prime powers, and, after tranposition,\n #1,1 is likewise the first prime factor but 2,1 (1,2 transposed) is the first \n #powers)\n\n exponents = powers.map{|i| (0..i).to_a}\n\n #takes each power from the prime factor and creates a new array with all the exponents\n #less than the power, which are used to calculate the divisors\n\n#first takes each element of \"exponents\" and creates a new array, using product\n#function, containing all combos of each of the prime factor exponents with the \n#others (e.g., for 288, the output of exponents.shift.product(*exponents) is all pairs of\n#0-5, which is the exponents of 2^5, and 0-2, which is the exponents of 3^2)\n\n#the next section of code takes all the pairs generated in \"exponents\" and uses them on the \n#prime factors, which are then multiplied together. This process generates an exhaustive\n#and non-duplicative list of divisors. For example, with 288, first 2^0 * 3^0 is calculated, then \n#2^0 * 3^1, etc., until all pairs have been multiplied.\n\n\n divisors = exponents.shift.product(*exponents).map do |powers|\n primes.zip(powers).map{|prime, power| prime ** power}.inject(:*)\n end\n\n#remove the number itself, per the challenge\n\n divisors.delete_if {|x| x == number}\n\n#add all the divisors (less then number itself) together and return the value\n\n return divisors.inject(:+)\n \nend", "def factors(num)\r\n factors = []\r\n sqrt = Math.sqrt(num)\r\n until num == 1\r\n\r\n factor_founded = false\r\n (2..sqrt).each do |i|\r\n if (num % i).zero?\r\n num /= i\r\n factors << i\r\n factor_founded = true\r\n break\r\n end\r\n end\r\n unless factor_founded\r\n factors << num\r\n num /= num\r\n end\r\n end\r\n return factors\r\nend", "def factors n\n 1.upto(Math.sqrt(n)).select{ |x| (n % x).zero?}.inject([]) do |arr,x|\n arr << x\n arr << n/x unless x == n/x\n arr.sort\n end\nend", "def n_prime_factors(number)\n detected_primes = n_detected_prime_fatores(number)\n\n start_factor = @primes.last ? @primes.last + 1 : 2\n not_detected_primes = n_not_detected_prime_factors(start_factor, number)\n detected_primes + not_detected_primes\n end", "def proper_factors(n)\n f = []\n 1.step((n/2).to_i, 1).each do |x|\n if n % x == 0\n f.push(x)\n end\n end\n f.sort\nend", "def find_factors(num)\n raise ArgumentError, \"num must be >= 0\" if num < 0\n return [n] if num <= 1\n result = []\n\n n = num\n if n.even?\n while n % 2 == 0\n result << 2\n n /= 2\n end\n end\n\n div = 3\n\n while (n > 1)\n while n % div == 0\n result << div\n n /= div\n end\n div += 2\n\n if (div * div > n)\n result << n\n break\n end\n end\n\n result\nend", "def factors(number)\n divisors = []\n if number > 0 \n dividend = number\n begin\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end until dividend == 0\n divisors\n end\n divisors\nend", "def triangular_number(n)\n n * (n + 1) / 2 # You can also do reduce(:+) but this is way less calculations\nend", "def pascals_triangle(n)\n triangle = []\n (1..n).each do |line|\n level = []\n num = 1\n (1..line).each do |idx|\n level << num\n num = (num * (line - idx) / idx)\n end\n triangle << level\n end\n triangle\nend", "def triangle(n)\n (n *(n + 1)) / 2\nend", "def factors\n k = 1\n max = Math.sqrt(self).ceil\n lofacs = []\n hifacs = []\n while k <= max.ceil\n if (self.to_f/k) == (self.to_i/k)\n lofacs << k\n hifacs << self/k unless self/k == k\n end\n k += 1\n end\n lofacs + hifacs.reverse\n end", "def factor(n)\n n /= 2 while n.even?\n i = 3\n while i * i <= n\n n /= i while n % i == 0\n i += 2\n end\n n\nend", "def factors(number)\r\n divisor = number\r\n factors = []\r\n while divisor > 0 do \r\n factors << number / divisor if number % divisor == 0\r\n divisor -= 1\r\n end \r\n factors\r\nend", "def factors(number)\n dividend = number\n divisors = []\n while number >= 1\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n break if dividend == 0\n end\n divisors\nend", "def factors_new(number)\n divisors = []\n dividend = number\n while dividend > 0 \n begin\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end \n divisors\n end\n divisors\nend", "def factors(n)\n small_factors = []\n square_root = Math.sqrt(n)\n\n i = 1\n while i <= square_root\n small_factors << i if n % i == 0\n i += 1\n end\n\n large_factors = small_factors.map { |small_factor| n / small_factor }\n\n if small_factors.last * small_factors.last == n # if it's a perfect square\n return small_factors + large_factors[1...-1].reverse\n else\n return small_factors + large_factors.drop(1).reverse\n end\nend", "def get_divisors n\n n = n/2 if n % 2 == 0 \n divisors = 1\n count = 0\n while n % 2 == 0\n count += 1\n n = n/2\n end\n divisors *= (count + 1)\n p = 3\n while n != 1\n count = 0\n while n % p == 0\n count += 1\n n = n/p\n end\n divisors *= (count + 1)\n p += 2\n end\n #puts divisors\n return divisors\nend", "def factors(number)\n divisor = number\n factors = []\n while divisor > 0\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend", "def prime_factors(n)\n factors = []\n divisor = 2\n\n while n > 1\n if (n % divisor).zero?\n power = 0\n n /= divisor while (n % divisor).zero? && (power += 1)\n factors << \"(#{divisor}#{power > 1 ? \"**#{power}\" : ''})\"\n end\n divisor += 1\n end\n\n factors.join\nend", "def factors(number)\n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend", "def factors(number)\n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend", "def factors(number)\n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend", "def factors(number)\n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend", "def factors(number)\n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend", "def factors(number)\n divisor = number\n factors = []\n begin\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end until divisor == 0\n factors\nend", "def factors(number)\n # TODO: can optimise by only going up to the square of the number\n (1..number).select { |x| number % x == 0 }.count\nend", "def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend", "def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend", "def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend", "def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend", "def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend", "def factors(number)\n divisor = number\n factors = []\n while divisor > 0 do\n factors << number / divisor if number % divisor == 0\n divisor -= 1\n end\n factors\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n puts \"Prime!!\" if divisors.length < 3\n divisors\nend", "def fuck_the_factors(n)\n f = []\n i = 2\n while n > 1\n while n % i == 0\n f.push(i)\n n /= i\n end\n i += 1\n end\n return f\nend", "def n_prime_factors(number)\n n_prime = 0\n (2..number / 2).each do |n|\n next unless (number % n).zero?\n n_prime += 1 if Prime.prime?(n)\n end\n n_prime\n end", "def number_of_factors(n)\n # bruteforce, simplest\n # least efficient way\n count = 0\n\n (1..n).each do |i|\n if n % i == 0\n count += 1\n end\n end\n\n count\nend", "def prime_factors(n)\n factors = []\n d = 2\n while n > 1\n while n % d == 0\n factors << d\n n /= d\n end\n d = d + 1\n if d*d > n\n if n > 1\n factors << n\n break\n end\n end\n end\n return factors\nend", "def num_factors(n)\n pf = prime_factors(n)\n freq = Hash.new(0)\n pf.each{ |i| freq[i] += 1 }\n freq.inject(1){ |t,(k,v)| t * (v+1) }\nend", "def factors(number)\n dividend = number\n divisors = []\n begin\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end until dividend == 0\n divisors\nend", "def factors(number)\n dividend = number\n divisors = []\n begin\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end until dividend == 0\n divisors\nend", "def find_factors(number)\n\t# start with lowest prime number\n\tinteger = 2\n\n\t# make sure integer doesn't exceed the actual number\n\twhile integer <= number do\n\t\t# integer will be returned when if it is a factor of number\n\t\treturn integer if number % integer == 0\n\n\t\t# if integer is not a factor move to next integer\n\t\tinteger += 1\n\tend\nend", "def factors(number)\n dividend = 1\n divisors = []\n while dividend <= number\n divisors << dividend if number % dividend == 0\n dividend += 1\n end\n divisors\nend", "def factors(number)\n dividend = number\n divisors = []\n begin\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end until dividend == 0\ndivisors\nend", "def factors(number)\n dividend = number\n divisors = []\n number.times do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors(number)\n dividend = number\n divisors = []\n while number > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def prime_factors(n)\n factors = []\n old_n = n\n @primes.each { |prime|\n if @factors_hash[n]\n factors += @factors_hash[n]\n factors.uniq!\n break\n end\n if n % prime == 0\n factors.push(prime)\n n /= prime\n end\n break if prime >= n\n # If the remainder is a prime, add and break\n if @prime_hash[n]\n factors.push(n)\n break\n end\n }\n @factors_hash[old_n] = factors\n return factors\nend", "def factors1(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def prime_factors(number)\n divisors = []\n divisor = 2\n\n while number > 1\n if number % divisor == 0\n number /= divisor\n divisors << divisor\n else\n divisor += 1\n end\n end\n\n divisors.uniq\nend", "def prime_factors( n )\nend", "def p_triangle(n)\n (0..n).each{|i|\n list = [1]\n element = 1\n k = 1\n (0..i-1).step(1){|index|\n element = element * (i-k+1)/k\n list.push element \n k += 1\n }\n yield(list)\n }\nend", "def prime_factors(number)\n factors = []\n i = 0\n if prime?(number)\n return [number]\n else\n new_prime = @primes[-1] + 2\n while @primes[-1] * 2 <= number\n if prime?(new_prime)\n @primes << new_prime\n end\n new_prime += 2\n end\n while @primes[i] <= Math.sqrt(number)\n if number % @primes[i] == 0\n factors << @primes[i]\n number /= @primes[i]\n i = 0\n else\n i += 1\n end\n end\n factors << number\n end\n return factors\nend", "def factors(number)\n divisor = number\n factors = []\n loop do\n if number == 0 || number < 0\n break\n else factors << number / divisor if number % divisor == 0\n divisor -= 1\n break if divisor == 0\n end\n end\n factors\n end", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors\n factors = []\n for divisor in 2..(Math.sqrt(self).to_i)\n if self%divisor == 0\n factors << divisor \n factors << (self/divisor)\n end\n end\n return factors.sort!.reverse!\n end", "def factors(number)\n divisor = number\n factors = []\n while divisor > 0\n factors << (number / divisor) if ((number % divisor) == 0)\n divisor -= 1\n end\n factors\nend", "def factors\n all_factors = []\n (1..Math.sqrt(self).to_i).each do |x|\n all_factors.push(x, self/x) if (self % x == 0)\n end\n\n all_factors.sort.uniq\n end", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end \n divisors\nend", "def factors(num)\n (1..Math::sqrt(num)).each do |x|\n if num % x == 0\n puts x\n puts num/x\n end\n end\n nil\nend", "def prime_factors(n)\n\tfps = []\n\t# check for even\n\tif n % 2 == 0\n\t\tfps.push(2)\n\t\tn = div_factor(n, 2)\n\tend\n\t# check odd factors\n\tfact = 3\n\tmaxFact = Math.sqrt(n)\n\twhile n > 1 && fact < maxFact\n\t\tif n % fact == 0\n\t\t\tfps.push(fact)\n\t\t\tn = div_factor(n, fact)\n\t\t\tmaxFact = Math.sqrt(n)\n\t\tend\n\t\tfact = fact + 2\n\tend\n\tif n > fps.last\n\t\tfps.push(n)\n\tend\n\tfps.sort!\nend", "def list_factors(n)\r\n m = 0\r\n #even\r\n if (n % 2 == 0)\r\n for i in 1..n\r\n if (n%i == 0)\r\n m+=1\r\n end\r\n end\r\n #odd\r\n else\r\n for i in (1..n).step(2) do\r\n if (n%i == 0)\r\n m+=1\r\n end\r\n end\r\n end \r\n return m\r\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend", "def factors(number)\n dividend = number\n divisors = []\n while dividend > 0 do\n divisors << number / dividend if number % dividend == 0\n dividend -= 1\n end\n divisors\nend" ]
[ "0.78042316", "0.7641671", "0.7603189", "0.73063123", "0.7284914", "0.72683084", "0.71597695", "0.7134039", "0.70848864", "0.7081967", "0.7031492", "0.702231", "0.70128363", "0.6969235", "0.6949987", "0.69363093", "0.6912634", "0.69066805", "0.6903337", "0.6895969", "0.6887601", "0.6870264", "0.6859034", "0.68545747", "0.68434495", "0.6806943", "0.68014", "0.67915756", "0.675956", "0.6747951", "0.67308444", "0.6728115", "0.6722941", "0.67077225", "0.67052615", "0.6704698", "0.6703605", "0.6703129", "0.6671889", "0.6669125", "0.6656659", "0.66511446", "0.6645705", "0.66422874", "0.66381204", "0.66278976", "0.6626551", "0.66153806", "0.6612325", "0.6612325", "0.6612325", "0.6612325", "0.6612287", "0.6611567", "0.6610491", "0.66025805", "0.66025805", "0.66025805", "0.66025805", "0.66025805", "0.66025805", "0.6597778", "0.6589846", "0.6574511", "0.6574381", "0.65719426", "0.6571892", "0.65525806", "0.65525806", "0.65521234", "0.6545691", "0.6543276", "0.6541414", "0.65401554", "0.65384436", "0.65379167", "0.6521291", "0.65210474", "0.65162313", "0.6513744", "0.65078175", "0.650728", "0.650728", "0.650728", "0.650728", "0.650728", "0.6503019", "0.6502539", "0.6496382", "0.6494684", "0.64943457", "0.6493708", "0.6480373", "0.64667624", "0.64667624", "0.64667624", "0.64667624", "0.64667624", "0.64667624", "0.64667624", "0.64667624" ]
0.0
-1
Inicializa el plato con tres argumentos: El nombre del plato, la lista de alimentos y la lista del peso de estos alimentos
def initialize (nombre,&block) @nombre = nombre @lista = Listas.new() @listagr = Listas.new() if block_given? if block.arity == 1 yield self else instance_eval(&block) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(nombre, platos)\n\t\t@nombre = nombre\n\t\t@platos = List.new\n\t\tfor plato in platos do\n\t\t\t@platos << plato\n\t\tend\n\tend", "def initialize(nombre,alimentos,cantidad)\n @nombre_plato = nombre # Nombre del Plato\n @lista_alimentos = alimentos # Lista con los alimentos que forman el plato\n @lista_cantidades = cantidad # Lista con las cantidades que hay que usar de cada alimento\n end", "def platos(options = {})\n plato = options[:nombre]\n nombre_plato = plato.name\n precio_plato = options[:precio]\n @precios << precio_plato\n @valor_energetico << plato.calculoCaloriasDSL\n @valor_ambiental << plato.calculoEmisionesDSL\n\n plato = \"(#{nombre_plato})\"\n plato << \"(#{precio_plato} €)\"\n @platos << plato\n end", "def initialize(nombre,gei,terreno,proteinas,lipidos,glucidos)\n @nombre, @gei, @terreno, @proteinas, @lipidos, @glucidos = nombre, gei, terreno, proteinas, lipidos, glucidos\n end", "def create\n # .permit Hay que indicar los parametros permitidos (se recomienda hacer en el modelo)\n @plato = Plato.new(plato_params) \n if @plato.save\n redirect_to @plato # Te muestra el plato recien creada\n else\n redirect_to new_plato_path\n end\n end", "def platos\n\t\treturn @platos\n\tend", "def initialize(nombre, proteinas, glucidos, lipidos)\n\t\t\t@nombre = nombre\n\t\t\t@proteinas = proteinas\n\t\t\t@glucidos = glucidos\n\t\t\t@lipidos = lipidos\n\t\tend", "def initialize(in_all_planets, in_system, in_formation)\n @system = in_system #name of system\n @all_planets = in_all_planets\n @formation = in_formation\n end", "def initialize(*args)\n self.platforms = [ ]\n\n args.each { |a|\n if a.kind_of?(String)\n platforms << Msf::Module::Platform.find_platform(a)\n elsif a.kind_of?(Range)\n b = Msf::Module::Platform.find_platform(a.begin)\n e = Msf::Module::Platform.find_platform(a.end)\n\n children = b.superclass.find_children\n r = (b::Rank .. e::Rank)\n children.each { |c|\n platforms << c if r.include?(c::Rank)\n }\n else\n platforms << a\n end\n\n }\n\n end", "def set_platillo\n @platillo = Platillo.find(params[:id])\n end", "def initialize(nombre, proteinas, glucidos, lipidos, datos)\n\t\t@nombre = nombre\n\t\t@proteinas = proteinas\n\t\t@glucidos = glucidos\n\t\t@lipidos = lipidos\n\t\t@datos = datos\n\tend", "def initialize(commands)\n m = commands.shift\n @map = Plateau.new(m[0],m[1])\n create_rover(commands)\n initial_placement\n end", "def platoon_params\n params.require(:platoon).permit(:name, :insignia_url)\n end", "def initialize(name, porcions=1, geiPerKg, terreno, carbs, proteins, lipidos)\n\t\t\t\t@name = name\n\t\t\t\t@geiPerKg = porcions*geiPerKg\n\t\t\t\t@gei = (@geiPerKg / 1000) * porcions * 100\n\t\t\t\t@terreno = porcions*terreno\n\t\t\t\t@carbs = porcions*carbs\n\t\t\t\t@proteins = porcions*proteins\n\t\t\t\t@lipidos = porcions*lipidos\n\t\t\tend", "def set_platoon\n @platoon = Platoon.find(params[:id])\n end", "def initialize (nombre, lista_alimentos, lista_cantidades)\n\t\t@nombre = nombre\n\t\t@lista_alimentos = lista_alimentos\n\t\t@lista_cantidades = lista_cantidades\n\tend", "def setup\n @parallax = Chingu::Parallax.create(:x => 0, :y => 0, :z => -1, :rotation_center => :top_left)\n @parallax << { :image => \"fondo.bmp\", :repeat_x => true, :repeat_y => true}\n # @image = Image[\"fondo.png\"]\n # @x = 0\n # @y = 0\n # @z = 0\n @comida_inicio = Time.now\n if $configuracion != nil\n peces = $configuracion[0][1].to_i\n tiburones = $configuracion[1][1].to_i\n reproducir_veces = $configuracion[2][1].to_i\n pez_vida_tiempo = $configuracion[3][1].to_i\n tiburon_vida_tiempo = $configuracion[4][1].to_i\n @comida_tasa = $configuracion[5][1].to_i\n pez_reproducir_tiempo = $configuracion[6][1].to_i\n else\n # print \"No hay configuracion establecida aun...\\n\"\n peces = 5\n tiburones = 1\n reproducir_veces = 5\n pez_vida_tiempo = 5\n tiburon_vida_tiempo = 5\n @comida_tasa = 1\n pez_reproducir_tiempo = 2\n end # if\n (peces/2).times { Pez.create.definir_parametros(1, pez_vida_tiempo, reproducir_veces, pez_reproducir_tiempo) }\n (peces/2).times { Pez.create.definir_parametros(2, pez_vida_tiempo, reproducir_veces, pez_reproducir_tiempo) }\n tiburones.times { Tiburon.create.definir_parametros(tiburon_vida_tiempo) }\n\n # Cuando es un numero impar de peces, se genera un pez con genero al azar\n Pez.create.definir_parametros(rand(2)+1, pez_vida_tiempo, reproducir_veces, pez_reproducir_tiempo) if peces % 2 != 0\n\n @tiempo_burbuja = Time.now\n\n end", "def initialize(nombre, platos)\n\t\tsuper(nombre, platos)\n\t\n\t\t@indEnergia = -> { if vCalorico < 670\n\t\t\t\t\t1\n\t\t\t\t elsif vCalorico >= 670 && vCalorico <= 830\n\t\t\t\t\t2\n\t\t\t\t elsif vCalorico > 830\n\t\t\t\t\t3\n\t\t\t\t end\n\t\t\t\t }\n\n\t\t@indGei = -> { if geiTotal < 800 \n\t\t\t\t\t1\n\t\t\t\t elsif geiTotal >= 800 && geiTotal <= 1200\n\t\t\t\t\t2\n\t\t\t\t elsif geiTotal > 1200\n\t\t\t\t\t3\n\t\t\t\t end\n\t\t\t }\n\tend", "def initialize(nombre, proteinas, glucidos, lipidos, datos, grupo)\n\t\tsuper(nombre, proteinas, glucidos, lipidos, datos)\n\t\t@grupo = grupo\n\tend", "def initialize (nombre, saturadas, monoinsaturadas, polinsaturadas, azucares, polialcoles, almidon, fibra, proteinas, sal)\n\t\t@nombre, @saturadas, @monoinsaturadas, @polinsaturadas, @azucares, @polialcoles, @almidon, @fibra, @proteinas, @sal = nombre, saturadas, monoinsaturadas, polinsaturadas, azucares, polialcoles, almidon, fibra, proteinas, sal\n\tend", "def initialize(nome, comentario)\n @nome = nome\n @comentario = comentario\n @estrelando = []\n end", "def initialize( plateau_de_jeu , name)\n @plateau= plateau_de_jeu\n @pion = @@numero_pion\n @nom = name\n @@numero_pion += 1\n end", "def initialize(name, protein, carbo, lipido, g, t)\n\t\t\t@nombre = name\t\t\t\t\t\t# Atributo utilizado para almacenar el nombre del alimento\n\t\t\t@proteinas = protein\t\t\t# Atributo utilizado para almacenar las proteinas del alimento\n\t\t\t@carbohidratos = carbo\t\t# Atributo utilizado para almacenar los carbohidratos del alimento\n\t\t\t@lipidos = lipido\t\t\t\t\t# Atributo utilizado para almacenar los lipidos del alimento\n\t\t\t@gei = g\t\t\t\t\t\t\t\t\t# Atributo utilizado para almacenar el valor de gases de efecto invernadero\n\t\t\t@terreno = t\t\t\t\t\t\t\t# Atributo utilizado para almacenar el valor del terreno del alimento\n\t\tend", "def initialize(args = {})\n @dinos = []\n @dinos.replace(args[:dinos]) if args[:dinos]\n end", "def initialize(args = {})\n @dinos = []\n @dinos.replace(args[:dinos]) if args[:dinos]\n end", "def initilize land_planes=[] #collection of planes\n\t\t@land_planes = land_planes\n\tend", "def initialize (nombre, lista_alimentos, gramos)\n @nombre, @lista_alimentos, @gramos = nombre, lista_alimentos, gramos\n end", "def initialize(nombre,proteinas,carbohidratos,lipidos, gei,terreno,cantidad = 1.0)\n\t\t@nombre = nombre\n\t\t@proteinas = proteinas\n\t\t@carbohidratos = carbohidratos\n\t\t@lipidos = lipidos\n\t\t@gei = gei\n\t\t@terreno = terreno\n\n\t\t@valorEnergetico = (@proteinas * 4 ) + (@carbohidratos * 4) + (@lipidos * 9)\n\t\t@cantidad = cantidad #En Kg\n\t\timpactoEnergia = case @valorEnergetico\n\t\t\twhen 0..67 then 1\n\t\t\twhen 670..83 then 2\n\t\t\telse 3\n\t\tend\n\t\timpactoHuellaDeCarbono = case @gei\n\t\t\twhen 0..80 then 1\n\t\t\twhen 80..120 then 2\n\t\t\telse 3\n\t\tend\n\t\t@huellaNutricional = (impactoEnergia + impactoHuellaDeCarbono)/2 \n\tend", "def initialize number, num_of_mc_in_each_floor, num_of_sc_in_each_floor\n\t\t\t#floor::area instead of independent area\n\n\t\t\t\n\t\t\t#this can be modularized\n @areas = Array.new\n\n\t\t\t@number = number\n\t\t\t# @name = \"Floor \" + number.to_s\n\t\t\t\n\t\t\t(0...num_of_mc_in_each_floor).each do |mc|\n\t \t\tmain_corridor = Main_Corridor.new(\"Floor \"[email protected]_s+\" mc \"+(mc+1).to_s, AreaType::MC)\n\t \t\t@areas << main_corridor \n\t\t\tend\n\t\t\t(0...num_of_sc_in_each_floor).each do |sc|\n\t\t\t\tsub_corridor = Sub_Corridor.new(\"Floor \"[email protected]_s+\" sc \"+(sc+1).to_s, AreaType::SC)\n\t \t\t@areas << sub_corridor\n\t\t\tend\n\n\t\t\t@allowed_power_consumption = num_of_mc_in_each_floor * 15 + num_of_sc_in_each_floor * 10\n\t\tend", "def create_mission_resources\n get_instructions\n map_plateau\n land_rovers\n end", "def initialize (nombre, lista_alimentos, gramos)\n super(nombre,lista_alimentos,gramos)\n end", "def initialize(mapa)\n mapatemp = []\n mapa.each_value {|value| mapatemp.push(value) }\n # Verificando que hay exactamente dos jugadores \n if mapa.length == 2\n # Verificando que en efecto son estrategias, si alguna no lo es se lanza excepcion\n if (!mapatemp[0].is_a?(Manual) && !mapatemp[0].is_a?(Uniforme) && !mapatemp[0].is_a?(Sesgada) && !mapatemp[0].is_a?(Copiar) && !mapatemp[0].is_a?(Pensar)) ||\n (!mapatemp[1].is_a?(Manual) && !mapatemp[1].is_a?(Uniforme) && !mapatemp[1].is_a?(Sesgada) && !mapatemp[1].is_a?(Copiar) && !mapatemp[1].is_a?(Pensar))\n raise \"Ambos elementos deben ser estrategias (Manual, Uniforme, Sesgada, Copiar o Pensar) \"\n else\n ml={}\n # Construyendo los mapas que permiten el control de la clase\n for i in mapa.keys\n ml=ml.merge({i =>0})\n end\n rond = {:Rounds => 0}\n @map=mapa\n @mapainicio=ml.merge(rond)\n @mapaactual=ml.merge(rond)\n\n estrategia1=@map[@map.keys[0]]\n estrategia2=@map[@map.keys[1]]\n \n #Se asignan los oponentes\n estrategia1.asignarOponente(estrategia2)\n estrategia2.asignarOponente(estrategia1)\n end\n else\n raise \"Deben haber dos estrategias (Manual, Uniforme, Sesgada, Copiar o Pensar)\"\n end\n end", "def initialize(nombre,lista_alimentos,acc_cantidad_alimentos)\n\t\tsuper(nombre,lista_alimentos,acc_cantidad_alimentos)\n\t\t@emisiones_gei = 0\n\t\t@area_terreno_m2 = 0\n\tend", "def initialize(name, length_y, width_x, monster, monster_status = \"alive\")\n @name = name\n @room_x = width_x\n @room_y = length_y\n @monster = monster\n @monster_status = monster_status\n @dropped_treasure = []\n @@instances << self\n \n if (name != \"Entryway\") && (name != \"Exit\")\n\n @dropped_treasure << treasure\n end\n \n end", "def initialize(nombre,apellido)#Debe recibir dos parametros: nombre y apellido\n @nombre=nombre\n @apellido=apellido\n @@persona.push self\n end", "def initialize( indiceTypeJeu, charge, pseudo, cheminMap, inc, start, hypo, nbHypo )\n\t\t# Tableau pour gerer les couleurs des hypotheses\n\t\t@tabCase = [\"../images/cases/noir.png\", \"../images/cases/violet.png\", \"../images/cases/bleu.png\", \"../images/cases/rouge.png\"]\n\t\t@tabCaseOver = [\"../images/cases/noirOver.png\", \"../images/cases/violetOver.png\", \"../images/cases/bleuOver.png\", \"../images/cases/rougeOver.png\"]\n\t\t@inc = inc\n\t\t@start = start\n\t\t@cheminMap = cheminMap\n\t\t@pseudo = pseudo\n @save_flag=true\n\t\t@indiceTypeJeu = indiceTypeJeu\n\t\t@flagHypo=false\n\t\t@labelGitan=false\n @os = RbConfig::CONFIG['host_os']\n\t\tif charge == 0 then\n\t\t\t@nbHypo = 0\n\t\t\t@map = Map.create(cheminMap)\n\t\t\t@hypo = Hypothese.creer(@map)\n\t\telsif charge == 1\n\t\t\t@nbHypo = nbHypo\n\t\t\t@hypo = hypo\n\t\t\t#Réactualisation de la map en fonction de l'hypothese\n\t\t\t@map = @hypo.faireHypothese()\n\t\t\t@map = @hypo.validerHypothese()\n\t\tend\n\n\t\t@tabFaireHypo = [\"../images/boutons/hypo/faireNoir.png\",\"../images/boutons/hypo/faireViolet.png\",\"../images/boutons/hypo/faireBleu.png\",\"../images/boutons/hypo/faireRouge.png\"]\n\t\t@tabFaireHypoOver = [\"../images/boutons/hypo/faireNoirOver.png\",\"../images/boutons/hypo/faireVioletOver.png\",\"../images/boutons/hypo/faireBleuOver.png\",\"../images/boutons/hypo/faireRougeOver.png\"]\n\t\t@tabValiderHypo = [\"../images/boutons/hypo/validerNoir.png\",\"../images/boutons/hypo/validerViolet.png\",\"../images/boutons/hypo/validerBleu.png\",\"../images/boutons/hypo/validerRouge.png\"]\n\t\t@tabValiderHypoOver = [\"../images/boutons/hypo/validerNoirOver.png\",\"../images/boutons/hypo/validerVioletOver.png\",\"../images/boutons/hypo/validerBleuOver.png\",\"../images/boutons/hypo/validerRougeOver.png\"]\n\t\t@tabRejeterHypo = [\"../images/boutons/hypo/rejeterNoir.png\",\"../images/boutons/hypo/rejeterViolet.png\",\"../images/boutons/hypo/rejeterBleu.png\",\"../images/boutons/hypo/rejeterRouge.png\"]\n\t\t@tabRejeterHypoOver = [\"../images/boutons/hypo/rejeterNoirOver.png\",\"../images/boutons/hypo/rejeterVioletOver.png\",\"../images/boutons/hypo/rejeterBleuOver.png\",\"../images/boutons/hypo/rejeterRougeOver.png\"]\n\n\t\tinitTimer()\n\t\tlancerGrille()\n end", "def initialize(nome = \"Sem nome\")\r\n @nome = nome\r\n @livros = []\r\n end", "def initialize(nombre,apellidos,peso,talla,edad,sexo,cintura,cadera,tricipital,bicipital,subescapular,suprailíaco, factorActividadFisica)\n \tsuper(nombre,apellidos,edad,sexo)\n\n \t@peso = peso\n \t@talla = talla\n \t@cintura = cintura\n \t@cadera = cadera\n \t@tricipital = tricipital\n \t@bicipital = bicipital\n \t@subescapular = subescapular\n \t@suprailíaco = suprailíaco\n\t\t@factorActividadFisica = factorActividadFisica\n \tend", "def set_producto_platillo\n @producto_platillo = ProductoPlatillo.find(params[:id])\n end", "def initialize(name) # All tech has a name, no?\n @name = name\n @labs = []\n end", "def initialize\n # create and locate the shovel\n shovel.location = start_room\n end", "def initialize(parametros)\n # En cada variable intanciada le asignamos un hash con la variable correspondiente\n @villano = parametros[:villano]\n @frase = parametros[:frase]\n end", "def initialize(mapa)\n\n # Verificar que hay exactamente dos jugadores y que \n # en efecto se trata de estrategias\n temp = []\n mapa.each_value {|value| temp.push(value) }\n temp1 = temp[0].class <= Estrategia\n temp2 = temp[1].class <= Estrategia\n keys = []\n mapa.each_key {|key| keys.push(key)}\n if mapa.length == 2\n if temp1 and temp2\n \n $mapa_partida = mapa\n $estrategias = temp\n $nombres = keys\n # estrategias de los dos jugadores\n @jugador0 = temp[0]\n @jugador1 = temp[1]\n #reconocer cuales son las estrategias del jugador 0 y 1 respectivamente\n @manual0 = @jugador0.instance_of?(Manual)\n @manual1 = @jugador1.instance_of?(Manual)\n @unif0 = @jugador0.instance_of?(Uniforme)\n @unif1 = @jugador1.instance_of?(Uniforme)\n @sesg0 = @jugador0.instance_of?(Sesgada)\n @sesg1 = @jugador1.instance_of?(Sesgada)\n @copiar0 = @jugador0.instance_of?(Copiar)\n @copiar1 = @jugador1.instance_of?(Copiar)\n @pensar0 = @jugador0.instance_of?(Pensar)\n @pensar1 = @jugador1.instance_of?(Pensar)\n else\n return \"Debe ingresar estrategias\"\n end\n else\n return \"El número de jugadores deben ser exactamente 2.\"\n end\n end", "def create\n @platillo = Platillo.new(platillo_params)\n @ingredients = platillo_params[:ingredients_attributes]\n debug @ingredients\n\n @platilloIngrendiente = Ingredient.new(@ingredients)\n @platilloIngrendiente.save\n respond_to do |format|\n if @platillo.save\n format.html { redirect_to @platillo, notice: 'Platillo creado exitosamente' }\n format.json { render :show, status: :created, location: @platillo }\n else\n format.html { render :new }\n format.json { render json: @platillo.errors, status: :unprocessable_entity }\n end\n end\n end", "def initialize(*args)\n super\n self.absorbido = {}\n self.absorbido[batalla.flota_atacante.object_id] = 0\n self.absorbido[batalla.flota_defensora.object_id] = 0\n end", "def build_system(name, planet)\n @planets[name] = planet\n end", "def pantallaJuego\n\t\[email protected]\n\t\[email protected] \"fondo.jpg\"\n\n\t\t# Inicializar estrategias y crear partida\n\n\t\tpiedra = Piedra.new (\"piedra\")\n\t\tpapel = Papel.new (\"papel\")\n\t\ttijeras = Tijeras.new (\"tijeras\")\n\t\tlagarto = Lagarto.new (\"lagarto\")\n\t\tspock = Spock.new (\"spock\")\n\t\tpesos = Hash[piedra => 2, papel => 5, tijeras => 4, lagarto => 3, spock => 1]\n\n\n\t\tif @s1 == \"uniforme\"\n\t\t\t@j1 = Uniforme.new \"1\", \"uniforme\", [piedra, papel, tijeras, lagarto, spock]\n\t\telsif @s1 == \"sesgada\"\n\t\t\t@j1 = Sesgada.new \"1\", \"sesgada\", pesos\n\t\telsif @s1 == \"manual\"\n\t\t\t@j1 = Manual.new \"1\", \"manual\"\n\t\telsif @s1 == \"copiar\"\n\t\t\t@j1 = Copiar.new \"1\", \"copiar\"\n\t\telsif @s1 == \"pensar\"\n\t\t\t@j1 = Pensar.new \"1\", \"pensar\"\n\t\tend\n\t\t\t\n\t\tif @s2 == \"uniforme\"\n\t\t\t@j2 = Uniforme.new \"2\", \"uniforme\", [piedra, papel, tijeras, lagarto, spock]\n\t\telsif @s2 == \"sesgada\"\n\t\t\t@j2 = Sesgada.new \"2\", \"sesgada\", pesos\n\t\telsif @s2 == \"manual\"\n\t\t\t@j2 = Manual.new \"2\", \"manual\"\n\t\telsif @s2 == \"copiar\"\n\t\t\t@j2 = Copiar.new \"2\", \"copiar\"\n\t\telsif @s2 == \"pensar\"\n\t\t\t@j2 = Pensar.new \"2\", \"pensar\"\n\t\tend\n\n\t\t#m = Partida.new Hash[\"1\" => @j1, \"2\" => @j2], @app\n\t\t\n\t\tif @rondas != \"\"\t\t\t\t\t\t\t\n\t\t\trondas(@rondas.to_i)\n\t\telsif @puntos != \"\"\n\t\t\talcanzar(@puntos.to_i)\n\t\tend\n\n\t\t\n\tend", "def initialize name, map\n #set meta data\n @name = name\n @players = Array.new\n @map = map\n\n # mode defaults to lobby\n @mode = :lobby\n @state = State.new []\n\n @finalized_players = PlayerFinalizationTracker.new\n\n @character_templates = [\n CharacterTemplate.new(\"devil\",[0,9]),\n CharacterTemplate.new(\"ghost\",[4,7])\n ]\n end", "def set_contiene_plato\n @contiene_plato = ContienePlato.find(params[:id])\n end", "def initialize(name, ship_type, pilot_limit)\n @name = name\n @ship_type = ship_type\n @pilot_limit = pilot_limit\n @pilot_list = []\n end", "def get_conjunto_platos\n i=0\n cadena=\"\"\n while(i<@platos)\n cadena=cadena+\"#{get_plato(i)}\"\n if(i!=@platos-1) #if para que no se añada \\n en el ultimo plato\n cadena=cadena+\"\\n\"\n end\n i=i+1\n end\n cadena\n end", "def initialize(nombre,alimentos,cantidad)\n super(nombre,alimentos,cantidad) # Llamada al contructor de la clase padre\n @emisiones_diarias = 0 # Variable para almacenar valor de efceto invernadero\n @metros_terreno = 0 # variable para almacenar valor del terreno\n end", "def initialize(name, proteins, glucids, fats)\n @name = name\n @proteins = proteins\n @glucids = glucids \n @fats = fats\n end", "def initialize\n\t\t@planets = [gallifrey, xander] # initialize hard coded planets\n\t\t#@planets.push(@new_planet) # adds new planets via user input to planets array\n\t\t@number_planets = @planets.length #counts planets by counting array elements\n\t\t@formation_year = rand(-3000000..2015)\n\t\t@age_of_system = 2015 - @formation_year\n\t\t\t\n\tend", "def initialize(nombre,lista,listagr)\n super(nombre,lista,listagr)\n @gei = 0\n\t\t@terreno = 0\n end", "def create\n @contiene_plato = ContienePlato.new(contiene_plato_params)\n\n respond_to do |format|\n if @contiene_plato.save\n format.html { redirect_to @contiene_plato, notice: 'Contiene plato was successfully created.' }\n format.json { render :show, status: :created, location: @contiene_plato }\n else\n format.html { render :new }\n format.json { render json: @contiene_plato.errors, status: :unprocessable_entity }\n end\n end\n end", "def initialize(name) # je recrée un initialize et je fais appel aux caractéristiques de la classe mère avec super\n super(name)\n\n @life_points = 100 # j'ajoute les caractéristiques propres au joueur humain\n @weapon_level = 1\n end", "def basic_clasificator origen,dpworld_data,stwd_data,hit_data\n origen.each do |params|\n\tputs \"FILA: #{params.to_s}\"\n $LOG.debug \" LIBERACION: #{params.to_s}\"\n case [ params['ptocreacion'] , params['solvenciaNotifId'] ]\n when ['DOCAU',1]\n dpworld_data << ReleaseCaucedo.new( params )\n when ['DOCAU',4]\n stwd_data << ReleaseSTWD.new( params )\n when ['DOHAI',2]\n\t hit_data << ReleaseHIT.new( params )\n end\n end\n [dpworld_data,stwd_data,hit_data]\nend", "def initialize(campos = {})\n @codigo_barras = campos.dig(:codigo_barras)\n @linha_digitavel = campos.dig(:linha_digitavel)\n\n super(campos)\n end", "def set_listas\n #@locais = Local.all.map{|l| [l.nome,l.id]}\n @locais = Local.all\n @periodos = ['Manhã','Tarde','Noite']\n @publicos = ['Infantil','Adulto']\n end", "def initialize(nombre,peso,talla,edad,sexo,imc,estados,rcc,rcca) #constructor\n super(nombre,peso,talla,edad,sexo,imc,estados,rcc,rcca)\n end", "def init_players\r\n markers = MARKERS.dup\r\n (1..NUM_PLAYERS).each do |player_num|\r\n player_type = multiple_choice(\"Choose player #{player_num} type\",\r\n 'h' => Human, 'c' => Computer)\r\n @players << player_type.new(markers.pop)\r\n end\r\n end", "def initialize\n @rooms = { #defines the rooms available for use on each floor\n :upstairs => [\"Master Bedroom\", \"A Guest Room\", \"Tower\", \"Balcony\", \"Observatory\", \"The Hole Room\"],\n :main => [\"Kitchen\", \"Library\", \"Study\", \"Dining Room\", \"Living Room\", \"Vault\"],\n :downstairs => [\"Furnace Room\", \"Chapel\", \"Storage Room\", \"The Pit\"]\n }\n\n @used_rooms = []\n @omen_count = 0 #Omens are a game event that change the story line. Once the omen count reaches 10 the haunt starts\n @player = Character.new\n intro #script\n entry_hall(\"Main Hallway\")\n game\n end", "def get_plato(num_plato)\n if (num_plato<0)&&(num_plato>@platos)\n raise \"El plato no existe\"\n else\n \"- #{get_descripcion(num_plato)}, #{@porciones[num_plato]}, #{@ingesta[num_plato]} g\"\n end\n end", "def initialize(name)\n @name = name\n @nota\n #declaracion v instancia\n end", "def initialize(params)\n @id = params[:id]\n @nombre = params[:nombre]\n @genero = params[:genero]\n @id_tropicos = params[:id_tropicos]\n @color1 = params[:color1]\n @color2 = params[:color2]\n @forma_vida1 = params[:forma_vida1]\n @forma_vida2 = params[:forma_vida2]\n @descripcion_es = params[:descripcion_es]\n @descripcion_en = params[:descripcion_en]\n @distribucion_es = params[:distribucion_es]\n @distribucion_en = params[:distribucion_en]\n @thumbnail = params[:thumbnail]\n end", "def initialize (solar_system)\n @planet_list = solar_system\n end", "def initialize\n @screen = Game_Screen.new\n @interpreter = Game_Interpreter.new(0, true)\n @map_id = 0\n @display_x = 0\n @display_y = 0\n create_vehicles\n end", "def contiene_plato_params\n params.require(:contiene_plato).permit(:order_id, :plt_id)\n end", "def initialize(some_planets, name, solar_age)\n @planets = some_planets\n @name = name\n @solar_age = solar_age\n end", "def initialize(nomee, idadee, alturaa, pesoo)\n \t@nome = nomee\n \t@idade = idadee\n \t@altura = alturaa\n \t@peso = pesoo\n end", "def initialize(name, &block)\n @name = name\n @platos = []\n @precios = []\n @valor_energetico = []\n @valor_ambiental = []\n\n if block_given?\n if block.arity == 1\n yield self\n else\n instance_eval(&block)\n end\n end\n end", "def initialize(name)\n @planets = []\n @name = name\n @constellation = nil\n @type = nil\n @age = 0\n end", "def epoc_set_plat_env plat\nend", "def list\n unless params[:platforma].nil?\n #plat = Platform.where('lower(platform) = ?', params[:platforma].downcase).first\n plat = Platform.ignoreCase(params[:platforma]).first\n end\n unless plat.nil? \n @aplikaces = plat.aplikaces.order(\"id DESC\")\n @plId = plat.id\n else \n @aplikaces = Aplikace.all.order(\"id DESC\")\n end\n @platforms = Platform.all\n end", "def initialize(planets)\n @solar_system = planets\n end", "def initializePesos\r\n \[email protected] do\r\n\t patron = @patrones[rand(@patrones.count-1)]\r\n @neuronas << {:class=>rand(@cantClases), :pesos => initPesos}\r\n\tend\r\n end", "def initialize(estacion) #SpaceStation\n super(estacion)\n end", "def from_params(params)\n self.cpus = params['cpus'].to_i\n self.ram = params['memory'].to_i\n self.video_ram = params['vram'].to_i\n self.hardware_id = params['hardwareuuid']\n self.os = self.class.os_types[params['ostype']]\n\n self.pae = params['pae'] == 'on' \n self.acpi = params['acpi'] == 'on' \n self.io_apic = params['io_apic'] == 'on' \n\n self.hardware_virtualization = params['hwvirtex'] == 'on' \n self.nested_paging = params['nestedpaging'] == 'on' \n self.tagged_tlb = params['vtxvpid'] == 'on' \n\n self.efi = params['firmware'] == 'efi'\n self.bios_logo_fade_in = params['bioslogofadein'] == 'on'\n self.bios_logo_fade_out = params['bioslogofadeout'] == 'on'\n self.bios_logo_display_time = params['bioslogodisplaytime'].to_i\n \n self.bios_boot_menu = case params['bootmenu']\n when 'disabled'\n false\n when 'message'\n :menu_only\n else\n true\n end\n \n self.boot_order = []\n %w(boot1 boot2 boot3 boot4).each do |boot_key|\n next unless params[boot_key] && params[boot_key] != 'none'\n boot_order << params[boot_key].to_sym\n end\n \n self.audio = params['audio'] != 'none'\n \n self\n end", "def initialize(ciclos, lupula, cebada, mezcla, levadura)\n\n @ciclos = ciclos\n @almacen = Almacen.new(lupula,cebada,mezcla,levadura)\n @silosCebada = Silos_Cebada.new\n @molino = Molino.new\n @pailaMezcla = Paila_Mezcla.new\n @cuba = Cuba_Filtracion.new\n @pailaCoccion = Paila_Coccion.new\n @tanquePreclarif = Tanque_Preclarificador.new \n @enfriador = Enfriador.new\n @tcc = TCC.new\n @filtroCerveza = Filtro_Cerveza.new\n @tanqueFiltroCerveza = Tanque_Cerveza.new\n @llenadora = Llenadora.new\n\n end", "def initialize\n self.lines = { \n \n :victoria => [:kings_cross, :euston, :warren_street, :oxford_circus, :green_park, :victoria, :pimlico], \n \n :bakerloo => [:elephant_castle, :lambeth_north, :waterloo, :embankment, :charing_cross, :picadilly_circus, :oxford_circus, :regents_park, :baker_street], \n \n :central => [:notting_hill_gate, :queensway, :lancaster_gate, :marble_arch, :bond_street, :oxford_circus, :tottenham_court_road, :holborn, :chancery_lane] \n }\n\n end", "def initialize ()\n\t\t# inicializa la variable baraja como un array vacio\n\t\t@baraja = []\n\t\t# recorre el array con todos los palos\n\t\tConstantes::PALOS.each do |p|\n\t\t\t# Recorre el array con todos los valores\n\t\t\tConstantes::VALORES.each do |v|\n\t\t\t\t# Para cada combinacion de palo/valor crea un objeto Carta y lo guarda en la baraja\n\t\t\t\tc = Carta.new v,p\n\t\t\t\t@baraja << (Carta.new v,p)\n\n\t\t\tend\n\t\tend\n\tend", "def create\n @platoon = Platoon.new(platoon_params)\n\n respond_to do |format|\n if @platoon.save\n format.html { redirect_to @platoon, notice: 'Platoon was successfully created.' }\n format.json { render action: 'show', status: :created, location: @platoon }\n else\n format.html { render action: 'new' }\n format.json { render json: @platoon.errors, status: :unprocessable_entity }\n end\n end\n end", "def initialize(name, degats, weaponType, durabilite, durabiliteMax, projectiles)\n super(name, 1, 200, 200, 450, 450)\n\n @degats = degats\n @weaponType = weaponType\n @durabilite = durabilite\n @durabiliteMax = durabiliteMax\n @projectiles = projectiles\n end", "def setup_players\n @players = []\n @players << add(Spaceship, 400, 320)\n @players << add(Tank, width/2, height-100)\n end", "def initialize(name_ini)\n\t\t# print \"Saisissez le nom de votre gladiateur : \"\n\n\t\t@name = name_ini #gets.chomp\n\n\t\t@life_points = 100\n\t\t@weapon_level = 1\n\n\tend", "def initalize(params) #Pirates should have a name, weight, and height.\n @name = params[:name]\n @weight = params[:weight]\n @height = params[:height]\n PIRATES << self #store pirates in array\n end", "def initialize(campos = {})\n campos = {\n aceite: 'N',\n parcela: '01'\n }.merge!(campos)\n super(campos)\n end", "def initialize(name,age,spoken_languages,computer_os, developer_type, location = \"Earth\", seating_position = \"Economy\")\n @name = name\n @age = age\n @spoken_languages = spoken_languages\n @computer_os = computer_os\n @developer_type = developer_type\n @location = location\n @seating_position = seating_position\n end", "def initialize(attrs = {})\n # Registro Nacional de Transportadores Rodoviarios de Carga\n @rntrc = attrs[:RNTRC]\n # Previsao\n @date = attrs[:dPrev]\n # Lotacao\n @capacity = attrs[:lota]\n # Conta Frete\n @ciot = attrs[:CIOT]\n\n # Coletas\n if attrs[:occ]\n @collections = create_resources(Collection, attrs[:occ])\n end\n\n # Vales pedagios\n if attrs[:valePed]\n @tolls = create_resources(Toll, attrs[:valePed])\n end\n\n # Veiculo\n if attrs[:veic]\n @vehicles = create_resources(Vehicle, attrs[:veic])\n end\n\n # Lacres\n if attrs[:lacRodo]\n @seals = to_array(attrs[:lacRodo])\n end\n\n if attrs[:moto]\n @drivers = create_resources(Person, attrs[:moto])\n end\n end", "def initialize(path,platform,archs=[])\n super(path)\n\n @platform = platform.to_s\n @archs = archs.map { |name| name.to_s }\n end", "def init_players(names)\n \n \n @dealer = CardDealer.instance\n \n #Inicializamos el array de jugadores\n @players = Array.new\n \n #Recorremos los nombres pasados y creamos tantos jugadores como nombres\n names.each do |s|\n\n players << Player.new(s)\n\n end\n end", "def add_constructions(building_type, building_vintage, climate_zone)\n\n OpenStudio::logFree(OpenStudio::Info, 'openstudio.model.Model', 'Started applying constructions')\n is_residential = \"No\" #default is nonresidential for building level\n\n # Assign construction to adiabatic construction\n # Assign a material to all internal mass objects\n cp02_carpet_pad = OpenStudio::Model::MasslessOpaqueMaterial.new(self)\n cp02_carpet_pad.setName('CP02 CARPET PAD')\n cp02_carpet_pad.setRoughness(\"VeryRough\")\n cp02_carpet_pad.setThermalResistance(0.21648)\n cp02_carpet_pad.setThermalAbsorptance(0.9)\n cp02_carpet_pad.setSolarAbsorptance(0.7)\n cp02_carpet_pad.setVisibleAbsorptance(0.8)\n\n normalweight_concrete_floor = OpenStudio::Model::StandardOpaqueMaterial.new(self)\n normalweight_concrete_floor.setName('100mm Normalweight concrete floor')\n normalweight_concrete_floor.setRoughness('MediumSmooth')\n normalweight_concrete_floor.setThickness(0.1016)\n normalweight_concrete_floor.setConductivity(2.31)\n normalweight_concrete_floor.setDensity(2322)\n normalweight_concrete_floor.setSpecificHeat(832)\n\n nonres_floor_insulation = OpenStudio::Model::MasslessOpaqueMaterial.new(self)\n nonres_floor_insulation.setName('Nonres_Floor_Insulation')\n nonres_floor_insulation.setRoughness(\"MediumSmooth\")\n nonres_floor_insulation.setThermalResistance(2.88291975297193)\n nonres_floor_insulation.setThermalAbsorptance(0.9)\n nonres_floor_insulation.setSolarAbsorptance(0.7)\n nonres_floor_insulation.setVisibleAbsorptance(0.7)\n\n floor_adiabatic_construction = OpenStudio::Model::Construction.new(self)\n floor_adiabatic_construction.setName('Floor Adiabatic construction')\n floor_layers = OpenStudio::Model::MaterialVector.new\n floor_layers << cp02_carpet_pad\n floor_layers << normalweight_concrete_floor\n floor_layers << nonres_floor_insulation\n floor_adiabatic_construction.setLayers(floor_layers)\n\n g01_13mm_gypsum_board = OpenStudio::Model::StandardOpaqueMaterial.new(self)\n g01_13mm_gypsum_board.setName('G01 13mm gypsum board')\n g01_13mm_gypsum_board.setRoughness('Smooth')\n g01_13mm_gypsum_board.setThickness(0.0127)\n g01_13mm_gypsum_board.setConductivity(0.1600)\n g01_13mm_gypsum_board.setDensity(800)\n g01_13mm_gypsum_board.setSpecificHeat(1090)\n g01_13mm_gypsum_board.setThermalAbsorptance(0.9)\n g01_13mm_gypsum_board.setSolarAbsorptance(0.7)\n g01_13mm_gypsum_board.setVisibleAbsorptance(0.5)\n\n wall_adiabatic_construction = OpenStudio::Model::Construction.new(self)\n wall_adiabatic_construction.setName('Wall Adiabatic construction')\n wall_layers = OpenStudio::Model::MaterialVector.new\n wall_layers << g01_13mm_gypsum_board\n wall_layers << g01_13mm_gypsum_board\n wall_adiabatic_construction.setLayers(wall_layers)\n\n m10_200mm_concrete_block_basement_wall= OpenStudio::Model::StandardOpaqueMaterial.new(self)\n m10_200mm_concrete_block_basement_wall.setName('M10 200mm concrete block basement wall')\n m10_200mm_concrete_block_basement_wall.setRoughness('MediumRough')\n m10_200mm_concrete_block_basement_wall.setThickness(0.2032)\n m10_200mm_concrete_block_basement_wall.setConductivity(1.326)\n m10_200mm_concrete_block_basement_wall.setDensity(1842)\n m10_200mm_concrete_block_basement_wall.setSpecificHeat(912)\n\n basement_wall_construction = OpenStudio::Model::Construction.new(self)\n basement_wall_construction.setName('Basement Wall construction')\n basement_wall_layers = OpenStudio::Model::MaterialVector.new\n basement_wall_layers << m10_200mm_concrete_block_basement_wall\n basement_wall_construction.setLayers(basement_wall_layers)\n\n basement_floor_construction = OpenStudio::Model::Construction.new(self)\n basement_floor_construction.setName('Basement Floor construction')\n basement_floor_layers = OpenStudio::Model::MaterialVector.new\n basement_floor_layers << m10_200mm_concrete_block_basement_wall\n basement_floor_layers << cp02_carpet_pad\n basement_floor_construction.setLayers(basement_floor_layers)\n\n self.getSurfaces.each do |surface|\n if surface.outsideBoundaryCondition.to_s == \"Adiabatic\"\n if surface.surfaceType.to_s == \"Wall\"\n surface.setConstruction(wall_adiabatic_construction)\n else\n surface.setConstruction(floor_adiabatic_construction)\n end\n elsif surface.outsideBoundaryCondition.to_s == \"OtherSideCoefficients\"\n # Ground\n if surface.surfaceType.to_s == \"Wall\"\n surface.setOutsideBoundaryCondition(\"Ground\")\n surface.setConstruction(basement_wall_construction)\n else\n surface.setOutsideBoundaryCondition(\"Ground\")\n surface.setConstruction(basement_floor_construction)\n end\n end\n end\n\n # Make the default construction set for the building\n bldg_def_const_set = self.add_construction_set(building_vintage, climate_zone, building_type, nil, is_residential)\n\n if bldg_def_const_set.is_initialized\n self.getBuilding.setDefaultConstructionSet(bldg_def_const_set.get)\n else\n OpenStudio::logFree(OpenStudio::Error, 'openstudio.model.Model', 'Could not create default construction set for the building.')\n return false\n end\n \n # Make a construction set for each space type, if one is specified\n self.getSpaceTypes.each do |space_type|\n \n # Get the standards building type\n stds_building_type = nil\n if space_type.standardsBuildingType.is_initialized\n stds_building_type = space_type.standardsBuildingType.get\n else\n OpenStudio::logFree(OpenStudio::Info, 'openstudio.model.Model', \"Space type called '#{space_type.name}' has no standards building type.\")\n end\n \n # Get the standards space type\n stds_spc_type = nil\n if space_type.standardsSpaceType.is_initialized\n stds_spc_type = space_type.standardsSpaceType.get\n else\n OpenStudio::logFree(OpenStudio::Info, 'openstudio.model.Model', \"Space type called '#{space_type.name}' has no standards space type.\")\n end \n \n # If the standards space type is Attic,\n # the building type should be blank.\n if stds_spc_type == 'Attic'\n stds_building_type = ''\n end\n\n # Attempt to make a construction set for this space type\n # and assign it if it can be created.\n spc_type_const_set = self.add_construction_set(building_vintage, climate_zone, stds_building_type, stds_spc_type, is_residential)\n if spc_type_const_set.is_initialized\n space_type.setDefaultConstructionSet(spc_type_const_set.get)\n end\n \n end\n \n # Add construction from story level, especially for the case when there are residential and nonresidential construction in the same building\n if building_type == 'SmallHotel'\n self.getBuildingStorys.each do |story|\n next if story.name.get == 'AtticStory'\n puts \"story = #{story.name}\"\n is_residential = \"No\" #default for building story level\n exterior_spaces_area = 0\n story_exterior_residential_area = 0\n \n # calculate the propotion of residential area in exterior spaces, see if this story is residential or not\n story::spaces.each do |space|\n next if space.exteriorWallArea == 0\n space_type = space.spaceType.get\n if space_type.standardsSpaceType.is_initialized\n space_type_name = space_type.standardsSpaceType.get\n end\n data = self.find_object(self.standards['space_types'], {'template'=>building_vintage, 'building_type'=>building_type, 'space_type'=>space_type_name})\n exterior_spaces_area += space.floorArea\n story_exterior_residential_area += space.floorArea if data['is_residential'] == \"Yes\" # \"Yes\" is residential, \"No\" or nil is nonresidential\n end\n is_residential = \"Yes\" if story_exterior_residential_area/exterior_spaces_area >= 0.5\n next if is_residential == \"No\"\n \n # if the story is identified as residential, assign residential construction set to the spaces on this story.\n building_story_const_set = self.add_construction_set(building_vintage, climate_zone, building_type, nil, is_residential)\n if building_story_const_set.is_initialized\n story::spaces.each do |space|\n space.setDefaultConstructionSet(building_story_const_set.get)\n end\n end\n end\n # Standars: For whole buildings or floors where 50% or more of the spaces adjacent to exterior walls are used primarily for living and sleeping quarters\n \n end \n \n # Make skylights have the same construction as fixed windows\n # sub_surface = self.getBuilding.defaultConstructionSet.get.defaultExteriorSubSurfaceConstructions.get\n # window_construction = sub_surface.fixedWindowConstruction.get\n # sub_surface.setSkylightConstruction(window_construction)\n\n\n # Assign a material to all internal mass objects\n material = OpenStudio::Model::StandardOpaqueMaterial.new(self)\n material.setName('Std Wood 6inch')\n material.setRoughness('MediumSmooth')\n material.setThickness(0.15)\n material.setConductivity(0.12)\n material.setDensity(540)\n material.setSpecificHeat(1210)\n material.setThermalAbsorptance(0.9)\n material.setSolarAbsorptance(0.7)\n material.setVisibleAbsorptance(0.7)\n construction = OpenStudio::Model::Construction.new(self)\n construction.setName('InteriorFurnishings')\n layers = OpenStudio::Model::MaterialVector.new\n layers << material\n construction.setLayers(layers)\n\n # Assign the internal mass construction to existing internal mass objects\n self.getSpaces.each do |space|\n internal_masses = space.internalMass\n internal_masses.each do |internal_mass|\n internal_mass.internalMassDefinition.setConstruction(construction)\n end\n end\n\n # get all the space types that are conditioned\n conditioned_space_names = find_conditioned_space_names(building_type, building_vintage, climate_zone)\n \n # add internal mass\n unless (building_type == 'SmallHotel') &&\n (building_vintage == '90.1-2004' or building_vintage == '90.1-2007' or building_vintage == '90.1-2010' or building_vintage == '90.1-2013')\n internal_mass_def = OpenStudio::Model::InternalMassDefinition.new(self)\n internal_mass_def.setSurfaceAreaperSpaceFloorArea(2.0)\n internal_mass_def.setConstruction(construction)\n conditioned_space_names.each do |conditioned_space_name|\n space = self.getSpaceByName(conditioned_space_name)\n if space.is_initialized\n space = space.get\n internal_mass = OpenStudio::Model::InternalMass.new(internal_mass_def)\n internal_mass.setName(\"#{space.name} Mass\") \n internal_mass.setSpace(space)\n end\n end\n end\n\n OpenStudio::logFree(OpenStudio::Info, 'openstudio.model.Model', 'Finished applying constructions')\n \n return true\n\n end", "def initialize attributes = {}\n @nombre = attributes[:nombre]\n @nit = attributes[:nit]\n @empleados = []\n @clientes = []\n end", "def initialize(nombre,cgrasas,cgrasassa,hcarbono,azucares,proteinas,sal,grasasmono,grasaspoli,polialcoholes,almidon,fibra,vita)\n\t\t@nombre=nombre\n\t\t@cgrasas=cgrasas\n\t\t@cgrasassa=cgrasassa\n\t\t@hcarbono=hcarbono\n\t\t@azucares=azucares\n\t\t@proteinas=proteinas\n\t\t@sal=sal\n\t\t@grasasmono=grasasmono\n\t\t@grasaspoli=grasaspoli\n\t\t@polialcoholes=polialcoholes\n\t\t@almidon=almidon\n\t\t@fibra=fibra\n\t\t@vitymin=vita\n\n\tend", "def initialize(model, name, owner)\n @model = model\n self.name = name\n self.owner = owner\n self.passengers = []\n self.cargo = []\n end", "def initialize \n\t\t@floor = \".\"\n\t\t@name = \"\"\n\t\t@symbol = \"\" \n\t\t@race = \"\"\n\t\t@inventory = [] \n\t\t@hit_points = 0 \n\t\t@position = \"\" \n\t\t@level = 1 \n\tend", "def initialize(name,dough,sauce,toppings=[])\n @name, @dough, @sauce, @toppings = name, dough, sauce, toppings\n end", "def initialize(name, age, gender, apartment,nil)\n @name = [\"name\"]\n @age = [\"age\"]\n @gender = [\"gender\"]\n @apartment = [\"apartment\"]\n end", "def platillo_params\n params.require(:platillo).permit(:name,:price,:category_id, :map ,:map_file_name,ingredients_attributes: [:name, :stock])\n end", "def initialize(name,belongs_to)\n @name = name\n @belongs_to = belongs_to\n\t\t@domain = belongs_to.domain \n\t\t@plant = belongs_to.plant\n @attributes = {}\n @child_of = []\n @parent_of = []\n\t\t@runtime_config = {}\n end" ]
[ "0.75948423", "0.74806696", "0.6430196", "0.6042649", "0.5900942", "0.58953977", "0.5888761", "0.583618", "0.5834506", "0.5817067", "0.58132565", "0.57384425", "0.5733541", "0.570629", "0.5689989", "0.5669143", "0.56585497", "0.5587773", "0.55867064", "0.5567224", "0.5549986", "0.5535864", "0.55269456", "0.5509072", "0.5509072", "0.5463542", "0.5450458", "0.54423195", "0.5408582", "0.54076034", "0.5401375", "0.5396664", "0.534632", "0.5343568", "0.53334856", "0.53264433", "0.5325166", "0.5312547", "0.5305796", "0.52845955", "0.52678376", "0.526279", "0.5262207", "0.52570873", "0.52530706", "0.5246273", "0.52426165", "0.5229796", "0.52149224", "0.52148235", "0.5211524", "0.52066535", "0.5206346", "0.5190178", "0.5176662", "0.5173648", "0.51700884", "0.5160402", "0.51603734", "0.5159711", "0.51571214", "0.514858", "0.5147813", "0.5141632", "0.5127553", "0.511558", "0.5110491", "0.5103655", "0.51023144", "0.5100012", "0.50993574", "0.5097511", "0.5089544", "0.508374", "0.5082673", "0.5080352", "0.5079662", "0.5074501", "0.50742686", "0.50665873", "0.5059063", "0.5057164", "0.50511545", "0.50510615", "0.5046402", "0.50461024", "0.5029436", "0.5025046", "0.50203174", "0.5020238", "0.5013255", "0.50127786", "0.5012221", "0.5011548", "0.50104034", "0.50087637", "0.50078696", "0.5003506", "0.5002122", "0.49996212", "0.49992335" ]
0.0
-1
Devuelve el porcentaje de proteinas de los alimentos en la lista
def prot grtotal = 0 sum = 0 #itera en las dos listas a la vez para poder calcular las #proteinas dependiendo de la cantidad y tambien suma #todas las cantidades para poder calcular el porcentaje #despues @lista.zip(@listagr).each do |normal, gr| grtotal += gr cant = gr/1000.0 sum += normal.prot*cant end (sum*100)/grtotal end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def porcentaje_proteinas\n recorrido = lista_alimentos.head\n acumulador = 0\n porcentaje = 0\n\n while recorrido != nil\n acumulador = acumulador + recorrido.value.proteinas + recorrido.value.carbohidratos + recorrido.value.lipidos\n porcentaje = porcentaje + recorrido.value.proteinas\n\n recorrido = recorrido.next\n end\n\n ((porcentaje * 100)/acumulador).round(2)\n end", "def porcentaje_proteinas\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n porcentaje_prot = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n porcentaje_prot += (auxNodo1.value.proteinas * auxNodo2.value) / 100\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return porcentaje_prot.round(1)\n end", "def proteinlist\n\n end", "def proteinas\n food = @ingredientes.head\n protein = 0.0\n while food != nil do\n protein += food[:value].proteinas * (food[:value].gramos / 1000.0)\n food = food[:next]\n end\n protein * (100.0 / @total_nutricional)\n end", "def porcentaje_lipidos\n recorrido = lista_alimentos.head\n acumulador = 0\n porcentaje = 0\n\n while recorrido != nil\n acumulador = acumulador + recorrido.value.proteinas + recorrido.value.carbohidratos + recorrido.value.lipidos\n porcentaje = porcentaje + recorrido.value.lipidos\n\n recorrido = recorrido.next\n end\n\n ((porcentaje * 100)/acumulador).round(2)\n end", "def por_proteinas\n\t\taux_proteinas = 0.0\n\t\ti = 0\n\t\twhile i < @lista_alimentos.size do\n\t\t\taux_proteinas += @lista_alimentos[i].proteinas * @lista_cantidades[i]\n\t\t\ti+=1\n\t\tend\n\t\treturn ((aux_proteinas/total_nutrientes)*100.0).round(2) \n\tend", "def get_proteinas\n @_100=((@proteinas*100)/@peso)\n @ir_100=(@_100/50)*100\n @porcion=((@proteinas*@gramos_porciones)/@peso)\n @ir_porcion=(@porcion/50)*100\n\t\t#p\"| #{@proteinas} | #{@_100} | #{@ir_100.round(1)}% | #{@porcion} | #{@ir_porcion.round(1)}% |\"\n [ @proteinas , @_100 , @ir_100.round(1) , @porcion , @ir_porcion.round(1) ]\n end", "def proteinas\n\t\treturn @proteinas*@cantidad\n\tend", "def porcentaje_lipidos\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n porcentaje_lip = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n porcentaje_lip += (auxNodo1.value.lipidos * auxNodo2.value) / 100\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return porcentaje_lip.round(1)\n end", "def kcalproteinas\n\t\t\t@proteinas * 4\n\t\tend", "def devolver_proteinas\n\t\treturn @proteinas\n\tend", "def por_lipidos\n\t\taux_lipidos = 0.0\n\t\ti = 1\n\t\twhile i < @lista_alimentos.size do\n\t\t\taux_lipidos += @lista_alimentos[i].lipidos * @lista_cantidades[i]\n\t\t\ti+=1\n\t\tend\n\t\treturn ((aux_lipidos/total_nutrientes)*100.0).round(2)\n\tend", "def pLipidos\n\t\tlip = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\ttotal += alimento.proteinas + alimento.lipidos + alimento.carbohidratos\n\t\t\tlip += alimento.lipidos\n\t\tend\n\t\treturn ((lip/total)*100).round\n\t\n\tend", "def pProteina \n\t\tprot = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\ttotal += (alimento.proteinas + alimento.lipidos + alimento.carbohidratos)\n\t\t\tprot += alimento.proteinas\n\t\tend\n\t\treturn ((prot/total)*100).round\t\n\tend", "def totalProteina \n\t\tprot = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\tprot += alimento.proteinas\n\t\tend\n\t\treturn prot.round(2)\n\tend", "def prot\n\t\tsuma = 0\n\t\tx = 0\n\t\tcantidad = 0\n\n\t\[email protected] do |i|\n\t\t\tcantidad = @gramos[x].valor / (i.proteinas + i.lipidos + i.carbohidratos)\n\t\t\tsuma += i.proteinas * cantidad\n\t\t\tx += 1\n\t\tend\t\n\n\t\treturn ((suma * 100) / gramos_total).round(2)\n\tend", "def porcentaje_carbohidratos\n recorrido = lista_alimentos.head\n acumulador = 0\n porcentaje = 0\n\n while recorrido != nil\n acumulador = acumulador + recorrido.value.proteinas + recorrido.value.carbohidratos + recorrido.value.lipidos\n porcentaje = porcentaje + recorrido.value.carbohidratos\n\n recorrido = recorrido.next\n end\n\n ((porcentaje * 100)/acumulador).round(2)\n end", "def total_nutrientes\n\t\ti = 0\n\t\tproteinas = carbohidratos = lipidos = 0.0\n\t\twhile i < @lista_alimentos.size do\n\t\t\tproteinas += (@lista_alimentos[i].proteinas)*(@lista_cantidades[i])\n\t\t\tcarbohidratos += (@lista_alimentos[i].carbohidratos)*(@lista_cantidades[i])\n\t\t\tlipidos += (@lista_alimentos[i].lipidos)*(@lista_cantidades[i])\n\t\t i+= 1\n\t\tend\n\t\treturn proteinas + lipidos + carbohidratos\n\tend", "def pHidratos\n\t\thidr = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\ttotal += alimento.proteinas + alimento.lipidos + alimento.carbohidratos\n\t\t\thidr += alimento.carbohidratos\n\t\tend\n\t\treturn ((hidr/total)*100).round\n\n\t\n\tend", "def proteinasIR\n\t\t((valorEnergeticoKJ.to_f*50)/8400).round(2)\n\tend", "def gramos\r\n grams = 0\r\n @lista_alimentos.each do |i|\r\n grams += 100\r\n end\r\n return grams\r\n end", "def cuantos_pares\n @pares = []\n @pares = @valores.to_h.select{|k, v| (2..2).cover?(v)}\n @pares.size\n end", "def suma_gramos\n\t\t\t@proteinas + @carbohidratos + @lipidos\n\t\tend", "def expand_peptides(peptides)\n amh = amino_acid_mass_hash()\n exp_pep = []\n if peptides.empty?\n return amh.keys\n else \n peptides.each do |pep|\n amh.keys.each do |aa|\n exp_pep << (pep + aa)\n end\n end\n end \n return exp_pep\n end", "def cartas_por_pinta\n @pintas = []\n @pintas = @mi_mano.group_by{|k, v| v[:pinta]}.map{|k, v| [k, v.count]}\n end", "def ponderado(pesos)\n @promedio = @p.zip(pesos).inject(0) do |suma, coordenada, peso| {suma+coordenada*peso }\n end\nend", "def synthesize(protein)\n adn = ''\n for a in (0..protein.length-1)\n aminoacido = protein[a,1]\n entropy = rand(100-10) + 10\n \n \n if (@aminoacidos.include?(aminoacido))\n \n adn = adn + @codons[aminoacido][entropy % (@codons[aminoacido].length)]\n end\n \n end\n @synthesize = adn\n end", "def lipidos\n food = @ingredientes.head\n lipidos = 0.0\n while food != nil do\n lipidos += food[:value].lipidos * (food[:value].gramos / 1000.0)\n food = food[:next]\n end\n lipidos * (100.0 / @total_nutricional)\n end", "def lip\n\t\tsuma = 0\n\t\tx = 0\n\t\tcantidad = 0\n\n\t\[email protected] do |i|\n\t\t\tcantidad = @gramos[x].valor / (i.proteinas + i.lipidos + i.carbohidratos)\n\t\t\tsuma += i.lipidos * cantidad\n\t\t\tx += 1\n\t\tend\t\n\n\t\treturn ((suma * 100) / gramos_total).round(2)\n\tend", "def lipidos\n\t\treturn @lipidos*@cantidad\n\tend", "def aliens\n self.populations.map do |pop|\n pop.alien\n end\n end", "def totalLipidos\n\t\tlip = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\tlip += alimento.lipidos\n\t\tend\n\t\treturn lip.round(2)\n\t\n\tend", "def proteinsPercent()\n\t\t\t\tplato = @alimentsList.head\n\t\t\t\tgrams = @gramsList.head\n\t\t\t\ttotalEnergy = 0.0\n\t\t\t\ttotalProteinsEnergy = 0.0\n\n\t\t\t\twhile plato != nil\n\t\t\t\t\ttotalEnergy += (plato.value.get_energia * grams.value) / 100\n\t\t\t\t\ttotalProteinsEnergy += (plato.value.get_energia_proteins * grams.value) / 100\n\n\t\t\t\t\tplato = plato.next\n\t\t\t\t\tgrams = grams.next\n\t\t\t\tend\n\n\t\t\t\treturn (totalProteinsEnergy * 100) / totalEnergy\n\t\t\tend", "def emisiones\n grtotal = 0\n sum = 0\n\t\t#recorre las dos listas a la vez para sacar los gases emitidos\n\t\t# de cada ingrediente segun el peso de este\n @lista.zip(@listagr).each do |normal, gr|\n cant = gr/1000.0\n sum += normal.gases*cant\n end\n @gei = sum\n\n end", "def total_ve\n\t\t\n\t\ttotal_ve = 0\n\t\ti = 0\n\t\t\n\t\twhile i < conjunto_alimentos.length do\n\t\t\n\t\t\ttotal_ve += conjunto_alimentos[i].gei + total_ve\n\t\t\ti += 1\n\n\t\tend\n\t\n\t\treturn total_ve\n\tend", "def terrenos\r\n terreno = 0\r\n @lista_alimentos.each do |i|\r\n terreno += i.terreno\r\n end\r\n return terreno\r\n end", "def asignaturas_peda_por(profe)\n # per = Horario.where('professor_id = ?', profe.id).joins(:asignatura).where('lectiva=true')\n per = Horario.where('professor_id = ?', profe.id).joins(:asignatura)\n .where('asignaturas.lectiva=TRUE').order('asignaturas.orden')\n a = per.map do |h|\n [\"#{h.asignatura.name} #{h.curso.name} \", \"#{h.horas}\"]\n end\n\n end", "def jugadas_posibles\n Array.new.tap do |jugadas_posibles|\n (1..8).each do |columna|\n (1..8).each do |fila|\n jugadas_posibles << [columna, fila] if puede_moverse?(columna, fila)\n end\n end\n end\n end", "def get_cout_ha_passages\n\t sum = 0\n\t self.putoparcelles.each do |putoparcelle|\n \t\tsum += putoparcelle.pulve.get_cout_ha_passage_col(self)\n end\n sum\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 irproteinas\n vag=(proteinas * 100) / 50\n vag.round(2)\n end", "def porcentajeGlucidos\r\n total_glucidos = 0.0\r\n la = @listaAlimentos.head\r\n lg = @listaGramos.head\r\n while la != nil do\r\n total_glucidos += (la.value.carbohidratos * lg.value) / 100\r\n la = la.next\r\n lg = lg.next\r\n end\r\n total_gramos = listaGramos.reduce(:+)\r\n porcentajeGlucidos = ((total_glucidos / total_gramos)*100).round(2)\r\n end", "def porcentaje_glucidos\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n porcentaje_gluc = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n porcentaje_gluc += (auxNodo1.value.glucidos * auxNodo2.value) / 100\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return porcentaje_gluc.round(1)\n end", "def resolve\n puts \"\\n--------------------------------\"\n puts \"Resolving isoforms...I think...\\n\\n\"\n \n pepHash = Hash.new {|h,k| h[k] = []}\n proHash = Hash.new {|h,k| h[k] = []}\n \n # Places proteins and peptides into hashes for mapping\n @samples.each do |key, value|\n value.combined.each do |file|\n File.open(file, \"r\").each_line do |line|\n parts = line.chomp.split(\"\\t\")\n peptide = parts[4]\n proteins = parts[5..-1]\n \n proteins.each do |protein|\n pepHash[peptide] << protein\n proHash[protein] << peptide\n end unless proteins == nil\n end\n end\n end\n \n # Transfers contents of hashes to arrays to allow for sorting\n pepHash.each {|key, value| @peptides << [key, value, 0]}\n proHash.each {|key, value| @proteins << [key, value, 0]}\n \n # Count unique proteins and then sort accordingly\n 0.upto(@peptides.length - 1).each do |i|\n @peptides[i][1].each {|protein| @peptides[i][2] += 1 if uniq?(@peptides, protein, i)}\n end\n \n @peptides = @peptides.sort_by {|item| [item[2], item[1].length]}\n @peptides.reverse!\n \n # Count unique peptides and then sort accordingly\n 0.upto(@proteins.length - 1).each do |i|\n @proteins[i][1].each {|peptide| @proteins[i][2] += 1 if uniq?(@proteins, peptide, i)}\n end\n \n @proteins = @proteins.sort_by {|item| [item[2], item[1].length]}\n @proteins.reverse!\n \n resolve_array(@peptides)\n resolve_array(@proteins)\n \n [@peptides, @proteins]\n end", "def geidiario\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n geitotal = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n geitotal += (auxNodo1.value.gei * auxNodo2.value) / 100\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return geitotal.round(1)\n end", "def asignar_proteinas(proteinas)\n @proteinas=proteinas\n end", "def expand_peptides_with_amino_acids(peptides, amh)\n exp_pep = []\n if peptides.empty?\n return amh.keys\n else \n peptides.each do |pep|\n amh.keys.each do |aa|\n exp_pep << (pep + aa)\n end\n end\n end \n return exp_pep\n end", "def align_all_local\n @results = []\n @proteins.each { |protein|\n @results << align_local(protein)\n }\n @results = @results.sort_by { |evaluated_protein| evaluated_protein.value }\n end", "def get_cout_ha_produits\n\t sum = 0\n\t self.putoparcelles.each do |putoparcelle|\n \t\tputoparcelle.pulve.putoproduits.each do |putoproduit|\n \t\t\tsum += putoproduit.get_cout_ha_parcelle(self)\n end\n end\n sum\n end", "def por_prote\n\t\t\t(@proteinas/suma_gramos)*100\n\t\tend", "def peptide_mass_with_amino_acids(peptide, amh)\n mass = 0\n peptide.chars.each do |pep|\n mass += amh[pep]\n end\n return mass\n end", "def vegetarian_ingredients\n vegetarian_list = shopping_list\n vegetarian_list[:protein].delete(:meat)\n vegetarian_list[:protein][:other].shift\n vegetarian_list\nend", "def lip\n grtotal = 0\n sum = 0\n\t\t#itera en las dos listas a la vez para poder calcular las \n #lipidos dependiendo de la cantidad y tambien suma\n #todas las cantidades para poder calcular el porcentaje\n #despues\n @lista.zip(@listagr).each do |normal, gr|\n grtotal += gr\n cant = gr/1000.0\n sum += normal.lip*cant\n end\n (sum*100)/grtotal\n end", "def vegetarian_ingredients \n vegetarian = shopping_list\n vegetarian[:protein].delete(:meat)\n vegetarian[:protein][:other].shift\n vegetarian\nend", "def pontosanunciante\n\n\t\tUsuario.find(self.id_usuario).meuspontos\n\n\tend", "def eficiencia_energetica\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n eficiencia_total = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n eficiencia_total += ((auxNodo1.value.terreno * auxNodo1.value.gei) / auxNodo1.value.terreno + auxNodo1.value.gei ) * auxNodo2.value\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return eficiencia_total.round(1)\n end", "def vegetaliana\n\t\thuevo = Alimento.new(\"Huevo\", 13.0, 1.1, 11.0, 4.2, 5.7)\n\t\tqueso = Alimento.new(\"Queso\",25.0,1.3,33.0,11.0,41.0)\n\t\tleche = Alimento.new(\"Leche de vaca\", 3.3, 4.8, 3.2, 3.2, 8.9)\n\t\tcerdo = Alimento.new(\"Cerdo\", 21.5, 0.0, 6.3, 7.6, 11.0)\n\t\tcordero = Alimento.new(\"Cordero\",18.0,0.0,3.1,50.0,164.0)\n\t\tvaca = Alimento.new(\"Carne de vaca\", 21.1,0.0,3.1,50.0,164.0)\n\t\tcamarones = Alimento.new(\"Camarones\",17.6,1.5,0.6,18.0,2.0)\n\t\tpollo = Alimento.new(\"Pollo\",20.6,0.0,5.6,5.7,7.1)\n\n\t\t[huevo,queso,leche,cerdo,cordero,vaca,camarones,pollo].each do |i|\n\t\t\tif (@alimentos.find { |x| x == i }) != nil\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\n\t\treturn true\n\tend", "def lipidsPercent()\n\t\t\t\tplato = @alimentsList.head\n\t\t\t\tgrams = @gramsList.head\n\t\t\t\ttotalEnergy = 0.0\n\t\t\t\ttotalLipidsEnergy = 0.0\n\n\t\t\t\twhile plato != nil\n\t\t\t\t\ttotalEnergy += (plato.value.get_energia * grams.value) / 100\n\t\t\t\t\ttotalLipidsEnergy += (plato.value.get_energia_lipidos * grams.value) / 100\n\n\t\t\t\t\tplato = plato.next\n\t\t\t\t\tgrams = grams.next\n\t\t\t\tend\n\n\t\t\t\treturn (totalLipidsEnergy * 100) / totalEnergy\n\t\t\tend", "def prepara_palavra(palavra)\r\n\tusagi=[]\r\n\tfor t in 0..(palavra.length()-1)\r\n\t\tusagi.push(palavra[t])\r\n\tend\r\n\t#puts usagi\r\n\treturn usagi\r\nend", "def por_lip\n\t\t\t(@lipidos/suma_gramos)*100\n\t\tend", "def hidratos_carbono\r\n hc = 0\r\n @lista_alimentos.each do |i|\r\n hc += i.carbohidratos\r\n end\r\n return hc\r\n end", "def get_energia_lipidos\n\t\t\t\t@lipidos * 9\n\t\t\tend", "def alignments\n map { |alignment| alignment }\n end", "def get_energia_proteins\n\t\t\t\t@proteins * 4\n\t\t\tend", "def filtrarPuentes(cad)\n aux=[]\n cad.each do |elemento|\n if (elemento[0] == \"P\")\n aux.push(convertPuente(elemento))\n end\n end\n return aux # [P,[3,1],[3,5]]\nend", "def gei\r\n geis = 0\r\n @lista_alimentos.each do |i|\r\n geis += i.gases\r\n end\r\n return geis\r\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 align_all_global\n @results = []\n @proteins.each { |protein|\n @results << align_global(protein)\n }\n @results = @results.sort_by { |evaluated_protein| evaluated_protein.value }\n end", "def totalGramos\n\t\tgramos = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\tgramos += alimento.gramos\n\t\tend\n\t\treturn gramos.round(2)\n\tend", "def get_almidon\n @_100=((@almidon*100)/@peso)\n #@ir_100=(@_100/90)*100\n @porcion=((@almidon*@gramos_porciones)/@peso)\n #@ir_porcion=(@porcion/90)*100\n [ @almidon , @_100 , 0 , @porcion , 0 ]\n end", "def peptide_to_mass(peptide)\n amh = amino_acid_mass_hash()\n mass_a = []\n peptide.chars.each {|p| mass_a << amh[p].to_s}\n mass_a.join(\"-\")\n end", "def mass(peptide)\n mass = 0\n for i in 0..peptide.length-1\n mass += peptide[i].to_i\n end\n mass\nend", "def total_protein\n food.protein * quantity\n end", "def aff()\n\t\t\t\tfor q in 1..20\n\t\t\t\t\tputs\n\t\t\t\tend\n\t\t\tprint @plateau[0][0],\" | \", @plateau[0][1],\" | \",@plateau[0][2]\n\t\t\tputs\n\t\t\tputs \"---------\"\n\t\t\tprint @plateau[1][0],\" | \", @plateau[1][1],\" | \",@plateau[1][2]\n\t\t\tputs\n\t\t\tputs \"---------\"\n\t\t\tprint @plateau[2][0],\" | \", @plateau[2][1],\" | \",@plateau[2][2]\n\t\t\tputs\n\tend", "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 disponibles\n total = []\n heros.each do |h|\n next unless h.tesoro\n next unless h.tesoro[item + 's']\n h.tesoro[item + 's'].each do |e|\n (total << h.id) if e == id\n end\n end\n total\n end", "def vizinhos_inimigos(territorio)\n r = []\n territorio.vizinhos.each do |v|\n v = get_pais(v)\n r.push v if v.owner != self\n end\n return r\n end", "def num_creator_2()\n\tlist_of_pandigs = [1,21,321,4321,54321,654321,7654321,87654321,987654321]\n\tlist_of_all_permutations = []\n\n\tlist_of_pandigs.each do |pandig|\n\t\ttemp_list = []\n\t\tpandig.to_s.each_char do |char|\n\t\t\ttemp_list << char.to_i\n\t\t\tlist_of_all_permutations << temp_list.permutation(temp_list.count).to_a\n\t\tend\n\tend\n\tclean_list = []\n\n\tlist_of_all_permutations.each do |perm|\n\t\tperm.each do |perm2|\n\t\t\t# if is_pandigital(perm2, pandigidictcreator()) == true\n\t\t\t\tclean_list << perm2.join()\n\t\t\t# end\n\t\tend\n\t\t# p perm\n\tend\n\treturn clean_list\nend", "def get_alco\n @_100=((@alco*100)/@peso)\n #@ir_100=(@_100/90)*100\n @porcion=((@alco*@gramos_porciones)/@peso)\n #@ir_porcion=(@porcion/90)*100\n [ @alco , @_100 , 0 , @porcion , 0 ]\n end", "def align_local(protein)\n # Vytvoreni tabulky\n x = protein.sequence.size\n y = @genome.sequence.size\n tab = Array.new(x+1) { Array.new(y+1) }\n\n # Vyplnime prvni radek a sloupec\n for i in 0..x\n tab[i][0] = 0\n end\n for j in 0..y\n tab[0][j] = 0\n end\n\n for i in 1..x\n for j in 1..y\n match = tab[i-1][j-1] + match(i, j, protein)\n delete = tab[i-1][j] + @@d\n insert = tab[i][j-1] + @@d\n\n tab[i][j] = [match, delete, insert, 0].max\n end\n end\n\n @table = tab\n value = 0\n @lok_max_coordinates = [0,0]\n for i in 1..x\n for j in 1..y\n if tab[i][j] >= value\n value = tab[i][j]\n @lok_max_coordinates = [i, j]\n end\n end\n end\n EvaluatedProtein.new(protein, value)\n end", "def kcallipidos\n\t\t\t@lipidos * 9\n\t\tend", "def por_carbohidratos\n \taux_carbohidratos = 0.0\n\t\ti = 1\n\t \twhile i < @lista_alimentos.size do\n\t\t\taux_carbohidratos += @lista_alimentos[i].carbohidratos * @lista_cantidades[i]\n\t\t\ti+=1\n\t\tend\n\t\treturn ((aux_carbohidratos/total_nutrientes)*100.0).round(2)\n\tend", "def emisiones_gei\n\n\t\tif @emisiones_gei == 0\n\n\t\t\t@lista_alimentos.each do |alimento|\n\n\t\t\t\t@emisiones_gei += alimento.kg_gei\n\t\t\tend\n\n\t\t\t@emisiones_gei = @emisiones_gei.round(2)\n\t\tend\n\n\n\t\t@emisiones_gei\n\tend", "def calculo_emisiones_diarias\n recorrido = lista_alimentos.head\n cantidad = lista_cantidades.head\n\n while (recorrido != nil && cantidad != nil)\n @emisiones_diarias = @emisiones_diarias + ((recorrido.value.gei * cantidad.value)/1000)\n\n recorrido = recorrido.next\n cantidad = cantidad.next\n end\n\n @emisiones_diarias\n end", "def get_usoterreno\n aux = 0.0\n @contenido.each do |alimento|\n aux += alimento.ground\n end\n @usoterreno = aux\n end", "def get_vct\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n vct = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n vct += (auxNodo1.value.get_val / (auxNodo1.value.proteinas + auxNodo1.value.glucidos + auxNodo1.value.lipidos)) * auxNodo2.value\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return vct.round(1)\n end", "def list_of_pvas\n super\n end", "def translate_allergens\n potential_allergen_ingredients.map(&:last).flatten.sort.uniq\n end", "def aff()\n\t\t\tprint @plateau[0][0],\"|\", @plateau[0][1],\"|\",@plateau[0][2]\n\t\t\tputs\n\t\t\tputs \"-----\"\n\t\t\tprint @plateau[1][0],\"|\", @plateau[1][1],\"|\",@plateau[1][2]\n\t\t\tputs\n\t\t\tputs \"-----\"\n\t\t\tprint @plateau[2][0],\"|\", @plateau[2][1],\"|\",@plateau[2][2]\n\t\t\tputs\n\tend", "def nucleotide_pi(seq = {})\n seq_length = seq.values[0].size - 1\n nt_position_hash = {}\n (0..seq_length).each do |n|\n nt_position_hash[n] = []\n seq.values.each do |s|\n nt_position_hash[n] << s[n]\n end\n end\n diver = 0\n com = 0\n nt_position_hash.each do |p,nt|\n nt.delete(\"-\")\n next if nt.size == 1\n nt_count = count(nt)\n combination = (nt.size)*(nt.size - 1)/2\n com += combination\n a = nt_count[\"A\"]\n c = nt_count[\"C\"]\n t = nt_count[\"T\"]\n g = nt_count[\"G\"]\n div = a*c + a*t + a*g + c*t + c*g + t*g\n diver += div\n end\n pi = (diver/com.to_f).round(5)\n return pi\nend", "def to_s\n\t\ti=0\n\t\tcadena = \"\"\n\t\twhile i<@lista_alimentos.size do\n\t\t\tcadena += \"#{@lista_alimentos[i].nombre} -> #{@lista_cantidades[i]} \"\n\t\t\ti += 1\n\t\t\n\t\tend\n\t\n\t\treturn cadena\n\tend", "def find_transcript_pbs(fasta)\n proteins = {}\n fasta = (fasta || '').gsub(/(n|N)/, '')\n unless fasta.empty?\n begin\n uri = URI(@config[:rbpdb][:url] + @config[:rbpdb][:pbs_path])\n res = Net::HTTP.post_form(\n uri,\n 'thresh' => 0.8,\n 'seq' => fasta\n )\n page = Nokogiri::HTML(res.body)\n page.css('table.pme-main tr.pme-row-0, table.pme-main tr.pme-row-1').each do |row|\n # Fetch base data.\n pos = Container::Position.new(\n score: row.children[1].text[0...-1].to_i,\n start: row.children[3].text.to_i,\n end: row.children[4].text.to_i,\n seq: row.children[5].text\n )\n\n # Fetch protein name and build result structure.\n prot = row.children[2].children[0].text.upcase\n proteins[prot] ||= Container::Protein.new(name: prot)\n proteins[prot].positions << pos\n end\n rescue StandardError => e\n puts e.message, e.backtrace\n retry\n end\n end\n proteins\n end", "def vocal_en_nombre_piloto(pilotos) \n pos = 0\n mayor = 0\n\n for i in 0..pilotos.size-1\n nombre = pilotos[i].downcase\n\n contador = 0\n for j in 0..nombre.size-1\n letra = nombre[j]\n if letra == 'a' || letra == 'e' || letra == 'i' || letra =='o' || letra =='u'\n contador = contador + 1\n end\n end\n\n if contador > mayor\n mayor = contador\n pos = i\n end\n end\n\n return pilotos[pos]\n\nend", "def huella\n huella = @alimentos.inject([0,0,0]) do |acc, i|\n if i.kcal_total < 670\n acc[0] += (1.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n elsif i.kcal_total > 830\n acc[0] += (3.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n else acc[0] += (2.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n end\n if (i.gases * 1000.0) < 800\n acc[0] += (1.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n elsif (i.gases * 1000.0) > 1200\n acc[0] += (3.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n else\n acc[0] += (2.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n\t\t\tend\n\n\t\t\tacc[2] += (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos))\n acc[1] += 1\n acc\n\t\tend\n\n\t\treturn (huella[0] / (2.0 * huella[2])).round(2)\n\tend", "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 show\n @header_class = 'TPA'\n # process parameters\n # should we equate I and L?\n equate_il = (params[:equate_il] == 'equateIL')\n # the sequence or id of the peptide\n seq = params[:id].upcase.gsub(/\\P{ASCII}/, '')\n\n # process the input, convert seq to a valid @sequence\n if seq.match?(/\\A[0-9]+\\z/)\n sequence = Sequence.includes(peptides: { uniprot_entry: %i[taxon] }).find_by(id: seq)\n @original_sequence = sequence.sequence\n else\n sequence = Sequence.single_search(seq, equate_il)\n @original_sequence = seq\n end\n\n # quit if it doensn't contain any peptides\n raise(NoMatchesFoundError, sequence.sequence) if sequence.present? && sequence.peptides(equate_il).empty?\n\n # get the uniprot entries of every peptide\n # only used for the open in uniprot links\n # and calculate the LCA\n if sequence.nil?\n # we didn't find the sequence in the database, so let's try to split it\n long_sequences = Sequence.advanced_single_search(seq, equate_il)\n # calculate possible uniprot entries\n temp_entries = long_sequences.map { |s| s.peptides(equate_il).map(&:uniprot_entry).to_set }\n # take the intersection of all sets\n @entries = temp_entries.reduce(:&)\n # check if the protein contains the startsequence\n @entries.select! { |e| e.protein_contains?(seq, equate_il) }\n\n # Calculate fa summary\n @fa_summary = UniprotEntry.summarize_fa(@entries)\n\n raise(NoMatchesFoundError, seq) if @entries.empty?\n\n @lineages = @entries.map(&:lineage).compact\n else\n @entries = sequence.peptides(equate_il).map(&:uniprot_entry)\n @lineages = sequence.lineages(equate_il, true).to_a\n\n # Get FA summary form cache\n @fa_summary = sequence.calculate_fa(equate_il)\n end\n\n @lca_taxon = Lineage.calculate_lca_taxon(@lineages) # calculate the LCA\n @root = Node.new(1, 'Organism', nil, 'root') # start constructing the tree\n common_hits = @lineages.map(&:hits).reduce(:+)\n @root.data['count'] = common_hits\n last_node = @root\n\n # common lineage\n @common_lineage = [] # construct the common lineage in this array\n l = @lca_taxon.lineage\n found = (@lca_taxon.name == 'root')\n while !found && l.has_next?\n t = l.next_t\n next if t.nil?\n\n found = (@lca_taxon.id == t.id)\n @common_lineage << t\n node = Node.new(t.id, t.name, @root, t.rank)\n node.data['count'] = common_hits\n last_node = last_node.add_child(node)\n end\n\n # distinct lineage\n @lineages.map { |lineage| lineage.set_iterator_position(l.get_iterator_position) }\n @lineages.each do |lineage|\n last_node_loop = last_node\n l = []\n while lineage.has_next?\n t = lineage.next_t\n next if t.nil?\n\n l << t.name # add the taxon name to the lineage\n node = Node.find_by_id(t.id, @root)\n if node.nil? # if the node isn't create yet\n node = Node.new(t.id, t.name, @root, t.rank)\n node.data['count'] = lineage.hits\n last_node_loop = last_node_loop.add_child(node)\n else\n node.data['count'] += lineage.hits\n last_node_loop = node\n end\n end\n end\n\n # don't show the root when we don't need it\n @root.sort_children\n\n # Table stuff\n @table_lineages = []\n @table_ranks = []\n\n @lineages.uniq!\n @table_lineages << @lineages.map { |lineage| lineage.name.name }\n @table_ranks << 'Organism'\n @lineages.map { |lineage| lineage.set_iterator_position(0) } # reset the iterator\n while @lineages[0].has_next?\n temp = @lineages.map(&:next_t)\n unless temp.compact.empty? # don't do anything if it only contains nils\n @table_lineages << temp\n @table_ranks << temp.compact[0].rank\n end\n end\n\n # sort by id from left to right\n root_taxon = Taxon.find(1)\n @table_lineages = @table_lineages.transpose.sort_by { |k| k[1..-1].map! { |lin| lin || root_taxon } }\n\n # sort entries\n @entries = @entries.to_a.sort_by { |e| e.taxon.nil? ? '' : e.taxon.name }\n\n @title = \"Tryptic peptide analysis of #{@original_sequence}\"\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @entries.to_json(only: :uniprot_accession_number, include: [{ ec_cross_references: { only: :ec_number_code } }, { go_cross_references: { only: :go_term_code } }]) }\n # TODO: switch to OJ for higher performance\n # format.json { render json: Oj.dump(@entries, :include => :name, :mode => :rails) }\n end\n rescue SequenceTooShortError\n flash[:error] = 'The sequence you searched for is too short.'\n redirect_to search_single_url\n rescue NoMatchesFoundError => e\n flash[:error] = \"No matches for peptide #{e.message}\"\n redirect_to search_single_url\n end", "def peptide_mass(peptide)\n mass = 0\n amh = amino_acid_mass_hash()\n peptide.chars.each do |pep|\n mass += amh[pep]\n end\n return mass\n end", "def minimum_proteins!(peptide_hits)\n #peptide_hit responds to .prots\n #peptide_hit responds to .aaseq\n \n #protein_hit responds to .id\n #protein_hit responds to .peps\n \n prot_to_peps, most_overlap, pep_to_prots = prepare_data(peptide_hits)\n \n prot_to_peps_sorted = prot_to_peps.sort_by do |prot, peps|\n # e.g. [ 0, 3, 2, 5]\n # [ 3 peptides with 1 unique protein, 2 peptides with 2 unique proteins,\n # 5 peptides with 3 unique proteins ]\n # !! the first index is always zero\n uniqueness_ar = Array.new(most_overlap+1,0)\n peps.each do |pep|\n size = pep_to_prots[pep].size\n uniqueness_ar[pep_to_prots[pep].size] += 1 # the num of proteins pep belongs to\n end\n uniqueness_ar\n end.reverse\n \n peps_seen = Set.new\n final_output_hash = {}\n prot_to_peps_sorted.each do |prot, peps_set|\n refined = peps_set.to_a.reject do |pep|\n if peps_seen.include?(pep)\n true\n else\n peps_seen << pep\n false\n end\n end\n \n final_output_hash[prot] = refined if refined.size > 0\n end\n \n final_peps_to_prots = Hash.new{ |h,k| h[k] = [] }\n final_output_hash.each do |prot, peps|\n peps.each {|pep| final_peps_to_prots[pep] << prot}\n end\n \n update_hits(peptide_hits, final_peps_to_prots)\n end", "def totalHidratos\n\t\thidr = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\thidr += alimento.carbohidratos\n\t\tend\n\t\treturn hidr.round(2)\n\tend", "def terreno\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n terrenototal = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n terrenototal += (auxNodo1.value.terreno * auxNodo2.value) / 100\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return terrenototal.round(1)\n end" ]
[ "0.75712186", "0.745569", "0.7149723", "0.71058214", "0.6997187", "0.69279116", "0.69185823", "0.69174534", "0.67578334", "0.67186654", "0.6548565", "0.6401285", "0.6373599", "0.6345635", "0.63302827", "0.6183669", "0.61441857", "0.6132254", "0.6110774", "0.60939866", "0.6084231", "0.5962558", "0.5949061", "0.5927201", "0.5865507", "0.5865047", "0.585638", "0.58246964", "0.58101493", "0.5806919", "0.5777685", "0.57734257", "0.5771528", "0.57590187", "0.575152", "0.5742355", "0.5715997", "0.569911", "0.5680439", "0.56588334", "0.5655562", "0.5621687", "0.56147176", "0.560457", "0.5597023", "0.5592546", "0.5586124", "0.55680746", "0.5557772", "0.555544", "0.55278164", "0.55005854", "0.5490084", "0.54749835", "0.5472706", "0.5451753", "0.5442618", "0.5434795", "0.5433192", "0.5422024", "0.54178363", "0.5412988", "0.53871375", "0.53810376", "0.5374321", "0.53743184", "0.5373566", "0.5356299", "0.53469324", "0.53111726", "0.5279784", "0.5265542", "0.5255221", "0.52537215", "0.5247508", "0.5247328", "0.5245518", "0.52436256", "0.52376497", "0.5226281", "0.5216581", "0.521122", "0.52094084", "0.52064854", "0.5198619", "0.5176631", "0.51747584", "0.515862", "0.5156991", "0.51516986", "0.51418877", "0.51404136", "0.5137735", "0.5135792", "0.51129615", "0.51101106", "0.5107444", "0.51040006", "0.5100506", "0.5092281" ]
0.6531954
11
Devuelve el porcentaje de lipidos de los alimentos en la lista
def lip grtotal = 0 sum = 0 #itera en las dos listas a la vez para poder calcular las #lipidos dependiendo de la cantidad y tambien suma #todas las cantidades para poder calcular el porcentaje #despues @lista.zip(@listagr).each do |normal, gr| grtotal += gr cant = gr/1000.0 sum += normal.lip*cant end (sum*100)/grtotal end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lipidos\n\t\treturn @lipidos*@cantidad\n\tend", "def porcentaje_lipidos\n recorrido = lista_alimentos.head\n acumulador = 0\n porcentaje = 0\n\n while recorrido != nil\n acumulador = acumulador + recorrido.value.proteinas + recorrido.value.carbohidratos + recorrido.value.lipidos\n porcentaje = porcentaje + recorrido.value.lipidos\n\n recorrido = recorrido.next\n end\n\n ((porcentaje * 100)/acumulador).round(2)\n end", "def lipidos\n food = @ingredientes.head\n lipidos = 0.0\n while food != nil do\n lipidos += food[:value].lipidos * (food[:value].gramos / 1000.0)\n food = food[:next]\n end\n lipidos * (100.0 / @total_nutricional)\n end", "def porcentaje_lipidos\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n porcentaje_lip = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n porcentaje_lip += (auxNodo1.value.lipidos * auxNodo2.value) / 100\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return porcentaje_lip.round(1)\n end", "def por_lipidos\n\t\taux_lipidos = 0.0\n\t\ti = 1\n\t\twhile i < @lista_alimentos.size do\n\t\t\taux_lipidos += @lista_alimentos[i].lipidos * @lista_cantidades[i]\n\t\t\ti+=1\n\t\tend\n\t\treturn ((aux_lipidos/total_nutrientes)*100.0).round(2)\n\tend", "def totalLipidos\n\t\tlip = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\tlip += alimento.lipidos\n\t\tend\n\t\treturn lip.round(2)\n\t\n\tend", "def terrenos\r\n terreno = 0\r\n @lista_alimentos.each do |i|\r\n terreno += i.terreno\r\n end\r\n return terreno\r\n end", "def disponibles\n total = []\n heros.each do |h|\n next unless h.tesoro\n next unless h.tesoro[item + 's']\n h.tesoro[item + 's'].each do |e|\n (total << h.id) if e == id\n end\n end\n total\n end", "def pLipidos\n\t\tlip = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\ttotal += alimento.proteinas + alimento.lipidos + alimento.carbohidratos\n\t\t\tlip += alimento.lipidos\n\t\tend\n\t\treturn ((lip/total)*100).round\n\t\n\tend", "def calculo_emisiones_diarias\n recorrido = lista_alimentos.head\n cantidad = lista_cantidades.head\n\n while (recorrido != nil && cantidad != nil)\n @emisiones_diarias = @emisiones_diarias + ((recorrido.value.gei * cantidad.value)/1000)\n\n recorrido = recorrido.next\n cantidad = cantidad.next\n end\n\n @emisiones_diarias\n end", "def emisiones\n grtotal = 0\n sum = 0\n\t\t#recorre las dos listas a la vez para sacar los gases emitidos\n\t\t# de cada ingrediente segun el peso de este\n @lista.zip(@listagr).each do |normal, gr|\n cant = gr/1000.0\n sum += normal.gases*cant\n end\n @gei = sum\n\n end", "def aliens\n self.populations.map do |pop|\n pop.alien\n end\n end", "def porcentaje_glucidos\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n porcentaje_gluc = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n porcentaje_gluc += (auxNodo1.value.glucidos * auxNodo2.value) / 100\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return porcentaje_gluc.round(1)\n end", "def ordenar_for\n\t @lista = self.map{ |a| a }\n\t \tfor i in ([email protected])\n\t\t\tfor j in ([email protected])\n\t\t\t\tif j+1 != @lista.count\n if @lista[j+1] < @lista[j]\n\t\t\t\t\t\t@lista[j],@lista[j+1] = @lista[j+1],@lista[j]\n \t\t\t\tend\n\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t@lista\n end", "def hidratos_carbono\r\n hc = 0\r\n @lista_alimentos.each do |i|\r\n hc += i.carbohidratos\r\n end\r\n return hc\r\n end", "def porcentaje_carbohidratos\n recorrido = lista_alimentos.head\n acumulador = 0\n porcentaje = 0\n\n while recorrido != nil\n acumulador = acumulador + recorrido.value.proteinas + recorrido.value.carbohidratos + recorrido.value.lipidos\n porcentaje = porcentaje + recorrido.value.carbohidratos\n\n recorrido = recorrido.next\n end\n\n ((porcentaje * 100)/acumulador).round(2)\n end", "def hidratos \n\t\t@hidratos = @azucares + @polialcoles + @almidon\n\t\treturn @hidratos\n\tend", "def porcentaje_proteinas\n recorrido = lista_alimentos.head\n acumulador = 0\n porcentaje = 0\n\n while recorrido != nil\n acumulador = acumulador + recorrido.value.proteinas + recorrido.value.carbohidratos + recorrido.value.lipidos\n porcentaje = porcentaje + recorrido.value.proteinas\n\n recorrido = recorrido.next\n end\n\n ((porcentaje * 100)/acumulador).round(2)\n end", "def total_nutrientes\n\t\ti = 0\n\t\tproteinas = carbohidratos = lipidos = 0.0\n\t\twhile i < @lista_alimentos.size do\n\t\t\tproteinas += (@lista_alimentos[i].proteinas)*(@lista_cantidades[i])\n\t\t\tcarbohidratos += (@lista_alimentos[i].carbohidratos)*(@lista_cantidades[i])\n\t\t\tlipidos += (@lista_alimentos[i].lipidos)*(@lista_cantidades[i])\n\t\t i+= 1\n\t\tend\n\t\treturn proteinas + lipidos + carbohidratos\n\tend", "def lip\n\t\tsuma = 0\n\t\tx = 0\n\t\tcantidad = 0\n\n\t\[email protected] do |i|\n\t\t\tcantidad = @gramos[x].valor / (i.proteinas + i.lipidos + i.carbohidratos)\n\t\t\tsuma += i.lipidos * cantidad\n\t\t\tx += 1\n\t\tend\t\n\n\t\treturn ((suma * 100) / gramos_total).round(2)\n\tend", "def cuantos_pares\n @pares = []\n @pares = @valores.to_h.select{|k, v| (2..2).cover?(v)}\n @pares.size\n end", "def total_ve\n\t\t\n\t\ttotal_ve = 0\n\t\ti = 0\n\t\t\n\t\twhile i < conjunto_alimentos.length do\n\t\t\n\t\t\ttotal_ve += conjunto_alimentos[i].gei + total_ve\n\t\t\ti += 1\n\n\t\tend\n\t\n\t\treturn total_ve\n\tend", "def clasificar_por_sal (lista)\n \n sal_recomendada = Lista.new()\n sal_excesiva = Lista.new()\n \n nodo = lista.extract\n \n while !(nodo.nil?)\n \n if nodo.value.sal > 6\n sal_excesiva.insert(nodo.value.sal)\n else\n sal_recomendada.insert(nodo.value.sal)\n end\n nodo = lista.extract\n end\n \n \"Los productos con una cantidad de sal menor o igual a la recomendada son #{sal_recomendada.to_s} y los que tienen una sal excesiva son #{sal_excesiva.to_s}\"\n \nend", "def lifters\n # binding.pry\n memberships.map { |membership| membership.lifter }.uniq\n end", "def ContarHijos(menu,padreid)\n @opcionMenus = OpcionMenu.all \n @son=0\n @i=1\n @opcionMenus.each do |arbol| \n \tif arbol.menu_id.to_i==menu.id.to_i and arbol.padre_id.to_i==padreid.to_i\n \t @son=@son+1\n \t @i=@i+1;\n \tend\n end\n return @son \n end", "def get_usoterreno\n aux = 0.0\n @contenido.each do |alimento|\n aux += alimento.ground\n end\n @usoterreno = aux\n end", "def huella\n\t\tindice1 = 0\n\t\t#dependiendo del vct de cada ingrediente, se le pone un indice\n\t\tif vct < 670\n\t\t\tindice1 = 1\n\t\t\t\n\t\telsif vct > 830\n\t\t\tindice1 = 3\n\t\telse \n\t\t\tindice1 = 2\n\t\tend \n\t\tindice2 = 0\n\t\t#dependiendo de los gases emitidos de cada ingrediente, \n\t\t#se le pone un indice\n\t\tif emisiones < 800\n\t\t\tindice2 = 1\n\t\telsif emisiones > 1200\n\t\t\tindice2 = 3\n\t\telse \n\t\t\tindice2 = 2\n\t\tend\n\t\t#hace la media de los indices sacados\n\t\tindiceres = (indice1+indice2)/2\n\t\t\n\n\tend", "def gei\r\n geis = 0\r\n @lista_alimentos.each do |i|\r\n geis += i.gases\r\n end\r\n return geis\r\n end", "def lipidsPercent()\n\t\t\t\tplato = @alimentsList.head\n\t\t\t\tgrams = @gramsList.head\n\t\t\t\ttotalEnergy = 0.0\n\t\t\t\ttotalLipidsEnergy = 0.0\n\n\t\t\t\twhile plato != nil\n\t\t\t\t\ttotalEnergy += (plato.value.get_energia * grams.value) / 100\n\t\t\t\t\ttotalLipidsEnergy += (plato.value.get_energia_lipidos * grams.value) / 100\n\n\t\t\t\t\tplato = plato.next\n\t\t\t\t\tgrams = grams.next\n\t\t\t\tend\n\n\t\t\t\treturn (totalLipidsEnergy * 100) / totalEnergy\n\t\t\tend", "def ordenEachMenus (array)\n ordenado = []\n array.each do\n |nodo|\n if ordenado.empty?\n ordenado.push(nodo)\n else\n indice = 0\n while indice < ordenado.length\n aporteActual = (nodo.collect { |alimento| alimento.valorEnergeticoKcal}).reduce(:+)\n aporteSiguiente = (ordenado[indice].collect { |alimento| alimento.valorEnergeticoKcal}).reduce(:+)\n if aporteActual <= aporteSiguiente\n ordenado.insert(indice, nodo)\n break\n elsif indice == ordenado.length-1\n ordenado.insert(indice+1, nodo)\n break\n end\n indice+=1\n end\n end\n end\n return ordenado\nend", "def set_listas\n #@locais = Local.all.map{|l| [l.nome,l.id]}\n @locais = Local.all\n @periodos = ['Manhã','Tarde','Noite']\n @publicos = ['Infantil','Adulto']\n end", "def lineage\n\t\tparents = []\n\t\tlist = self\n\t\twhile list.parentlist_id\n\t\t\tlist = List.find(list.parentlist_id)\n\t\t\tparents << list\n\t\tend\n\t\t\n\t\tif parents.length > 0\n \t\tparents.reverse!.slice(1..-1)\n else\n parents\n end\n end", "def pHidratos\n\t\thidr = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\ttotal += alimento.proteinas + alimento.lipidos + alimento.carbohidratos\n\t\t\thidr += alimento.carbohidratos\n\t\tend\n\t\treturn ((hidr/total)*100).round\n\n\t\n\tend", "def porcentajeGlucidos\r\n total_glucidos = 0.0\r\n la = @listaAlimentos.head\r\n lg = @listaGramos.head\r\n while la != nil do\r\n total_glucidos += (la.value.carbohidratos * lg.value) / 100\r\n la = la.next\r\n lg = lg.next\r\n end\r\n total_gramos = listaGramos.reduce(:+)\r\n porcentajeGlucidos = ((total_glucidos / total_gramos)*100).round(2)\r\n end", "def asignaturas_peda_por(profe)\n # per = Horario.where('professor_id = ?', profe.id).joins(:asignatura).where('lectiva=true')\n per = Horario.where('professor_id = ?', profe.id).joins(:asignatura)\n .where('asignaturas.lectiva=TRUE').order('asignaturas.orden')\n a = per.map do |h|\n [\"#{h.asignatura.name} #{h.curso.name} \", \"#{h.horas}\"]\n end\n\n end", "def geidiario\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n geitotal = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n geitotal += (auxNodo1.value.gei * auxNodo2.value) / 100\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return geitotal.round(1)\n end", "def show\n @occupant = Occupant.find(params[:id])\n\n\n @d_list = Array.new # список требуемых умений (пока пустой)\n @descriptions = @occupant.oskills.select(\"description\").where(:id => @occupant.oskills) # умения из id в текст\n @descriptions.each do |d| #\n @d_list << d.description # заполнение списка умений\n end #\n @good_skills_with_job_id = Jskill.select(\"job_list_id\").where(:description => @d_list) # выбор подходящих умений среди всех вакансий\n @id_list = Array.new # список id подходящих вакансий (с дублями)\n @good_skills_with_job_id.each do |s| #\n @id_list << s.job_list_id # заполнение списка id\n end #\n @id_list_unique = @id_list.uniq # список уникальных id\n @fully_compatible_job_list_ids = Array.new # список вакансий, полностью подходящих по набору умений (пока пустой)\n\n @current_job_skills = Array.new # список всех требуемых умений вакансии (временный)\n @id_list_unique.each do |i| #\n @current_job_skill_ids = Jskill.select(\"description\").where(:job_list_id => i) # получение списка id всех требуемых умений вакансии\n @current_job_skills.clear #\n @current_job_skill_ids.each do |e| #\n @current_job_skills << e.description # заполнение списка всех требуемых умений вакансии\n end #\n if (@d_list & @current_job_skills).size == @current_job_skills.size #\n @fully_compatible_job_list_ids << i # заполнение списка id вакансий, полностью подходящих по набору умений\n end #\n end #\n @partially_compatible_job_list_ids = @id_list_unique - @fully_compatible_job_list_ids # заполнение списка id вакансий, частично подходящих по набору умений\n\n @fully_compatible_job_lists = JobList.where(\"expire > :expire AND id IN (:id)\", {:expire => Time.now.to_date, :id => @fully_compatible_job_list_ids}).order(\"salary DESC\")\n @partially_compatible_job_lists = JobList.where(\"expire > :expire AND id IN (:id)\", {:expire => Time.now.to_date, :id => @partially_compatible_job_list_ids}).order(\"salary DESC\")\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @occupant }\n end\n end", "def prot\n\t\tgrtotal = 0\n\t\tsum = 0\n\t\t#itera en las dos listas a la vez para poder calcular las\n\t\t#proteinas dependiendo de la cantidad y tambien suma\n\t\t#todas las cantidades para poder calcular el porcentaje\n\t\t#despues\n\t\[email protected](@listagr).each do |normal, gr|\n\t\t\tgrtotal += gr\n\t\t\tcant = gr/1000.0\n\t\t\tsum += normal.prot*cant \n\t\tend\n\t\t(sum*100)/grtotal\n\tend", "def eficiencia_energetica\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n eficiencia_total = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n eficiencia_total += ((auxNodo1.value.terreno * auxNodo1.value.gei) / auxNodo1.value.terreno + auxNodo1.value.gei ) * auxNodo2.value\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return eficiencia_total.round(1)\n end", "def vegetaliana\n\t\thuevo = Alimento.new(\"Huevo\", 13.0, 1.1, 11.0, 4.2, 5.7)\n\t\tqueso = Alimento.new(\"Queso\",25.0,1.3,33.0,11.0,41.0)\n\t\tleche = Alimento.new(\"Leche de vaca\", 3.3, 4.8, 3.2, 3.2, 8.9)\n\t\tcerdo = Alimento.new(\"Cerdo\", 21.5, 0.0, 6.3, 7.6, 11.0)\n\t\tcordero = Alimento.new(\"Cordero\",18.0,0.0,3.1,50.0,164.0)\n\t\tvaca = Alimento.new(\"Carne de vaca\", 21.1,0.0,3.1,50.0,164.0)\n\t\tcamarones = Alimento.new(\"Camarones\",17.6,1.5,0.6,18.0,2.0)\n\t\tpollo = Alimento.new(\"Pollo\",20.6,0.0,5.6,5.7,7.1)\n\n\t\t[huevo,queso,leche,cerdo,cordero,vaca,camarones,pollo].each do |i|\n\t\t\tif (@alimentos.find { |x| x == i }) != nil\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\n\t\treturn true\n\tend", "def mastered_weapon_proficiencies\n self.weapon_categories.map(&:common_weapons).flatten.map(&:id) + self.common_weapons.map(&:id)\n end", "def listarAjudas(numAjuda = 0)\n\n ajd = []\n index = 0\n numAjuda.times do\n ajd << @plvAjudas[index]\n index += 1\n end\n return ajd\n end", "def nivel_no_final\r\n #collect llama al bloque una vez por cada elemento del mismo y crea un nuevo arreglo que contiene los valores retornados\r\n #nivels = movimiento.collect{ |valor_pos| valor_pos.nivel }\r\n \r\n if jugador_actual == 'O'\r\n movimiento.collect{ |valor_pos| valor_pos.nivel }.min\r\n #nivels.max\r\n else\r\n movimiento.collect{ |valor_pos| valor_pos.nivel }.max\r\n end\r\n end", "def gramos\r\n grams = 0\r\n @lista_alimentos.each do |i|\r\n grams += 100\r\n end\r\n return grams\r\n end", "def terreno\n grtotal = 0\n sum = 0\n\t\t#recorre las dos listas a la vez para sacar el terreno\n #usado de cada ingrediente segun el peso de este\n @lista.zip(@listagr).each do |normal, gr|\n cant = gr/1000.0\n sum += normal.terreno*cant\n end\n @terreno = sum\n\n end", "def current_astronauts\n missions.map {|mission| mission.astronaut}.uniq\n \n end", "def galleries\n self.paintings.map{|painitng| painitng.gallery}.uniq\n end", "def laughers \n self.funnies.map {|funny| funny.user_id}\n end", "def clasificar_por_imc (lista)\n \n imc_bajo = Lista.new()\n imc_normal = Lista.new()\n imc_excesivo = Lista.new()\n\n nodo = lista.extract\n \n while !(nodo.nil?)\n\n if nodo.value.datos_ant.indice_masa_corporal >= 30\n imc_excesivo.insert(nodo.value.datos_ant.indice_masa_corporal)\n elsif nodo.value.datos_ant.indice_masa_corporal >=18.5\n imc_normal.insert(nodo.value.datos_ant.indice_masa_corporal)\n else\n imc_bajo.insert(nodo.value.datos_ant.indice_masa_corporal)\n end\n nodo = lista.extract\n end\n\n \"Los IMC por debajo de lo normal son #{imc_bajo.to_s}, los IMC dentro de lo normal son #{imc_normal.to_s} y los que tienen un IMC excesivo son #{imc_excesivo.to_s}\"\n\nend", "def porcentaje_proteinas\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n porcentaje_prot = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n porcentaje_prot += (auxNodo1.value.proteinas * auxNodo2.value) / 100\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return porcentaje_prot.round(1)\n end", "def lista(contatos)\n\tfor i in 0..contatos.size-1\n\t\tputs (\"#{i+1}. #{contatos[i].nome}\")\n\t\ti = i + 1\n\tend\nend", "def vizinhos_inimigos(territorio)\n r = []\n territorio.vizinhos.each do |v|\n v = get_pais(v)\n r.push v if v.owner != self\n end\n return r\n end", "def totalHidratos\n\t\thidr = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\thidr += alimento.carbohidratos\n\t\tend\n\t\treturn hidr.round(2)\n\tend", "def show\n\t @lawyers = Lawyer.all\n @states = State.all\n\n @NumLaw = 0 # Contador de posições do vetor @AvailableLawyers\n @AvailableLawyers = []\n\n for i in [email protected] \n if ((@client.state).upcase).split == (@lawyers[i].state).split # Verificador Estado do cliente \n # = Estado do advogado \n @AvailableLawyers[@NumLaw] = @lawyers[i]\n @NumLaw += 1 \n end \n end \n\n if @AvailableLawyers.empty? # Se estiver vazio, retorna 0 e exibe na tela:\n #\"Desculpe, não possuímos nenhum advogado cadastrado no seu estado.\"\n @IdealLawyer = 0 \n \n else \n\n for j in [email protected]\n\n if @AvailableLawyers[0].state == @states[j].name\n\n save = j # Salva a posição do estado em questão\n break\n\n end \n end\n\n for i in [email protected]\n\n if (@states[save].interaction ).to_i > @AvailableLawyers.length \n\n @states[save].interaction = \"1\" # Caso o número de interações exceder o limite, dá reset\n\n end \n\n if @AvailableLawyers[i].order == @states[save].interaction\n \n @IdealLawyer = @AvailableLawyers[i] # Retorno do advogado na mesma ordem da interação\n break\n\n end\n end \n \n @states[save].interaction = ((@states[save].interaction).to_i + 1).to_s # Crescendo a fila\n @states[save].save\n\n end\n end", "def emisiones_gei\n\n\t\tif @emisiones_gei == 0\n\n\t\t\t@lista_alimentos.each do |alimento|\n\n\t\t\t\t@emisiones_gei += alimento.kg_gei\n\t\t\tend\n\n\t\t\t@emisiones_gei = @emisiones_gei.round(2)\n\t\tend\n\n\n\t\t@emisiones_gei\n\tend", "def get_cout_ha_passages\n\t sum = 0\n\t self.putoparcelles.each do |putoparcelle|\n \t\tsum += putoparcelle.pulve.get_cout_ha_passage_col(self)\n end\n sum\n end", "def cartas_por_pinta\n @pintas = []\n @pintas = @mi_mano.group_by{|k, v| v[:pinta]}.map{|k, v| [k, v.count]}\n end", "def totalSimplificado\n @biblioteca.livrosComoLista.map(&:preco).inject(0){|total, preco| total += preco}\n end", "def total_life\n items.map(&:life).inject(0) { |sum, current| sum += current }\n end", "def show\n @job_list = JobList.find(params[:id])\n \n @d_list = Array.new # список требуемых умений (пока пустой)\n @descriptions = @job_list.jskills.select(\"description\").where(:id => @job_list.jskills) # умения из id в текст\n @descriptions.each do |d| #\n @d_list << d.description # заполнение списка умений\n end #\n @good_skills_with_occupant_id = Oskill.select(\"occupant_id\").where(:description => @d_list) # выбор подходящих умений среди всех кандидатов\n @id_list = Array.new # список id подходящих работников (с дублями)\n @good_skills_with_occupant_id.each do |s| #\n @id_list << s.occupant_id # заполнение списка id\n end #\n @id_list_unique = @id_list.uniq # список уникальных id\n @fully_compatible_occupant_ids = Array.new # список работников, полностью подходящих по набору умений (пока пустой)\n @id_list_unique.each do |i| #\n if @id_list.find_all{ |ii| ii == i }.size == @d_list.size #\n @fully_compatible_occupant_ids << i # заполнение списка id работников, полностью подходящих по набору умений\n end #\n end #\n @partially_compatible_occupant_ids = @id_list_unique - @fully_compatible_occupant_ids # заполнение списка id работников, частично подходящих по набору умений\n\n @fully_compatible_occupants = Occupant.where(:status => 1, :id => @fully_compatible_occupant_ids).order(\"salary ASC\")\n @partially_compatible_occupants = Occupant.where(:status => 1, :id => @partially_compatible_occupant_ids).order(\"salary ASC\")\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @job_list }\n end\n end", "def callout_ids(li_ordinal)\n current_list.inject([]) {|collector, element|\n collector << element[:id] if element[:ordinal] == li_ordinal\n collector\n } * ' '\n end", "def cantidad_casas_hoteles\n aux = 0\n \n @propiedades.each do |i|\n aux += i.cantidad_casas_hoteles\n end\n \n return aux\n end", "def owners\n # set @owners instance variable by\n # 1) grabbing all Ownerships containing this panlist\n # 2) converting each Ownership into an Owner\n @owners ||= Ownership.where(list_id: self.id).map do |ownership|\n Owner.find_by_netid(ownership.owner_id)\n end\n end", "def curar_pokemones\n @pokemones.each do |pokemon|\n pokemon.curar\n end\n @pokemon_actual = 0\n end", "def get_energia_lipidos\n\t\t\t\t@lipidos * 9\n\t\t\tend", "def devolver_azucar \n\t\treturn @azucares\n\tend", "def contador_letras(nombres)\n nombres.map{ |x| x.length} # [7, 6, 8, 7, 5, 3, 3]\nend", "def to_s\n\ts = \"\\nLista de Individuos y sus alimentos\\n\"\n for j in [email protected]\n s << @individuos[j].to_s + \"\\n\"\n end\n s\n end", "def get_hidratos\n @_100=((@hidratos*100)/@peso)\n @ir_100=(@_100/260)*100\n @porcion=((@hidratos*@gramos_porciones)/@peso)\n @ir_porcion=(@porcion/260)*100\n [ @hidratos , @_100 , @ir_100.round(1) , @porcion , @ir_porcion.round(1) ]\n end", "def laboratorios_id\n laboratorios.all.map { |l| l.id }\n end", "def panier_en_vente\n \t@paniers_ = Panier.where('revendeur_id = ? AND deleted = 0', self.id)\n \t@paniers= []\n \t@paniers_.each do |panier|\n \t\tif panier.has_declinaison\n \t\t\t@paniers << panier\n \t\tend\n \tend\n \t\n \treturn @paniers.count\n end", "def my_followers_mottos\n followers_list.map {|f| f.life_motto}\n end", "def kcallipidos\n\t\t\t@lipidos * 9\n\t\tend", "def areatrapezoide\n\t\tdt = 5\n\t\tsi = []\n\t\tgi.each do |i|\n\t\t\ts = (((gi[i]-gi[0]) + ((gi[i - 1]) - gi[0])) /2 ) * dt\n\t\t\tsi.push(s)\n\t\tend \n\t\treturn si\n\tend", "def directs\n alias_ids.map(&:e).map(&:company).map(&:id)\n end", "def dodaj_do_listy(*jid)\n\tkontakty(*jid) do |kontakt|\n\t\tnext if subskryp?(kontakt)\n\t\tkontakt.autoryzacja\n\tend\n end", "def defeated_enemy_ids\n @defeated_enemies_count ||= {}\n @defeated_enemies_count.keys.sort\n #@defeated_enemies ||= BestiaryConfig.get_enemy_array\n end", "def jugadas_posibles\n Array.new.tap do |jugadas_posibles|\n (1..8).each do |columna|\n (1..8).each do |fila|\n jugadas_posibles << [columna, fila] if puede_moverse?(columna, fila)\n end\n end\n end\n end", "def vegetarian_ingredients\n vegetarian_list = shopping_list\n vegetarian_list[:protein].delete(:meat)\n vegetarian_list[:protein][:other].shift\n vegetarian_list\nend", "def current_occupancy\n self.dinosaurs.size\n end", "def huella\n huella = @alimentos.inject([0,0,0]) do |acc, i|\n if i.kcal_total < 670\n acc[0] += (1.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n elsif i.kcal_total > 830\n acc[0] += (3.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n else acc[0] += (2.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n end\n if (i.gases * 1000.0) < 800\n acc[0] += (1.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n elsif (i.gases * 1000.0) > 1200\n acc[0] += (3.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n else\n acc[0] += (2.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n\t\t\tend\n\n\t\t\tacc[2] += (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos))\n acc[1] += 1\n acc\n\t\tend\n\n\t\treturn (huella[0] / (2.0 * huella[2])).round(2)\n\tend", "def nombre_handle(list)\n return list.size\nend", "def nombre_enfants\n \n enfants = 0\n \n self.membres.each {\n |m|\n enfants += (age_at(Date.today, m.date_de_naissance) > 12 ? 0:1)\n }\n\n return enfants\n \n end", "def extraer_lista_final\n ref = @final\n @final = ref.anterior\n if @final != nil\n @final.siguiente = nil\n else\n @principio = @final\n end\n ref\n end", "def dominant_octopus(fish)\n #sorted = []\n return fish if fish.length < 2\n pivot = fish.first\n left = fish[1..-1].select { |feesh| feesh.length <= pivot.length }\n #p left\n right = fish[1..-1].select { |feesh| feesh.length > pivot.length }\n\n dominant_octopus(left) + [pivot] + dominant_octopus(right)\n \n\n\nend", "def por_carbohidratos\n \taux_carbohidratos = 0.0\n\t\ti = 1\n\t \twhile i < @lista_alimentos.size do\n\t\t\taux_carbohidratos += @lista_alimentos[i].carbohidratos * @lista_cantidades[i]\n\t\t\ti+=1\n\t\tend\n\t\treturn ((aux_carbohidratos/total_nutrientes)*100.0).round(2)\n\tend", "def por_proteinas\n\t\taux_proteinas = 0.0\n\t\ti = 0\n\t\twhile i < @lista_alimentos.size do\n\t\t\taux_proteinas += @lista_alimentos[i].proteinas * @lista_cantidades[i]\n\t\t\ti+=1\n\t\tend\n\t\treturn ((aux_proteinas/total_nutrientes)*100.0).round(2) \n\tend", "def lancamentos_para_efetivar\n\t\t@entries = []\n\t\tself.categories.each do |c|\n\t\t\tc.lancamentos_ate_mes(Date.today).each do |e|\n\t\t\t\tif(e.mes_nao_efetivado(Date.today))\n\t\t\t\t\t@entries << e\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t@entries\n\tend", "def moverPrimasADespacho(cantidad_lotes)\n\t\n\nend", "def verTodasVentas()\n totalVentas=0\n for i in(0..$ventas.size-1)\n for j in(0..$ventas[i].size-1)\n end\n totalVentas=totalVentas\n end\n puts \"Total Vendido: #{totalVentas}\"\n end", "def get_position_list\n\n end", "def ponderado(pesos)\n @promedio = @p.zip(pesos).inject(0) do |suma, coordenada, peso| {suma+coordenada*peso }\n end\nend", "def superweening_adorningly(counterstand_pyrenomycetales)\n end", "def list_of_pvas\n super\n end", "def points\n @puntos = 0\n students.each do |s| \n @puntos += s.points\n end\n @puntos += house_points\n end", "def ordered_list; end", "def expedientes_relacionados\n Expediente.find(:all, :conditions => %|id in (select expediente_relacion_id from expedientes_expedientes where expediente_id = #{id}) or \n id in (select expediente_id from expedientes_expedientes where expediente_relacion_id = #{id})|)\n end", "def unit_idlers\n world.units.active.find_all { |u|\n unit_isidler(u)\n }\n end", "def to_s\n recorrido = lista_alimentos.head\n cantidad = lista_cantidades.head\n formateo = []\n\n while (recorrido != nil && cantidad != nil)\n salida = cantidad.value.to_s + \"gr de \" + recorrido.value.nombre\n formateo.push(salida)\n\n recorrido = recorrido.next\n cantidad = cantidad.next\n end\n\n formateo\n end", "def valor_energetico\n\t\ti = 0\n\t\tvalorC = 0.0\n\t\twhile i< @lista_alimentos.size do\n\t\t\tvalorC += @lista_alimentos[i].valorEnergetico\n\t\t\ti+=1\n\t\tend\n\t\treturn valorC\n\tend" ]
[ "0.6922224", "0.6846168", "0.65876055", "0.6431781", "0.61838275", "0.6118949", "0.6088629", "0.606659", "0.60066", "0.5936304", "0.58227605", "0.58082926", "0.57529956", "0.5724973", "0.5722998", "0.57205975", "0.57114935", "0.5624686", "0.56010556", "0.5575378", "0.55415606", "0.5511888", "0.5510672", "0.5494803", "0.5487997", "0.54807395", "0.5477931", "0.5467936", "0.5442578", "0.5439602", "0.5438838", "0.54039246", "0.54014146", "0.5379249", "0.53763974", "0.5371634", "0.5355639", "0.53551644", "0.5354691", "0.5328702", "0.5328601", "0.5324445", "0.53225565", "0.5314008", "0.5299406", "0.5296416", "0.5283403", "0.5279107", "0.5277871", "0.52621233", "0.52612644", "0.52561665", "0.52481896", "0.5246668", "0.52398384", "0.52355516", "0.5227738", "0.520806", "0.52063644", "0.5180644", "0.5176214", "0.5173439", "0.5171195", "0.5160485", "0.51587766", "0.5156817", "0.51519", "0.5147723", "0.5123791", "0.51106745", "0.5094433", "0.5093796", "0.50869226", "0.508374", "0.50815713", "0.5077525", "0.5075974", "0.5074412", "0.50724345", "0.5070897", "0.5069993", "0.5067918", "0.50649685", "0.50589514", "0.50526917", "0.5047738", "0.5043526", "0.50419855", "0.5039959", "0.50397617", "0.5034435", "0.5026906", "0.50243765", "0.5022354", "0.50223273", "0.5019794", "0.50178915", "0.5017854", "0.50127864", "0.50127625" ]
0.61981773
4
Devuelve el porcentaje de carbohidratos de los alimentos en la lista
def carbo grtotal = 0 sum = 0 #itera en las dos listas a la vez para poder calcular las #cabrohidratos dependiendo de la cantidad y tambien suma #todas las cantidades para poder calcular el porcentaje #despues @lista.zip(@listagr).each do |normal, gr| grtotal += gr cant = gr/1000.0 sum += normal.carbo*cant end (sum*100)/grtotal end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def porcentaje_lipidos\n recorrido = lista_alimentos.head\n acumulador = 0\n porcentaje = 0\n\n while recorrido != nil\n acumulador = acumulador + recorrido.value.proteinas + recorrido.value.carbohidratos + recorrido.value.lipidos\n porcentaje = porcentaje + recorrido.value.lipidos\n\n recorrido = recorrido.next\n end\n\n ((porcentaje * 100)/acumulador).round(2)\n end", "def porcentaje_carbohidratos\n recorrido = lista_alimentos.head\n acumulador = 0\n porcentaje = 0\n\n while recorrido != nil\n acumulador = acumulador + recorrido.value.proteinas + recorrido.value.carbohidratos + recorrido.value.lipidos\n porcentaje = porcentaje + recorrido.value.carbohidratos\n\n recorrido = recorrido.next\n end\n\n ((porcentaje * 100)/acumulador).round(2)\n end", "def porcentaje_lipidos\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n porcentaje_lip = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n porcentaje_lip += (auxNodo1.value.lipidos * auxNodo2.value) / 100\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return porcentaje_lip.round(1)\n end", "def hidratos_carbono\r\n hc = 0\r\n @lista_alimentos.each do |i|\r\n hc += i.carbohidratos\r\n end\r\n return hc\r\n end", "def por_lipidos\n\t\taux_lipidos = 0.0\n\t\ti = 1\n\t\twhile i < @lista_alimentos.size do\n\t\t\taux_lipidos += @lista_alimentos[i].lipidos * @lista_cantidades[i]\n\t\t\ti+=1\n\t\tend\n\t\treturn ((aux_lipidos/total_nutrientes)*100.0).round(2)\n\tend", "def por_carbohidratos\n \taux_carbohidratos = 0.0\n\t\ti = 1\n\t \twhile i < @lista_alimentos.size do\n\t\t\taux_carbohidratos += @lista_alimentos[i].carbohidratos * @lista_cantidades[i]\n\t\t\ti+=1\n\t\tend\n\t\treturn ((aux_carbohidratos/total_nutrientes)*100.0).round(2)\n\tend", "def terrenos\r\n terreno = 0\r\n @lista_alimentos.each do |i|\r\n terreno += i.terreno\r\n end\r\n return terreno\r\n end", "def cuantos_pares\n @pares = []\n @pares = @valores.to_h.select{|k, v| (2..2).cover?(v)}\n @pares.size\n end", "def porcentaje_proteinas\n recorrido = lista_alimentos.head\n acumulador = 0\n porcentaje = 0\n\n while recorrido != nil\n acumulador = acumulador + recorrido.value.proteinas + recorrido.value.carbohidratos + recorrido.value.lipidos\n porcentaje = porcentaje + recorrido.value.proteinas\n\n recorrido = recorrido.next\n end\n\n ((porcentaje * 100)/acumulador).round(2)\n end", "def totalLipidos\n\t\tlip = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\tlip += alimento.lipidos\n\t\tend\n\t\treturn lip.round(2)\n\t\n\tend", "def porcentaje_glucidos\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n porcentaje_gluc = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n porcentaje_gluc += (auxNodo1.value.glucidos * auxNodo2.value) / 100\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return porcentaje_gluc.round(1)\n end", "def emisiones\n grtotal = 0\n sum = 0\n\t\t#recorre las dos listas a la vez para sacar los gases emitidos\n\t\t# de cada ingrediente segun el peso de este\n @lista.zip(@listagr).each do |normal, gr|\n cant = gr/1000.0\n sum += normal.gases*cant\n end\n @gei = sum\n\n end", "def total_nutrientes\n\t\ti = 0\n\t\tproteinas = carbohidratos = lipidos = 0.0\n\t\twhile i < @lista_alimentos.size do\n\t\t\tproteinas += (@lista_alimentos[i].proteinas)*(@lista_cantidades[i])\n\t\t\tcarbohidratos += (@lista_alimentos[i].carbohidratos)*(@lista_cantidades[i])\n\t\t\tlipidos += (@lista_alimentos[i].lipidos)*(@lista_cantidades[i])\n\t\t i+= 1\n\t\tend\n\t\treturn proteinas + lipidos + carbohidratos\n\tend", "def pLipidos\n\t\tlip = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\ttotal += alimento.proteinas + alimento.lipidos + alimento.carbohidratos\n\t\t\tlip += alimento.lipidos\n\t\tend\n\t\treturn ((lip/total)*100).round\n\t\n\tend", "def lipidos\n food = @ingredientes.head\n lipidos = 0.0\n while food != nil do\n lipidos += food[:value].lipidos * (food[:value].gramos / 1000.0)\n food = food[:next]\n end\n lipidos * (100.0 / @total_nutricional)\n end", "def calculo_emisiones_diarias\n recorrido = lista_alimentos.head\n cantidad = lista_cantidades.head\n\n while (recorrido != nil && cantidad != nil)\n @emisiones_diarias = @emisiones_diarias + ((recorrido.value.gei * cantidad.value)/1000)\n\n recorrido = recorrido.next\n cantidad = cantidad.next\n end\n\n @emisiones_diarias\n end", "def pHidratos\n\t\thidr = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\ttotal += alimento.proteinas + alimento.lipidos + alimento.carbohidratos\n\t\t\thidr += alimento.carbohidratos\n\t\tend\n\t\treturn ((hidr/total)*100).round\n\n\t\n\tend", "def totalHidratos\n\t\thidr = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\thidr += alimento.carbohidratos\n\t\tend\n\t\treturn hidr.round(2)\n\tend", "def porcentajeGlucidos\r\n total_glucidos = 0.0\r\n la = @listaAlimentos.head\r\n lg = @listaGramos.head\r\n while la != nil do\r\n total_glucidos += (la.value.carbohidratos * lg.value) / 100\r\n la = la.next\r\n lg = lg.next\r\n end\r\n total_gramos = listaGramos.reduce(:+)\r\n porcentajeGlucidos = ((total_glucidos / total_gramos)*100).round(2)\r\n end", "def total_ve\n\t\t\n\t\ttotal_ve = 0\n\t\ti = 0\n\t\t\n\t\twhile i < conjunto_alimentos.length do\n\t\t\n\t\t\ttotal_ve += conjunto_alimentos[i].gei + total_ve\n\t\t\ti += 1\n\n\t\tend\n\t\n\t\treturn total_ve\n\tend", "def carbohidratos\n\t\treturn @carbohidratos*@cantidad\n\tend", "def gramos\r\n grams = 0\r\n @lista_alimentos.each do |i|\r\n grams += 100\r\n end\r\n return grams\r\n end", "def lipidos\n\t\treturn @lipidos*@cantidad\n\tend", "def kcalglucidos\n\t\t\t@carbohidratos * 4\n\t\tend", "def get_usoterreno\n aux = 0.0\n @contenido.each do |alimento|\n aux += alimento.ground\n end\n @usoterreno = aux\n end", "def car\n\t\tsuma = 0\n\t\tx = 0\n\t\tcantidad = 0\n\n\t\[email protected] do |i|\n\t\t\tcantidad = @gramos[x].valor / (i.proteinas + i.lipidos + i.carbohidratos)\n\t\t\tsuma += i.carbohidratos * cantidad\n\t\t\tx += 1\n\t\tend\t\n\n\t\treturn ((suma * 100) / gramos_total).round(2)\n\tend", "def get_azucares\n @_100=((@azucares*100)/@peso)\n @ir_100=(@_100/90)*100\n @porcion=((@azucares*@gramos_porciones)/@peso)\n @ir_porcion=(@porcion/90)*100\n [ @azucares , @_100 , @ir_100.round(1) , @porcion , @ir_porcion.round(1) ]\n end", "def lip\n grtotal = 0\n sum = 0\n\t\t#itera en las dos listas a la vez para poder calcular las \n #lipidos dependiendo de la cantidad y tambien suma\n #todas las cantidades para poder calcular el porcentaje\n #despues\n @lista.zip(@listagr).each do |normal, gr|\n grtotal += gr\n cant = gr/1000.0\n sum += normal.lip*cant\n end\n (sum*100)/grtotal\n end", "def kcallipidos\n\t\t\t@lipidos * 9\n\t\tend", "def hidratos \n\t\t@hidratos = @azucares + @polialcoles + @almidon\n\t\treturn @hidratos\n\tend", "def carbohidratos\n food = @ingredientes.head\n carbos = 0.0\n while food != nil do\n carbos += food[:value].carbohidratos * (food[:value].gramos / 1000.0)\n food = food[:next]\n end\n carbos * (100.0 / @total_nutricional)\n end", "def emisiones_gei\n\n\t\tif @emisiones_gei == 0\n\n\t\t\t@lista_alimentos.each do |alimento|\n\n\t\t\t\t@emisiones_gei += alimento.kg_gei\n\t\t\tend\n\n\t\t\t@emisiones_gei = @emisiones_gei.round(2)\n\t\tend\n\n\n\t\t@emisiones_gei\n\tend", "def huella\n\t\tindice1 = 0\n\t\t#dependiendo del vct de cada ingrediente, se le pone un indice\n\t\tif vct < 670\n\t\t\tindice1 = 1\n\t\t\t\n\t\telsif vct > 830\n\t\t\tindice1 = 3\n\t\telse \n\t\t\tindice1 = 2\n\t\tend \n\t\tindice2 = 0\n\t\t#dependiendo de los gases emitidos de cada ingrediente, \n\t\t#se le pone un indice\n\t\tif emisiones < 800\n\t\t\tindice2 = 1\n\t\telsif emisiones > 1200\n\t\t\tindice2 = 3\n\t\telse \n\t\t\tindice2 = 2\n\t\tend\n\t\t#hace la media de los indices sacados\n\t\tindiceres = (indice1+indice2)/2\n\t\t\n\n\tend", "def get_alco\n @_100=((@alco*100)/@peso)\n #@ir_100=(@_100/90)*100\n @porcion=((@alco*@gramos_porciones)/@peso)\n #@ir_porcion=(@porcion/90)*100\n [ @alco , @_100 , 0 , @porcion , 0 ]\n end", "def gei\r\n geis = 0\r\n @lista_alimentos.each do |i|\r\n geis += i.gases\r\n end\r\n return geis\r\n end", "def valor_energetico\n\t\ti = 0\n\t\tvalorC = 0.0\n\t\twhile i< @lista_alimentos.size do\n\t\t\tvalorC += @lista_alimentos[i].valorEnergetico\n\t\t\ti+=1\n\t\tend\n\t\treturn valorC\n\tend", "def eficiencia_energetica\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n eficiencia_total = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n eficiencia_total += ((auxNodo1.value.terreno * auxNodo1.value.gei) / auxNodo1.value.terreno + auxNodo1.value.gei ) * auxNodo2.value\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return eficiencia_total.round(1)\n end", "def por_proteinas\n\t\taux_proteinas = 0.0\n\t\ti = 0\n\t\twhile i < @lista_alimentos.size do\n\t\t\taux_proteinas += @lista_alimentos[i].proteinas * @lista_cantidades[i]\n\t\t\ti+=1\n\t\tend\n\t\treturn ((aux_proteinas/total_nutrientes)*100.0).round(2) \n\tend", "def disponibles\n total = []\n heros.each do |h|\n next unless h.tesoro\n next unless h.tesoro[item + 's']\n h.tesoro[item + 's'].each do |e|\n (total << h.id) if e == id\n end\n end\n total\n end", "def get_cout_ha_passages\n\t sum = 0\n\t self.putoparcelles.each do |putoparcelle|\n \t\tsum += putoparcelle.pulve.get_cout_ha_passage_col(self)\n end\n sum\n end", "def geidiario\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n geitotal = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n geitotal += (auxNodo1.value.gei * auxNodo2.value) / 100\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return geitotal.round(1)\n end", "def porcentaje_proteinas\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n porcentaje_prot = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n porcentaje_prot += (auxNodo1.value.proteinas * auxNodo2.value) / 100\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return porcentaje_prot.round(1)\n end", "def clasificar_por_imc (lista)\n \n imc_bajo = Lista.new()\n imc_normal = Lista.new()\n imc_excesivo = Lista.new()\n\n nodo = lista.extract\n \n while !(nodo.nil?)\n\n if nodo.value.datos_ant.indice_masa_corporal >= 30\n imc_excesivo.insert(nodo.value.datos_ant.indice_masa_corporal)\n elsif nodo.value.datos_ant.indice_masa_corporal >=18.5\n imc_normal.insert(nodo.value.datos_ant.indice_masa_corporal)\n else\n imc_bajo.insert(nodo.value.datos_ant.indice_masa_corporal)\n end\n nodo = lista.extract\n end\n\n \"Los IMC por debajo de lo normal son #{imc_bajo.to_s}, los IMC dentro de lo normal son #{imc_normal.to_s} y los que tienen un IMC excesivo son #{imc_excesivo.to_s}\"\n\nend", "def terreno\n grtotal = 0\n sum = 0\n\t\t#recorre las dos listas a la vez para sacar el terreno\n #usado de cada ingrediente segun el peso de este\n @lista.zip(@listagr).each do |normal, gr|\n cant = gr/1000.0\n sum += normal.terreno*cant\n end\n @terreno = sum\n\n end", "def totalSimplificado\n @biblioteca.livrosComoLista.map(&:preco).inject(0){|total, preco| total += preco}\n end", "def por_lip\n\t\t\t(@lipidos/suma_gramos)*100\n\t\tend", "def get_almidon\n @_100=((@almidon*100)/@peso)\n #@ir_100=(@_100/90)*100\n @porcion=((@almidon*@gramos_porciones)/@peso)\n #@ir_porcion=(@porcion/90)*100\n [ @almidon , @_100 , 0 , @porcion , 0 ]\n end", "def huella\n huella = @alimentos.inject([0,0,0]) do |acc, i|\n if i.kcal_total < 670\n acc[0] += (1.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n elsif i.kcal_total > 830\n acc[0] += (3.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n else acc[0] += (2.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n end\n if (i.gases * 1000.0) < 800\n acc[0] += (1.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n elsif (i.gases * 1000.0) > 1200\n acc[0] += (3.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n else\n acc[0] += (2.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n\t\t\tend\n\n\t\t\tacc[2] += (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos))\n acc[1] += 1\n acc\n\t\tend\n\n\t\treturn (huella[0] / (2.0 * huella[2])).round(2)\n\tend", "def aliens\n self.populations.map do |pop|\n pop.alien\n end\n end", "def areatrapezoide\n\t\tdt = 5\n\t\tsi = []\n\t\tgi.each do |i|\n\t\t\ts = (((gi[i]-gi[0]) + ((gi[i - 1]) - gi[0])) /2 ) * dt\n\t\t\tsi.push(s)\n\t\tend \n\t\treturn si\n\tend", "def prot\n\t\tgrtotal = 0\n\t\tsum = 0\n\t\t#itera en las dos listas a la vez para poder calcular las\n\t\t#proteinas dependiendo de la cantidad y tambien suma\n\t\t#todas las cantidades para poder calcular el porcentaje\n\t\t#despues\n\t\[email protected](@listagr).each do |normal, gr|\n\t\t\tgrtotal += gr\n\t\t\tcant = gr/1000.0\n\t\t\tsum += normal.prot*cant \n\t\tend\n\t\t(sum*100)/grtotal\n\tend", "def curar_pokemones\n @pokemones.each do |pokemon|\n pokemon.curar\n end\n @pokemon_actual = 0\n end", "def devolver_azucar \n\t\treturn @azucares\n\tend", "def cartas_por_pinta\n @pintas = []\n @pintas = @mi_mano.group_by{|k, v| v[:pinta]}.map{|k, v| [k, v.count]}\n end", "def lip\n\t\tsuma = 0\n\t\tx = 0\n\t\tcantidad = 0\n\n\t\[email protected] do |i|\n\t\t\tcantidad = @gramos[x].valor / (i.proteinas + i.lipidos + i.carbohidratos)\n\t\t\tsuma += i.lipidos * cantidad\n\t\t\tx += 1\n\t\tend\t\n\n\t\treturn ((suma * 100) / gramos_total).round(2)\n\tend", "def kcalproteinas\n\t\t\t@proteinas * 4\n\t\tend", "def aibc(g)\n\t\t# recibe un vector de datos del alimento\n\t\t# devuelve los aibc del alimento, o glucosa, para cada individuo\n\t\tg.map{ |gi| gi.each_with_index.map{ |gindex, i| if0(gindex, gi[0], gi[i-1]) if i > 0 } }.map{ |gi| gi.reject{ |gij| gij.class == nil::NilClass } }.map{ |ri| ri.reduce(0, :+) }\n\tend", "def pProteina \n\t\tprot = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\ttotal += (alimento.proteinas + alimento.lipidos + alimento.carbohidratos)\n\t\t\tprot += alimento.proteinas\n\t\tend\n\t\treturn ((prot/total)*100).round\t\n\tend", "def cantidad_casas_hoteles\n aux = 0\n \n @propiedades.each do |i|\n aux += i.cantidad_casas_hoteles\n end\n \n return aux\n end", "def total_life\n items.map(&:life).inject(0) { |sum, current| sum += current }\n end", "def get_hidratos\n @_100=((@hidratos*100)/@peso)\n @ir_100=(@_100/260)*100\n @porcion=((@hidratos*@gramos_porciones)/@peso)\n @ir_porcion=(@porcion/260)*100\n [ @hidratos , @_100 , @ir_100.round(1) , @porcion , @ir_porcion.round(1) ]\n end", "def get_energia_lipidos\n\t\t\t\t@lipidos * 9\n\t\t\tend", "def promedio(restaurant_menu)\n suma_total = 0\n restaurant_menu.each { |k,v| suma_total += v }\n suma_total / restaurant_menu.length.to_f\nend", "def totalTerreno()\n\t\t\t\t# terreno = (terreno * grammi) / 100\n\n\t\t\t\tplato = alimentsList.head\n\t\t\t\tgrams = gramsList.head\n\n\t\t\t\ttotalTerreno = 0.0\n\n\t\t\t\twhile plato != nil\n\t\t\t\t\ttotalTerreno += (plato.value.terreno * grams.value) / 100\n\n\t\t\t\t\tplato = plato.next\n\t\t\t\t\tgrams = grams.next\n\t\t\t\tend\n\n\t\t\t\treturn totalTerreno\n\t\t\tend", "def irazucares\n vag=(azucares * 100) / 90\n vag.round(2)\n end", "def indice_masa_corporal\n\t\t(peso / (talla * talla) * 10000).round(1)\n\tend", "def apport_calorique(repas)\n @calrep = 0\n #on fait la somme des calories acquises ce jour\n repas.each do |r|\n @calrep += r.calories\n end\n @calrep.round\n end", "def vct\n grtotal = 0\n sum = 0\n\t\t#recorre las dos listas a la vez para sacar el valor\n\t\t#nutricional de cada ingrediente segun el peso de este\n @lista.zip(@listagr).each do |normal, gr|\n cant = gr/1000.0\n sum += normal.val_en*cant\n end\n sum\n end", "def proteinas\n food = @ingredientes.head\n protein = 0.0\n while food != nil do\n protein += food[:value].proteinas * (food[:value].gramos / 1000.0)\n food = food[:next]\n end\n protein * (100.0 / @total_nutricional)\n end", "def totalGramos\n\t\tgramos = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\tgramos += alimento.gramos\n\t\tend\n\t\treturn gramos.round(2)\n\tend", "def calc_perc_carbohydrates\r\n alimentos = @food.collect { |x| x.carbohydrates }\r\n gramos = @quantities.collect { |x| x/100.0 }\r\n result = 0.0\r\n\r\n for i in 0...alimentos.size\r\n result += (gramos[i] * alimentos[i]) * 4\r\n end\r\n result /= @vct\r\n end", "def aumentar(array, aumento, desde, hasta)\n arr_filtro = array[desde..hasta] #rango de los datos filtrados\n arr_filtro.map!{|venta_mensual| venta_mensual * aumento}.sum #valor total por el porcentaje de aumento\nend", "def vegetaliana\n\t\thuevo = Alimento.new(\"Huevo\", 13.0, 1.1, 11.0, 4.2, 5.7)\n\t\tqueso = Alimento.new(\"Queso\",25.0,1.3,33.0,11.0,41.0)\n\t\tleche = Alimento.new(\"Leche de vaca\", 3.3, 4.8, 3.2, 3.2, 8.9)\n\t\tcerdo = Alimento.new(\"Cerdo\", 21.5, 0.0, 6.3, 7.6, 11.0)\n\t\tcordero = Alimento.new(\"Cordero\",18.0,0.0,3.1,50.0,164.0)\n\t\tvaca = Alimento.new(\"Carne de vaca\", 21.1,0.0,3.1,50.0,164.0)\n\t\tcamarones = Alimento.new(\"Camarones\",17.6,1.5,0.6,18.0,2.0)\n\t\tpollo = Alimento.new(\"Pollo\",20.6,0.0,5.6,5.7,7.1)\n\n\t\t[huevo,queso,leche,cerdo,cordero,vaca,camarones,pollo].each do |i|\n\t\t\tif (@alimentos.find { |x| x == i }) != nil\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\n\t\treturn true\n\tend", "def nivel_no_final\r\n #collect llama al bloque una vez por cada elemento del mismo y crea un nuevo arreglo que contiene los valores retornados\r\n #nivels = movimiento.collect{ |valor_pos| valor_pos.nivel }\r\n \r\n if jugador_actual == 'O'\r\n movimiento.collect{ |valor_pos| valor_pos.nivel }.min\r\n #nivels.max\r\n else\r\n movimiento.collect{ |valor_pos| valor_pos.nivel }.max\r\n end\r\n end", "def totalProteina \n\t\tprot = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\tprot += alimento.proteinas\n\t\tend\n\t\treturn prot.round(2)\n\tend", "def por_carbo\n\t\t\t(@carbohidratos/suma_gramos)*100\n\t\tend", "def proteinas\n\t\treturn @proteinas*@cantidad\n\tend", "def IVA (precio_iva)\n precio_iva.map {|plato, precio| precio * 1.19}\n end", "def uno_mas\n\t\t@edad += 1\n\t\tif @edad < EDAD_MAXIMA\n\t\t\t@altura += @inc_alt\n\t\t\t@contador += prod_nar if @edad >= @ini_fru\n\t\telse\n\t\t\tmuere\n\t\tend\n\t\t@edad\n\tend", "def irpolialcoholes\n vag=(polialcoholes * 100) / 90\n vag.round(2)\n end", "def current_occupancy\n self.dinosaurs.size\n end", "def area_terreno\n\n\t\tif @area_terreno_m2 == 0\n\n\t\t\t@lista_alimentos.each do |alimento|\n\n\t\t\t\t@area_terreno_m2 += alimento.area_terreno\n\t\t\tend\n\n\t\t\t@area_terreno_m2 = @area_terreno_m2.round(2)\n\t\tend\n\n\t\t@area_terreno_m2\n\tend", "def calculo_valor_calorico_total\n recorrido = lista_alimentos.head\n cantidad = lista_cantidades.head\n acumulador = 0\n\n while (recorrido != nil && cantidad != nil)\n acumulador = acumulador + (((recorrido.value.proteinas * cantidad.value)/1000) * 4) + (((recorrido.value.lipidos * cantidad.value)/1000) * 9) + (((recorrido.value.carbohidratos * cantidad.value)/1000) * 4)\n\n recorrido = recorrido.next\n cantidad = cantidad.next\n end\n\n acumulador.round(2)\n end", "def terreno\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n terrenototal = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n terrenototal += (auxNodo1.value.terreno * auxNodo2.value) / 100\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return terrenototal.round(1)\n end", "def get_proteinas\n @_100=((@proteinas*100)/@peso)\n @ir_100=(@_100/50)*100\n @porcion=((@proteinas*@gramos_porciones)/@peso)\n @ir_porcion=(@porcion/50)*100\n\t\t#p\"| #{@proteinas} | #{@_100} | #{@ir_100.round(1)}% | #{@porcion} | #{@ir_porcion.round(1)}% |\"\n [ @proteinas , @_100 , @ir_100.round(1) , @porcion , @ir_porcion.round(1) ]\n end", "def nombre_enfants\n \n enfants = 0\n \n self.membres.each {\n |m|\n enfants += (age_at(Date.today, m.date_de_naissance) > 12 ? 0:1)\n }\n\n return enfants\n \n end", "def prot\n\t\tsuma = 0\n\t\tx = 0\n\t\tcantidad = 0\n\n\t\[email protected] do |i|\n\t\t\tcantidad = @gramos[x].valor / (i.proteinas + i.lipidos + i.carbohidratos)\n\t\t\tsuma += i.proteinas * cantidad\n\t\t\tx += 1\n\t\tend\t\n\n\t\treturn ((suma * 100) / gramos_total).round(2)\n\tend", "def corrimiento(car)\n tam = MINUSCULAS.length\n indice = MAYUSCULAS.index(car)\n nueva = MAYUSCULAS[indice..tam]\n nueva << MAYUSCULAS[0...indice]\n return nueva\n end", "def contador_letras(nombres)\n nombres.map{ |x| x.length} # [7, 6, 8, 7, 5, 3, 3]\nend", "def get_vct\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n vct = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n vct += (auxNodo1.value.get_val / (auxNodo1.value.proteinas + auxNodo1.value.glucidos + auxNodo1.value.lipidos)) * auxNodo2.value\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return vct.round(1)\n end", "def lista(contatos)\n\tfor i in 0..contatos.size-1\n\t\tputs (\"#{i+1}. #{contatos[i].nome}\")\n\t\ti = i + 1\n\tend\nend", "def calcular()\n lista_nombres=@individuos[0].get_lista_nombres\n lista_nombres.each do |nombre|\n cont=0\n igind=0\n #puts nombre\n for j in [email protected]\n\tglucosa=@individuos[j].get_glucosa.to_f\n #puts glucosa\n aibc=@individuos[j].get_aibc(nombre)\n #puts aibc\n aux=aibc/glucosa*100\n #puts aux\n igind=igind+aux\n\tcont=cont+1\n end\n igind=igind/cont\n #puts igind\n @resultados << nombre + \" \" + igind.round(2).to_s + \"\\n\"\n end\n end", "def organizingContainers3(containers)\n length = containers.length\n container_capacity = Array.new(length, 0)\n ball_quantity = Array.new(length, 0)\n\n containers.each_with_index do |container, container_index|\n container.each_with_index do |num_of_balls, ball_index|\n container_capacity[container_index] += num_of_balls\n ball_quantity[ball_index] += num_of_balls\n end\n end\n\n ball_quantity.sort == container_capacity.sort ? 'Possible' : 'Impossible'\nend", "def carbsPercent()\n\t\t\t\tplato = @alimentsList.head\n\t\t\t\tgrams = @gramsList.head\n\t\t\t\ttotalEnergy = 0.0\n\t\t\t\ttotalCarbsEnergy = 0.0\n\n\t\t\t\twhile plato != nil\n\t\t\t\t\ttotalEnergy += (plato.value.get_energia * grams.value) / 100\n\t\t\t\t\ttotalCarbsEnergy += (plato.value.get_energia_carbs * grams.value) / 100\n\n\t\t\t\t\tplato = plato.next\n\t\t\t\t\tgrams = grams.next\n\t\t\t\tend\n\n\t\t\t\treturn (totalCarbsEnergy * 100) / totalEnergy\n\t\t\tend", "def total_calorie\n sum = 0\n food_meals.each do |food_meal|\n sum += food_meal.food.calorie\n end\n return sum\n end", "def victoire\n \n [[@a1, @a2, @a3],\n [@a1, @b2, @c3],\n [@a1, @b1, @c1],\n [@b1, @b2, @b3],\n [@c1, @c2, @c3],\n [@c1, @b2, @a3],\n [@a2, @b2, @c2],\n [@a3, @b3, @c3]]\n end", "def ponderado(pesos)\n @promedio = @p.zip(pesos).inject(0) do |suma, coordenada, peso| {suma+coordenada*peso }\n end\nend", "def totalCaloricValue()\n\t\t\t\tplato = @alimentsList.head\n\t\t\t\tgrams = @gramsList.head\n\t\t\t\ttotal = 0.0\n\n\t\t\t\twhile plato != nil\n\t\t\t\t\ttotal += (plato.value.get_energia() * grams.value) / 100\n\t\t\t\t\tplato = plato.next\n\t\t\t\t\tgrams = grams.next\n\t\t\t\tend\n\n\t\t\t\treturn total\n\t\t\tend", "def carne\n\t\tcerdo = Alimento.new(\"Cerdo\", 21.5, 0.0, 6.3, 7.6, 11.0)\n\t\tcordero = Alimento.new(\"Cordero\",18.0,0.0,3.1,50.0,164.0)\n\t\tvaca = Alimento.new(\"Carne de vaca\", 21.1,0.0,3.1,50.0,164.0)\n\t\tpollo = Alimento.new(\"Pollo\",20.6,0.0,5.6,5.7,7.1)\n\t\tsuma = 0\n\n\t\t[cerdo,cordero,vaca,pollo].each do |i|\n\t\t\tif (@alimentos.find_index { |x| x == i } != nil)\n\t\t\t\tsuma += @gramos[@alimentos.find_index { |x| x == i }].valor\n\t\t\tend\t\t\n\t\tend\n\n\t\treturn suma >= (gramos_total * 0.45)\n\tend", "def in_pacchetti_equi da: 25\n conteggio = self.count\n\n if conteggio < da\n avanzamento = da.in_decimale / conteggio\n indice = 0\n\n self.each.with_index do |elemento, indice_elemento|\n pacchetto = [ elemento ]\n indice += avanzamento\n indice = da if indice_elemento == conteggio - 1\n yield pacchetto, indice_elemento + 1, conteggio if block_given?\n end\n else\n avanzamento = conteggio / da.in_decimale\n elementi_presi = 0\n contatore = 0\n indice = 0\n\n while contatore < da\n elementi_da_prendere = (indice + avanzamento).round - 1\n pacchetto = self[elementi_presi..elementi_da_prendere]\n elementi_presi = elementi_da_prendere + 1\n indice += avanzamento\n contatore += 1\n yield pacchetto, elementi_presi, conteggio if block_given?\n end\n end\n\n self\n end" ]
[ "0.70856917", "0.7081741", "0.67340094", "0.6727324", "0.6558635", "0.64568347", "0.6398554", "0.636553", "0.6354793", "0.6332955", "0.62779236", "0.6260405", "0.624348", "0.62261814", "0.62215585", "0.6201042", "0.61955035", "0.6185234", "0.61794966", "0.6162606", "0.61162025", "0.61083794", "0.6104068", "0.61037296", "0.6091375", "0.5986248", "0.59818935", "0.597898", "0.59787863", "0.5942206", "0.59133655", "0.59096676", "0.5889237", "0.58835125", "0.58548516", "0.58346176", "0.58247215", "0.58168554", "0.5799246", "0.57573444", "0.57551396", "0.5744013", "0.5742606", "0.5721813", "0.5686128", "0.5665095", "0.56469166", "0.56464106", "0.5644317", "0.5633944", "0.56163114", "0.5616082", "0.5609384", "0.5607186", "0.5605889", "0.56010306", "0.5598937", "0.5592001", "0.5587422", "0.5580814", "0.55583453", "0.5550791", "0.5546706", "0.5522621", "0.5522289", "0.5516079", "0.5511081", "0.5497525", "0.5494199", "0.54933137", "0.54927605", "0.54908764", "0.5479484", "0.5463727", "0.54547215", "0.54486215", "0.54373765", "0.5426335", "0.5422951", "0.5422256", "0.5418153", "0.5413915", "0.54115057", "0.53971124", "0.5390017", "0.53879786", "0.53664535", "0.535967", "0.5356837", "0.53508925", "0.5350838", "0.5349414", "0.5341185", "0.53366375", "0.5326678", "0.53219295", "0.5321145", "0.5315825", "0.53119177", "0.5309815" ]
0.6392535
7
Devuelve el valor energetico total, siendo este la suma de todos los valores energeticos de los alimentos
def vct grtotal = 0 sum = 0 #recorre las dos listas a la vez para sacar el valor #nutricional de cada ingrediente segun el peso de este @lista.zip(@listagr).each do |normal, gr| cant = gr/1000.0 sum += normal.val_en*cant end sum end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculo_valor_calorico_total\n recorrido = lista_alimentos.head\n cantidad = lista_cantidades.head\n acumulador = 0\n\n while (recorrido != nil && cantidad != nil)\n acumulador = acumulador + (((recorrido.value.proteinas * cantidad.value)/1000) * 4) + (((recorrido.value.lipidos * cantidad.value)/1000) * 9) + (((recorrido.value.carbohidratos * cantidad.value)/1000) * 4)\n\n recorrido = recorrido.next\n cantidad = cantidad.next\n end\n\n acumulador.round(2)\n end", "def valor_energetico\n\t\ti = 0\n\t\tvalorC = 0.0\n\t\twhile i< @lista_alimentos.size do\n\t\t\tvalorC += @lista_alimentos[i].valorEnergetico\n\t\t\ti+=1\n\t\tend\n\t\treturn valorC\n\tend", "def calcular_total\n\t\treturn calcular_seguro*calcular_incremento\n\tend", "def calculo_valor_energetico\n\t\t\t(@carbohidratos*4) + (@lipidos*9) + (@proteinas*4)\n\t\tend", "def totalCaloricValue()\n\t\t\t\tplato = @alimentsList.head\n\t\t\t\tgrams = @gramsList.head\n\t\t\t\ttotal = 0.0\n\n\t\t\t\twhile plato != nil\n\t\t\t\t\ttotal += (plato.value.get_energia() * grams.value) / 100\n\t\t\t\t\tplato = plato.next\n\t\t\t\t\tgrams = grams.next\n\t\t\t\tend\n\n\t\t\t\treturn total\n\t\t\tend", "def get_valor_energetico\n \n return ((@proteinas + @glucidos) * 4 + @lipidos * 9).round(1)\n \n \n end", "def get_valor_energetico\n\n return ((@proteinas + @glucidos) * 4 + @lipidos * 9).round(1)\n\n end", "def total_ve\n\t\t\n\t\ttotal_ve = 0\n\t\ti = 0\n\t\t\n\t\twhile i < conjunto_alimentos.length do\n\t\t\n\t\t\ttotal_ve += conjunto_alimentos[i].gei + total_ve\n\t\t\ti += 1\n\n\t\tend\n\t\n\t\treturn total_ve\n\tend", "def valor_energetico\n @proteinas * 4.0 + @carbohidratos * 4.0 + @lipidos * 9.0\n end", "def geiTotal\n\t\t@geiSuma = 0\n\t\[email protected] do |alimento|\n\t\t\t@geiSuma += alimento.gei\n\t\tend\n\t\treturn @geiSuma.round(2)\n\tend", "def valor_energetico\n (@proteinas * 4) + (@glucidos * 4) + (@grasas * 9)\n end", "def valor_total(estado)\n\t\t@valor = 0\n\t\tself.parts.each do |p|\n\t\t\tif(p.confirmacao == estado)\n\t\t\t\t@valor += p.valor\n\t\t\tend\n\t\tend\n\t\t@valor\n\tend", "def total_calorie\n sum = 0\n food_meals.each do |food_meal|\n sum += food_meal.food.calorie\n end\n return sum\n end", "def eficiencia_energetica\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n eficiencia_total = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n eficiencia_total += ((auxNodo1.value.terreno * auxNodo1.value.gei) / auxNodo1.value.terreno + auxNodo1.value.gei ) * auxNodo2.value\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return eficiencia_total.round(1)\n end", "def total_value\r\n return 0 if self.value.nil?\r\n self.value + self.expenses.includes(:expense).map{ |e|\r\n (e.quantity || 0) * (e.expense.signed_price || 0)\r\n }.sum\r\n end", "def valor_efetivado\n\t\tself.valor_total(1)\n\tend", "def each\n\t\tval = 0\n\t\[email protected] do |x|\n\t\t\tval = x.val_energetico\n\t\tend\n\t\treturn val\n\tend", "def valor_total_gasto\n\t\tself.qualificacoes.sum(:valor_gasto)\n\tend", "def total\n @sum = @products.values.inject(0, :+)\n @total = @sum + (@sum * 0.075).round(2)\n return @total\n end", "def sum_totals\n @total = Lote.where(:programacion_id => @programacion.first).sum(:precio_t)\n @total = Money.new(\"#{@total}00\", \"USD\").format\n @cantidades = Lote.where(:programacion_id => @programacion.first).sum(:cantidad)\n end", "def terrenoTotal\n\t\t@terrenoSuma = 0\n\t\[email protected] do |alimento|\n\t\t\t@terrenoSuma += alimento.terreno\n\t\tend\n\t\treturn @terrenoSuma.round(2)\n\tend", "def genera_renglon_total\n\t\ttotal = Hash.new\n\t\t@renglones_reporte.each do |renglon|\n\t\t\t\trenglon.columnas.keys.each do |columna|\n\t\t\t\t\tif total[columna].nil?\n\t\t\t\t\t\ttotal[columna] = {:total => renglon.columnas[columna][:total], :promedio => 0}\n\t\t\t\t\telse\n\t\t\t\t\t\ttotal[columna][:total] += renglon.columnas[columna][:total]\n\t\t\t\t\tend\n\t\t\t\tend\n\t\tend\n\t\ttotal_t = total[\"Total\"][:total]\n \ttotal[\"Total\"][:promedio] = 100\n\t\ttotal.keys.each do |key|\n\t\t\tbegin\n\t\t\t\ttotal[key][:promedio] = (total[key][:total]/total_t.to_f*100).round\n\t\t\trescue\n\t\t\t\ttotal[key][:promedio] = 0\n\t\t\tend\n\t\tend\n\t\t@total = total\n\tend", "def total\n Float(@values.values.reduce(:+))\n end", "def total\n return (@listOfItem.inject(0){|sum,e| sum += e.total}).round_to(2)\n end", "def opcion4(inventario)\n sum = 0\n inventario.each do |llave,valor|\n sum += valor\n end\n \n puts \"El stock total de la tienda es: #{sum}\"\nend", "def total_amount\n \t amount = 0\n \t operation_items.each do | oi |\n \t\tamount = amount + oi.amount\n end\n amount\n end", "def totalSimplificado\n @biblioteca.livrosComoLista.map(&:preco).inject(0){|total, preco| total += preco}\n end", "def set_total\r\n self.total = self.order_items.collect{ |order_item| order_item.valid? ? (order_item.sub_total) : 0 }.sum.to_d\r\n end", "def total\r\n sum = 0\r\n sales_lines.each do |line|\r\n sum += line.line_amount unless line.line_amount.blank?\r\n end\r\n return sum\r\n end", "def calcula_pago_total\n \t \tmonto = self.monto\n \t\ttipo_cliente = self.tipo\n \t\tif tipo_cliente == \"colocadora\"\n \t\t\tmonto = ((monto* 0.00)+monto).to_i\n \t\telse\n \t\t\tmonto = ((monto* 0.50)+monto).to_i\n \t\tend\n \tend", "def total\n sum(:total)\n end", "def total\n # TODO: implement total\n if products.length == 0\n return 0\n end\n ((@products.values.sum)*1.075).round(2)\n end", "def calculo_emisiones_diarias\n recorrido = lista_alimentos.head\n cantidad = lista_cantidades.head\n\n while (recorrido != nil && cantidad != nil)\n @emisiones_diarias = @emisiones_diarias + ((recorrido.value.gei * cantidad.value)/1000)\n\n recorrido = recorrido.next\n cantidad = cantidad.next\n end\n\n @emisiones_diarias\n end", "def calc_total\n (@total_after_tax * @gratuity) + @total_after_tax\n end", "def emisiones\n grtotal = 0\n sum = 0\n\t\t#recorre las dos listas a la vez para sacar los gases emitidos\n\t\t# de cada ingrediente segun el peso de este\n @lista.zip(@listagr).each do |normal, gr|\n cant = gr/1000.0\n sum += normal.gases*cant\n end\n @gei = sum\n\n end", "def calcular_monto_total\n self.monto_total = total_de_unidades_funcionales\n end", "def precio_total_compras\n compras.sum(:precio_total)\n #p = 0\n #compras.each do |compra|\n #p += (compra.precio_total || 0)\n #end\n #return p\n end", "def set_importe_total\n self.importe_total = 0\n self.detalles.each do |detalle|\n self.importe_total += detalle.precio_unitario * detalle.cantidad unless detalle.marked_for_destruction?\n end\n end", "def total\n if @products.length == 0\n return 0\n else\n total = @products.values.reduce(:+)\n total*= 1.075 #Tax\n total = total.round(2)\n return total\n end\n end", "def calculate_eficiencia_diaria\n\t\taux = @head\n\t\twhile (aux != nil) do\n\t\t\t$eficiencia_diaria += aux[\"value\"].get_eficiencia_energetica\n\t\t\taux = aux[\"next\"]\n\t\tend\n\t\t$eficiencia_diaria = $eficiencia_diaria.ceil(2)\n\n\tend", "def totalkcal\n\t\t\tkcalproteinas + kcallipidos + kcalglucidos\n\t\tend", "def total\n if @products.empty?\n return 0\n else\n total = (@products.values.sum * 1.075).round(2)\n end\n return total\n end", "def valor_deducao\n deducoes.reduce(0) do |total,deducao|\n total += deducao.valor\n end\n end", "def total\n @total = 0\n @ordered_items.each do |item|\n @total += item[1]\n end\n return @total\n end", "def ir_grasa_total \n\t\t@grasa_ir = grasas_totales\n\t\t@ir_grasa_total = (@grasa_ir/70.to_f) * 100\n\t\t@ir_grasa_total.round(1)\n\tend", "def total\n (@products.values.sum * 1.075).round(2)\n end", "def total\n total = 0\n @products.values.each do |price|\n total += price\n end\n total += (0.075 * total).round(2)\n end", "def totalLipidos\n\t\tlip = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\tlip += alimento.lipidos\n\t\tend\n\t\treturn lip.round(2)\n\t\n\tend", "def total\n @total\n end", "def total\n total = 0\n self.menu_items.each do |item|\n total += item.price\n end\n \"$#{total}\"\n end", "def item_total\n line_items.map(&:total).reduce(:+)\n end", "def grasas_totales \n\t\t@grasas_totales = @saturadas + @monoinsaturadas + @polinsaturadas\n\t\treturn @grasas_totales\n\tend", "def suma_valores\n resultados = {}\n self.totales = {}\n self.totales_por_comprobante = {}\n\n # revisa todas las monedas\n EmpCuentab.monedas.each do |moneda, id_moneda|\n resultados[moneda] = {\n valor: 0.0,\n descuento: 0.0,\n desc_general: 0.0,\n subtotal: 0.0,\n iva: 0.0,\n ieps: 0.0,\n total: 0.0,\n }\n \n com_det_compra.where(moneda: moneda).each do |cdc|\n valor = cdc.precio * cdc.cantidad\n desc_cdc = valor * (cdc.descuento / 100)\n subtotal_temp = valor - desc_cdc\n desc_gral = subtotal_temp * (descuento / 100)\n subtotal = valor - desc_cdc - desc_gral\n iva = subtotal * (cdc.iva / 100)\n ieps = subtotal * (cdc.ieps / 100)\n total = subtotal + iva + ieps\n\n resultados[moneda][:valor] += valor\n resultados[moneda][:descuento] += desc_cdc\n resultados[moneda][:desc_general] += desc_gral\n resultados[moneda][:subtotal] += subtotal\n resultados[moneda][:iva] += iva\n resultados[moneda][:ieps] += ieps\n resultados[moneda][:total] += total\n\n # actualiza totales\n totales[moneda] = 0.0 unless totales[moneda]\n totales[moneda] += total\n\n # actualiza totales por comprobante\n comprobante = cdc.comprobante ? cdc.comprobante : \"Sin comprobante\"\n tipo_comp = cdc.tipo_comprobante ? cdc.tipo_comprobante : nil\n # total, moneda, nombre del departamento, id del departamento, comprobante, tipo de comprobante\n totales_por_comprobante[comprobante] = [0.0, nil, nil, nil, nil] unless totales_por_comprobante[comprobante]\n totales_por_comprobante[comprobante][0] += total\n totales_por_comprobante[comprobante][1] = cdc.moneda\n totales_por_comprobante[comprobante][2] = cdc.emp_locacion.nombre\n totales_por_comprobante[comprobante][3] = cdc.emp_locacion.id\n totales_por_comprobante[comprobante][4] = comprobante\n totales_por_comprobante[comprobante][5] = tipo_comp\n end\n end\n\n resultados\n end", "def total_correcto\n suma = subtotal + iva + ieps\n unless suma == total\n errors.add(:total, 'La sumatoria del subtotal, IVA e IEPS, no concuerda')\n end\n end", "def total\n if @products == {}\n return 0 \n else\n m = 0\n @products.values.each do |v|\n m += v\n end\n\n sum = (m + (m * 0.075)).round(2)\n return sum\n end\n end", "def valor_pendente\n\t\tself.valor_total(0)\n\tend", "def item_total\n tot = 0\n self.line_items.each do |li|\n tot += li.total\n end\n self.item_total = tot\n end", "def calculate_total\n order_items.sum(:total)\n end", "def invoice_total\n self.invoices.sum(:total).to_f\n end", "def invoice_total\n self.invoices.sum(:total).to_f\n end", "def saldo_total\n ias = object\n .inventory_articles\n .select { |ia| ia.inventory_id == current_inventory.id }\n\n return 0 unless ias.length > 0\n\n ias.first.count\n end", "def total; end", "def total\n @total = items.inject(0.0) { |sum, order_line_item| sum + order_line_item.subtotal }\n end", "def sumar_insumo(nombreInsumo, cantidad)\n\t\tcase nombreInsumo\n\t\t\twhen \"cebada\" then (@cebada += cantidad)\n\t\t\twhen \"arroz_maiz\" then (@arroz_maiz += cantidad)\n\t\t\twhen \"levadura\" then (@levadura += cantidad)\n\t\t\twhen \"lupulo\" then (@lupulo += cantidad)\n\t\t\twhen \"producto_silos_cebada\" then \n\t\t\t\t(@producto_silos_cebada += cantidad)\n\t\t\twhen \"producto_molino\" then \n\t\t\t\t(@producto_molino += cantidad)\n\t\t\twhen \"producto_paila_mezcla\" then \n\t\t\t\t(@producto_paila_mezcla += cantidad)\n\t\t\twhen \"producto_cuba_filtracion\" then \n\t\t\t\t(@producto_cuba_filtracion += cantidad)\n\t\t\twhen \"producto_paila_coccion\" then \n\t\t\t\t(@producto_paila_coccion += cantidad)\n\t\t\twhen \"producto_tanque_preclarificador\" then \n\t\t\t\t(@producto_tanque_preclarificador += cantidad)\n\t\t\twhen \"producto_enfriador\" then \n\t\t\t\t(@producto_enfriador += cantidad)\n\t\t\twhen \"producto_tcc\" then (@producto_tcc += cantidad)\n\t\t\twhen \"producto_filtro_cerveza\" then \n\t\t\t\t(@producto_filtro_cerveza += cantidad)\n\t\t\twhen \"producto_tanque_cerveza\" then \n\t\t\t\t(@producto_tanque_cerveza += cantidad)\n\t\t\twhen \"cerveza\" then (@cerveza += cantidad)\n\t\tend\n\tend", "def total\n total = (@products.values.sum) * 1.075\n return total.round(2)\n end", "def item_total\n @promotion_attributed_line_items.map(&:amount).sum\n end", "def total\n cart_value = 0\n self.line_items.each do |line_item|\n cart_value += line_item.value\n end\n cart_value\n end", "def total\n self.delivery_price +\n self.delivery_tax_amount +\n order_items.inject(BigDecimal(0)) { |t, i| t + i.total }\n end", "def total\n total_invoice_items_price(invoice_items)\n end", "def total\n add_products = 0\n @products.each_value do |cost|\n add_products += cost\n end\n total = (add_products + (add_products * 0.075)).round(2)\n return total\n end", "def product_total\n\t\ttotal = 0\n\t\tself.items.each do |item|\n\t\t\ttotal += item.amount\n\t\tend\n\t\ttotal\n\tend", "def expense_total\n self.expenses.sum(:amount).to_f\n end", "def total\n (amount + fee) if amount\n end", "def total\n return 0 if @products.empty?\n total = (@products.sum { |name, price| price } * 1.075).round(2)\n return total\n end", "def total_price\n puts \"O PRECO TOTAL DE ORDER FOI CHAMADO\"\n self.line_items.to_a.sum{ |item| item.total_price}\n end", "def dieta_gases_anuales(gramos)\n aux = @head\n suma_gases = 0\n i = 0\n while (!aux.nil?)\n suma_gases += aux[:value].auxiliar(gramos[i])\n aux = aux[:next]\n i = i+1\n end\n return suma_gases.round(2)\n\n end", "def total\n total_cache(:total) || (sub_total + total_tax)\n end", "def uno_mas\n\t\t@edad += 1\n\t\tif @edad < EDAD_MAXIMA\n\t\t\t@altura += @inc_alt\n\t\t\t@contador += prod_nar if @edad >= @ini_fru\n\t\telse\n\t\t\tmuere\n\t\tend\n\t\t@edad\n\tend", "def sum (tableau)\n chiffre = 0\n tableau.each do |element|\n chiffre = chiffre + element\n end\n return chiffre\nend", "def valor\n\t\t@valor = 0\n\t\tself.parts.each do |p|\n\t\t\t@valor += p.valor\n\t\tend\n\t\t@valor\n\tend", "def total_expenses\n self.expenses.sum(\"amount\")\n end", "def get_total\n counts = convert_to_hash(@item_list)\n uniq_items = @item_list.uniq\n\n final = (@total - @sale.apply(uniq_items, counts)).round(2) # Used round for precision\n puts get_invoice + final.to_s\n final\n end", "def valorEnergetico\n\t\treturn @valorEnergetico*@cantidad\n\tend", "def total_deposit\n self.group_loan_memberships.sum(\"deposit\")\n end", "def preco_total\n produto.preco * quantidade\n end", "def total_item\n @items.reject {|item| item.quantity == 0}\n invoice_total = @items.sum {|item| item.sale_price * item.quantity}\n\n end", "def total\n \tsubtotal\n end", "def total_earned\n totals = []\n\n self.orders.each do |order|\n totals << order.total_price\n end \n\n return totals.inject{ |sum, n| sum + n } \n end", "def total\n @total\n end", "def total_ise_amount(ise)\n total = 0 \n ise.each do |obj|\n total = total + obj[1]\n end\n return total\n end", "def total\n sum = 0\n subtotal = @products.values\n subtotal.each do |price|\n sum += price.to_f\n end\n\n total = (sum * 1.075).round(2)\n return total\n end", "def geidiario\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n geitotal = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n geitotal += (auxNodo1.value.gei * auxNodo2.value) / 100\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return geitotal.round(1)\n end", "def total_nutrientes\n\t\ti = 0\n\t\tproteinas = carbohidratos = lipidos = 0.0\n\t\twhile i < @lista_alimentos.size do\n\t\t\tproteinas += (@lista_alimentos[i].proteinas)*(@lista_cantidades[i])\n\t\t\tcarbohidratos += (@lista_alimentos[i].carbohidratos)*(@lista_cantidades[i])\n\t\t\tlipidos += (@lista_alimentos[i].lipidos)*(@lista_cantidades[i])\n\t\t i+= 1\n\t\tend\n\t\treturn proteinas + lipidos + carbohidratos\n\tend", "def valorenergetico\n acumulador1 = 0\n nodo = @head\n while nodo != @tail\n acumulador1 = acumulador1 + nodo.value.valor_energetico\n nodo = nodo.next\n end\n acumulador1\n end", "def total\n sum = 0\n order_items.each do |order_item|\n if order_item.item.price.present? && order_item.quantity.present?\n sum += order_item.item.price * order_item.quantity\n end\n end\n return sum\n end", "def total_expenses\n expenses.sum(:amount) || 0.0\n end", "def gramos_total\n\t\tsuma = 0\n\t\t\n\t\[email protected] do |i|\n\t\t\tsuma += i\n\t\tend\n\n\t\treturn suma.round(2)\n\tend", "def total\n total = 0\n line_items.each do |line_item|\n total += line_item.item.price * line_item.quantity\n end\n total\n end", "def calculate\n self.total\n end", "def emisiones_gei\n\n\t\tif @emisiones_gei == 0\n\n\t\t\t@lista_alimentos.each do |alimento|\n\n\t\t\t\t@emisiones_gei += alimento.kg_gei\n\t\t\tend\n\n\t\t\t@emisiones_gei = @emisiones_gei.round(2)\n\t\tend\n\n\n\t\t@emisiones_gei\n\tend" ]
[ "0.7801345", "0.75953615", "0.75719833", "0.75447595", "0.74794805", "0.7475394", "0.74084604", "0.7201876", "0.714915", "0.71391714", "0.7070051", "0.70661396", "0.70606476", "0.70429116", "0.70119995", "0.69994986", "0.69851625", "0.69218004", "0.6907074", "0.68829495", "0.68778586", "0.6870331", "0.685702", "0.68310416", "0.6821395", "0.6816632", "0.68150795", "0.679666", "0.6794991", "0.67884547", "0.6780617", "0.6777803", "0.6774597", "0.6772595", "0.6770915", "0.6764339", "0.6763731", "0.67494804", "0.67465866", "0.6709738", "0.6695242", "0.6687076", "0.66836774", "0.6679508", "0.6665873", "0.6648951", "0.66307", "0.6626195", "0.6621554", "0.6620362", "0.6619216", "0.6616988", "0.66158193", "0.66053206", "0.65980864", "0.659031", "0.65755427", "0.65643334", "0.65626806", "0.65626806", "0.6549694", "0.65435916", "0.65410715", "0.6540565", "0.65374017", "0.65372837", "0.6531084", "0.65285325", "0.65227526", "0.65217364", "0.6518163", "0.6517501", "0.65018255", "0.6491745", "0.64897466", "0.6487283", "0.6467284", "0.646391", "0.6463896", "0.64602244", "0.64580154", "0.64569825", "0.6451999", "0.64448804", "0.64384276", "0.6432424", "0.64286774", "0.6426195", "0.64198774", "0.6418721", "0.64168006", "0.6415176", "0.63987476", "0.63894314", "0.6387896", "0.6382199", "0.6373738", "0.6370201", "0.6370042", "0.63693863" ]
0.6485656
76
Devuelve el plato formateado
def to_s string = @nombre + " ,Ingredientes: " @lista.zip(@listagr).each do |normal, gr| string += normal.nombre + " " string += gr.to_s + " gr " end string end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_plato_s\r\n aaa = \"\"\r\n aaa +=\"Plato: #{@nombre} \\n\"\r\n @lista_alimentos.each do |i|\r\n aaa +=\"Valor energético: #{i.val_ener} \\n\"\r\n end\r\n return aaa\r\n end", "def platos(options = {})\n plato = options[:nombre]\n nombre_plato = plato.name\n precio_plato = options[:precio]\n @precios << precio_plato\n @valor_energetico << plato.calculoCaloriasDSL\n @valor_ambiental << plato.calculoEmisionesDSL\n\n plato = \"(#{nombre_plato})\"\n plato << \"(#{precio_plato} €)\"\n @platos << plato\n end", "def get_plato(num_plato)\n if (num_plato<0)&&(num_plato>@platos)\n raise \"El plato no existe\"\n else\n \"- #{get_descripcion(num_plato)}, #{@porciones[num_plato]}, #{@ingesta[num_plato]} g\"\n end\n end", "def platos\n\t\treturn @platos\n\tend", "def create\n # .permit Hay que indicar los parametros permitidos (se recomienda hacer en el modelo)\n @plato = Plato.new(plato_params) \n if @plato.save\n redirect_to @plato # Te muestra el plato recien creada\n else\n redirect_to new_plato_path\n end\n end", "def get_conjunto_platos\n i=0\n cadena=\"\"\n while(i<@platos)\n cadena=cadena+\"#{get_plato(i)}\"\n if(i!=@platos-1) #if para que no se añada \\n en el ultimo plato\n cadena=cadena+\"\\n\"\n end\n i=i+1\n end\n cadena\n end", "def formation; end", "def campoord_inicial\n 'ubicacion'\n end", "def to_s\n\t\[email protected] do |alimento|\n\t\t\tputs alimento.nombre\n\t\tend\n\tend", "def create\n @contiene_plato = ContienePlato.new(contiene_plato_params)\n\n respond_to do |format|\n if @contiene_plato.save\n format.html { redirect_to @contiene_plato, notice: 'Contiene plato was successfully created.' }\n format.json { render :show, status: :created, location: @contiene_plato }\n else\n format.html { render :new }\n format.json { render json: @contiene_plato.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_producto_platillo\n @producto_platillo = ProductoPlatillo.find(params[:id])\n end", "def platform\n data.platform\n end", "def create\n @comentario_plato = ComentarioPlato.new(comentario_plato_params)\n\n respond_to do |format|\n if @comentario_plato.save\n format.html { redirect_to @comentario_plato, notice: 'Comentario plato was successfully created.' }\n format.json { render :show, status: :created, location: @comentario_plato }\n else\n format.html { render :new }\n format.json { render json: @comentario_plato.errors, status: :unprocessable_entity }\n end\n end\n end", "def recto_verso!\n self.type= 'physical' unless self.type == 'physical'\n self.label= 'Sides' unless self.label == 'Sides'\n create_div_node struct_map, {:order=>'1'} unless divs_with_attribute(false,'ORDER','1').first\n create_div_node struct_map, {:order=>'2'} unless divs_with_attribute(false,'ORDER','2').first\n if (div = divs_with_attribute(false,'ORDER','1').first)\n div['LABEL'] = 'Recto' unless div['LABEL'] == 'Recto'\n end\n if (div = divs_with_attribute(false,'ORDER','2').first)\n div['LABEL'] = 'Verso' unless div['LABEL'] == 'Verso'\n end\n struct_map\n end", "def generos\n (self.genero == 1) ? \"Masculino\" : \"Femenino\"\n end", "def plate\n @plate\n end", "def set_contiene_plato\n @contiene_plato = ContienePlato.find(params[:id])\n end", "def precio\n\t\t@precio\n\tend", "def tipo_formulario?(form_tipo) \n \tif form_tipo == 1\n \t\treturn \"form_membro\"\n \telse\n \t\treturn \"form_estagio\"\n end\n end", "def setar_data\n if params[\"laudo\"]\n unless params[\"laudo\"][\"data_formatada\"].blank?\n $data_formatada = params[\"laudo\"][\"data_formatada\"]\n end\n else\n if params['voluntario'] and params['voluntario']['criterios'] and params['voluntario']['criterios']['data_formatada']\n $data_formatada = params['voluntario']['criterios']['data_formatada']\n end\n end\n end", "def to_s\n \"Nombre del plato: #{@nombre}\"\n end", "def producto_platillo_params\n params.require(:producto_platillo).permit(:id_pro_pla, :producto, :platillo, :cantidad, :unidad_medida)\n end", "def get_descripcion(num_plato)\n if (num_plato<0)&&(num_plato>@platos)\n raise \"El plato no existe\"\n else\n \"#{@descripcion[num_plato]}\"\n end\n end", "def create\n combo_producto\n combo_platillo\n @producto_platillo = ProductoPlatillo.new(producto_platillo_params)\n\n respond_to do |format|\n if @producto_platillo.save\n format.html { redirect_to @producto_platillo, notice: 'El Detalle del Platillo Fue Creado Exitosamente.' }\n format.json { render :show, status: :created, location: @producto_platillo }\n else\n format.html { render :new }\n format.json { render json: @producto_platillo.errors, status: :unprocessable_entity }\n end\n end\n end", "def manufacture; end", "def apply plataform\n\n end", "def titulo_guia\n titulo = []\n\n t = Especie.find(params[:especie_id])\n a = t.adicional\n\n tipo_region = params[:tipo_region] == \"anp\" ? \"ANP \" : \"Municipio de \"\n \n if a.nombre_comun_principal.present?\n titulo[0] = \"Guía de #{a.nombre_comun_principal}\"\n else\n titulo[0] = \"Guía de #{t.nombre_cientifico}\"\n end\n\n titulo[1] = tipo_region + params[:nombre_region]\n titulo\n end", "def set_platillo\n @platillo = Platillo.find(params[:id])\n end", "def platoon_params\n params.require(:platoon).permit(:name, :insignia_url)\n end", "def comentario_plato_params\n params.require(:comentario_plato).permit(:user_id, :plt_id, :fecha, :puntaje, :contenido)\n end", "def b_format_form\n \"#{id} - #{cert_ope}\"\n end", "def campos_filtro1_gen\n campos_filtro1\n end", "def get_modo()\r\n\t\treturn \"tipo\"\r\n\tend", "def partido\n localidad.partido\n end", "def set_comentario_plato\n @comentario_plato = ComentarioPlato.find(params[:id])\n end", "def contiene_plato_params\n params.require(:contiene_plato).permit(:order_id, :plt_id)\n end", "def to_label\n if quadra.nil? then\n \"#{area.nome}-#{numero.to_i}\"\n else\n \"#{area.nome}-#{quadra}-#{numero.to_i}\"\n end\n end", "def create\n @platillo = Platillo.new(params[:platillo])\n\n respond_to do |format|\n if @platillo.save\n format.html { redirect_to(@platillo, :notice => 'Platillo was successfully created.') }\n format.xml { render :xml => @platillo, :status => :created, :location => @platillo }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @platillo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def get_tipo_formated\n case tipo\n when 'A' then 'A (Impar)'\n when 'B' then 'B (Par)'\n when 'V' then 'V (Verano)'\n end\n end", "def camposDescarga(tipo_descarga=nil)\n checkbox = ''\n campos = { x_tipo_distribucion: 'Tipo de distribución', x_cat_riesgo: 'Categorías de riesgo y comercio internacional', x_ambiente: 'Ambiente', x_nombres_comunes: 'Nombres comunes', x_bibliografia: 'Bibliografía' }\n \n case tipo_descarga\n when 'basica'\n when 'avanzada'\n campos.merge!({ x_col_basicas: 'Columnas basicas', x_taxa_sup: 'Taxonomía superior', x_url_ev: 'URL de la especie en enciclovida' })\n when 'region'\n campos = { x_num_reg: 'Número de registros' }.merge(campos.merge!({ x_col_basicas: 'Columnas basicas', x_taxa_sup: 'Taxonomía superior', x_url_ev: 'URL de la especie en enciclovida' }))\n when 'checklist'\n campos.merge!({ x_estatus: 'Solo válidos/aceptados', x_distribucion: 'Distribución (reportada en literatura)', x_residencia: 'Categoría de residencia (aves)', x_formas: 'Formas de crecimiento (plantas)', x_interaccion: 'Interacciones biológicas' }) \n end\n \n campos.each do |valor, label|\n if valor.to_s == 'x_col_basicas'\n checkbox << check_box_tag('f_desc[]', valor, true, style: 'display: none;', id: \"f_#{tipo_descarga}_#{valor}\")\n else\n checkbox << \"<div class='custom-control custom-switch'>\"\n checkbox << check_box_tag('f_desc[]', valor, false, class: \"custom-control-input\", id: \"f_#{tipo_descarga}_#{valor}\")\n checkbox << \"<label class='custom-control-label' for='f_#{tipo_descarga}_#{valor}'>#{label}</label>\"\n checkbox << \"</div>\"\n end\n\n \n end\n\n checkbox.html_safe\n end", "def set_platoon\n @platoon = Platoon.find(params[:id])\n end", "def to_s\n \"La eficiencia energetica del plato es: #{eficiencia_energetica()}\"\n end", "def create\n @concepto_de_pago = ConceptoDePago.new(concepto_de_pago_params)\n #@plazo = @concepto_de_pago.diferencia \n # @concepto_de_pago.plazoRecordatorio = Chronic.parse(@concepto_de_pago.diferencia, :now => @concepto_de_pago.fechaVencimiento)\n\n respond_to do |format|\n if @concepto_de_pago.save\n format.html { redirect_to @concepto_de_pago, notice: 'Concepto de pago fue creado exitosamente.' }\n format.json { render :show, status: :created, location: @concepto_de_pago }\n else\n format.html { render :new }\n format.json { render json: @concepto_de_pago.errors, status: :unprocessable_entity }\n end\n end\n end", "def mi_carrera\n\n\tend", "def politico_params\n params.require(:politico).permit(:municipio, :activo, :picture, :modificador, :creador, :descripcion, :nombre, :apellido, :cedula, :sexo, :partido, :telefono, :celular, :email, :whatsapp, :instagram, :twitter, :facebook, :puntov, :cNombre, :cCel1, :cCel2, :cTel, :cWhatsapp, :cEmail)\n end", "def precio_boleto_params\n\tparams.require(:precio_boleto).permit(:precio, :clase, :destino, :origen)\n\tend", "def epoc_set_plat_env plat\nend", "def to_s\n \"#{get_titulo} #{get_porcentaje}\\n#{get_conjunto_platos}\\nV.C.T. | % #{get_vct} | #{get_proteinas} - #{get_grasas} - #{get_hidratos}\" \n end", "def precio_boleto_params\n params.require(:precio_boleto).permit(:precio, :origen, :destino, :clase)\n end", "def precio_mercado\n @serie.valor_primer_dia('precio')\n end", "def to_s() # :nodoc:\n mano_seleccionada = super.to_s\n if not @movimientos.nil?\n return \"Las estrategias suministradas son \" + @movimientos.to_s + \" \" + mano_seleccionada\n end\n return \"El diccionario de estrategias provista no es valida\"\n end", "def ubicacion_tipo_nombre_entidad\n if self.tipo.eql?(\"pais\")\n \"#{self.nombre}\"\n elsif self.tipo.eql?(\"localidad\")\n \"#{self.nombre} (#{self.entidad_superior.tipo.capitalize} #{self.entidad_superior.nombre})\"\n else\n \"#{self.tipo.capitalize} #{self.nombre} (#{self.entidad_superior.tipo.capitalize} #{self.entidad_superior.nombre})\"\n end\n end", "def rover_plato_params\n params.require(:rover_plato).permit(:x_position_size, :y_position_size)\n end", "def format\n if ControlledVocabulary.for(:geo_image_format).include? geo_mime_type\n ControlledVocabulary.for(:geo_image_format).find(geo_mime_type).label\n elsif ControlledVocabulary.for(:geo_raster_format).include? geo_mime_type\n ControlledVocabulary.for(:geo_raster_format).find(geo_mime_type).label\n elsif ControlledVocabulary.for(:geo_vector_format).include? geo_mime_type\n ControlledVocabulary.for(:geo_vector_format).find(geo_mime_type).label\n end\n end", "def gastronomium_params\n params.require(:gastronomium).permit(:plato, :descripcion, :imagen)\n end", "def to_s\n recorrido = lista_alimentos.head\n cantidad = lista_cantidades.head\n formateo = []\n\n while (recorrido != nil && cantidad != nil)\n salida = cantidad.value.to_s + \"gr de \" + recorrido.value.nombre\n formateo.push(salida)\n\n recorrido = recorrido.next\n cantidad = cantidad.next\n end\n\n formateo.push(@emisiones_diarias)\n formateo.push(@metros_terreno)\n\n formateo\n end", "def inspect\n\n \"Tetronimo: type: #{@type}, value: #{@value}, rotation: #{@rotation}, grid_row: #{@grid_row}, grid_col: #{@grid_col}\"\n\n end", "def plantio_params\n params.require(:plantio).permit(:dt_inicial, :dt_final, :area_id, :fazenda_id, :cultivo_id, :status_plantio_id)\n end", "def set_precio_boleto\n\t@precio_boleto = PrecioBoleto.find(params[:id])\n\tend", "def create\n @platform = Platform.new(platform_params)\n\n if @platform.save\n flash[:success] = \"#{@platform.name} was successfully created.\"\n redirect_to platforms_path\n else \n flash[:warning] = \"Format error.\"\n render new_platform_path\n end\n end", "def porc_grasa\n\t\t(1.2 * self.indice_masa_corporal + 0.23 * edad - 10.8 * sexo - 5.4).round(1)\n\tend", "def to_s\n\t\tsuper().to_s +\n\t\t\" -- Talla: #{@talla} -- Circunferencia Cintura: #{@circun_cintu} -- Circunferencia Cadera: #{@circun_cadera}\"\n\tend", "def campoord_inicial\n 'fecharec'\n end", "def create\n @grua = Grua.new(grua_params)\n @grua.dicc_mantenciones = @grua.set_dicc_mantenciones(@grua.tipo, @grua.horometro)\n\n if @grua.tipo == \"Eléctrica\"\n @grua.mantenciones = [6000, 2000, 1000, 250]\n elsif @grua.tipo == \"Gas\"\n @grua.mantenciones = [2800, 1400, 700, 350]\n elsif @grua.tipo == \"Apilador\"\n @grua.mantenciones = [2000, 1000, 500]\n else @grua.mantenciones = []\n end\n\n respond_to do |format|\n if @grua.save\n format.html { redirect_to @grua, notice: 'Grua creada exitosamente.' }\n format.json { render :show, status: :created, location: @grua }\n else\n format.html { render :new }\n format.json { render json: @grua.errors, status: :unprocessable_entity }\n end\n end\n end", "def to_s\n\t\t\"Por 100g o 100ml de producto\\tIr del producto\\tPor porcion de X gramos\\tIR por porcion\\n\"+\n\t\t\" Valor energetico: #{valorenergeticoKJ}/#{valorenergeticoKcal}\\t#{irenergeticoKJ}/#{irenergeticoKcal}\\t#{valorenergeticoKJp}/#{valorenergeticoKcalp}\\t#{irenergeticoKJp}/#{irenergeticoKcalp}\\n\"+\n\t\t\" Grasas: #{cgrasas}\\t#{irgrasas}\\t#{valorgrasasp}\\t#{irgrasasp}\\n\"+\n\t\t\" Grasas monosaturadas: #{grasasmono}\\t#{irmonograsas}\\t#{valormonograsasp}\\t#{irmonograsaslp}\\n\"+\n\t\t\" Grasas poliinsaturadas: #{grasaspoli}\\t#{irpoliinsaturadas}\\t#{valorgrasasp}\\t#{irpoliinsaturadas}\\n\"+\n\t\t\" Hidratos de carbono: #{hcarbono}\\t#{irhidratos}\\t#{valorhidratosp}\\t#{irhidratosp}\\n\"+\n\t\t\" Azucares: #{azucares}\\t#{irazucares}\\t#{valorazucaresp}\\t#{irazucaresp}\\n\"+\n\t\t\" Polialcoholes: #{polialcoholes}\\t#{irpolialcoholes}\\t#{valorpolialcoholesp}\\t#{irpolialcoholesp}\\n\"+\n\t\t\" Almidon: #{almidon}\\t#{iralmidon}\\t#{valoralmidonp}\\t#{iralmidonp}\\n\"+\n\t\t\" Fibra alimentaria: #{fibra}\\t#{irfibra}\\t#{valorfibrap}\\t#{irfibrap}\\n\"+\n\t\t\" Sal: #{sal}\\t#{irsal}\\t#{valorsalp}\\t#{irsalp}\\n\"+\n\t\t\" Vitamina/mineral: #{vitymin}\\t#{irvitaminas}\\t#{valorvityminp}\\t#{irvitaminasp}\\n\"\n\tend", "def set_precio_boleto\n @precio_boleto = PrecioBoleto.find(params[:id])\n end", "def slogan\n # 'A maneira mais fácil de pré-qualificar ao Atlas.'\n ''\n end", "def ubicacion\n communes_str = @stats.pluralize_communes\n if @stats.communes.size > 1\n comm_st = \" las comunas de \"\n elsif communes_str == \"\"\n comm_st = \"\"\n else\n comm_st = \" la comuna de \"\n end\n regions_str = @stats.pluralize_regions\n if @stats.regions.size > 1\n reg_st = \" las regiones de \"\n elsif regions_str == \"\"\n reg_st = \"\"\n else\n reg_st = \" la region de \"\n end\n country_str = @stats.pluralize_countries\n if @stats.countries.size > 1\n coun_st = \" los paises \"\n elsif country_str == \"\"\n coun_st = \"\"\n else\n coun_st = \" el pais \"\n end\n\n s = \"La zona elegida se encuentra dentro de \" + comm_st + communes_str +\n \", \" + reg_st + regions_str +\" y \" + coun_st + country_str + \".\"\n return s\n end", "def create\n @prueba = Prueba.new(prueba_params)\n\n cantidadAlmacenada = @prueba.cantidad_almacenada\n cantidadDesechada = @prueba.cantidad_desechada\n\n @prueba.cantidad = cantidadAlmacenada + cantidadDesechada \n\n respond_to do |format|\n if @prueba.save\n\n @etiqueta = Etiqueta.new\n\n etiquetaAnalisis = @prueba.etiqueta.etiqueta\n idAnalisis = @prueba.id\n idAnalisisString = idAnalisis.to_s\n\n @etiqueta.etiqueta = etiquetaAnalisis + idAnalisisString + \"-\"\n @etiqueta.formato_id = 2\n @etiqueta.save\n\n format.html { redirect_to etiqueta_mostrar_path(@etiqueta.id), notice: 'Prueba was successfully created.' }\n format.json { render :show, status: :created, location: @prueba }\n else\n format.html { render :new }\n format.json { render json: @prueba.errors, status: :unprocessable_entity }\n end\n end\n end", "def presentacion\n \"La marca del Ventilador es #{@marca}\"\n end", "def create \n @lancamentorapido = Lancamentorapido.new(params[:lancamentorapido])\n \n #Validações padrão\n @lancamentorapido.tipo = :receita if @lancamentorapido.tipo.blank?\n @lancamentorapido.valor = 0 if @lancamentorapido.valor.blank? \n \n respond_to do |format|\n if @lancamentorapido.save\n format.html { redirect_to lancamentorapidos_path, notice: 'Lancamento was successfully created.' } \n# format.html { redirect_to '/lancamentorapidos'}\n format.json { render json: lancamentorapidos_path, status: :created, location: @lancamentorapido }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lancamentorapido.errors, status: :unprocessable_entity }\n end\n end\n end", "def to_s() # :nodoc:\n mano_seleccionada = super.to_s # Hago un llamado al metodo to_s de mi padre que maneja\n # la impresion de la mano seleccionada\n if not @estrategias.nil?\n return \"Las estrategias suministradas son \" + @estrategias.to_s + \" \" + mano_seleccionada\n end\n return \"La lista de estrategias provista no es valida\"\n end", "def build_get_pallet_number_form()\n\n#\t---------------------------------\n#\t Define fields to build form from\n#\t---------------------------------\n\tfield_configs = Array.new\n\n field_configs[0] = {:field_type => 'TextField',\n\t\t\t\t\t\t:field_name => 'pallet_number'}\n\n\n\n\tbuild_form(nil,field_configs,'submit_mixed_pallet_id','pallet_number','submit')\n\nend", "def show\n if @input.devolucion\n @es_devolucion = \"Devolución\"\n else\n @es_devolucion = [\"Remito: \",@input.remito].join\n end\n end", "def get_txt_panneau\n\t\treturn [mdl_par.panneaux[0].to_s,mdl_par.panneaux[1].to_s]\n\tend", "def modelo_carne_build_data_right(doc, boleto, colunas, linhas)\n # LOGOTIPO do BANCO\n doc.image boleto.logotipo, x: (colunas[2] - 0.11), y: linhas[0]\n\n # Numero do banco\n doc.moveto x: colunas[4], y: linhas[0]\n doc.show \"#{boleto.banco}-#{boleto.banco_dv}\", tag: :grande\n\n # linha digitavel\n doc.moveto x: colunas[6], y: linhas[0]\n doc.show boleto.codigo_barras.linha_digitavel, tag: :media\n\n # local de pagamento\n doc.moveto x: colunas[2], y: linhas[1]\n doc.show boleto.local_pagamento\n\n # vencimento\n doc.moveto x: colunas[11], y: linhas[1]\n doc.show boleto.data_vencimento.to_s_br\n\n # cedente\n doc.moveto x: colunas[2], y: linhas[2]\n doc.show boleto.cedente\n\n # agencia/codigo cedente\n doc.moveto x: colunas[11], y: linhas[2]\n doc.show boleto.agencia_conta_boleto\n\n # data do documento\n doc.moveto x: colunas[2], y: linhas[3]\n doc.show boleto.data_documento.to_s_br if boleto.data_documento\n\n # numero documento\n doc.moveto x: colunas[3], y: linhas[3]\n doc.show boleto.documento_numero\n\n # especie doc.\n doc.moveto x: colunas[8], y: linhas[3]\n doc.show boleto.especie_documento\n\n # aceite\n doc.moveto x: colunas[9], y: linhas[3]\n doc.show boleto.aceite\n\n # dt processamento\n doc.moveto x: colunas[10], y: linhas[3]\n doc.show boleto.data_processamento.to_s_br if boleto.data_processamento\n\n # nosso numero\n doc.moveto x: colunas[11], y: linhas[3]\n doc.show boleto.nosso_numero_boleto\n\n # uso do banco\n ## nada...\n\n # carteira\n doc.moveto x: colunas[3], y: linhas[4]\n doc.show boleto.carteira\n\n # especie\n doc.moveto x: colunas[5], y: linhas[4]\n doc.show boleto.especie\n\n # quantidade\n doc.moveto x: colunas[7], y: linhas[4]\n doc.show boleto.quantidade\n\n # valor documento\n doc.moveto x: colunas[8], y: linhas[4]\n doc.show boleto.valor_documento.to_currency\n\n # valor do documento\n doc.moveto x: colunas[11], y: linhas[4]\n doc.show boleto.valor_documento.to_currency\n\n # Instruções\n doc.moveto x: colunas[2], y: linhas[5]\n doc.show boleto.instrucao1\n doc.moveto x: colunas[2], y: linhas[6]\n doc.show boleto.instrucao2\n doc.moveto x: colunas[2], y: linhas[7]\n doc.show boleto.instrucao3\n doc.moveto x: colunas[2], y: linhas[8]\n doc.show boleto.instrucao4\n doc.moveto x: colunas[2], y: linhas[9]\n doc.show boleto.instrucao5\n doc.moveto x: colunas[2], y: linhas[10]\n doc.show boleto.instrucao6\n\n # Sacado\n doc.moveto x: colunas[2], y: linhas[11]\n if boleto.sacado && boleto.sacado_documento\n doc.show \"#{boleto.sacado} - #{boleto.sacado_documento.formata_documento}\"\n end\n\n # Sacado endereço\n doc.moveto x: colunas[2], y: linhas[12]\n doc.show boleto.sacado_endereco.to_s\n\n # codigo de barras\n # Gerando codigo de barra com rghost_barcode\n if boleto.codigo_barras\n doc.barcode_interleaved2of5(boleto.codigo_barras, width: '10.3 cm', height: '1.2 cm', x: colunas[2],\n y: linhas[14])\n end\n end", "def calculo \n self.minutos_reales = 5 * 480 #cantidad de OPERARIOS * Jornada de Trabajo(Turnos)\n self.costo_minuto = 89 #Costo Real por minuto\n self.otros_costos = 540 * 89 #Tiempo Total(Minutos) * Costo Real por Minutos\n self.costo_mano_obra = 420 * 5 * 89 # Jornada Minutos * Cantidad Operarios * Costo Real por minutos \n self.manoObraPlaneada = 650.000 * 5 # Salario Total * Cantidad de operarios \n end", "def create\n @insumo_plato = InsumoPlato.new(insumo_plato_params)\n\n respond_to do |format|\n if @insumo_plato.save\n format.html { redirect_to @insumo_plato, notice: 'Insumo plato was successfully created.' }\n format.json { render :show, status: :created, location: @insumo_plato }\n else\n format.html { render :new }\n format.json { render json: @insumo_plato.errors, status: :unprocessable_entity }\n end\n end\n end", "def tipo\n return ModeloQytetet::TipoCasilla::CALLE\n end", "def fuel_type; end", "def set_rover_plato\n @rover_plato = RoverPlato.find(params[:id])\n end", "def create\n @precio_boleto = PrecioBoleto.new(precio_boleto_params)\n\n respond_to do |format|\n if @precio_boleto.save\n format.html { redirect_to @precio_boleto, notice: 'Precio boleto was successfully created.' }\n format.json { render action: 'show', status: :created, location: @precio_boleto }\n else\n format.html { render action: 'new' }\n format.json { render json: @precio_boleto.errors, status: :unprocessable_entity }\n end\n end\n end", "def user_os_complex\r\n end", "def calorie_info\n return \"#{self.name} $#{self.price} (#{self.calorie}kcal)\"\n end", "def new\n @voluntario = Voluntario.new\n @voluntario.build_endereco\n @voluntario.criterios.build\n @voluntario.inclusoes.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @voluntario }\n end\n end", "def vialidad_condicion_w\n if self.vialidad_condicion == 'E'\n return 'Excelente'\n elsif self.vialidad_condicion == 'B'\n return 'Bueno'\n elsif self.vialidad_condicion == 'R'\n return 'Regular'\n elsif self.vialidad_condicion == 'M'\n return 'Malo'\n end\n end", "def huella_nutricional_plato\n\n\t\tenergia_plato = valor_calorico_total\n\n\t\tii_energia_plato = 0\n\t\trange_energia = [670,830]\n\n\t\tif energia_plato <= range_energia.first\n\t\t\tii_energia_plato = 1\n\t\telsif energia_plato > range_energia.first && energia_plato <= range_energia.last\n\t\t\tii_energia_plato = 2\n\t\telsif energia_plato > range_energia.last\n\t\t\tii_energia_plato = 3\n\t\tend\n\n\t\tgei_plato = emisiones_gei\n\n\t\tii_gei_plato = 0\n\n\t\trange_gei = [800,1200]\n\n\t\tif gei_plato <= range_gei.first\n\t\t\tii_gei_plato = 1\n\t\telsif gei_plato > range_gei.first && gei_plato <= range_gei.last\n\t\t\tii_gei_plato = 2\n\t\telsif gei_plato > range_gei.last\n\t\t\tii_gei_plato = 3\n\t\tend\n\t\t\t\n\t\thn_plato = ((ii_gei_plato + ii_energia_plato) / 2).round\n\n\tend", "def cassete_params\n params.require(:cassete).permit(:formato, :pelicula_id)\n end", "def to_s\n\t\t\t \"( Nombre:#{@nombre}, Conjunto Alimentos: #{@la} ,Conjunto Gramos: #{@lg} ,Proteinas :#{@proteinas},Carbo :#{@carbohidratos},Lipidos :#{@lipidos},VCT :#{@vct} )\"\n\n\t\tend", "def to_s; toDataMetaForm end", "def to_s; toDataMetaForm end", "def create\n @interno = Interno.new(interno_params)\n @interno.state = 'Activo'\n @interno.lugarNacimiento=(params[:palabra])\n \n if @interno.save\n flash[:success] = 'Interno fue creado exitosamente'\n redirect_to @interno\n else\n render action: \"new\"\n end\n \n end", "def mtus\n build_system_layout\n @mtus\n end", "def new\n @cegonha = Cegonha.new\n @editar_localizacao = params[:editar_localizacao]\n @cegonha.build_motorista\n\n\n\n if params[:cegonha_contratada]\n @cegonha.build_empresa\n @cegonha.build_pagamento\n\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cegonha }\n end\n end", "def sichtbar_machen()\n # TODO\n end", "def create\n \tparams[:matricula][:escola_id] = current_escola_id\n \tparams[:matricula][:user_id] = current_user.id\n \tif params[:matricula][:valor_seg_parcela_matricula].blank?\n \t\tbegin\n\t \t\tplano = Plano.find params[:matricula][:plano_id]\n\t \t\tparams[:matricula][:valor_pri_parcela_matricula] = plano.valor_matricula\n \t\trescue\n \t\tend\n \tend\n \tparams[:matricula][\"data_inicio_parcelas(3i)\"] = params[:matricula][:dia_vcto_parcelas]\n @matricula = @aluno.matriculas.new(params[:matricula])\n\t@parcelas = []\n respond_to do |format|\n if params[:preview]\n \[email protected]?\n \t@parcelas = @matricula.gerar_financeiro(false)\n \tformat.html { render :action => \"new\" }\n elsif @matricula.save\n flash[:notice] = 'Matricula Gerada!'\n format.html { redirect_to(alunos_path) }\n format.xml { render :xml => @matricula, :status => :created, :location => @matricula }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @matricula.errors, :status => :unprocessable_entity }\n end\n end\n end", "def resource_params\n params.require(:tratamiento).permit(:tipo)\n end", "def create\n @platoon = Platoon.new(platoon_params)\n\n respond_to do |format|\n if @platoon.save\n format.html { redirect_to @platoon, notice: 'Platoon was successfully created.' }\n format.json { render action: 'show', status: :created, location: @platoon }\n else\n format.html { render action: 'new' }\n format.json { render json: @platoon.errors, status: :unprocessable_entity }\n end\n end\n end", "def build_rebin_label_station_form(rebin_label_station,action,caption,is_edit = nil,is_create_retry = nil)\n\n#\t---------------------------------\n#\t Define fields to build form from\n#\t---------------------------------\n codes = Facility.find_all_by_facility_type_code(\"packhouse\").map{|g|[g.facility_code]}\n\tfield_configs = Array.new\n\tfield_configs[0] = {:field_type => 'TextField',\n\t\t\t\t\t\t:field_name => 'rebin_label_station_code'}\n\n\tif is_edit == false\n\t field_configs[1] = {:field_type => 'DropDownField',\n\t\t\t\t\t\t:field_name => 'packhouse_code',\n\t\t\t\t\t\t:settings => {:list => codes}}\n\telse\n\t field_configs[1] = {:field_type => 'LabelField',\n\t\t\t\t\t\t:field_name => 'packhouse_code'}\n\tend\n\n\n\tfield_configs[2] = {:field_type => 'TextField',\n\t\t\t\t\t\t:field_name => 'ip_address'}\n\n\tbuild_form(rebin_label_station,field_configs,action,'rebin_label_station',caption,is_edit)\n\nend", "def t_undrwrng; catdet.form(:name, 'rpcControlSensorSettingForm').text_field(:id,'tempThresholdLoWrn'); end", "def to_s\n case @tipo \n when Tipo_casilla::SORPRESA\n mensaje = \"Nombre: #{@nombre}, Tipo: #{@tipo}, Mazo: #{@mazo}\"\n when Tipo_casilla::CALLE\n mensaje = \"Nombre: #{@nombre}, Tipo: #{@tipo}, Importe: #{@importe}\"\n when Tipo_casilla::DESCANSO\n mensaje = \"Nombre: #{@nombre}, Tipo: #{@tipo}\"\n when Tipo_casilla::JUEZ\n mensaje = \"Nombre: #{@nombre}, Tipo: #{@tipo}, Número Cárcel: #{@@carcel}\"\n when Tipo_casilla::IMPUESTO\n mensaje = \"Nombre: #{@nombre}, Tipo: #{@tipo}, Número Cárcel: #{@importe}\"\n end\n end" ]
[ "0.64062184", "0.6357404", "0.6337269", "0.6286646", "0.58576596", "0.58085454", "0.5794861", "0.5599799", "0.55175865", "0.5472756", "0.5460662", "0.54113203", "0.53879315", "0.5373294", "0.536605", "0.53602815", "0.53516716", "0.5335703", "0.53335243", "0.5331892", "0.5320667", "0.5319701", "0.52916294", "0.52863", "0.52843964", "0.5270303", "0.5261832", "0.52538323", "0.5235955", "0.52318555", "0.51994604", "0.51922655", "0.51817644", "0.5178205", "0.5177011", "0.51567686", "0.5145016", "0.5137631", "0.51322395", "0.51266956", "0.51168895", "0.50979453", "0.507897", "0.5059833", "0.50545526", "0.504858", "0.5036303", "0.50272375", "0.5023563", "0.50185245", "0.50164014", "0.5012372", "0.5006199", "0.4999877", "0.49983722", "0.49940348", "0.49918213", "0.4986295", "0.49837485", "0.49827868", "0.4978675", "0.49761483", "0.4969896", "0.49680966", "0.49632287", "0.49550363", "0.4946664", "0.49406782", "0.49379387", "0.49357164", "0.49351084", "0.49343273", "0.49234858", "0.4921514", "0.49141744", "0.49124745", "0.4912201", "0.49104124", "0.49059743", "0.49036336", "0.48946303", "0.4892497", "0.4890039", "0.48725885", "0.4862584", "0.48596835", "0.48570532", "0.48555565", "0.48530447", "0.48441273", "0.48441273", "0.4843846", "0.48433012", "0.48428604", "0.48427063", "0.4841649", "0.48378673", "0.483126", "0.48310947", "0.48217285", "0.482124" ]
0.0
-1
Permite comparar platos por su valor energetico total
def <=> (other) vct <=> other.vct end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valorsemaforo\n va = Float(valoractual)\n if va < Float(self.valorfinalrojo)\n 1\n elsif va < Float(self.valorfinalamarillo)\n 2\n else\n 3\n end\n end", "def get_valor_energetico\n \n return ((@proteinas + @glucidos) * 4 + @lipidos * 9).round(1)\n \n \n end", "def vct\n grtotal = 0\n sum = 0\n\t\t#recorre las dos listas a la vez para sacar el valor\n\t\t#nutricional de cada ingrediente segun el peso de este\n @lista.zip(@listagr).each do |normal, gr|\n cant = gr/1000.0\n sum += normal.val_en*cant\n end\n sum\n end", "def calculo_valor_energetico\n\t\t\t(@carbohidratos*4) + (@lipidos*9) + (@proteinas*4)\n\t\tend", "def calculo_valor_calorico_total\n recorrido = lista_alimentos.head\n cantidad = lista_cantidades.head\n acumulador = 0\n\n while (recorrido != nil && cantidad != nil)\n acumulador = acumulador + (((recorrido.value.proteinas * cantidad.value)/1000) * 4) + (((recorrido.value.lipidos * cantidad.value)/1000) * 9) + (((recorrido.value.carbohidratos * cantidad.value)/1000) * 4)\n\n recorrido = recorrido.next\n cantidad = cantidad.next\n end\n\n acumulador.round(2)\n end", "def get_valor_energetico\n\n return ((@proteinas + @glucidos) * 4 + @lipidos * 9).round(1)\n\n end", "def precio_total_compras\n compras.sum(:precio_total)\n #p = 0\n #compras.each do |compra|\n #p += (compra.precio_total || 0)\n #end\n #return p\n end", "def geiTotal\n\t\t@geiSuma = 0\n\t\[email protected] do |alimento|\n\t\t\t@geiSuma += alimento.gei\n\t\tend\n\t\treturn @geiSuma.round(2)\n\tend", "def plato_mas_barato(menu)\n llave = menu.keys\n barato = menu[llave[0]]\n plate = llave[0]\n menu.each do |plato, valor|\n if valor < barato\n plate = plato\n barato = valor\n end\n end\n plate\nend", "def vCalorico\n\t\tcalc = Calculadora.new\n\t\tvalCal = 0\t\t\n\t\[email protected] do |alimento|\n\t\t\tvalCal += calc.valorKiloCalorico(alimento)\n\t\tend\n\t\treturn valCal.round(2)\n\tend", "def cmp\n\n a = self.invoices_data.interval_for( interval(4.month), first_day ).sum(:sumOfPNCTOT)\n b = self.carpark_data.and_year(today.year).sum(:number_of_car)\n divide(a, b)\n end", "def valorizacao\n \t\tif self.tipo_de_operacao.compra?\n ((self.atual - self.entrada) / self.entrada) * 100.0\n else\n ((self.entrada - self.atual) / self.atual ) * 100.0\n end\n \tend", "def ausgleich\n\t\tsums = {}\n\t\t%w(jo caro).each do |who|\n\t\t\tsums[who] = @db.get_first_value(\"select summe from sum_#{who} where jahr = #{@options[:jahr]} and monat = #{@options[:monat]} and gemeinsam = 'g'\").to_f\n\t\tend\n\n\t\tif(sums['jo'] == sums['caro'])\n\t\t\tputs \"Gleichstand\"\n\t\t\treturn\n\t\tend\n\n\t\tausg = ((sums['jo'] + sums['caro']) / 2 - sums['jo']).abs\n\t\t\n\t\tif(sums['jo'] > sums['caro'])\n\t\t\tprintf(\"Caro an Jo: %.2f EUR\\n\", ausg)\n\t\telse\n\t\t\tprintf(\"Jo an Caro: %.2f EUR\\n\", ausg)\n\t\tend\n\t\t\n\tend", "def plato_mas_caro(menu)\n llave = menu.keys\n caro = menu[llave[0]]\n plate = llave[0]\n menu.each do |plato, valor|\n if valor > caro\n plate = plato\n caro = valor\n end\n end\n plate\nend", "def uberXL_fare_calculator(distance, minutes)\n base_fareXL = 3.85\n xlTotal = base_fareXL + (0.50 * minutes.to_i) + (2.85 * distance.to_i)\n if xlTotal < 10.50\n puts 10.50\n else\n puts \"The total for an UberXL is #{xlTotal}\"\n end\nend", "def genera_renglon_total\n\t\ttotal = Hash.new\n\t\t@renglones_reporte.each do |renglon|\n\t\t\t\trenglon.columnas.keys.each do |columna|\n\t\t\t\t\tif total[columna].nil?\n\t\t\t\t\t\ttotal[columna] = {:total => renglon.columnas[columna][:total], :promedio => 0}\n\t\t\t\t\telse\n\t\t\t\t\t\ttotal[columna][:total] += renglon.columnas[columna][:total]\n\t\t\t\t\tend\n\t\t\t\tend\n\t\tend\n\t\ttotal_t = total[\"Total\"][:total]\n \ttotal[\"Total\"][:promedio] = 100\n\t\ttotal.keys.each do |key|\n\t\t\tbegin\n\t\t\t\ttotal[key][:promedio] = (total[key][:total]/total_t.to_f*100).round\n\t\t\trescue\n\t\t\t\ttotal[key][:promedio] = 0\n\t\t\tend\n\t\tend\n\t\t@total = total\n\tend", "def terrenoTotal\n\t\t@terrenoSuma = 0\n\t\[email protected] do |alimento|\n\t\t\t@terrenoSuma += alimento.terreno\n\t\tend\n\t\treturn @terrenoSuma.round(2)\n\tend", "def costo_por_km\n\t\tcase tipo_servicio.downcase\n\t\t\twhen \"distrital\"\n\t\t\t\tif nro_pasajeros <= 3\n\t\t\t\t\treturn 0.5\n\t\t\t\telse\n\t\t\t\t\treturn 0.7\n\t\t\t\tend\n\t\t\twhen \"interprovincial\"\n\t\t\t\tif nro_pasajeros <= 3\n\t\t\t\t\treturn 0.8\n\t\t\t\telse\n\t\t\t\t\treturn 0.9\n\t\t\t\tend\n\t\t\t\t\n\t\t\twhen \"interdepartamental\"\n\t\t\t\tif nro_pasajeros <= 3\n\t\t\t\t\treturn 1.25\n\t\t\t\telse\n\t\t\t\t\treturn 1.5\n\t\t\t\tend\n\t\t\telse\n\t\t\t\treturn 0\t\t\t\t\n\t\tend\n\tend", "def uberSUV_fare_calculator(distance, minutes)\n base_fareSUV = 14.00\n suvTotal = base_fareSUV + (0.80 * minutes.to_i) + (4.50 * distance.to_i)\n if suvTotal < 25.00\n puts 25.00\n else\n puts \"The total for an UberSUV is #{suvTotal}\"\n end\nend", "def carne\n\t\tcerdo = Alimento.new(\"Cerdo\", 21.5, 0.0, 6.3, 7.6, 11.0)\n\t\tcordero = Alimento.new(\"Cordero\",18.0,0.0,3.1,50.0,164.0)\n\t\tvaca = Alimento.new(\"Carne de vaca\", 21.1,0.0,3.1,50.0,164.0)\n\t\tpollo = Alimento.new(\"Pollo\",20.6,0.0,5.6,5.7,7.1)\n\t\tsuma = 0\n\n\t\t[cerdo,cordero,vaca,pollo].each do |i|\n\t\t\tif (@alimentos.find_index { |x| x == i } != nil)\n\t\t\t\tsuma += @gramos[@alimentos.find_index { |x| x == i }].valor\n\t\t\tend\t\t\n\t\tend\n\n\t\treturn suma >= (gramos_total * 0.45)\n\tend", "def totalCaloricValue()\n\t\t\t\tplato = @alimentsList.head\n\t\t\t\tgrams = @gramsList.head\n\t\t\t\ttotal = 0.0\n\n\t\t\t\twhile plato != nil\n\t\t\t\t\ttotal += (plato.value.get_energia() * grams.value) / 100\n\t\t\t\t\tplato = plato.next\n\t\t\t\t\tgrams = grams.next\n\t\t\t\tend\n\n\t\t\t\treturn total\n\t\t\tend", "def get_current_pe_ratio_comparable\n\t\t\tcomparables = @sorted_comparables\n\t\t\tnew_array = [] \n\t\t\tcomparables.each {|item| new_array << item.current_PE_ratio;}\n\t\t\t@current_pe_comp = @current_stock_price * ( ((new_array.inject(:+) / new_array.count).to_f) / @current_pe_ratio)\n\n \t\treturn @current_pe_comp\n\t\tend", "def valorenergeticoKcal\n veKJ=(cgrasas * 9) + (cgrasassa * 9) + (grasasmono * 9) + (grasaspoli * 9) + (hcarbono * 4) + (polialcoholes * 2.4) + (almidon * 4) + (fibra * 2) + (proteinas * 4) + (sal * 6)\n veKJ.round(2)\n end", "def valor_energetico\n @proteinas * 4.0 + @carbohidratos * 4.0 + @lipidos * 9.0\n end", "def totalProteina \n\t\tprot = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\tprot += alimento.proteinas\n\t\tend\n\t\treturn prot.round(2)\n\tend", "def valor_calorico\n if eficiencia_energetica() < 670\n return 1\n end\n if eficiencia_energetica() > 830\n return 3\n else\n return 2\n end\n end", "def check_for_tot_bal\n val1 = @txt_val1.text.gsub(/[$]/, '$' => '')\n val2 = @txt_val2.text.gsub(/[$]/, '$' => '')\n val3 = @txt_val3.text.gsub(/[$]/, '$' => '')\n val4 = @txt_val4.text.gsub(/[$]/, '$' => '')\n val5 = @txt_val5.text.gsub(/[$]/, '$' => '')\n total_val_expected = [val1, val2, val3, val4, val5].map(&:to_f).inject(:+)\n total_val_actual = @txt_val_ttltext.gsub(/[$]/, '$' => '').to_f\n total_val_expected == total_val_actual\n end", "def vrat_celkovy_soucet_vah\n soucet = 0\n @pole_vah.each do |prvek| \n soucet += prvek.to_i\n end\n return soucet\n end", "def calculo \n self.minutos_reales = 5 * 480 #cantidad de OPERARIOS * Jornada de Trabajo(Turnos)\n self.costo_minuto = 89 #Costo Real por minuto\n self.otros_costos = 540 * 89 #Tiempo Total(Minutos) * Costo Real por Minutos\n self.costo_mano_obra = 420 * 5 * 89 # Jornada Minutos * Cantidad Operarios * Costo Real por minutos \n self.manoObraPlaneada = 650.000 * 5 # Salario Total * Cantidad de operarios \n end", "def <=>(otroPlato)\n\t\treturn valor_energetico <=> otroPlato.valor_energetico\n\tend", "def valorcompensacion(idiguana, tipo)\n sumvalor = Iguanaspago.sum('valor', :conditions => [\"iguana_id = ? and tipo = ?\", idiguana, tipo])\n return sumvalor.to_i\n end", "def geidiario\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n geitotal = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n geitotal += (auxNodo1.value.gei * auxNodo2.value) / 100\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return geitotal.round(1)\n end", "def pProteina \n\t\tprot = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\ttotal += (alimento.proteinas + alimento.lipidos + alimento.carbohidratos)\n\t\t\tprot += alimento.proteinas\n\t\tend\n\t\treturn ((prot/total)*100).round\t\n\tend", "def totalLipidos\n\t\tlip = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\tlip += alimento.lipidos\n\t\tend\n\t\treturn lip.round(2)\n\t\n\tend", "def total\n (@products.values.sum * 1.075).round(2)\n end", "def calcula_imc\n \n if @peso/@altura*@altura < 18\n puts \"vc esta magro\"\n elsif @peso/@altura*@altura <= 25\n puts \"vc esta no peso ideal\"\n elsif @peso/@altura*@altura > 25\n puts \"vc esta acima do peso\"\n end\n \n end", "def total_correcto\n suma = subtotal + iva + ieps\n unless suma == total\n errors.add(:total, 'La sumatoria del subtotal, IVA e IEPS, no concuerda')\n end\n end", "def por_carbohidratos\n \taux_carbohidratos = 0.0\n\t\ti = 1\n\t \twhile i < @lista_alimentos.size do\n\t\t\taux_carbohidratos += @lista_alimentos[i].carbohidratos * @lista_cantidades[i]\n\t\t\ti+=1\n\t\tend\n\t\treturn ((aux_carbohidratos/total_nutrientes)*100.0).round(2)\n\tend", "def totalPrazo(cp,quant)\n\t\treg = cp.size - 1\n\t\tret = 0\n\t\tfor ct in (0..reg)\n\t\t\tret = ret + (desconto(Produt.find(cp[ct]).prazo, Produt.find(cp[ct]).id) * quant[ct])\n\t\tend\n\t\treturn ret\n\tend", "def calculate_total_cost(a, stripped_row, k)\n total_cost = 0\n count = 0\n sum = 0\n delivery = \"\"\n mul_value = (a[:\"Cost Per GB\"].to_i * stripped_row[1].to_i)\n if mul_value >= a[:\"Minimum Cost\"].to_i\n if count > 0\n if mul_value < sum\n sum = mul_value\n delivery = k\n total_cost = sum\n return total_cost, delivery\n end\n else\n sum = mul_value\n count += 1\n total_cost = sum\n delivery = k\n return total_cost, delivery\n end\n end\n end", "def calcular_mayor(valor_1,valor_2)\n if valor_1 > valor_2\n puts \"El valor mayor es #{valor_1}\"\n elsif valor_2 > valor_1\n puts \"El valor mayor es #{valor_2}\"\n else\n puts \"Los valores son iguales\"\n end\nend", "def vrat_soucet_vah(jedinec)\n soucet = 0\n citac = 0\n jedinec.each do |prvek| \n if(prvek)then\n soucet += @pole_vah[citac].to_i\n end\n citac +=1\n end\n return soucet\n end", "def total_the_check\n @total_check = ((check * tip) + check).round(2)\n end", "def par_compare(a, b)\n if a.par_price.price > b.par_price.price\n -1\n elsif a.par_price.price < b.par_price.price\n 1\n else\n @formed.find_index(a) < @formed.find_index(b) ? -1 : 1\n end\n end", "def calcula_pago_total\n \t \tmonto = self.monto\n \t\ttipo_cliente = self.tipo\n \t\tif tipo_cliente == \"colocadora\"\n \t\t\tmonto = ((monto* 0.00)+monto).to_i\n \t\telse\n \t\t\tmonto = ((monto* 0.50)+monto).to_i\n \t\tend\n \tend", "def getMoneySpent(keyboards, drives, b)\n arrK = keyboards.sort.reverse\n arrD = drives.sort.reverse\n\n return -1 if keyboards.length == 1 && drives.length == 1 && (keyboards.sum + drives.sum) > b\n\n max = 0\n arrK.each do |k|\n arrD.each do |d|\n sum = k + d\n max = sum if sum <= b && sum > max\n end\n end\n\n max\nend", "def valor_total(estado)\n\t\t@valor = 0\n\t\tself.parts.each do |p|\n\t\t\tif(p.confirmacao == estado)\n\t\t\t\t@valor += p.valor\n\t\t\tend\n\t\tend\n\t\t@valor\n\tend", "def calcular_total\n\t\treturn calcular_seguro*calcular_incremento\n\tend", "def carbo \n grtotal = 0\n sum = 0\n\t\t#itera en las dos listas a la vez para poder calcular las \n #cabrohidratos dependiendo de la cantidad y tambien suma\n #todas las cantidades para poder calcular el porcentaje\n #despues\n @lista.zip(@listagr).each do |normal, gr|\n grtotal += gr\n cant = gr/1000.0\n sum += normal.carbo*cant\n end\n (sum*100)/grtotal\n end", "def total\n total = (@products.values.sum) * 1.075\n return total.round(2)\n end", "def moneys_total\n moneys_total = 0\n mini_map_cells.each do |cell|\n moneys_total += cell.terrain.money\n moneys_total += cell.sp_resource.money unless cell.sp_resource.blank?\n moneys_total += cell.construction.money unless cell.construction.blank?\n end\n return moneys_total\n end", "def totalHidratos\n\t\thidr = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\thidr += alimento.carbohidratos\n\t\tend\n\t\treturn hidr.round(2)\n\tend", "def uberX_fare_calculator(distance, minutes)\n base_fareX = 2.55\n xTotal = base_fareX + (0.35 * minutes.to_i) + (1.75 * distance.to_i)\n if xTotal < 8\n puts 8\n else\n puts \"The total for an UberX is #{xTotal}\"\n end\nend", "def valorazucaresp\n\t\tvag=(azucares * 70) / 100\n vag.round(2)\n\tend", "def terreno\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n terrenototal = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n terrenototal += (auxNodo1.value.terreno * auxNodo2.value) / 100\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return terrenototal.round(1)\n end", "def menor_total(num)\n lines = read()\n lines.each do |x|\n arr = x.split(\" \")\n existencia = arr[3].to_i + arr[2].to_i + arr[1].to_i\n if existencia < num\n puts \"el #{arr[0]} tiene #{existencia} existencia\"\n end\n end\nend", "def vct\n\t\tsuma = 0\n\t\t\n\t\tsuma += prot * gramos_total * 4 / 100\n\t\tsuma += car * gramos_total * 4 / 100\n\t\tsuma += lip * gramos_total * 9 / 100\n\t\t\n\t\treturn suma.round(2)\n\tend", "def valor_energetico\n (@proteinas * 4) + (@glucidos * 4) + (@grasas * 9)\n end", "def valor_total_gasto\n\t\tself.qualificacoes.sum(:valor_gasto)\n\tend", "def total\n tot = 0\n for card in @cards\n tot += card.value\n end\n if has_ace and tot < 12\n tot2 = tot + 10\n if @stand\n return tot2\n else\n return [ tot, tot2 ]\n end\n else\n return tot\n end\n end", "def total\n tot = 0\n for card in @cards\n tot += card.value\n end\n if has_ace and tot < 12\n tot2 = tot + 10\n if tot2 > 17\n return tot2\n elsif tot2 == 17\n unless @hit_soft_17\n return tot2\n end\n end\n end\n return tot\n end", "def uberB_fare_calculator(distance, minutes)\n base_fareB = 7\n bTotal = base_fareB + (0.65 * minutes.to_i) + (3.75 * distance.to_i)\n if bTotal < 15\n puts 15\n else\n puts \"The total for an UberBlack is #{bTotal}\"\n end\nend", "def check_current_space\n if @parcels.empty?\n puts @volume.to_i\n else\n sum = 0\n @parcels.each do |parcel|\n sum += parcel.volume.to_i\n end\n puts @volume.to_i - sum\n end\n end", "def get_vct\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n vct = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n vct += (auxNodo1.value.get_val / (auxNodo1.value.proteinas + auxNodo1.value.glucidos + auxNodo1.value.lipidos)) * auxNodo2.value\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return vct.round(1)\n end", "def grasas_totales \n\t\t@grasas_totales = @saturadas + @monoinsaturadas + @polinsaturadas\n\t\treturn @grasas_totales\n\tend", "def valorenergeticoKcalp\n\t\tvag=(valorenergeticoKcal * 70) / 100\n\t\tvag.round(2)\n\tend", "def irvitaminas\n vag=(vitymin * 100) / 50\n vag.round(2)\n end", "def test_total_cost\n dinner = Checksplitter.new(20, 20, 4)\n \n assert_equal(dinner.total_cost, (dinner.meal_cost + dinner.tip).to_f)\n end", "def huellaAmbiental\r\n indiceCarbono = 0.0\r\n if @geiTotal < 800.0\r\n indiceCarbono = 1.0\r\n elsif @geiTotal <= 1200.0\r\n indiceCarbono = 2.0\r\n else\r\n indiceCarbono = 3.0\r\n end\r\n\r\n indiceEnergia = 0.0\r\n if kcalPlato < 670.0\r\n calorias = 1.00\r\n elsif kcalPlato <= 830.0\r\n calorias = 2.0\r\n else\r\n calorias = 3.0\r\n end\r\n\r\n return (indiceCarbono + indiceEnergia)/2\r\n end", "def valorproteinasp\n\t\tvag=(proteinas * 70) / 100\n vag.round(2)\n\tend", "def total\n # TODO: implement total\n if products.length == 0\n return 0\n end\n ((@products.values.sum)*1.075).round(2)\n end", "def <=> other\n gasto_total <=> other.gasto_total\n end", "def porcentaje_carbohidratos\n recorrido = lista_alimentos.head\n acumulador = 0\n porcentaje = 0\n\n while recorrido != nil\n acumulador = acumulador + recorrido.value.proteinas + recorrido.value.carbohidratos + recorrido.value.lipidos\n porcentaje = porcentaje + recorrido.value.carbohidratos\n\n recorrido = recorrido.next\n end\n\n ((porcentaje * 100)/acumulador).round(2)\n end", "def vat_amount\n line_total(true) - line_total(false)\n end", "def valorgrasaspolip\n\t\tvag=(grasaspoli * 70) / 100\n vag.round(2)\n\tend", "def getMoneySpent(keyboards, drives, b)\n total = -1\n keyboards.each do |k|\n drives.each do |d|\n sum = k + d\n total = max(total, sum) if sum <= b\n end\n end\n\n total\nend", "def val_carta_mayor\n @carta_mayor = @mi_mano.sort_by {|k, v| v[:valor]}.last\n @carta_mayor[1][:valor]\n end", "def atribuirValor\n\t\t@@compras.each do |produto|\n\t\t\ti = @@compras.index(produto)\n\t\t\tcase produto\n\t\t\t\twhen \"par de meias\"\n\t\t\t\t\t@@compras[i] = 11.99\n\t\t\t\twhen \"camiseta\"\n\t\t\t\t\t@@compras[i] = 29.99\n\t\t\t\twhen \"chinelo\"\n\t\t\t\t\t@@compras[i] = 24.99\n\t\t\t\telse\n\t\t\t\t\tthrow \"Produto não consta.\"\n\t\t\tend\n\t\tend\n\tend", "def valorgrasassatup\n\t\tvag=(cgrasassa * 70) / 100\n vag.round(2)\n\tend", "def preco_total\n produto.preco * quantidade\n end", "def por_carbo\n\t\t\t(@carbohidratos/suma_gramos)*100\n\t\tend", "def suma_elementos(perrito)\n suma = 0\n perrito.each do |elemento|\n if elemento > 50\n suma += elemento \n end\n end\n puts \"La suma de los elementos del arreglo es: #{suma}\"\nend", "def valorpolialcoholesp\n\t\tvag=(polialcoholes * 70) / 100\n vag.round(2)\n\tend", "def getMoneySpent(keyboards, drives, budget)\n #\n # Write your code here.\n #\n highest_combination = -1\n keyboards.each do |keyboard|\n drives.each do |drive|\n sum = keyboard + drive\n highest_combination = sum if sum <= budget && sum > highest_combination\n end\n end\n highest_combination;\nend", "def total_ve\n\t\t\n\t\ttotal_ve = 0\n\t\ti = 0\n\t\t\n\t\twhile i < conjunto_alimentos.length do\n\t\t\n\t\t\ttotal_ve += conjunto_alimentos[i].gei + total_ve\n\t\t\ti += 1\n\n\t\tend\n\t\n\t\treturn total_ve\n\tend", "def car\n\t\tsuma = 0\n\t\tx = 0\n\t\tcantidad = 0\n\n\t\[email protected] do |i|\n\t\t\tcantidad = @gramos[x].valor / (i.proteinas + i.lipidos + i.carbohidratos)\n\t\t\tsuma += i.carbohidratos * cantidad\n\t\t\tx += 1\n\t\tend\t\n\n\t\treturn ((suma * 100) / gramos_total).round(2)\n\tend", "def ir_grasa_total \n\t\t@grasa_ir = grasas_totales\n\t\t@ir_grasa_total = (@grasa_ir/70.to_f) * 100\n\t\t@ir_grasa_total.round(1)\n\tend", "def calcular_ganancia\n dolar = Option.instance.dolar_libre.to_f\n dinero_acumulado = self.movements.inject(0) do |total,m|\n total + m.monto_neto\n end\n precio_en_dolares = (dinero_acumulado / dolar)\n return (precio_en_dolares - self.copia.precio_compra.to_f)\n end", "def irpoliinsaturadas\n vag=(grasaspoli * 100) / 70\n vag.round(2)\n end", "def call(items, total)\n total >= @min_value ? total.mult(BigDecimal.new(100).sub(@percentage, 4), 4).div(BigDecimal.new(100), 4) : total\n end", "def total\n return (@listOfItem.inject(0){|sum,e| sum += e.total}).round_to(2)\n end", "def calcular_valores_parciais(items, items_quantidade, items_valor, modo_calcular_servico = nil)\n valor_total_calculado = 0.0\n items.each_pair { |id, booleano|\n puts(\"Percorrendo Array[id]: \"+id+\", booleando=\"+booleano.to_s)\n if(booleano) then\n item = obter_item_por_produto_id(id)\n item_qtd = items_quantidade.fetch(id)\n puts(\"Item no Loop: \"+item.produto.descricao+\", valor_unit=\"+item.valor_unitario.to_s+\", qtd=\"+item_qtd.to_s)\n if (!modo_calcular_servico) then\n items_valor[id] = (item.valor_unitario * item_qtd)\n valor_total_calculado += items_valor.fetch(id)\n elsif (item.produto.adiciona_taxa_servico)\n valor_total_calculado += (item.valor_unitario * item_qtd * 0.1)\n end\n end\n }\n valor_total_calculado\nend", "def valorvityminp\n\t\tvag=(vitymin * 70) / 100\n vag.round(2)\n end", "def huella_nutricional_plato\n\n\t\tenergia_plato = valor_calorico_total\n\n\t\tii_energia_plato = 0\n\t\trange_energia = [670,830]\n\n\t\tif energia_plato <= range_energia.first\n\t\t\tii_energia_plato = 1\n\t\telsif energia_plato > range_energia.first && energia_plato <= range_energia.last\n\t\t\tii_energia_plato = 2\n\t\telsif energia_plato > range_energia.last\n\t\t\tii_energia_plato = 3\n\t\tend\n\n\t\tgei_plato = emisiones_gei\n\n\t\tii_gei_plato = 0\n\n\t\trange_gei = [800,1200]\n\n\t\tif gei_plato <= range_gei.first\n\t\t\tii_gei_plato = 1\n\t\telsif gei_plato > range_gei.first && gei_plato <= range_gei.last\n\t\t\tii_gei_plato = 2\n\t\telsif gei_plato > range_gei.last\n\t\t\tii_gei_plato = 3\n\t\tend\n\t\t\t\n\t\thn_plato = ((ii_gei_plato + ii_energia_plato) / 2).round\n\n\tend", "def pLipidos\n\t\tlip = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\ttotal += alimento.proteinas + alimento.lipidos + alimento.carbohidratos\n\t\t\tlip += alimento.lipidos\n\t\tend\n\t\treturn ((lip/total)*100).round\n\t\n\tend", "def valorgrasasp\n\t\tvag=(cgrasas * 70) / 100\n\t\tvag.round(2)\n\tend", "def ahorrodinero(año)\n\n i = 0\n final = Array.new \n final1 = Array.new \n final2 = Array.new \n \n\n datos = Valore.where(:año => año)\n \n datos.each do |datos|\n \n \n final[i] = datos.read_attribute(\"es\")\n final1[i] = datos.read_attribute(\"tarifa\")\n final2[i] = final1[i]*final[i]\n \n i = i +1\n \n \n end\n \n return final2\n\n\n\n end", "def test_find_DEDUCCIONES_SIN_DETALLE\n \n deduccion_conyuge = RevenueParameter.find(:first, :conditions => \"name = 'CONYUGE' \") \n assert_in_delta(8000.0, deduccion_conyuge.value, 0.01)\n \n deduccion_minimo_no_imponible = RevenueParameter.find(:first, :conditions => \"name = 'MINIMO_NO_IMPONIBLE' \") \n assert_in_delta(7500.0, deduccion_minimo_no_imponible.value, 0.01)\n \n end", "def calculate_total\n total = 0\n cards.each {|a_card| total += a_card.value }\n #correct for Aces, if we have blown over 21\n cards.each do |a_card| \n if a_card.face == ACE \n total -= (ACE_VALUE - ACE_ALT_VALUE) if total > BLACKJACK\n end\n end\n total\n end", "def get_total_item_working_volume(rc_to_volume)\n total_working_volume = {qty: 0, units: MICROLITERS}\n rc_to_volume.values.each do |wk_volume| \n if wk_volume.fetch(:units) == total_working_volume.fetch(:units)\n total_working_volume[:qty] += wk_volume[:qty]\n else \n raise 'not the same units!!'\n end\n end\n return total_working_volume\n end", "def consumo\n estado_actual - estado_anterior\n end" ]
[ "0.62825483", "0.62064", "0.6145978", "0.61371344", "0.60808647", "0.6078517", "0.6076519", "0.60492235", "0.6032232", "0.60245836", "0.6024375", "0.60042644", "0.5982968", "0.59565896", "0.59354764", "0.5919332", "0.5907339", "0.5898129", "0.58932996", "0.5884366", "0.5882779", "0.58801734", "0.58592474", "0.5851322", "0.58167166", "0.5811566", "0.57933736", "0.578255", "0.578151", "0.57801193", "0.5773909", "0.5772973", "0.57665", "0.5743392", "0.57363665", "0.57030475", "0.56700605", "0.56669855", "0.5665985", "0.5660193", "0.5640477", "0.5638186", "0.56377906", "0.5635469", "0.5634136", "0.563199", "0.56105936", "0.5610025", "0.56093585", "0.56018597", "0.5600484", "0.5589844", "0.55773115", "0.55771", "0.5576155", "0.5573312", "0.5570564", "0.556312", "0.5559098", "0.5553272", "0.55489725", "0.55474705", "0.5537419", "0.5536574", "0.55233103", "0.55173993", "0.55167854", "0.5516268", "0.55118626", "0.54989886", "0.5498704", "0.5494093", "0.54938626", "0.5491995", "0.5482316", "0.54816717", "0.54720247", "0.5468994", "0.5467665", "0.54632324", "0.546134", "0.54583436", "0.54580456", "0.5454843", "0.5454267", "0.54491144", "0.5445912", "0.5442529", "0.5434929", "0.5434015", "0.54337853", "0.542727", "0.5421142", "0.541289", "0.541271", "0.54026", "0.5397079", "0.539395", "0.53936356", "0.53888094", "0.5387983" ]
0.0
-1
Inicializa subplato usando el initialize de la clase plato
def initialize(nombre,lista,listagr) super(nombre,lista,listagr) @gei = 0 @terreno = 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(nombre, platos)\n\t\t@nombre = nombre\n\t\t@platos = List.new\n\t\tfor plato in platos do\n\t\t\t@platos << plato\n\t\tend\n\tend", "def initialize(...)\n super\n mon_initialize\n end", "def init\n end", "def init\n end", "def init\n end", "def init; end", "def init; end", "def init; end", "def init; end", "def initialize\n super\n @sub = Subordinate2.new\n end", "def initialize(nombre,alimentos,cantidad)\n @nombre_plato = nombre # Nombre del Plato\n @lista_alimentos = alimentos # Lista con los alimentos que forman el plato\n @lista_cantidades = cantidad # Lista con las cantidades que hay que usar de cada alimento\n end", "def initialize\n super()\n init_data()\n end", "def at_init\n\n\t\tend", "def init\n\n end", "def initialize(*args)\n super\n mon_initialize\n end", "def initialize\n\t\t\n\tend", "def initialize(devtype,param)\n setupDevice(devtype,param) ;\n end", "def initialize\n init\n end", "def initialize(nombre,peso,talla,edad,sexo,imc,estados,rcc,rcca) #constructor\n super(nombre,peso,talla,edad,sexo,imc,estados,rcc,rcca)\n end", "def initialize(opts = {})\n debug \"MappingSubmodule INIT: opts #{opts}\"\n end", "def initFloor\n floor_geo = Geometry.new('Floor', @@floor)\n floor_geo.setMaterial(@floor_mat)\n floor_geo.setLocalTranslation(0, -0.1, 0)\n self.rootNode.attachChild(floor_geo)\n #Make the floor physical with mass 0.0f! */\n @floor_phy = RigidBodyControl.new(0.0)\n floor_geo.addControl(@floor_phy)\n @bulletAppState.getPhysicsSpace().add(@floor_phy)\n end", "def initialize\n set_config\n end", "def bootstrap_init\n end", "def initialize(estacion) #SpaceStation\n super(estacion)\n end", "def initialize\n\tinit\n\tsuper\nend", "def initialize\n initialize!\n end", "def initialize\n initialize!\n end", "def initialize\n\n\tend", "def initialize\n\n\tend", "def init; end", "def initialize(parent); end", "def initialize() end", "def initialize\n \n end", "def init\n self\n end", "def pre_initialize; end", "def initialize # utilise la classe player pour demander les infos aux joueurs et la classe baord pour lancer la tipar\n puts \" The Houmous Project présente Morbac\"\n @player_one = Player.new\n @player_one.informations\n @player_two = Player.new\n @player_two.informations\n @boboard = Board.new\n end", "def init\n\nend", "def initialize(parent_wnd)\r\n super(parent_wnd)\r\n \r\n @core_game = nil\r\n @splash_name = File.join(@resource_path, \"icons/mariazza_title_trasp.png\")\r\n @algorithm_name = \"AlgCpuMariazza\" \r\n #core game name (created on base class)\r\n @core_name_class = 'CoreGameMariazza'\r\n \r\n # game commands\r\n @game_cmd_bt_list = []\r\n\r\n ## NOTE: don't forget to initialize variables also in ntfy_base_gui_start_new_game\r\n end", "def initialize()\n\t\tend", "def set_contiene_plato\n @contiene_plato = ContienePlato.find(params[:id])\n end", "def initialize\n\t \t# loading or not loading should be the key here.\n end", "def initialize\n define_os\n define_path\n read_settings\n end", "def init_weather\r\n # Make weather\r\n @weather = RPG::Weather.new(@viewport1)\r\n end", "def initialize\r\n\r\n end", "def init(primaryStage) end", "def init_round!\n @warehouse.throw_away_overload!\n produce!\n new_building!\n end", "def initialize()\n @mano = $sin_jugada\n end", "def initialize\n super()\n end", "def initialize\n super()\n end", "def initialize\n super()\n end", "def initialize\n super()\n end", "def initialize\n super()\n end", "def initialize\n super()\n end", "def initialize\n super()\n end", "def initialize(nombre, carrera)\n # se ejecuta el consutrctor de la clase Chileno que solo recibe nombre\n super nombre\n # se asigna carrera\n @carrera = carrera\n end", "def boot\n Rucola::Plugin.before_boot\n do_boot\n Rucola::Plugin.after_boot\n end", "def init\n raise NotImplementedError\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end" ]
[ "0.631851", "0.62075806", "0.6024455", "0.6024455", "0.6024455", "0.6010467", "0.6010467", "0.6010467", "0.6010467", "0.5902726", "0.5898603", "0.58943474", "0.58850664", "0.5882713", "0.5865234", "0.5858763", "0.5854551", "0.5842785", "0.5827869", "0.58032185", "0.57929856", "0.57875264", "0.57869196", "0.5782692", "0.5777521", "0.56906", "0.56906", "0.56822926", "0.56822926", "0.5657509", "0.56435114", "0.55888474", "0.5568883", "0.555798", "0.5557487", "0.5556998", "0.5553933", "0.55488145", "0.55487293", "0.55441546", "0.5537511", "0.5536654", "0.5531148", "0.5519436", "0.5514674", "0.55138695", "0.5510712", "0.55093193", "0.55093193", "0.55093193", "0.55093193", "0.55093193", "0.55093193", "0.55093193", "0.5498631", "0.549058", "0.5485574", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472", "0.5476472" ]
0.0
-1
Devuelve las emisiones de gases totales del plato
def emisiones grtotal = 0 sum = 0 #recorre las dos listas a la vez para sacar los gases emitidos # de cada ingrediente segun el peso de este @lista.zip(@listagr).each do |normal, gr| cant = gr/1000.0 sum += normal.gases*cant end @gei = sum end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def emisiones_gei\n\n\t\tif @emisiones_gei == 0\n\n\t\t\t@lista_alimentos.each do |alimento|\n\n\t\t\t\t@emisiones_gei += alimento.kg_gei\n\t\t\tend\n\n\t\t\t@emisiones_gei = @emisiones_gei.round(2)\n\t\tend\n\n\n\t\t@emisiones_gei\n\tend", "def huella\n\t\tindice1 = 0\n\t\t#dependiendo del vct de cada ingrediente, se le pone un indice\n\t\tif vct < 670\n\t\t\tindice1 = 1\n\t\t\t\n\t\telsif vct > 830\n\t\t\tindice1 = 3\n\t\telse \n\t\t\tindice1 = 2\n\t\tend \n\t\tindice2 = 0\n\t\t#dependiendo de los gases emitidos de cada ingrediente, \n\t\t#se le pone un indice\n\t\tif emisiones < 800\n\t\t\tindice2 = 1\n\t\telsif emisiones > 1200\n\t\t\tindice2 = 3\n\t\telse \n\t\t\tindice2 = 2\n\t\tend\n\t\t#hace la media de los indices sacados\n\t\tindiceres = (indice1+indice2)/2\n\t\t\n\n\tend", "def get_energia\n\t\t\t\t@lipidos * 9 + @proteins * 4 + @carbs * 4\n\t\t\tend", "def calculo \n self.minutos_reales = 5 * 480 #cantidad de OPERARIOS * Jornada de Trabajo(Turnos)\n self.costo_minuto = 89 #Costo Real por minuto\n self.otros_costos = 540 * 89 #Tiempo Total(Minutos) * Costo Real por Minutos\n self.costo_mano_obra = 420 * 5 * 89 # Jornada Minutos * Cantidad Operarios * Costo Real por minutos \n self.manoObraPlaneada = 650.000 * 5 # Salario Total * Cantidad de operarios \n end", "def gei\r\n geis = 0\r\n @lista_alimentos.each do |i|\r\n geis += i.gases\r\n end\r\n return geis\r\n end", "def porcentaje_graso\n (1.2*calcular_imc)+(0.23*@edad)-(10.8*@sexo)-5.4\n end", "def porcentajegrasa\n\t\t1.2 * imc + 0.23 * @edad - 10.8 * @sexo - 5.4\n\tend", "def huellaAmbiental\r\n indiceCarbono = 0.0\r\n if @geiTotal < 800.0\r\n indiceCarbono = 1.0\r\n elsif @geiTotal <= 1200.0\r\n indiceCarbono = 2.0\r\n else\r\n indiceCarbono = 3.0\r\n end\r\n\r\n indiceEnergia = 0.0\r\n if kcalPlato < 670.0\r\n calorias = 1.00\r\n elsif kcalPlato <= 830.0\r\n calorias = 2.0\r\n else\r\n calorias = 3.0\r\n end\r\n\r\n return (indiceCarbono + indiceEnergia)/2\r\n end", "def grasas_totales \n\t\t@grasas_totales = @saturadas + @monoinsaturadas + @polinsaturadas\n\t\treturn @grasas_totales\n\tend", "def oppg\n (opp_possessions.to_f)/games\n end", "def oppg\n (opp_possessions.to_f)/games\n end", "def gramos\r\n grams = 0\r\n @lista_alimentos.each do |i|\r\n grams += 100\r\n end\r\n return grams\r\n end", "def get_energia_proteins\n\t\t\t\t@proteins * 4\n\t\t\tend", "def get_usoterreno\n aux = 0.0\n @contenido.each do |alimento|\n aux += alimento.ground\n end\n @usoterreno = aux\n end", "def totalGramos\n\t\tgramos = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\tgramos += alimento.gramos\n\t\tend\n\t\treturn gramos.round(2)\n\tend", "def room_draws\n return og + oo + cg + co;\n end", "def average_finish_time(game, nb_game)\n\n#On initialise la somme des nombres de laps\nsomme = 0\n\n#On teste si le nombre de parties > 100, si non on n'accpete pas\n\tif nb_game < 100 then puts \"Il faut un nombre > 100 !\"\n\n#Si oui, on lance nb_parties (en l'occurence 150) fois le jeu (en l'occurence Stairways)\n\telse\n\t\t\tnb_game.times do game\n\t\t\tsomme += stairway\n\t\t\tend\n\n#On affiche la moyenne du nombre de parties\n\t\tputs \"**************************************************************************\"\n\t\tputs \"Le score moyen de vos #{nb_game} parties est de #{somme/nb_game} !\"\n\t\tputs \"**************************************************************************\"\n\n\tend\n\nend", "def huella\n huella = @alimentos.inject([0,0,0]) do |acc, i|\n if i.kcal_total < 670\n acc[0] += (1.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n elsif i.kcal_total > 830\n acc[0] += (3.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n else acc[0] += (2.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n end\n if (i.gases * 1000.0) < 800\n acc[0] += (1.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n elsif (i.gases * 1000.0) > 1200\n acc[0] += (3.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n else\n acc[0] += (2.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n\t\t\tend\n\n\t\t\tacc[2] += (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos))\n acc[1] += 1\n acc\n\t\tend\n\n\t\treturn (huella[0] / (2.0 * huella[2])).round(2)\n\tend", "def get_gei\n aux = 0.0\n @contenido.each do |alimento|\n aux += alimento.gei\n end\n @gei = aux\n end", "def gut\n n = 0.0\n if actor?\n n += self.actor.guts_param\n n += self.class.guts_param\n for equip in equips\n next if equip.nil?\n n += equip.guts_param\n end\n else\n n += self.enemy.guts_param\n end\n for state in states\n next if state.nil?\n n += state.guts_param\n end\n # determine min/max guts value\n n = [n, 0].max\n n = [n, guts_max].min\n \n return n\n end", "def get_energia_lipidos\n\t\t\t\t@lipidos * 9\n\t\t\tend", "def calcula_imc\n \n if @peso/@altura*@altura < 18\n puts \"vc esta magro\"\n elsif @peso/@altura*@altura <= 25\n puts \"vc esta no peso ideal\"\n elsif @peso/@altura*@altura > 25\n puts \"vc esta acima do peso\"\n end\n \n end", "def totalkcal\n\t\t\tkcalproteinas + kcallipidos + kcalglucidos\n\t\tend", "def huella_ambiental\r\n energia = 0.0\r\n carbono = 0.0\r\n huella = 0.0\r\n if vct < 670 then\r\n energia = 1.0\r\n elsif vct <= 830 then\r\n energia = 2.0\r\n else\r\n energia = 3.0\r\n end\r\n if gei < 800 then\r\n carbono = 1.0\r\n elsif terrenos <= 1200 then\r\n carbono = 2.0\r\n else\r\n carbono = 3.0\r\n end\r\n huella = (energia + carbono)/2\r\n return huella\r\n \r\n end", "def calc\n calc_spawn_zombie\n calc_move_zombies\n calc_player\n calc_kill_zombie\n end", "def irmonograsas\n vag=(grasasmono * 100) / 70\n vag.round(2)\n end", "def kcalglucidos\n\t\t\t@carbohidratos * 4\n\t\tend", "def calcular_ganancia\n dolar = Option.instance.dolar_libre.to_f\n dinero_acumulado = self.movements.inject(0) do |total,m|\n total + m.monto_neto\n end\n precio_en_dolares = (dinero_acumulado / dolar)\n return (precio_en_dolares - self.copia.precio_compra.to_f)\n end", "def huellaAmbiental\r\n if (menuValido == true)\r\n gei = 0.0\r\n terreno = 0.0\r\n @menu.each do |i|\r\n gei += i.gei\r\n terreno += i.terreno\r\n end\r\n return \"GEI: #{gei}, Uso de terreno: #{terreno}\"\r\n else\r\n return \"El sujeto no es valido pues no consume la cantidad diaria reomendada\"\r\n end\r\n end", "def get_energia_carbs\n\t\t\t\t@carbs * 4\n\t\t\tend", "def valor_energetico\n (@proteinas * 4) + (@glucidos * 4) + (@grasas * 9)\n end", "def porcentajeGlucidos\r\n total_glucidos = 0.0\r\n la = @listaAlimentos.head\r\n lg = @listaGramos.head\r\n while la != nil do\r\n total_glucidos += (la.value.carbohidratos * lg.value) / 100\r\n la = la.next\r\n lg = lg.next\r\n end\r\n total_gramos = listaGramos.reduce(:+)\r\n porcentajeGlucidos = ((total_glucidos / total_gramos)*100).round(2)\r\n end", "def get_grasas\n @_100=((@grasas*100)/@peso)\n @ir_100=(@_100/70)*100\n @porcion=((@grasas*@gramos_porciones)/@peso)\n @ir_porcion=(@porcion/70)*100\n [ @grasas , @_100 , @ir_100.round(1) , @porcion , @ir_porcion.round(1) ]\n end", "def adjourn_points_giocataend\r\n # at the end of the game remain to calculate the primiera\r\n player1 = @players[0]\r\n player2 = @players[1]\r\n hand1 = @carte_prese[player1.name]\r\n hand2 = @carte_prese[player2.name]\r\n prim_res_arr = calculate_primiera(hand1, hand2)\r\n @log.debug(\"Primiera of #{player1.name}:#{prim_res_arr[0]}, #{player2.name}: #{prim_res_arr[1]}\")\r\n # update points on all players\r\n ix = 0\r\n [player1, player2].each do |pl|\r\n points_info = @points_curr_segno[pl.name]\r\n points_info[:primiera] = prim_res_arr[ix]\r\n #calculate total\r\n tot = 0\r\n points_info.each do |k,v|\r\n next if k == :tot\r\n tot += v\r\n end\r\n points_info[:tot] = tot\r\n ix += 1\r\n end\r\n end", "def calculo_valor_energetico\n\t\t\t(@carbohidratos*4) + (@lipidos*9) + (@proteinas*4)\n\t\tend", "def Grass\n \n \tif sexo == \"Hombre\"\n \t\t\n \t\tsexo = 1\n \telse\n \t\n \t\tsexo = 0\n \tend\n\t\n grasas = 1.2 * @imc + 0.23 * edad - 10.8 * sexo - 5.4\n \n if @imc < 18.5 \n puts \"Flaco\"\n else if @imc < 24.9 \n puts \"Aceptable\"\n else \n puts \"Obeso\"\n end \nend \n\n \n return grasas\n \n end", "def imc\n\t\tnum = (@peso/(@talla*@talla)).round(2)\n\t\tif num < 18.5\n\t\t\tnum #- Bajo peso\"\n\t\telsif num > 18.5 and num < 24.9\n\t\t\tnum #- Adecuado\"\n\t\telsif num > 25.0 and num < 29.9\n\t\t\tnum #- Sobrepeso\"\n\t\telsif num > 30.0 and num < 34.9\n\t\t\tnum #Obesidad grado 1\"\n\t\telsif num > 35.0 and num < 39.9\n\t\t\tnum #- Obesidad grado 2\"\n\t\telsif num > 40\n\t\t\tnum #- Obesidad grado 2\"\n\t\tend\t\t\t\n\tend", "def valorenergeticoKcal\n veKJ=(cgrasas * 9) + (cgrasassa * 9) + (grasasmono * 9) + (grasaspoli * 9) + (hcarbono * 4) + (polialcoholes * 2.4) + (almidon * 4) + (fibra * 2) + (proteinas * 4) + (sal * 6)\n veKJ.round(2)\n end", "def irpoliinsaturadas\n vag=(grasaspoli * 100) / 70\n vag.round(2)\n end", "def promedios\n promedio = (@nota1.to_f + @nota2.to_f + @nota3.to_f) / 3\n promedio\n end", "def irgrasassaturadas\n vag=(cgrasassa * 100) / 70\n vag.round(2)\n end", "def grasa\n\t\t1.2 * imc + 0.23 * @edad - 10.8 * ( sexo ? 1 : 0) - 5.4\n\tend", "def horas_porasignar(asig_id,solucion)\n # horas requeridas de esta materia en este curso\n req = self.horas_por_semanas.where(:asignatura_id => asig_id).last.horasporsemana\n #horas ya agendadas en esta materia\n agend = solucion.sol_cursos.where(:curso_id => self.id, :asignatura_id => asig_id).count\n return(req-agend) \n end", "def dieta_gases_diarios(gramos)\n gases_diarios = dieta_gases_anuales(gramos)/365\n return gases_diarios.round(3)\n end", "def grasa(sexo,peso,talla)\n\t\t@grasa = 1.2*imc(peso,talla)+0.23*@edad-10.8*sexo-5.4\n\tend", "def dieta_gases_anuales(gramos)\n aux = @head\n suma_gases = 0\n i = 0\n while (!aux.nil?)\n suma_gases += aux[:value].auxiliar(gramos[i])\n aux = aux[:next]\n i = i+1\n end\n return suma_gases.round(2)\n\n end", "def calcular_imc\n (@peso)/(@altura*@altura)\n end", "def formula(start)\n\tpencils = start * 20\n\tboxes = pencils / 100\n\treturn pencils, boxes\nend", "def add_nova_entidade\r\n\t\tif (Gosu::milliseconds - @ultimo_tempo ) / rand(20 ... 2500) == 1 \r\n\t\t\ttipo_proj = rand(0 ... Meteoros.length )\r\n\t\t\timg_size = Gosu::Image.new(Meteoros[rand(0 ... Meteoros.length )]).width\r\n\t\t\t@entidades << Projetil.new( rand(4 ... (Std_Width_Game-(2*img_size))) , 1, 0, Gosu::Image.new(Meteoros[tipo_proj]), rand(50 ... 300), Meteoros[tipo_proj])\r\n\t\t\t@ultimo_tempo = Gosu::milliseconds\r\n\t\tend\r\n\tend", "def avg_kills_per_shot\n 1 / avg_shots_per_kill\n end", "def avg_kills_per_shot\n 1 / avg_shots_per_kill\n end", "def gases_anual()\n gas=0\n aux=@head\n\n loop do\n gas+=(aux.value).gases\n aux=aux.next\n break if aux==nil\n end\n gas=gas*365\n return gas\n end", "def ener_kcal \n\t\t@ener_kcal = @saturadas * 9 + @monoinsaturadas * 9 + @polinsaturadas * 9 + @azucares * 4 + @polialcoles * 2.4 + @almidon * 4 + @fibra * 2 + @proteinas * 4 + @sal * 6\n\t\treturn @ener_kcal\n\tend", "def valormonograsasp\n\t\tvag=(grasasmono * 70) / 100\n vag.round(2)\n\tend", "def salvar_calculados\n self.cif_dolares = fob_dolares.to_f + seguro.to_f + flete_I.to_f + flete_II.to_f + otros_gastos.to_f\n self.cif_bolivianos = 7.07 * cif_dolares.to_f\n self.ga = cif_bolivianos * 0.10\n self.iva = (cif_bolivianos.to_f + ga.to_f) * 0.1494\n self.ice = (cif_bolivianos.to_f + ga.to_f) * 0.18\n self.total_impuestos = ga.to_f + iva.to_f + ice.to_f + diu.to_f\n # otros_1 = ibmetro\n # otros_2 = ibnorca\n self.total_servicios = almacenaje.to_f + senasac.to_f + camara_comercio.to_f + otros_1.to_f + otros_2.to_f + nuestros_servicios.to_f + gastos_tramite.to_f\n \n self.total_despacho = total_impuestos.to_f + total_servicios.to_f\n end", "def total_ve\n\t\t\n\t\ttotal_ve = 0\n\t\ti = 0\n\t\t\n\t\twhile i < conjunto_alimentos.length do\n\t\t\n\t\t\ttotal_ve += conjunto_alimentos[i].gei + total_ve\n\t\t\ti += 1\n\n\t\tend\n\t\n\t\treturn total_ve\n\tend", "def calories_per_liter\n 672\n end", "def macro_percentages\n \n if self.total_calories!=nil and self.protein_grams != nil and self.carbohydrate_grams!=nil and self.fat_grams!=nil\n return {:protein=>protein_grams.to_f/total_calories, :carbohydrate => carbohydrate_grams.to_f/total_calories, :fat=> fat_grams.to_f/total_calories}\n end\n\n return nil\n end", "def porcentaje_glucidos\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n porcentaje_gluc = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n porcentaje_gluc += (auxNodo1.value.glucidos * auxNodo2.value) / 100\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return porcentaje_gluc.round(1)\n end", "def average_plate(plates)\n\ta = 0\n\tplates.each{ |key,value| a += value }\n\tvalor_promedio = a / plates.length\n\tputs \"el valor promedio de los platos es: #{valor_promedio}\"\nend", "def totalHidratos\n\t\thidr = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\thidr += alimento.carbohidratos\n\t\tend\n\t\treturn hidr.round(2)\n\tend", "def gases()\n gas=0\n aux=@head\n\n loop do\n gas+=(aux.value).gases\n aux=aux.next\n break if aux==nil\n end\n return gas\n end", "def calorie_count\n @sugar_amount * CALORIES_PER_SUGAR_GRAM +\n @flour_amount * CALORIES_PER_FLOUR_GRAM\n end", "def gramos_total\n\t\tsuma = 0\n\t\t\n\t\[email protected] do |i|\n\t\t\tsuma += i\n\t\tend\n\n\t\treturn suma.round(2)\n\tend", "def total_point\n lecture.etcs_point\n end", "def carbohidratos\n\t\treturn @carbohidratos*@cantidad\n\tend", "def porc_grasa\n\t\t(1.2 * self.indice_masa_corporal + 0.23 * edad - 10.8 * sexo - 5.4).round(1)\n\tend", "def number_of_kcal_per_meal\n kcal_per_recipe = recipe_ingredients.each.sum do |recipe_ingredient|\n calories_per_gram = recipe_ingredient.ingredient.calories / 100 \n kilograms_of_ingredient = recipe_ingredient.calculated_weight_in_grams / 1000\n (calories_per_gram * kilograms_of_ingredient) #kcal\n end\n kcal_per_recipe / num_people\n end", "def totalTerreno()\n\t\t\t\t# terreno = (terreno * grammi) / 100\n\n\t\t\t\tplato = alimentsList.head\n\t\t\t\tgrams = gramsList.head\n\n\t\t\t\ttotalTerreno = 0.0\n\n\t\t\t\twhile plato != nil\n\t\t\t\t\ttotalTerreno += (plato.value.terreno * grams.value) / 100\n\n\t\t\t\t\tplato = plato.next\n\t\t\t\t\tgrams = grams.next\n\t\t\t\tend\n\n\t\t\t\treturn totalTerreno\n\t\t\tend", "def calculo_emisiones_diarias\n recorrido = lista_alimentos.head\n cantidad = lista_cantidades.head\n\n while (recorrido != nil && cantidad != nil)\n @emisiones_diarias = @emisiones_diarias + ((recorrido.value.gei * cantidad.value)/1000)\n\n recorrido = recorrido.next\n cantidad = cantidad.next\n end\n\n @emisiones_diarias\n end", "def renglon_a_grafica\n\t\tgenera_renglon_total\n\t\tdevuelto = Hash.new\n\t\t@renglones_reporte[0].id_columnas.each do |key|\n\t\t\tdevuelto[key] = @total[key][:promedio]\n\t\tend\n\t\tdevuelto\n\tend", "def totalProteina \n\t\tprot = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\tprot += alimento.proteinas\n\t\tend\n\t\treturn prot.round(2)\n\tend", "def gal_artist\n beef = paintings.map{|exp| exp.artist.years_active} #accesing artist object in paintings method(mentioned above) and years_active instance_method\n tot = beef.inject{|sum, n| sum + n} #sum of all\n # avg = (beef_tot / beef.length).round(0) #avg of the num of elements(beef_tot) divide by number of arrays we summed up (beef.length)\n # binding.pry\n\n end", "def grams\n gram_equivalent / amount\n end", "def totals\n t=['Totaux']\n # bottoms est un arrau de totaux des différents mois de l'exercice\n bottoms = 1.upto(@period.list_months.size).collect do |i| # i va de 1 à 12 par ex\n lines.sum {|l| l[i]} # l[i] car l[0] est nature.name\n end\n t + bottoms + [bottoms.sum {|i| i}]\n end", "def totals\n t=['Totaux']\n # bottoms est un arrau de totaux des différents mois de l'exercice\n bottoms = 1.upto(@period.list_months.size).collect do |i| # i va de 1 à 12 par ex\n lines.sum {|l| l[i]} # l[i] car l[0] est nature.name\n end\n t + bottoms + [bottoms.sum {|i| i}]\n end", "def objetivos_y_carga_diaria\n mes = params[:mes].to_i\n anio = params[:anio].to_i\n vendedor_id = params[:vendedor_id].to_i\n vendedor = Vendedor.find(vendedor_id)\n totales = Hash.new\n total_ob_op = ObjetivoMensual.total_objetivos_punto_venta(anio, mes, vendedor, 7)\n total_ob_pm = ObjetivoMensual.total_objetivos_punto_venta(anio, mes, vendedor, 4)\n total_ob_v = ObjetivoMensual.total_objetivos_punto_venta(anio, mes, vendedor, 5)\n total_ob_csi = ObjetivoMensual.total_objetivos_punto_venta(anio, mes, vendedor, 3)\n total_ob_fin = ObjetivoMensual.total_objetivos_punto_venta(anio, mes, vendedor, 8)\n total_op = ObjetivoMensual.asignado_o_proyeccion(anio, mes, vendedor, 7)\n total_pm = ObjetivoMensual.asignado_o_proyeccion(anio, mes, vendedor, 4)\n total_v = ObjetivoMensual.asignado_o_proyeccion(anio, mes, vendedor, 5)\n total_csi = ObjetivoMensual.asignado_o_proyeccion(anio, mes, vendedor, 3)\n total_fin = ObjetivoMensual.asignado_o_proyeccion(anio, mes, vendedor, 8)\n totales[:ob_oportunidades] = total_ob_op\n totales[:ob_pruebas_manejo] = total_ob_pm\n totales[:ob_ventas] = total_ob_v\n totales[:ob_csi] = total_ob_csi\n totales[:ob_fin] = total_ob_fin\n totales[:oportunidades] = total_op\n totales[:pruebas_manejo] = total_pm\n totales[:ventas] = total_v\n totales[:calidad] = total_csi\n totales[:financiaciones] = total_fin\n render json: totales.to_json\n end", "def valor_energetico\n @proteinas * 4.0 + @carbohidratos * 4.0 + @lipidos * 9.0\n end", "def gasoline_gal\n @current_gasoline ||= quantity * fuel_per_hour * hours_per_year\n end", "def calc_race_gv(course)\n # Rails.logger.info(\"Process course #{course}\")\n total_delta = 0.0\n meet_cnt = 0\n meets = get_meets\n meets.each do |meet|\n delta = process_course(meet,course)\n next if delta == nil\n meet_cnt += 1\n total_delta += delta\n calc_runners_gv(course)\n end\n total_delta / meet_cnt\n end", "def moneys_total\n moneys_total = 0\n mini_map_cells.each do |cell|\n moneys_total += cell.terrain.money\n moneys_total += cell.sp_resource.money unless cell.sp_resource.blank?\n moneys_total += cell.construction.money unless cell.construction.blank?\n end\n return moneys_total\n end", "def virus_effects\n predicted_deaths \n speed_of_spread \n end", "def virus_effects\n predicted_deaths \n speed_of_spread \n end", "def area_terreno\n\n\t\tif @area_terreno_m2 == 0\n\n\t\t\t@lista_alimentos.each do |alimento|\n\n\t\t\t\t@area_terreno_m2 += alimento.area_terreno\n\t\t\tend\n\n\t\t\t@area_terreno_m2 = @area_terreno_m2.round(2)\n\t\tend\n\n\t\t@area_terreno_m2\n\tend", "def huella_nutricional\n numero1 = self.calculo_valor_calorico_total\n numero2 = self.calculo_emisiones_diarias\n\n if numero1 < 670\n ienergia = 1\n elsif numero1 <=830\n ienergia = 2\n else\n ienergia = 3\n end\n\n if numero2 < 800\n icarbono = 1\n elsif numero2 <= 1200\n icarbono = 2\n else\n icarbono = 3\n end\n\n media = (ienergia + icarbono)/2\n end", "def irgrasas\n vag=(cgrasas * 100) / 70\n vag.round(2)\n end", "def espacios_disponibles_motos\n Space.where(sp_state: false, sp_type: 'MOTO').count\n end", "def calc\n calc_in_game\n calc_sprite_selection\n end", "def kcalproteinas\n\t\t\t@proteinas * 4\n\t\tend", "def horas_cierre\n return current_user.grupo.end_times if current_user && !current_user.grupo.nil?\n\n HORAS_CIERRE\n end", "def get_valor_energetico\n \n return ((@proteinas + @glucidos) * 4 + @lipidos * 9).round(1)\n \n \n end", "def total_impact\n component_total(components)\n end", "def uno_mas\n\t\t@edad += 1\n\t\tif @edad < EDAD_MAXIMA\n\t\t\t@altura += @inc_alt\n\t\t\t@contador += prod_nar if @edad >= @ini_fru\n\t\telse\n\t\t\tmuere\n\t\tend\n\t\t@edad\n\tend", "def treasure_prob\n return $data_enemies[@enemy_id].treasure_prob\n end", "def terrenoTotal\n\t\t@terrenoSuma = 0\n\t\[email protected] do |alimento|\n\t\t\t@terrenoSuma += alimento.terreno\n\t\tend\n\t\treturn @terrenoSuma.round(2)\n\tend", "def avg_shots_per_kill\n @shots.to_f / @kills\n end", "def geiTotal\n\t\t@geiSuma = 0\n\t\[email protected] do |alimento|\n\t\t\t@geiSuma += alimento.gei\n\t\tend\n\t\treturn @geiSuma.round(2)\n\tend", "def cantidad_casas_hoteles\n aux = 0\n \n @propiedades.each do |i|\n aux += i.cantidad_casas_hoteles\n end\n \n return aux\n end", "def virus_effects\n predicted_deaths\n speed_of_spread\n end", "def virus_effects\n predicted_deaths\n speed_of_spread\n end" ]
[ "0.7007304", "0.64219606", "0.63615984", "0.61674726", "0.6152264", "0.6081921", "0.6004554", "0.5976921", "0.59723467", "0.5932031", "0.5932031", "0.5914249", "0.59133124", "0.5884698", "0.58457065", "0.58386594", "0.5831559", "0.57558656", "0.57444376", "0.5742091", "0.5724126", "0.5709624", "0.57028264", "0.569841", "0.5691267", "0.56857073", "0.5666858", "0.56613", "0.5626122", "0.56237143", "0.5613223", "0.5613038", "0.56093645", "0.55817175", "0.55808216", "0.5574751", "0.55718124", "0.55657387", "0.5562292", "0.5559387", "0.5548432", "0.55456066", "0.55403167", "0.55374634", "0.5534174", "0.5507915", "0.5498802", "0.5494314", "0.5490359", "0.54862046", "0.54862046", "0.5469552", "0.54672974", "0.54609084", "0.54560876", "0.54558444", "0.5440419", "0.54403794", "0.54397696", "0.5434657", "0.54191947", "0.541071", "0.5407891", "0.54065996", "0.540558", "0.5404196", "0.54027855", "0.53963894", "0.537628", "0.5369053", "0.5361857", "0.53595287", "0.53582424", "0.53573096", "0.53386056", "0.53386056", "0.5331119", "0.5328392", "0.532258", "0.5321436", "0.53205776", "0.53178036", "0.53178036", "0.531704", "0.5316621", "0.53161263", "0.53111655", "0.5308971", "0.53080887", "0.5306503", "0.5304867", "0.530215", "0.53002924", "0.5292534", "0.5291179", "0.52888834", "0.5287975", "0.5287634", "0.5279039", "0.5279039" ]
0.74137914
0
Devuelve la cantidad de terreno usado total del plato
def terreno grtotal = 0 sum = 0 #recorre las dos listas a la vez para sacar el terreno #usado de cada ingrediente segun el peso de este @lista.zip(@listagr).each do |normal, gr| cant = gr/1000.0 sum += normal.terreno*cant end @terreno = sum end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def terrenoTotal\n\t\t@terrenoSuma = 0\n\t\[email protected] do |alimento|\n\t\t\t@terrenoSuma += alimento.terreno\n\t\tend\n\t\treturn @terrenoSuma.round(2)\n\tend", "def totalHidratos\n\t\thidr = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\thidr += alimento.carbohidratos\n\t\tend\n\t\treturn hidr.round(2)\n\tend", "def totalLipidos\n\t\tlip = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\tlip += alimento.lipidos\n\t\tend\n\t\treturn lip.round(2)\n\t\n\tend", "def totalTerreno()\n\t\t\t\t# terreno = (terreno * grammi) / 100\n\n\t\t\t\tplato = alimentsList.head\n\t\t\t\tgrams = gramsList.head\n\n\t\t\t\ttotalTerreno = 0.0\n\n\t\t\t\twhile plato != nil\n\t\t\t\t\ttotalTerreno += (plato.value.terreno * grams.value) / 100\n\n\t\t\t\t\tplato = plato.next\n\t\t\t\t\tgrams = grams.next\n\t\t\t\tend\n\n\t\t\t\treturn totalTerreno\n\t\t\tend", "def calculo_valor_calorico_total\n recorrido = lista_alimentos.head\n cantidad = lista_cantidades.head\n acumulador = 0\n\n while (recorrido != nil && cantidad != nil)\n acumulador = acumulador + (((recorrido.value.proteinas * cantidad.value)/1000) * 4) + (((recorrido.value.lipidos * cantidad.value)/1000) * 9) + (((recorrido.value.carbohidratos * cantidad.value)/1000) * 4)\n\n recorrido = recorrido.next\n cantidad = cantidad.next\n end\n\n acumulador.round(2)\n end", "def precio_total_compras\n compras.sum(:precio_total)\n #p = 0\n #compras.each do |compra|\n #p += (compra.precio_total || 0)\n #end\n #return p\n end", "def totalProteina \n\t\tprot = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\tprot += alimento.proteinas\n\t\tend\n\t\treturn prot.round(2)\n\tend", "def precio_total_comprar\n precio_compra = @coste + ((@num_casas + @num_hoteles) * @titulo.precio_edificar).to_i\n \n return precio_compra\n end", "def calculo \n self.minutos_reales = 5 * 480 #cantidad de OPERARIOS * Jornada de Trabajo(Turnos)\n self.costo_minuto = 89 #Costo Real por minuto\n self.otros_costos = 540 * 89 #Tiempo Total(Minutos) * Costo Real por Minutos\n self.costo_mano_obra = 420 * 5 * 89 # Jornada Minutos * Cantidad Operarios * Costo Real por minutos \n self.manoObraPlaneada = 650.000 * 5 # Salario Total * Cantidad de operarios \n end", "def calcular_total\n\t\treturn calcular_seguro*calcular_incremento\n\tend", "def calculo_valor_energetico\n\t\t\t(@carbohidratos*4) + (@lipidos*9) + (@proteinas*4)\n\t\tend", "def calcula_pago_total\n \t \tmonto = self.monto\n \t\ttipo_cliente = self.tipo\n \t\tif tipo_cliente == \"colocadora\"\n \t\t\tmonto = ((monto* 0.00)+monto).to_i\n \t\telse\n \t\t\tmonto = ((monto* 0.50)+monto).to_i\n \t\tend\n \tend", "def number_of_units\n return 0.0 if demand.zero?\n return super unless full_load_hours&.positive?\n\n if input_capacity&.positive?\n demand / (input_capacity * full_load_hours)\n elsif output_capacity&.positive?\n (demand - output_of_loss) / (output_capacity * full_load_hours)\n else\n super\n end\n end", "def total_nutrientes\n\t\ti = 0\n\t\tproteinas = carbohidratos = lipidos = 0.0\n\t\twhile i < @lista_alimentos.size do\n\t\t\tproteinas += (@lista_alimentos[i].proteinas)*(@lista_cantidades[i])\n\t\t\tcarbohidratos += (@lista_alimentos[i].carbohidratos)*(@lista_cantidades[i])\n\t\t\tlipidos += (@lista_alimentos[i].lipidos)*(@lista_cantidades[i])\n\t\t i+= 1\n\t\tend\n\t\treturn proteinas + lipidos + carbohidratos\n\tend", "def totalGramos\n\t\tgramos = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\tgramos += alimento.gramos\n\t\tend\n\t\treturn gramos.round(2)\n\tend", "def vrat_celkovy_soucet_vah\n soucet = 0\n @pole_vah.each do |prvek| \n soucet += prvek.to_i\n end\n return soucet\n end", "def number_of_units\n dataset_get(:number_of_units) || fetch(:number_of_units, false) do\n # #to_i also checks if it is nil\n if input_capacity.nil? || input_capacity.zero? ||\n full_load_hours.nil? || full_load_hours.zero?\n 0\n else\n used_capacity = input_capacity * capacity_to_demand_multiplier * full_load_hours\n (demand || preset_demand) / used_capacity\n end\n end\n end", "def moneys_total\n moneys_total = 0\n mini_map_cells.each do |cell|\n moneys_total += cell.terrain.money\n moneys_total += cell.sp_resource.money unless cell.sp_resource.blank?\n moneys_total += cell.construction.money unless cell.construction.blank?\n end\n return moneys_total\n end", "def get_valor_energetico\n \n return ((@proteinas + @glucidos) * 4 + @lipidos * 9).round(1)\n \n \n end", "def geiTotal\n\t\t@geiSuma = 0\n\t\[email protected] do |alimento|\n\t\t\t@geiSuma += alimento.gei\n\t\tend\n\t\treturn @geiSuma.round(2)\n\tend", "def totalCaloricValue()\n\t\t\t\tplato = @alimentsList.head\n\t\t\t\tgrams = @gramsList.head\n\t\t\t\ttotal = 0.0\n\n\t\t\t\twhile plato != nil\n\t\t\t\t\ttotal += (plato.value.get_energia() * grams.value) / 100\n\t\t\t\t\tplato = plato.next\n\t\t\t\t\tgrams = grams.next\n\t\t\t\tend\n\n\t\t\t\treturn total\n\t\t\tend", "def calculo_metros_terreno\n recorrido = lista_alimentos.head\n cantidad = lista_cantidades.head\n\n while (recorrido != nil && cantidad != nil)\n @metros_terreno = @emisiones_diarias + ((recorrido.value.terreno * cantidad.value)/1000)\n\n recorrido = recorrido.next\n cantidad = cantidad.next\n end\n\n @metros_terreno\n end", "def cantidad_casas_hoteles\n aux = 0\n \n @propiedades.each do |i|\n aux += i.cantidad_casas_hoteles\n end\n \n return aux\n end", "def items_cesta()\n @total_cesta_cables = 0\n @items_cesta = 0\n CestaCable.all.each{|c| t=TipoMaterial.find_by_id(c.tipo_material_id);c.cantidad =1 unless !c.cantidad.blank?; suma= t.costo * c.cantidad unless t.nil?; @total_cesta_cables += suma unless t.nil?; @items_cesta += 1 unless t.nil?}\n\n return @items_cesta\nend", "def get_usoterreno\n aux = 0.0\n @contenido.each do |alimento|\n aux += alimento.ground\n end\n @usoterreno = aux\n end", "def get_valor_energetico\n\n return ((@proteinas + @glucidos) * 4 + @lipidos * 9).round(1)\n\n end", "def num_tankoubon; end", "def total_bill\n (@bill * (1 + @tip)).ceil.to_i\n end", "def vct\n grtotal = 0\n sum = 0\n\t\t#recorre las dos listas a la vez para sacar el valor\n\t\t#nutricional de cada ingrediente segun el peso de este\n @lista.zip(@listagr).each do |normal, gr|\n cant = gr/1000.0\n sum += normal.val_en*cant\n end\n sum\n end", "def total_units\n return @total_units\n end", "def carbohidratos\n\t\treturn @carbohidratos*@cantidad\n\tend", "def total_tonnes\n\t\t(calculations.collect(&:tonnes).sum).round 2\n\tend", "def preco_total\n produto.preco * quantidade\n end", "def percent_resources_used\n guests = self.xen_guests.map{|xm| m = xm.guest.machine; [m.ram, m.cpu_cores ]}.transpose.map{|c| c.sum }\n return [ 0, 0] if guests.empty?\n my_resources = [machine.ram,machine.cpu ]\n\n if my_resources.first == 0 or my_resources.last == 0 then\n return [ 0, 0] \n end\n \n# => [17152, 23]\n#>> [xen.model.ram, xen.model.cpu ]\n#=> [32768, 8]\n#>> (17152.to_f / 32768.to_f * 100) .to_i\n#=> 52\n#>> [ [17152, 23], [32768, 8]].transpose.map{|r| (r.first.to_f / r.last.to_f * 100).to_i }\n [ guests , my_resources ].transpose.map{|r| (r.first.to_f / r.last.to_f * 100).to_i }\n end", "def set_importe_total\n self.importe_total = 0\n self.detalles.each do |detalle|\n self.importe_total += detalle.precio_unitario * detalle.cantidad unless detalle.marked_for_destruction?\n end\n end", "def terrenos\r\n terreno = 0\r\n @lista_alimentos.each do |i|\r\n terreno += i.terreno\r\n end\r\n return terreno\r\n end", "def calculate_tar\n (Smoke.by_user(self.id).sum(:counted) * cigaret_tar).convert_to('milligram')\n .to_i\n .round(2)\n end", "def totalSimplificado\n @biblioteca.livrosComoLista.map(&:preco).inject(0){|total, preco| total += preco}\n end", "def genera_renglon_total\n\t\ttotal = Hash.new\n\t\t@renglones_reporte.each do |renglon|\n\t\t\t\trenglon.columnas.keys.each do |columna|\n\t\t\t\t\tif total[columna].nil?\n\t\t\t\t\t\ttotal[columna] = {:total => renglon.columnas[columna][:total], :promedio => 0}\n\t\t\t\t\telse\n\t\t\t\t\t\ttotal[columna][:total] += renglon.columnas[columna][:total]\n\t\t\t\t\tend\n\t\t\t\tend\n\t\tend\n\t\ttotal_t = total[\"Total\"][:total]\n \ttotal[\"Total\"][:promedio] = 100\n\t\ttotal.keys.each do |key|\n\t\t\tbegin\n\t\t\t\ttotal[key][:promedio] = (total[key][:total]/total_t.to_f*100).round\n\t\t\trescue\n\t\t\t\ttotal[key][:promedio] = 0\n\t\t\tend\n\t\tend\n\t\t@total = total\n\tend", "def grasas_totales \n\t\t@grasas_totales = @saturadas + @monoinsaturadas + @polinsaturadas\n\t\treturn @grasas_totales\n\tend", "def gramos_total\n\t\tsuma = 0\n\t\t\n\t\[email protected] do |i|\n\t\t\tsuma += i\n\t\tend\n\n\t\treturn suma.round(2)\n\tend", "def vCalorico\n\t\tcalc = Calculadora.new\n\t\tvalCal = 0\t\t\n\t\[email protected] do |alimento|\n\t\t\tvalCal += calc.valorKiloCalorico(alimento)\n\t\tend\n\t\treturn valCal.round(2)\n\tend", "def total_the_check\n @total_check = ((check * tip) + check).round(2)\n end", "def available_units\n return 0 if status == NO_SPACE\n\n 999\n end", "def total_digestate_potash\n\t\t(calculations.collect(&:calc_digestate_potash).sum).round 3\n\tend", "def valorazucaresp\n\t\tvag=(azucares * 70) / 100\n vag.round(2)\n\tend", "def sum_produits_used\n sum = 0\n self.protofactures.each { |p| sum += p.prix_unit * (p.quantite - p.stock) }\n sum\n end", "def terreno\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n terrenototal = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n terrenototal += (auxNodo1.value.terreno * auxNodo2.value) / 100\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return terrenototal.round(1)\n end", "def terreno\n\t\treturn @terreno*@cantidad\n\tend", "def subtotal\n precio * cantidad\n end", "def total\n array = @products.values\n if array != []\n tally = array.reduce(:+)\n tally += (0.075 * tally)\n return tally.round(2)\n else\n return 0\n end\n end", "def porcentaje_carbohidratos\n recorrido = lista_alimentos.head\n acumulador = 0\n porcentaje = 0\n\n while recorrido != nil\n acumulador = acumulador + recorrido.value.proteinas + recorrido.value.carbohidratos + recorrido.value.lipidos\n porcentaje = porcentaje + recorrido.value.carbohidratos\n\n recorrido = recorrido.next\n end\n\n ((porcentaje * 100)/acumulador).round(2)\n end", "def valor_total_gasto\n\t\tself.qualificacoes.sum(:valor_gasto)\n\tend", "def traitementTotal(taille)\n self.traitementPixel(taille)\n self.traitementMonochrome()\n \n return @grille = self.traitementPicross(taille)\n end", "def getPrecioVenta\n precio = (cantidadCasasHoteles) *(@precioCompra +@precioEdificar) *@factorRevalorizacion \n return precio\n end", "def total_digestate_tonnes\n\t\t(calculations.collect(&:calc_digestate_tonnes).sum).round 2\n\tend", "def costo_por_km\n\t\tcase tipo_servicio.downcase\n\t\t\twhen \"distrital\"\n\t\t\t\tif nro_pasajeros <= 3\n\t\t\t\t\treturn 0.5\n\t\t\t\telse\n\t\t\t\t\treturn 0.7\n\t\t\t\tend\n\t\t\twhen \"interprovincial\"\n\t\t\t\tif nro_pasajeros <= 3\n\t\t\t\t\treturn 0.8\n\t\t\t\telse\n\t\t\t\t\treturn 0.9\n\t\t\t\tend\n\t\t\t\t\n\t\t\twhen \"interdepartamental\"\n\t\t\t\tif nro_pasajeros <= 3\n\t\t\t\t\treturn 1.25\n\t\t\t\telse\n\t\t\t\t\treturn 1.5\n\t\t\t\tend\n\t\t\telse\n\t\t\t\treturn 0\t\t\t\t\n\t\tend\n\tend", "def valor_energetico\n @proteinas * 4.0 + @carbohidratos * 4.0 + @lipidos * 9.0\n end", "def huella_nutricional\n (valor_calorico() + huella_carbono()) / 2\n end", "def total_meters\n data[:total_meters]\n end", "def por_carbohidratos\n \taux_carbohidratos = 0.0\n\t\ti = 1\n\t \twhile i < @lista_alimentos.size do\n\t\t\taux_carbohidratos += @lista_alimentos[i].carbohidratos * @lista_cantidades[i]\n\t\t\ti+=1\n\t\tend\n\t\treturn ((aux_carbohidratos/total_nutrientes)*100.0).round(2)\n\tend", "def pProteina \n\t\tprot = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\ttotal += (alimento.proteinas + alimento.lipidos + alimento.carbohidratos)\n\t\t\tprot += alimento.proteinas\n\t\tend\n\t\treturn ((prot/total)*100).round\t\n\tend", "def total_fuel_gallons\n self.inject(0) do |accum,trip|\n accum += trip.fuel_volume_gal\n accum\n end\n end", "def times_sum\n time_sum = 0\n self.voltas.each { |lap_num, lap_stat| time_sum += time_in_ms(lap_stat[:tempo])}\n return time_sum\n end", "def sum_totals\n @total = Lote.where(:programacion_id => @programacion.first).sum(:precio_t)\n @total = Money.new(\"#{@total}00\", \"USD\").format\n @cantidades = Lote.where(:programacion_id => @programacion.first).sum(:cantidad)\n end", "def calorie_count\n @sugar_amount * CALORIES_PER_SUGAR_GRAM +\n @flour_amount * CALORIES_PER_FLOUR_GRAM\n end", "def totalImpuestosTrasladados valor\n @totalImpuestosTrasladados = valor.to_f\n end", "def total_land_use\n return nil if [number_of_units, land_use_per_unit].any?(&:nil?)\n\n number_of_units * land_use_per_unit\n end", "def numarulTotalDePersoane()\n @@instantePersoana += 1\n puts \"Numarul total de persoane: #@@instantePersoana\"\n end", "def total_digestate_nitrogen\n\t\t(calculations.collect(&:calc_digestate_nitrogen).sum).round 3\n\tend", "def pHidratos\n\t\thidr = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\ttotal += alimento.proteinas + alimento.lipidos + alimento.carbohidratos\n\t\t\thidr += alimento.carbohidratos\n\t\tend\n\t\treturn ((hidr/total)*100).round\n\n\t\n\tend", "def compute_fullcnpswage\n ( full_caissebase + full_process_bonuses ).ceil\n end", "def pretotal\n total\n end", "def ir_grasa_total \n\t\t@grasa_ir = grasas_totales\n\t\t@ir_grasa_total = (@grasa_ir/70.to_f) * 100\n\t\t@ir_grasa_total.round(1)\n\tend", "def indice_masa_corporal\n\t\t(peso / (talla * talla) * 10000).round(1)\n\tend", "def total\n tot = 0\n for card in @cards\n tot += card.value\n end\n if has_ace and tot < 12\n tot2 = tot + 10\n if tot2 > 17\n return tot2\n elsif tot2 == 17\n unless @hit_soft_17\n return tot2\n end\n end\n end\n return tot\n end", "def how_many\n return @@total_samurais\n end", "def huella_nutricional_plato\n\n\t\tenergia_plato = valor_calorico_total\n\n\t\tii_energia_plato = 0\n\t\trange_energia = [670,830]\n\n\t\tif energia_plato <= range_energia.first\n\t\t\tii_energia_plato = 1\n\t\telsif energia_plato > range_energia.first && energia_plato <= range_energia.last\n\t\t\tii_energia_plato = 2\n\t\telsif energia_plato > range_energia.last\n\t\t\tii_energia_plato = 3\n\t\tend\n\n\t\tgei_plato = emisiones_gei\n\n\t\tii_gei_plato = 0\n\n\t\trange_gei = [800,1200]\n\n\t\tif gei_plato <= range_gei.first\n\t\t\tii_gei_plato = 1\n\t\telsif gei_plato > range_gei.first && gei_plato <= range_gei.last\n\t\t\tii_gei_plato = 2\n\t\telsif gei_plato > range_gei.last\n\t\t\tii_gei_plato = 3\n\t\tend\n\t\t\t\n\t\thn_plato = ((ii_gei_plato + ii_energia_plato) / 2).round\n\n\tend", "def calc_total_cost()\n\t\ttotal_cost = @cost.to_i * 0.9\n\tend", "def total_demand\n info[:total_demand]\n end", "def num_nulos\n t = @filas*@columnas\n nn = 0\n \n @filas.times do |i|\n nn += @pos[i].size\n i += 1\n end\n\n n = t - nn\n n.to_f/t.to_f\n end", "def totalPrazo(cp,quant)\n\t\treg = cp.size - 1\n\t\tret = 0\n\t\tfor ct in (0..reg)\n\t\t\tret = ret + (desconto(Produt.find(cp[ct]).prazo, Produt.find(cp[ct]).id) * quant[ct])\n\t\tend\n\t\treturn ret\n\tend", "def units_per_package\n unit_factor = self.service.displayed_pricing_map.unit_factor\n units_per_package = unit_factor || 1\n\n return units_per_package\n end", "def valor_total(estado)\n\t\t@valor = 0\n\t\tself.parts.each do |p|\n\t\t\tif(p.confirmacao == estado)\n\t\t\t\t@valor += p.valor\n\t\t\tend\n\t\tend\n\t\t@valor\n\tend", "def total_resources\n self.balance + self.fuel_reserve\n end", "def per_trip_total\n (per_ticket_cost + checked_bag_cost + per_trip_accom)\n end", "def total; end", "def calories_per_liter\n 672\n end", "def percent_used\n\t\t\t\treturn nil unless meminfo?\n\t\t\t\tmemory = IO.foreach('/proc/meminfo').first(3)\n\t\t\t\ttotal = memory[0].split[1].to_i\n\t\t\t\ttotal.-(memory[2].split[1].to_i).*(100).fdiv(total).round(2)\n\t\t\tend", "def soma_total\n\n\t\t\n\t\tif janeiro.present?\n\t\t\tjaneiro\n\t\telse\n\t\t\tjaneiro == 0 or unless janeiro.present?\n\t\t\tself.janeiro = 0\n\t\t\tend\n\t\tend\n\t\tif fevereiro.present?\n\t\t\tfevereiro\n\t\telse\n\t\t\tfevereiro == 0 or unless fevereiro.present?\n\t\t\tself.fevereiro = 0\n\t\t\tend\n\t\tend\n\n\n\tif marco.present?\n\t\tmarco\n\telse \n\t\tmarco == 0 or unless marco.present?\n\t\tself.marco = 0\t\n\tend\nend\t\nif abril.present?\n\tabril\nelse abril == 0 or unless abril.present?\n\tself.abril = 0\nend\nend\t\nif maio.present?\n\tmaio\nelse maio == 0 or unless maio.present?\n\tself.maio = 0\nend\nend\t\nif junho.present?\n\tjunho\nelse junho == 0 or unless junho.present?\n\tself.junho = 0\nend\nend\t\nif julho.present?\n\tjulho\nelse julho == 0 or unless julho.present?\n\tself.julho = 0\nend\nend\t\nif agosto.present?\n\tagosto\nelse agosto == 0 or unless agosto.present?\n\tself.agosto = 0\nend\nend\t\nif setembro.present?\n\tsetembro\nelse setembro == 0 or unless setembro.present?\n\tself.setembro = 0\nend\nend\t\nif outubro.present?\n\toutubro\nelse outubro == 0 or unless outubro.present?\n\tself.outubro = 0\nend\nend\t\nif novembro.present?\n\tnovembro\nelse novembro == 0 or unless novembro.present?\n\tself.novembro = 0\nend\nend\t\nif dezembro.present?\n\tdezembro\nelse dezembro == 0 or unless dezembro.present?\n\tself.dezembro = 0\nend\nend\t\n\nif (self.janeiro == 0 and self.fevereiro == 0 and self.marco == 0 and \n\tself.abril == 0 and self.maio == 0 and self.junho == 0 and\t\n\tself.julho == 0 and self.agosto == 0 and self.setembro == 0 and \n\tself.outubro == 0 and self.novembro == 0 and self.dezembro == 0)\n\tself.total = 0\nelse\n\tself.total = (janeiro + fevereiro + marco + abril + \n\tmaio + junho + julho + agosto + setembro + \n\toutubro + novembro + dezembro)\nend\nend", "def totalImpuestosRetenidos valor\n @totalImpuestosRetenidos = valor.to_f\n end", "def total_susus_global\n susus = Susu.all.count\n end", "def valorEnergetico\n\t\treturn @valorEnergetico*@cantidad\n\tend", "def total_annual_rent_collected\n units.map { |unit| unit.is_vacant ? 0 : unit.monthly_rent }.reduce(:+) * 12\n end", "def porcentajeGlucidos\r\n total_glucidos = 0.0\r\n la = @listaAlimentos.head\r\n lg = @listaGramos.head\r\n while la != nil do\r\n total_glucidos += (la.value.carbohidratos * lg.value) / 100\r\n la = la.next\r\n lg = lg.next\r\n end\r\n total_gramos = listaGramos.reduce(:+)\r\n porcentajeGlucidos = ((total_glucidos / total_gramos)*100).round(2)\r\n end", "def promedio(visitas_diarias)\n visitas_diarias.sum / visitas_diarias.count #suma de los datos dividido la cantidad de datos\nend", "def valorenergeticoKcal\n veKJ=(cgrasas * 9) + (cgrasassa * 9) + (grasasmono * 9) + (grasaspoli * 9) + (hcarbono * 4) + (polialcoholes * 2.4) + (almidon * 4) + (fibra * 2) + (proteinas * 4) + (sal * 6)\n veKJ.round(2)\n end", "def calcular_monto_total\n self.monto_total = total_de_unidades_funcionales\n end", "def calcular_ganancia\n dolar = Option.instance.dolar_libre.to_f\n dinero_acumulado = self.movements.inject(0) do |total,m|\n total + m.monto_neto\n end\n precio_en_dolares = (dinero_acumulado / dolar)\n return (precio_en_dolares - self.copia.precio_compra.to_f)\n end", "def calc_total_gpus\n @total_gpus = 0\n #if @cluster_title.eql?(\"Ruby\")\n # # For the Ruby cluster, pbsnodes takes into account two debug nodes with two GPUs along with the other Ruby GPU nodes. The debug nodes will not be considered in the total GPUs and unallocated GPUs calculation, as they cannot be allocated as part of a regular job request with other GPU nodes. Here np = 20 is the number of processors for a GPU node rather than a debug node (np = 16) in a Ruby cluster.\n # @total_gpus = nodes_info.scan(/np = 20/).size\n # else\n # @total_gpus = nodes_info.lines(\"\\n\\n\").size\n #end\n end" ]
[ "0.7538809", "0.72674954", "0.7005634", "0.6921853", "0.6915203", "0.68969107", "0.6772101", "0.6701636", "0.66948617", "0.6673541", "0.6666854", "0.6627229", "0.65935284", "0.6584838", "0.65822995", "0.65815425", "0.64792293", "0.64722085", "0.6446697", "0.64099574", "0.63909304", "0.6376667", "0.63616765", "0.63559866", "0.63484615", "0.6345258", "0.6345062", "0.6341277", "0.63354504", "0.6311801", "0.62792075", "0.626524", "0.6255724", "0.62301224", "0.62299085", "0.6216584", "0.62124556", "0.6206737", "0.62012863", "0.6192464", "0.6191563", "0.61879563", "0.61879164", "0.6177675", "0.6175983", "0.6167109", "0.61610913", "0.6148053", "0.61466044", "0.61423624", "0.6140437", "0.61402655", "0.6138343", "0.613692", "0.61363965", "0.61222005", "0.61219573", "0.61216044", "0.61069113", "0.61051214", "0.60999024", "0.6098865", "0.6096011", "0.6088563", "0.6084565", "0.6083458", "0.6069169", "0.60658795", "0.6058041", "0.60579515", "0.60409445", "0.6026195", "0.6025479", "0.6009374", "0.60077256", "0.60014254", "0.5999094", "0.59990144", "0.5997076", "0.5995223", "0.59910995", "0.59897333", "0.59776706", "0.59714293", "0.59676", "0.5964299", "0.595694", "0.5951523", "0.5949683", "0.59477186", "0.5946731", "0.5933245", "0.59315354", "0.59272444", "0.592151", "0.59142965", "0.5913771", "0.59001905", "0.58980805", "0.58964175" ]
0.6598443
12
Devuelve el subplato formateado
def to_s string = "Gases " + @gei.to_s + " Uso de terreno anual " + @terreno.to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_socioeduk_subforma_entrada\n @socioeduk_subforma_entrada = Socioeduk::SubformaEntrada.find(params[:id])\n end", "def formation; end", "def partido\n localidad.partido\n end", "def to_s() # :nodoc:\n mano_seleccionada = super.to_s\n if not @movimientos.nil?\n return \"Las estrategias suministradas son \" + @movimientos.to_s + \" \" + mano_seleccionada\n end\n return \"El diccionario de estrategias provista no es valida\"\n end", "def to_plato_s\r\n aaa = \"\"\r\n aaa +=\"Plato: #{@nombre} \\n\"\r\n @lista_alimentos.each do |i|\r\n aaa +=\"Valor energético: #{i.val_ener} \\n\"\r\n end\r\n return aaa\r\n end", "def subcontrat_params\n params.require(:subcontrat).permit(:ruc, :name, :address1, :distrito, :provincia, :dpto, :pais)\n end", "def to_s() # :nodoc:\n mano_seleccionada = super.to_s # Hago un llamado al metodo to_s de mi padre que maneja\n # la impresion de la mano seleccionada\n if not @estrategias.nil?\n return \"Las estrategias suministradas son \" + @estrategias.to_s + \" \" + mano_seleccionada\n end\n return \"La lista de estrategias provista no es valida\"\n end", "def titulo_guia\n titulo = []\n\n t = Especie.find(params[:especie_id])\n a = t.adicional\n\n tipo_region = params[:tipo_region] == \"anp\" ? \"ANP \" : \"Municipio de \"\n \n if a.nombre_comun_principal.present?\n titulo[0] = \"Guía de #{a.nombre_comun_principal}\"\n else\n titulo[0] = \"Guía de #{t.nombre_cientifico}\"\n end\n\n titulo[1] = tipo_region + params[:nombre_region]\n titulo\n end", "def to_label\n if quadra.nil? then\n \"#{area.nome}-#{numero.to_i}\"\n else\n \"#{area.nome}-#{quadra}-#{numero.to_i}\"\n end\n end", "def get_plato(num_plato)\n if (num_plato<0)&&(num_plato>@platos)\n raise \"El plato no existe\"\n else\n \"- #{get_descripcion(num_plato)}, #{@porciones[num_plato]}, #{@ingesta[num_plato]} g\"\n end\n end", "def to_s\n recorrido = lista_alimentos.head\n cantidad = lista_cantidades.head\n formateo = []\n\n while (recorrido != nil && cantidad != nil)\n salida = cantidad.value.to_s + \"gr de \" + recorrido.value.nombre\n formateo.push(salida)\n\n recorrido = recorrido.next\n cantidad = cantidad.next\n end\n\n formateo.push(@emisiones_diarias)\n formateo.push(@metros_terreno)\n\n formateo\n end", "def set_papel_sublimacion_producto\n @papel_sublimacion_producto = PapelSublimacionProducto.find(params[:id])\n end", "def sub_d\n end", "def subtitulo_params\n #params.require(:subtitulo).permit(:curso_id, :idioma_id)\n \n params.require(:subtitulo).permit(:curso_descripcion, :curso_nombre, :curso_name, :idioma_descripcion, :idioma_nombre, :idioma_name, :curso_id, :idioma_id)\n end", "def sub_sector; end", "def to_s\n\t\tsuper().to_s +\n\t\t\" -- Talla: #{@talla} -- Circunferencia Cintura: #{@circun_cintu} -- Circunferencia Cadera: #{@circun_cadera}\"\n\tend", "def new # modificacion para transacciones\n @solicitudrecurso = Solicitudrecurso.new \n \n #identifico los tipos distintos de recurso\n @tipos = Recurso.find(:all).map{ |i| i.descripcion }.uniq\n \n # cargo los dias y horas posibles para los select\n @dias=Dia.find(:all,:conditions=>['en_uso = ?',\"t\"])\n @horas=Horario.find(:all,:conditions=>['en_uso = ?',\"t\"])\n\n #obtengo y formateo la fecha actual\n @[email protected]=formato_europeo(Date.today)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @solicitudrecurso }\n end\n end", "def sub_e\n end", "def to_s\n\t\[email protected] do |alimento|\n\t\t\tputs alimento.nombre\n\t\tend\n\tend", "def b_format_form\n \"#{id} - #{cert_ope}\"\n end", "def Subj\r\n subj.cap_first\r\n end", "def to_s\n recorrido = lista_alimentos.head\n cantidad = lista_cantidades.head\n formateo = []\n\n while (recorrido != nil && cantidad != nil)\n salida = cantidad.value.to_s + \"gr de \" + recorrido.value.nombre\n formateo.push(salida)\n\n recorrido = recorrido.next\n cantidad = cantidad.next\n end\n\n formateo\n end", "def set_substancia\n @substancia = Substancia.find(params[:id])\n end", "def set_subtitulo\n @subtitulo = Subtitulo.find(params[:id])\n end", "def set_subcontrat\n @subcontrat = Subcontrat.find(params[:id])\n end", "def campoord_inicial\n 'ubicacion'\n end", "def platos(options = {})\n plato = options[:nombre]\n nombre_plato = plato.name\n precio_plato = options[:precio]\n @precios << precio_plato\n @valor_energetico << plato.calculoCaloriasDSL\n @valor_ambiental << plato.calculoEmisionesDSL\n\n plato = \"(#{nombre_plato})\"\n plato << \"(#{precio_plato} €)\"\n @platos << plato\n end", "def generos\n (self.genero == 1) ? \"Masculino\" : \"Femenino\"\n end", "def to_s\n \"Nombre del plato: #{@nombre}\"\n end", "def show \n authorize! :show_almacen,Sigesp::Solicitud \n respond_to do |format|\n format.html {\n @grupo = SolicitudGrupo.grupoSolicitud(@sigesp_solicitud.numsol)\n if @grupo.nil?\n @grupo = SolicitudGrupo.new \n @grupo.solicitudes.append @sigesp_solicitud\n end \n }\n format.pdf do\n @solicitud = Sigesp::Solicitud.find(params[:id])\n end\n end\n end", "def get_conjunto_platos\n i=0\n cadena=\"\"\n while(i<@platos)\n cadena=cadena+\"#{get_plato(i)}\"\n if(i!=@platos-1) #if para que no se añada \\n en el ultimo plato\n cadena=cadena+\"\\n\"\n end\n i=i+1\n end\n cadena\n end", "def precio\n\t\t@precio\n\tend", "def ubicacion_tipo_nombre_entidad\n if self.tipo.eql?(\"pais\")\n \"#{self.nombre}\"\n elsif self.tipo.eql?(\"localidad\")\n \"#{self.nombre} (#{self.entidad_superior.tipo.capitalize} #{self.entidad_superior.nombre})\"\n else\n \"#{self.tipo.capitalize} #{self.nombre} (#{self.entidad_superior.tipo.capitalize} #{self.entidad_superior.nombre})\"\n end\n end", "def subtotal\n precio * cantidad\n end", "def get_descripcion(num_plato)\n if (num_plato<0)&&(num_plato>@platos)\n raise \"El plato no existe\"\n else\n \"#{@descripcion[num_plato]}\"\n end\n end", "def platos\n\t\treturn @platos\n\tend", "def modelo_carne_build_data_right(doc, boleto, colunas, linhas)\n # LOGOTIPO do BANCO\n doc.image boleto.logotipo, x: (colunas[2] - 0.11), y: linhas[0]\n\n # Numero do banco\n doc.moveto x: colunas[4], y: linhas[0]\n doc.show \"#{boleto.banco}-#{boleto.banco_dv}\", tag: :grande\n\n # linha digitavel\n doc.moveto x: colunas[6], y: linhas[0]\n doc.show boleto.codigo_barras.linha_digitavel, tag: :media\n\n # local de pagamento\n doc.moveto x: colunas[2], y: linhas[1]\n doc.show boleto.local_pagamento\n\n # vencimento\n doc.moveto x: colunas[11], y: linhas[1]\n doc.show boleto.data_vencimento.to_s_br\n\n # cedente\n doc.moveto x: colunas[2], y: linhas[2]\n doc.show boleto.cedente\n\n # agencia/codigo cedente\n doc.moveto x: colunas[11], y: linhas[2]\n doc.show boleto.agencia_conta_boleto\n\n # data do documento\n doc.moveto x: colunas[2], y: linhas[3]\n doc.show boleto.data_documento.to_s_br if boleto.data_documento\n\n # numero documento\n doc.moveto x: colunas[3], y: linhas[3]\n doc.show boleto.documento_numero\n\n # especie doc.\n doc.moveto x: colunas[8], y: linhas[3]\n doc.show boleto.especie_documento\n\n # aceite\n doc.moveto x: colunas[9], y: linhas[3]\n doc.show boleto.aceite\n\n # dt processamento\n doc.moveto x: colunas[10], y: linhas[3]\n doc.show boleto.data_processamento.to_s_br if boleto.data_processamento\n\n # nosso numero\n doc.moveto x: colunas[11], y: linhas[3]\n doc.show boleto.nosso_numero_boleto\n\n # uso do banco\n ## nada...\n\n # carteira\n doc.moveto x: colunas[3], y: linhas[4]\n doc.show boleto.carteira\n\n # especie\n doc.moveto x: colunas[5], y: linhas[4]\n doc.show boleto.especie\n\n # quantidade\n doc.moveto x: colunas[7], y: linhas[4]\n doc.show boleto.quantidade\n\n # valor documento\n doc.moveto x: colunas[8], y: linhas[4]\n doc.show boleto.valor_documento.to_currency\n\n # valor do documento\n doc.moveto x: colunas[11], y: linhas[4]\n doc.show boleto.valor_documento.to_currency\n\n # Instruções\n doc.moveto x: colunas[2], y: linhas[5]\n doc.show boleto.instrucao1\n doc.moveto x: colunas[2], y: linhas[6]\n doc.show boleto.instrucao2\n doc.moveto x: colunas[2], y: linhas[7]\n doc.show boleto.instrucao3\n doc.moveto x: colunas[2], y: linhas[8]\n doc.show boleto.instrucao4\n doc.moveto x: colunas[2], y: linhas[9]\n doc.show boleto.instrucao5\n doc.moveto x: colunas[2], y: linhas[10]\n doc.show boleto.instrucao6\n\n # Sacado\n doc.moveto x: colunas[2], y: linhas[11]\n if boleto.sacado && boleto.sacado_documento\n doc.show \"#{boleto.sacado} - #{boleto.sacado_documento.formata_documento}\"\n end\n\n # Sacado endereço\n doc.moveto x: colunas[2], y: linhas[12]\n doc.show boleto.sacado_endereco.to_s\n\n # codigo de barras\n # Gerando codigo de barra com rghost_barcode\n if boleto.codigo_barras\n doc.barcode_interleaved2of5(boleto.codigo_barras, width: '10.3 cm', height: '1.2 cm', x: colunas[2],\n y: linhas[14])\n end\n end", "def tipo_formulario?(form_tipo) \n \tif form_tipo == 1\n \t\treturn \"form_membro\"\n \telse\n \t\treturn \"form_estagio\"\n end\n end", "def to_s\n\t\ts = \"\"\n\t\t\n s += super + \"\\n\\n\"\n\n s += \"Emisiones de gases en kg CO2 \" + emisiones_gei.to_s + \"\\n\"\n\n s+= \"Cantidad de terreno empleado en m2 \" + area_terreno.to_s + \"\\n\"\n\tend", "def build_subline_form(action,caption)\n\n\tline_config_codes = LineConfig.find_by_sql('select distinct line_config_code from line_configs').map{|g|[g.line_config_code]}\n\tline_config_codes.unshift(\"<empty>\")\n#\t---------------------------------\n#\t Define fields to build form from\n#\t---------------------------------\n\t field_configs = Array.new\n\t field_configs[0] = {:field_type => 'TextField',\n\t\t\t\t\t\t:field_name => 'subline_code'}\n\n\t field_configs[1] = {:field_type => 'TextField',\n\t\t\t\t\t\t:field_name => 'subline_description'}\n\n#\t----------------------------------------------------------------------------------------------\n#\tCombo fields to represent foreign key (line_config_id) on related table: line_configs\n#\t----------------------------------------------------------------------------------------------\n\tfield_configs[2] = {:field_type => 'DropDownField',\n\t\t\t\t\t\t:field_name => 'line_config_code',\n\t\t\t\t\t\t:settings => {:list => line_config_codes}}\n\n\tbuild_form(nil,field_configs,action,'subline',caption)\n\nend", "def subescapular\n\t\t(@subescapular[0] + @subescapular[1] + @subescapular[2])/3\n\tend", "def ubicacion\n communes_str = @stats.pluralize_communes\n if @stats.communes.size > 1\n comm_st = \" las comunas de \"\n elsif communes_str == \"\"\n comm_st = \"\"\n else\n comm_st = \" la comuna de \"\n end\n regions_str = @stats.pluralize_regions\n if @stats.regions.size > 1\n reg_st = \" las regiones de \"\n elsif regions_str == \"\"\n reg_st = \"\"\n else\n reg_st = \" la region de \"\n end\n country_str = @stats.pluralize_countries\n if @stats.countries.size > 1\n coun_st = \" los paises \"\n elsif country_str == \"\"\n coun_st = \"\"\n else\n coun_st = \" el pais \"\n end\n\n s = \"La zona elegida se encuentra dentro de \" + comm_st + communes_str +\n \", \" + reg_st + regions_str +\" y \" + coun_st + country_str + \".\"\n return s\n end", "def subtotal1\n @subtotal1 = @uomd + @clean\n end", "def slogan\n # 'A maneira mais fácil de pré-qualificar ao Atlas.'\n ''\n end", "def asignar_titulo_propiedad()\n \n end", "def socioeduk_subforma_entrada_params\n params.require(:socioeduk_subforma_entrada).permit(:descricao, :forma_entrada_id)\n end", "def set_contiene_plato\n @contiene_plato = ContienePlato.find(params[:id])\n end", "def grafico_area_oferta(modalidad, offer_title = nil, real_data = true)\n # VERIFICAR SI FUNCIONA PARA CASOS EN QUE NO SE TIENE SUFICIENTE INFORMACION\n aux = modalidad == SALE ? \"venta\" : \"arriendo\"\n title = @num_title.to_s + \".\" + @num_subtitle.to_s + \" Área promedio (#{aux.capitalize})\"\n legend = \"<b>Área promedio</b> de cada propiedad en <b>\" + aux + \"</b>\"\\\n \" en relación a la cantidad de habitaciones.\"\n space_points = 0\n parts = []\n\n # Titulo oferta y subtitulo.\n parts << {type: :offer_title, content: offer_title}\n parts << {type: :sub_title, content: title}\n\n if real_data\n # CONSULTAS BD\n rooms_area = []\n zero_count = 0\n min_rooms = @type_of_property == [HOUSE] ? HOUSE_MIN_ROOMS : 1\n for rooms in min_rooms..(min_rooms + 3)\n room_area = @stats.properties_mean_area(modalidad, rooms, @type_of_property)\n zero_count += 1 if room_area == 0\n rooms_area << room_area\n end\n\n if zero_count == rooms_area.size\n # No hay datos\n legend = NO_MESSAGE\n\n else\n # Hay datos\n # Grafico\n parts << {type: :graph}\n end\n\n # texto.\n parts << {type: :text, content: legend}\n\n # CHECKEAR ESPACIO EN LA PAGINA\n space_points += getTotalHeight(parts)\n checkPageSkip(space_points)\n\n # TITULO OFERTA\n drawOfferTitle(offer_title)\n\n # TITULO\n drawSubTitle(title, :oferta)\n\n # TEXTO\n drawText(legend)\n\n # GRAFICO\n if zero_count != rooms_area.size\n g = Gruff::Bar.new\n g.theme = GRAPH_STYLE\n g.title = \"Área promedio en \" + aux\n g.y_axis_label = \"Área en m^2\"\n g = formatDecimalLabels(aux, g)\n # la funcion acontinuacion retorna un string de error si lo hay y pone la\n # data en el grafico\n errores = data_por_habitacion(rooms_area, g, OFFER)\n g.minimum_value = 0\n g.show_labels_for_bar_values = true\n pad_bottom(PADDING * 2) do \n image StringIO.new(g.to_blob), GRAPH_POS\n end\n\n printErrors(errores)\n end\n\n else\n # parts << {type: :text, content: legend}\n # space_points += getTotalHeight(parts)\n\n png_path = Rails.root.join('app', 'pdfs', 'placeholders', 'area_promedio_arriendo_placeholder.jpg')\n drawFakeData(space_points, png_path, title, :oferta, offer_title)\n\n end\n end", "def subdivision\n @subdivision\n end", "def campos_filtro1_gen\n campos_filtro1\n end", "def anulacion \n @solicitud=Solicitud.find(params[:id])\n @causal_select=CausalesAnulacionRevocatoria.find(:all,:conditions=>\"anulacion=true\",:order=>\"causa asc\")\n @width_layout = '660'\n end", "def to_s\n output = @name\n output << \"\\n#{'=' * @name.size}\\n\"\n output << \"Platos: #{@platos.join(', ')}\\n\"\n output << \"Precio total del menu: #{@precios.reduce(:+)}\\n\"\n output << \"\\nValor calorico total del menu: #{@valor_energetico.reduce(:+).round(1)}\"\n output << \"\\nValor de las emisiones de CO2 del menu: #{@valor_ambiental.reduce(:+).round(1)} \\n\"\n\n end", "def calorie_info\n return \"#{self.name} $#{self.price} (#{self.calorie}kcal)\"\n end", "def set_subpart\n @subpart = Subpart.find(params[:id])\n end", "def texto_plano\n\t\tusuario.texto_plano\t\n\tend", "def por_extenso\n Extenso.por_extenso(self)\n end", "def marcoReal\n\t\t@marcoReal\n\tend", "def sauvegarder()\n\t\[email protected] = Header.temps\n\t\[email protected] = Header.score\n\t\[email protected] = @content[\"grille\"]\n\n\t\t## Sauvegarde la partie dans un fichier yaml au nom de l'utilisateur\n\t\[email protected] (@content[\"pseudo\"])\n\n\t\treturn self\n\tend", "def to_s\n \"La eficiencia energetica del plato es: #{eficiencia_energetica()}\"\n end", "def subgenres; end", "def suivre; end", "def to_s\n \"#{get_titulo} #{get_porcentaje}\\n#{get_conjunto_platos}\\nV.C.T. | % #{get_vct} | #{get_proteinas} - #{get_grasas} - #{get_hidratos}\" \n end", "def porc_grasa\n\t\t(1.2 * self.indice_masa_corporal + 0.23 * edad - 10.8 * sexo - 5.4).round(1)\n\tend", "def ToCoStoiPrzyA()\n return @RownanieWielomianu.first.WspolczynnikPomocniczy\n end", "def to_s\n return super.to_s + \"Fianza: #{@fianza}\\n\"\n end", "def to_s\n\n\t\tsuma_gramos = 0\n\t\tcantidades.collect{|i| suma_gramos += i}\n\n\t\tresult = \"\\n#{@nombre}:\\n\\n\"\n\t\t\n\t\t\n\t\[email protected]{|i| result += i.to_s + \"\\n\"}\n\t\tresult += \"Emisiones de gases de efecto invernadero diarias: #{emisionesEfectoInvDiarias}\\nTerreno total utilizado: #{terrenoTotal}\"\n\n\t\tresult\n\tend", "def mi_carrera\n\n\tend", "def to_s\n\t\t\t \"( Nombre:#{@nombre}, Conjunto Alimentos: #{@la} ,Conjunto Gramos: #{@lg} ,Proteinas :#{@proteinas},Carbo :#{@carbohidratos},Lipidos :#{@lipidos},VCT :#{@vct} )\"\n\n\t\tend", "def to_s\n\t\t\t\"#{@nombre}: #{@proteinas}g de proteínas, #{@glucidos}g de glúcidos y #{@lipidos}g de lípidos\"\n\t\tend", "def set_informativo_obra\n @informativo_obra = InformativoObra.find(params[:id])\n end", "def precio_mercado\n @serie.valor_primer_dia('precio')\n end", "def formatear(raw_rut)\n rut = raw_rut.to_s.delete '.-'\n if rut.blank?\n return rut\n end\n rut_end = rut[rut.length - 1, rut.length]\n rut_init_temp = rut[0, rut.length - 1]\n rut_init = ''\n while rut_init_temp.length > 3 do\n rut_init = '.' + rut_init_temp[rut_init_temp.length - 3, rut_init_temp.length] + rut_init\n rut_init_temp = rut_init_temp[0, rut_init_temp.length - 3]\n end\n rut = rut_init_temp+rut_init+'-'+rut_end\n return rut\n end", "def set_tinta_sublimacion_producto\n @tinta_sublimacion_producto = TintaSublimacionProducto.find(params[:id])\n end", "def descuento_sueldo(sueldo, tipo_obrero)\n\tif tipo_obrero == 'o'\n\t\tsueldo - (sueldo * 0.12) #OCURRE A\n\telse\n\t\tsueldo - (sueldo * 0.15) #OCURRE B\n\tend\nend", "def to_s\n departamento\n end", "def recto_verso!\n self.type= 'physical' unless self.type == 'physical'\n self.label= 'Sides' unless self.label == 'Sides'\n create_div_node struct_map, {:order=>'1'} unless divs_with_attribute(false,'ORDER','1').first\n create_div_node struct_map, {:order=>'2'} unless divs_with_attribute(false,'ORDER','2').first\n if (div = divs_with_attribute(false,'ORDER','1').first)\n div['LABEL'] = 'Recto' unless div['LABEL'] == 'Recto'\n end\n if (div = divs_with_attribute(false,'ORDER','2').first)\n div['LABEL'] = 'Verso' unless div['LABEL'] == 'Verso'\n end\n struct_map\n end", "def new\n\n \n @empresa = Empresa.find(:first, :conditions => [\"prefijo = ?\", params[:empresa_id]] )\n @productos_gtin_13 = Producto.find(:all, :conditions => [\"tipo_gtin.tipo = ? and prefijo = ?\", \"GTIN-13\", params[:empresa_id]], :include => [:tipo_gtin]) if params[:empresa_id].size == 5\n \n if params[:empresa_id].size == 5\n\n @excede_gtin13 = true if (@productos_gtin_13.size >= 10) \n\n end\n\n @producto = @empresa.producto.build # Se crea el form_for\n \n @gtin = params[:gtin] if params[:gtin] != ''# SI esta gtin es para crear gtin tipo 14 base 8 o gtin 14 base 13\n \n\n @producto_ = Producto.find(:first, :conditions => [\"gtin like ?\", params[:gtin]]) if params[:gtin]\n @base = TipoGtin.find(:first, :conditions =>[\"tipo like ? and base like ?\", \"GTIN-14\", @producto_.tipo_gtin.tipo]) if @producto_\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @producto }\n end\n end", "def new\n @voluntario = Voluntario.new\n @voluntario.build_endereco\n @voluntario.criterios.build\n @voluntario.inclusoes.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @voluntario }\n end\n end", "def to_s\r\n super + \"\\nHuella nutricional, GEI: #{@geiTotal} y Uso de Terreno: #{@terrenoTotal}\"\r\n end", "def construir_ruta(a, b)\n # ...\n\n puts 'Context: Definiendo ruta con la estrategia (no estoy seguro cual es)'\n @estrategia.algoritmo(a, b)\n\n # ...\n end", "def set_precio_boleto\n\t@precio_boleto = PrecioBoleto.find(params[:id])\n\tend", "def set_producto_platillo\n @producto_platillo = ProductoPlatillo.find(params[:id])\n end", "def show\n add_breadcrumb \"Detalles\", @prospectos\n end", "def full_descripcion \n \"#{asunto.nombre} - \"+\"#{nombre}\" \n end", "def info_conta\n # CAMPO TAMANHO\n # agencia 3\n # conta corrente 7\n \"#{agencia}#{conta_corrente}\"\n end", "def subcategorium_params\n params.require(:subcategorium).permit(:nombre, :categorias_id)\n end", "def set_subclonnit\n @subclonnit = Subclonnit.find(params[:id])\n end", "def create\n @prueba = Prueba.new(prueba_params)\n\n cantidadAlmacenada = @prueba.cantidad_almacenada\n cantidadDesechada = @prueba.cantidad_desechada\n\n @prueba.cantidad = cantidadAlmacenada + cantidadDesechada \n\n respond_to do |format|\n if @prueba.save\n\n @etiqueta = Etiqueta.new\n\n etiquetaAnalisis = @prueba.etiqueta.etiqueta\n idAnalisis = @prueba.id\n idAnalisisString = idAnalisis.to_s\n\n @etiqueta.etiqueta = etiquetaAnalisis + idAnalisisString + \"-\"\n @etiqueta.formato_id = 2\n @etiqueta.save\n\n format.html { redirect_to etiqueta_mostrar_path(@etiqueta.id), notice: 'Prueba was successfully created.' }\n format.json { render :show, status: :created, location: @prueba }\n else\n format.html { render :new }\n format.json { render json: @prueba.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_insumo_plato\n @insumo_plato = InsumoPlato.find(params[:id])\n end", "def get_txt_panneau\n\t\treturn [mdl_par.panneaux[0].to_s,mdl_par.panneaux[1].to_s]\n\tend", "def relacion_cc\n\t\t(ccintura / ccadera).round(2)\n\tend", "def formato_titulo\n [email protected](\".\")\n auxiliar=\"\"\n titulo_for.each do |i|\n \n aux=i.capitalize\n aux+=(\".\")\n auxiliar+=aux\n end\n @titulo=auxiliar\n end", "def sub_l\n end", "def to_s\n \t\t\t\"(Nombre:#{@nombre},Proteinas:#{@proteinas},Carbohidratos:#{@carbohidratos},Lipidos:#{@Lipidos},Gei:#{@gei},Terreno:#{@terreno})\"\n \t\t\n\t\tend", "def set_formulario\n @formulario = Formulario.find(params[:id])\n end", "def set_formulario\n @formulario = Formulario.find(params[:id])\n end", "def set_formulario\n @formulario = Formulario.find(params[:id])\n end", "def set_formulario\n @formulario = Formulario.find(params[:id])\n end", "def apply plataform\n\n end", "def camposDescarga(tipo_descarga=nil)\n checkbox = ''\n campos = { x_tipo_distribucion: 'Tipo de distribución', x_cat_riesgo: 'Categorías de riesgo y comercio internacional', x_ambiente: 'Ambiente', x_nombres_comunes: 'Nombres comunes', x_bibliografia: 'Bibliografía' }\n \n case tipo_descarga\n when 'basica'\n when 'avanzada'\n campos.merge!({ x_col_basicas: 'Columnas basicas', x_taxa_sup: 'Taxonomía superior', x_url_ev: 'URL de la especie en enciclovida' })\n when 'region'\n campos = { x_num_reg: 'Número de registros' }.merge(campos.merge!({ x_col_basicas: 'Columnas basicas', x_taxa_sup: 'Taxonomía superior', x_url_ev: 'URL de la especie en enciclovida' }))\n when 'checklist'\n campos.merge!({ x_estatus: 'Solo válidos/aceptados', x_distribucion: 'Distribución (reportada en literatura)', x_residencia: 'Categoría de residencia (aves)', x_formas: 'Formas de crecimiento (plantas)', x_interaccion: 'Interacciones biológicas' }) \n end\n \n campos.each do |valor, label|\n if valor.to_s == 'x_col_basicas'\n checkbox << check_box_tag('f_desc[]', valor, true, style: 'display: none;', id: \"f_#{tipo_descarga}_#{valor}\")\n else\n checkbox << \"<div class='custom-control custom-switch'>\"\n checkbox << check_box_tag('f_desc[]', valor, false, class: \"custom-control-input\", id: \"f_#{tipo_descarga}_#{valor}\")\n checkbox << \"<label class='custom-control-label' for='f_#{tipo_descarga}_#{valor}'>#{label}</label>\"\n checkbox << \"</div>\"\n end\n\n \n end\n\n checkbox.html_safe\n end", "def sauvegarderJeu()\n\t\t# création de la sauvegarde\n\t\t@sauvegarde = Sauvegarde.creer( self.joueur,self.carte,self.nbTour )\n\n @sauvegardeYaml = SauvegardeYAML.creer(self.joueur.nom)\n @sauvegardeYaml.enregistrement( self.sauvegarde)\n\n\tend" ]
[ "0.59966326", "0.5819607", "0.57580656", "0.5590646", "0.5560854", "0.55449665", "0.5520069", "0.55178744", "0.5517249", "0.5474457", "0.5380645", "0.5361924", "0.5354927", "0.53380233", "0.5329441", "0.5319763", "0.53035355", "0.52955365", "0.527948", "0.52722704", "0.52690643", "0.5253816", "0.525258", "0.52524006", "0.524775", "0.5240193", "0.5232169", "0.52129185", "0.5198422", "0.5186959", "0.5153089", "0.5147318", "0.51445454", "0.51266456", "0.5121937", "0.5118899", "0.5103526", "0.51000166", "0.50978327", "0.50942177", "0.50934756", "0.5093165", "0.50901705", "0.5067944", "0.5046266", "0.5040546", "0.50394106", "0.50390005", "0.50369817", "0.50359076", "0.50292706", "0.50241655", "0.502251", "0.5020137", "0.5020032", "0.5005292", "0.4995908", "0.49944058", "0.49916378", "0.49892953", "0.49629027", "0.49578318", "0.49545178", "0.49488842", "0.49432755", "0.49401808", "0.49397957", "0.49359518", "0.49256778", "0.4922429", "0.49195415", "0.49188533", "0.49172315", "0.490784", "0.49014953", "0.48956996", "0.4894794", "0.48878255", "0.48780793", "0.48778707", "0.48751655", "0.48624882", "0.48551288", "0.48509842", "0.48434162", "0.48417303", "0.48388687", "0.4837687", "0.4836165", "0.48343897", "0.4819965", "0.48182848", "0.48176596", "0.48140848", "0.48127845", "0.48127845", "0.48127845", "0.48127845", "0.481239", "0.48088175", "0.48069882" ]
0.0
-1
Permite calcular la huella energetica de cada subplato
def huella indice1 = 0 #dependiendo del vct de cada ingrediente, se le pone un indice if vct < 670 indice1 = 1 elsif vct > 830 indice1 = 3 else indice1 = 2 end indice2 = 0 #dependiendo de los gases emitidos de cada ingrediente, #se le pone un indice if emisiones < 800 indice2 = 1 elsif emisiones > 1200 indice2 = 3 else indice2 = 2 end #hace la media de los indices sacados indiceres = (indice1+indice2)/2 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculo_valor_energetico\n\t\t\t(@carbohidratos*4) + (@lipidos*9) + (@proteinas*4)\n\t\tend", "def get_energia\n\t\t\t\t@lipidos * 9 + @proteins * 4 + @carbs * 4\n\t\t\tend", "def get_valor_energetico\n \n return ((@proteinas + @glucidos) * 4 + @lipidos * 9).round(1)\n \n \n end", "def eficiencia_energetica\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n eficiencia_total = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n eficiencia_total += ((auxNodo1.value.terreno * auxNodo1.value.gei) / auxNodo1.value.terreno + auxNodo1.value.gei ) * auxNodo2.value\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return eficiencia_total.round(1)\n end", "def calc_horas(ramo_id)\n ret = 0 \n self.asignaturas.where(:ramo_id => ramo_id).each do |asig|\n \n aux1=0\n \n self.horas_por_semanas.where(:asignatura_id => asig.id).each do |horas|\n aux1= aux1+horas.horasporsemana\n end\n ret= ret+aux1 \n end\n\n return(ret)\n end", "def valor_energetico\n (@proteinas * 4) + (@glucidos * 4) + (@grasas * 9)\n end", "def get_valor_energetico\n\n return ((@proteinas + @glucidos) * 4 + @lipidos * 9).round(1)\n\n end", "def valorenergeticoKcal\n veKJ=(cgrasas * 9) + (cgrasassa * 9) + (grasasmono * 9) + (grasaspoli * 9) + (hcarbono * 4) + (polialcoholes * 2.4) + (almidon * 4) + (fibra * 2) + (proteinas * 4) + (sal * 6)\n veKJ.round(2)\n end", "def calcular()\n lista_nombres=@individuos[0].get_lista_nombres\n lista_nombres.each do |nombre|\n cont=0\n igind=0\n #puts nombre\n for j in [email protected]\n\tglucosa=@individuos[j].get_glucosa.to_f\n #puts glucosa\n aibc=@individuos[j].get_aibc(nombre)\n #puts aibc\n aux=aibc/glucosa*100\n #puts aux\n igind=igind+aux\n\tcont=cont+1\n end\n igind=igind/cont\n #puts igind\n @resultados << nombre + \" \" + igind.round(2).to_s + \"\\n\"\n end\n end", "def huella\n huella = @alimentos.inject([0,0,0]) do |acc, i|\n if i.kcal_total < 670\n acc[0] += (1.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n elsif i.kcal_total > 830\n acc[0] += (3.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n else acc[0] += (2.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n end\n if (i.gases * 1000.0) < 800\n acc[0] += (1.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n elsif (i.gases * 1000.0) > 1200\n acc[0] += (3.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n else\n acc[0] += (2.0 * (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos)))\n\t\t\tend\n\n\t\t\tacc[2] += (@gramos[acc[1]].valor / (i.proteinas + i.lipidos + i.carbohidratos))\n acc[1] += 1\n acc\n\t\tend\n\n\t\treturn (huella[0] / (2.0 * huella[2])).round(2)\n\tend", "def valor_energetico\n @proteinas * 4.0 + @carbohidratos * 4.0 + @lipidos * 9.0\n end", "def ahorrodinero(año)\n\n i = 0\n final = Array.new \n final1 = Array.new \n final2 = Array.new \n \n\n datos = Valore.where(:año => año)\n \n datos.each do |datos|\n \n \n final[i] = datos.read_attribute(\"es\")\n final1[i] = datos.read_attribute(\"tarifa\")\n final2[i] = final1[i]*final[i]\n \n i = i +1\n \n \n end\n \n return final2\n\n\n\n end", "def huella_nutricional_plato\n\n\t\tenergia_plato = valor_calorico_total\n\n\t\tii_energia_plato = 0\n\t\trange_energia = [670,830]\n\n\t\tif energia_plato <= range_energia.first\n\t\t\tii_energia_plato = 1\n\t\telsif energia_plato > range_energia.first && energia_plato <= range_energia.last\n\t\t\tii_energia_plato = 2\n\t\telsif energia_plato > range_energia.last\n\t\t\tii_energia_plato = 3\n\t\tend\n\n\t\tgei_plato = emisiones_gei\n\n\t\tii_gei_plato = 0\n\n\t\trange_gei = [800,1200]\n\n\t\tif gei_plato <= range_gei.first\n\t\t\tii_gei_plato = 1\n\t\telsif gei_plato > range_gei.first && gei_plato <= range_gei.last\n\t\t\tii_gei_plato = 2\n\t\telsif gei_plato > range_gei.last\n\t\t\tii_gei_plato = 3\n\t\tend\n\t\t\t\n\t\thn_plato = ((ii_gei_plato + ii_energia_plato) / 2).round\n\n\tend", "def huella_nutricional\n ((get_impacto_energia + get_impacto_gei)/2).ceil(2)\n end", "def huellaNut \n\t\t(@indEnergia.call + @indGei.call)/2.0\n\tend", "def huellaAmbiental\r\n indiceCarbono = 0.0\r\n if @geiTotal < 800.0\r\n indiceCarbono = 1.0\r\n elsif @geiTotal <= 1200.0\r\n indiceCarbono = 2.0\r\n else\r\n indiceCarbono = 3.0\r\n end\r\n\r\n indiceEnergia = 0.0\r\n if kcalPlato < 670.0\r\n calorias = 1.00\r\n elsif kcalPlato <= 830.0\r\n calorias = 2.0\r\n else\r\n calorias = 3.0\r\n end\r\n\r\n return (indiceCarbono + indiceEnergia)/2\r\n end", "def calculo \n self.minutos_reales = 5 * 480 #cantidad de OPERARIOS * Jornada de Trabajo(Turnos)\n self.costo_minuto = 89 #Costo Real por minuto\n self.otros_costos = 540 * 89 #Tiempo Total(Minutos) * Costo Real por Minutos\n self.costo_mano_obra = 420 * 5 * 89 # Jornada Minutos * Cantidad Operarios * Costo Real por minutos \n self.manoObraPlaneada = 650.000 * 5 # Salario Total * Cantidad de operarios \n end", "def get_alco\n @_100=((@alco*100)/@peso)\n #@ir_100=(@_100/90)*100\n @porcion=((@alco*@gramos_porciones)/@peso)\n #@ir_porcion=(@porcion/90)*100\n [ @alco , @_100 , 0 , @porcion , 0 ]\n end", "def ener_kcal \n\t\t@ener_kcal = @saturadas * 9 + @monoinsaturadas * 9 + @polinsaturadas * 9 + @azucares * 4 + @polialcoles * 2.4 + @almidon * 4 + @fibra * 2 + @proteinas * 4 + @sal * 6\n\t\treturn @ener_kcal\n\tend", "def huella_nutricional\n (valor_calorico() + huella_carbono()) / 2\n end", "def verificaesonitre (primo, secondo, terzo)\n\tesonicomuni=0\n\t#se il secondo e il terzo includono lo stesso esone lo conto come comune\n\tprimo.each do |v|\n\t\tif secondo.include?(v) then\n\t\t\tif terzo.include?(v) then \n\t\t\t\tesonicomuni=esonicomuni+1\n\t\t\tend\n\t\tend\t\t\t\t\t\n\tend\n\tprimosecondo=0\n\tprimo.each do |v|\n\t\tif secondo.include?(v) then\n\t\t\tif terzo.include?(v)==false then \n\t\t\t\tprimosecondo=primosecondo+1\n\t\t\tend\n\t\tend\t\t\t\t\t\n\tend\n\tsecondoterzo=0\n\tsecondo.each do |v|\n\t\tif terzo.include?(v) then\n\t\t\tif primo.include?(v)==false then \n\t\t\t\tsecondoterzo=secondoterzo+1\n\t\t\tend\n\t\tend\t\t\t\t\t\n\tend\n\tprimoterzo=0\n\tprimo.each do |v|\n\t\tif terzo.include?(v) then\n\t\t\tif secondo.include?(v)==false then \n\t\t\t\tprimoterzo=primoterzo+1\n\t\t\tend\n\t\tend\t\t\t\t\t\n\tend\n\t#il numero di esoni totali è così calcolato\n\tesoni=esonicomuni+primosecondo+secondoterzo+primoterzo+(primo.length-esonicomuni-primosecondo-primoterzo)+(secondo.length-esonicomuni-primosecondo-secondoterzo)+(terzo.length-secondoterzo-esonicomuni-primoterzo)\n\treturn esoni\nend", "def ausgleich\n\t\tsums = {}\n\t\t%w(jo caro).each do |who|\n\t\t\tsums[who] = @db.get_first_value(\"select summe from sum_#{who} where jahr = #{@options[:jahr]} and monat = #{@options[:monat]} and gemeinsam = 'g'\").to_f\n\t\tend\n\n\t\tif(sums['jo'] == sums['caro'])\n\t\t\tputs \"Gleichstand\"\n\t\t\treturn\n\t\tend\n\n\t\tausg = ((sums['jo'] + sums['caro']) / 2 - sums['jo']).abs\n\t\t\n\t\tif(sums['jo'] > sums['caro'])\n\t\t\tprintf(\"Caro an Jo: %.2f EUR\\n\", ausg)\n\t\telse\n\t\t\tprintf(\"Jo an Caro: %.2f EUR\\n\", ausg)\n\t\tend\n\t\t\n\tend", "def suprailiaco\n\t\t(@suprailiaco[0] + @suprailiaco[1] + @suprailiaco[2])/3\n\tend", "def ir_energetico \n\t\t@ener_ir = ener_kj\n\t\t@ir_energetico = (@ener_ir/8400.to_f) * 100\n\t\t@ir_energetico.round(1)\n\tend", "def totalHidratos\n\t\thidr = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\thidr += alimento.carbohidratos\n\t\tend\n\t\treturn hidr.round(2)\n\tend", "def vCalorico\n\t\tcalc = Calculadora.new\n\t\tvalCal = 0\t\t\n\t\[email protected] do |alimento|\n\t\t\tvalCal += calc.valorKiloCalorico(alimento)\n\t\tend\n\t\treturn valCal.round(2)\n\tend", "def get_almidon\n @_100=((@almidon*100)/@peso)\n #@ir_100=(@_100/90)*100\n @porcion=((@almidon*@gramos_porciones)/@peso)\n #@ir_porcion=(@porcion/90)*100\n [ @almidon , @_100 , 0 , @porcion , 0 ]\n end", "def pHidratos\n\t\thidr = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\ttotal += alimento.proteinas + alimento.lipidos + alimento.carbohidratos\n\t\t\thidr += alimento.carbohidratos\n\t\tend\n\t\treturn ((hidr/total)*100).round\n\n\t\n\tend", "def pProteina \n\t\tprot = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\ttotal += (alimento.proteinas + alimento.lipidos + alimento.carbohidratos)\n\t\t\tprot += alimento.proteinas\n\t\tend\n\t\treturn ((prot/total)*100).round\t\n\tend", "def geidiario\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n geitotal = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n geitotal += (auxNodo1.value.gei * auxNodo2.value) / 100\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return geitotal.round(1)\n end", "def get_azucares\n @_100=((@azucares*100)/@peso)\n @ir_100=(@_100/90)*100\n @porcion=((@azucares*@gramos_porciones)/@peso)\n @ir_porcion=(@porcion/90)*100\n [ @azucares , @_100 , @ir_100.round(1) , @porcion , @ir_porcion.round(1) ]\n end", "def get_usoterreno\n aux = 0.0\n @contenido.each do |alimento|\n aux += alimento.ground\n end\n @usoterreno = aux\n end", "def irpoliinsaturadas\n vag=(grasaspoli * 100) / 70\n vag.round(2)\n end", "def terreno\n grtotal = 0\n sum = 0\n\t\t#recorre las dos listas a la vez para sacar el terreno\n #usado de cada ingrediente segun el peso de este\n @lista.zip(@listagr).each do |normal, gr|\n cant = gr/1000.0\n sum += normal.terreno*cant\n end\n @terreno = sum\n\n end", "def total_ve\n\t\t\n\t\ttotal_ve = 0\n\t\ti = 0\n\t\t\n\t\twhile i < conjunto_alimentos.length do\n\t\t\n\t\t\ttotal_ve += conjunto_alimentos[i].gei + total_ve\n\t\t\ti += 1\n\n\t\tend\n\t\n\t\treturn total_ve\n\tend", "def get_vagas_eleicao(ano, cargo, localizacao)\n return $vagas[ano.to_s][localizacao.nome][cargo.to_s].to_i\nend", "def valor_energetico\n\t\ti = 0\n\t\tvalorC = 0.0\n\t\twhile i< @lista_alimentos.size do\n\t\t\tvalorC += @lista_alimentos[i].valorEnergetico\n\t\t\ti+=1\n\t\tend\n\t\treturn valorC\n\tend", "def indice_masa_corporal\n\t\t(peso / (talla * talla) * 10000).round(1)\n\tend", "def irmonograsas\n vag=(grasasmono * 100) / 70\n vag.round(2)\n end", "def totalProteina \n\t\tprot = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\tprot += alimento.proteinas\n\t\tend\n\t\treturn prot.round(2)\n\tend", "def emisiones\n grtotal = 0\n sum = 0\n\t\t#recorre las dos listas a la vez para sacar los gases emitidos\n\t\t# de cada ingrediente segun el peso de este\n @lista.zip(@listagr).each do |normal, gr|\n cant = gr/1000.0\n sum += normal.gases*cant\n end\n @gei = sum\n\n end", "def get_energia_proteins\n\t\t\t\t@proteins * 4\n\t\t\tend", "def calcular_imc\n (@peso)/(@altura*@altura)\n end", "def por_carbohidratos\n \taux_carbohidratos = 0.0\n\t\ti = 1\n\t \twhile i < @lista_alimentos.size do\n\t\t\taux_carbohidratos += @lista_alimentos[i].carbohidratos * @lista_cantidades[i]\n\t\t\ti+=1\n\t\tend\n\t\treturn ((aux_carbohidratos/total_nutrientes)*100.0).round(2)\n\tend", "def subescapular\n\t\t(@subescapular[0] + @subescapular[1] + @subescapular[2])/3\n\tend", "def traer_insumo(nombreInsumo, cantidad)\n\t case nombreInsumo\n\t\t when \"cebada\" then \n\t\t\t if (@cebada >= cantidad)\n\t\t\t\t @cebada -= cantidad\n\t\t\t\t resultado = cantidad\n\t\t\t else\n\t\t\t\t resultado = @cebada\n\t\t\t\t @cebada = 0\n\t\t\t end\n\t\t\t return resultado\n\t\t when \"arroz_maiz\" then\n\t\t\t if (@arroz_maiz >= cantidad)\n\t\t\t\t @arroz_maiz -= cantidad\n\t\t\t\t resultado = cantidad\n\t\t\t else\n\t\t\t\t resultado = @arroz_maiz\n\t\t\t\t @arroz_maiz = 0\n\t\t\t end\n\t\t\t return resultado\n\t\t when \"levadura\" then\n\t\t\t if (@levadura >= cantidad)\n\t\t\t\t @levadura -= cantidad\n\t\t\t\t resultado = cantidad\n\t\t\t else\n\t\t\t\t resultado = @levadura\n\t\t\t\t @levadura = 0\n\t\t\t end\n\t\t\t return resultado\n\t\t when \"lupulo\" then\n\t\t\t if (@lupulo >= cantidad)\n\t\t\t\t @lupulo -= cantidad\n\t\t\t\t resultado = cantidad\n\t\t\t else\n\t\t\t\t resultado = @lupulo\n\t\t\t\t @lupulo = 0\n\t\t\t end\n\t\t\t return resultado\n\t\t when \"producto_silos_cebada\" then\n\t\t\t if (@producto_silos_cebada >= cantidad)\n\t\t\t\t @producto_silos_cebada -= cantidad\n\t\t\t\t resultado = cantidad\n\t\t\t else\n\t\t\t\t resultado = @producto_silos_cebada\n\t\t\t\t @producto_silos_cebada = 0\n\t\t\t end\n\t\t\t return resultado\n\t\t when \"producto_molino\" then\n\t\t\t if (@producto_molino >= cantidad)\n\t\t\t\t @producto_molino -= cantidad\n\t\t\t\t resultado = cantidad\n\t\t\t else\n\t\t\t\t resultado = @producto_molino\n\t\t\t\t @producto_molino = 0\n\t\t\t end\n\t\t\t return resultado\n\t\t when \"producto_paila_mezcla\" then\n\t\t\t if (@producto_paila_mezcla >= cantidad)\n\t\t\t\t @producto_paila_mezcla -= cantidad\n\t\t\t\t resultado = cantidad\n\t\t\t else\n\t\t\t\t resultado = @producto_paila_mezcla\n\t\t\t\t @producto_paila_mezcla = 0\n\t\t\t end\n\t\t\t return resultado\n\t\t when \"producto_cuba_filtracion\" then\n\t\t\t if (@producto_cuba_filtracion >= cantidad)\n\t\t\t\t @producto_cuba_filtracion -= cantidad\n\t\t\t\t resultado = cantidad\n\t\t\t else\n\t\t\t\t resultado = @producto_cuba_filtracion\n\t\t\t\t @producto_cuba_filtracion = 0\n\t\t\t end\n\t\t\t return resultado\n\t\t when \"producto_paila_coccion\" then\n\t\t\t if (@producto_paila_coccion >= cantidad)\n\t\t\t\t @producto_paila_coccion -= cantidad\n\t\t\t\t resultado = cantidad\n\t\t\t else\n\t\t\t\t resultado = @producto_paila_coccion\n\t\t\t\t @producto_paila_coccion = 0\n\t\t\t end\n\t\t\t return resultado\n\t\t when \"producto_tanque_preclarificador\" then\n\t\t\t if (@producto_tanque_preclarificador >= cantidad)\n\t\t\t\t @producto_tanque_preclarificador -= cantidad\n\t\t\t\t resultado = cantidad\n\t\t\t else\n\t\t\t\t resultado = @producto_tanque_preclarificador\n\t\t\t\t @producto_tanque_preclarificador = 0\n\t\t\t end\n\t\t\t return resultado\n\t\t when \"producto_enfriador\" then\n\t\t\t if (@producto_enfriador >= cantidad)\n\t\t\t\t @producto_enfriador -= cantidad\n\t\t\t\t resultado = cantidad\n\t\t\t else\n\t\t\t\t resultado = @producto_enfriador\n\t\t\t\t @producto_enfriador = 0\n\t\t\t end\n\t\t\t return resultado\n\t\t when \"producto_tcc\" then\n\t\t\t if (@producto_tcc >= cantidad)\n\t\t\t\t @producto_tcc -= cantidad\n\t\t\t\t resultado = cantidad\n\t\t\t else\n\t\t\t\t resultado = @producto_tcc\n\t\t\t\t @producto_tcc = 0\n\t\t\t end\n\t\t\t return resultado\n\t\t when \"producto_filtro_cerveza\" then\n\t\t\t if (@producto_filtro_cerveza >= cantidad)\n\t\t\t\t @producto_filtro_cerveza -= cantidad\n\t\t\t\t resultado = cantidad\n\t\t\t else\n\t\t\t\t resultado = @producto_filtro_cerveza\n\t\t\t\t @producto_filtro_cerveza = 0\n\t\t\t end\n\t\t\t return resultado\n\t\t when \"producto_tanque_cerveza\" then\n\t\t\t if (@producto_tanque_cerveza >= cantidad)\n\t\t\t\t @producto_tanque_cerveza -= cantidad\n\t\t\t\t resultado = cantidad\n\t\t\t else\n\t\t\t\t resultado = @producto_tanque_cerveza\n\t\t\t\t @producto_tanque_cerveza = 0\n\t\t\t end\n\t\t\t return resultado\n\t\t when \"cerveza\" then\n\t\t\t if (@cerveza >= cantidad)\n\t\t\t\t @cerveza -= cantidad\n\t\t\t\t resultado = cantidad\n\t\t\t else\n\t\t\t\t resultado = @cerveza\n\t\t\t\t @cerveza = 0\n\t\t\t end\n\t\t\t return resultado\n\t end\n\tend", "def get_energia_lipidos\n\t\t\t\t@lipidos * 9\n\t\t\tend", "def geiTotal\n\t\t@geiSuma = 0\n\t\[email protected] do |alimento|\n\t\t\t@geiSuma += alimento.gei\n\t\tend\n\t\treturn @geiSuma.round(2)\n\tend", "def horas_porasignar(asig_id,solucion)\n # horas requeridas de esta materia en este curso\n req = self.horas_por_semanas.where(:asignatura_id => asig_id).last.horasporsemana\n #horas ya agendadas en esta materia\n agend = solucion.sol_cursos.where(:curso_id => self.id, :asignatura_id => asig_id).count\n return(req-agend) \n end", "def huella_nutricional\n numero1 = self.calculo_valor_calorico_total\n numero2 = self.calculo_emisiones_diarias\n\n if numero1 < 670\n ienergia = 1\n elsif numero1 <=830\n ienergia = 2\n else\n ienergia = 3\n end\n\n if numero2 < 800\n icarbono = 1\n elsif numero2 <= 1200\n icarbono = 2\n else\n icarbono = 3\n end\n\n media = (ienergia + icarbono)/2\n end", "def most_specific_subdivision; end", "def grasa(sexo,peso,talla)\n\t\t@grasa = 1.2*imc(peso,talla)+0.23*@edad-10.8*sexo-5.4\n\tend", "def kcalglucidos\n\t\t\t@carbohidratos * 4\n\t\tend", "def irazucares\n vag=(azucares * 100) / 90\n vag.round(2)\n end", "def carbo \n grtotal = 0\n sum = 0\n\t\t#itera en las dos listas a la vez para poder calcular las \n #cabrohidratos dependiendo de la cantidad y tambien suma\n #todas las cantidades para poder calcular el porcentaje\n #despues\n @lista.zip(@listagr).each do |normal, gr|\n grtotal += gr\n cant = gr/1000.0\n sum += normal.carbo*cant\n end\n (sum*100)/grtotal\n end", "def irproteinas\n vag=(proteinas * 100) / 50\n vag.round(2)\n end", "def prot\n\t\tsuma = 0\n\t\tx = 0\n\t\tcantidad = 0\n\n\t\[email protected] do |i|\n\t\t\tcantidad = @gramos[x].valor / (i.proteinas + i.lipidos + i.carbohidratos)\n\t\t\tsuma += i.proteinas * cantidad\n\t\t\tx += 1\n\t\tend\t\n\n\t\treturn ((suma * 100) / gramos_total).round(2)\n\tend", "def terrenoTotal\n\t\t@terrenoSuma = 0\n\t\[email protected] do |alimento|\n\t\t\t@terrenoSuma += alimento.terreno\n\t\tend\n\t\treturn @terrenoSuma.round(2)\n\tend", "def calcular_total\n\t\treturn calcular_seguro*calcular_incremento\n\tend", "def get_grasas\n @_100=((@grasas*100)/@peso)\n @ir_100=(@_100/70)*100\n @porcion=((@grasas*@gramos_porciones)/@peso)\n @ir_porcion=(@porcion/70)*100\n [ @grasas , @_100 , @ir_100.round(1) , @porcion , @ir_porcion.round(1) ]\n end", "def salvar_calculados\n self.cif_dolares = fob_dolares.to_f + seguro.to_f + flete_I.to_f + flete_II.to_f + otros_gastos.to_f\n self.cif_bolivianos = 7.07 * cif_dolares.to_f\n self.ga = cif_bolivianos * 0.10\n self.iva = (cif_bolivianos.to_f + ga.to_f) * 0.1494\n self.ice = (cif_bolivianos.to_f + ga.to_f) * 0.18\n self.total_impuestos = ga.to_f + iva.to_f + ice.to_f + diu.to_f\n # otros_1 = ibmetro\n # otros_2 = ibnorca\n self.total_servicios = almacenaje.to_f + senasac.to_f + camara_comercio.to_f + otros_1.to_f + otros_2.to_f + nuestros_servicios.to_f + gastos_tramite.to_f\n \n self.total_despacho = total_impuestos.to_f + total_servicios.to_f\n end", "def alRomia(nombro)\n\n romiajLiteroj = [\"M\", \"CM\", \"D\", \"CD\", \"C\", \"XC\", \"L\", \"XL\", \"X\", \"IX\", \"V\", \"IV\", \"I\"]\n arabajLiteroj = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]\n \n romia = \"\"\n komenca = nombro\n \n for j in 0..romiajLiteroj.count - 1\n \n romiaLitero = romiajLiteroj[j] \n arabaSumo = arabajLiteroj[j]\n div = komenca / arabaSumo\n \n if div > 0\n \n for i in 0..div-1\n romia += romiaLitero\n end\n \n komenca -= arabaSumo * div\n end\n end\n\n return romia\nend", "def grasas_totales \n\t\t@grasas_totales = @saturadas + @monoinsaturadas + @polinsaturadas\n\t\treturn @grasas_totales\n\tend", "def totalLipidos\n\t\tlip = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\tlip += alimento.lipidos\n\t\tend\n\t\treturn lip.round(2)\n\t\n\tend", "def huella_ambiental\r\n energia = 0.0\r\n carbono = 0.0\r\n huella = 0.0\r\n if vct < 670 then\r\n energia = 1.0\r\n elsif vct <= 830 then\r\n energia = 2.0\r\n else\r\n energia = 3.0\r\n end\r\n if gei < 800 then\r\n carbono = 1.0\r\n elsif terrenos <= 1200 then\r\n carbono = 2.0\r\n else\r\n carbono = 3.0\r\n end\r\n huella = (energia + carbono)/2\r\n return huella\r\n \r\n end", "def car\n\t\tsuma = 0\n\t\tx = 0\n\t\tcantidad = 0\n\n\t\[email protected] do |i|\n\t\t\tcantidad = @gramos[x].valor / (i.proteinas + i.lipidos + i.carbohidratos)\n\t\t\tsuma += i.carbohidratos * cantidad\n\t\t\tx += 1\n\t\tend\t\n\n\t\treturn ((suma * 100) / gramos_total).round(2)\n\tend", "def irgrasas\n vag=(cgrasas * 100) / 70\n vag.round(2)\n end", "def subtotal\n precio * cantidad\n end", "def terrenos\r\n terreno = 0\r\n @lista_alimentos.each do |i|\r\n terreno += i.terreno\r\n end\r\n return terreno\r\n end", "def euclides_extendido(a,b)\n\n x,z=[],[]\n t_primo=false\n #condicion para comprobar si el numero b es mayor que a si es asi se hace un swap\n if(b.to_i>a.to_i)\n x[1],x[2]=b.to_i,a.to_i\n else\n x[1],x[2]=a.to_i,b.to_i\n end\n z[0],z[1]=0,1\n i=1\n r=x[1]%x[2]\n #puts \"resto al comienzo: #{r}\"\n if r==0\n t_primo=false\n else\n while(r>0)\n #puts \"#{\"=\"*30}\"\n if(i>=2)\n #puts \"entre...\"\n z[i]=(-1*((x[i-1]/x[i]).to_i))*z[i-1]+z[i-2]\n x[i+1]=x[i-1]%x[i]\n end\n r=x[i+1]\n mcd=x[i]\n if(mcd==1)\n t_primo=true\n #en caso de que el inverso de negativo, se suma al numero mayor que se paso a la función.\n if(z[i-1]<0)\n @inverso=z[i-1]+x[1]\n else\n @inverso=z[i-1]\n end\n end\n i+=1\n #puts \"#{\"=\"*30}\"\n end\n\n end\n #puts \"MCD: #{mcd}\"\n t_primo\n end", "def emisiones_gei\n\n\t\tif @emisiones_gei == 0\n\n\t\t\t@lista_alimentos.each do |alimento|\n\n\t\t\t\t@emisiones_gei += alimento.kg_gei\n\t\t\tend\n\n\t\t\t@emisiones_gei = @emisiones_gei.round(2)\n\t\tend\n\n\n\t\t@emisiones_gei\n\tend", "def secuenciasugerida \n #recupera los hijos del padre de la cuenta a crear \n\t\thijos = Catalogo.where(\"padre_id = ? AND activo = ?\", idcuenta, true)\n\n #configuracion del nivel a crear\n\t\tidnivel = Catalogo.find_by(id: idcuenta).nivel_id\n\t\tnivelh = Nivel.find_by(id: idnivel).numnivel + 1\n\n nivel = Nivel.find_by(numnivel: nivelh)\n nrodigitos = nivel.nrodigitos\n nrodigitostotal = nivel.nrodigitostotal\n digito = 0\n aux = 0\n\n hijos.each do |e|\n \taux = e.codigo.last(nrodigitos).to_i\n \t\tif digito < aux\n\t\t\t\tdigito = aux\n \t\tend\n \tend\n \tdigito = digito + 1\n \tc =\"\"\n \tnrodigitos.times { c = c + \"0\" }\n \tc = c.to_s + digito.to_s \t\n \t\t\n #codigo sugerido\n \treturn c.last(nrodigitos).to_s\n\tend", "def carbohidratos\n\t\treturn @carbohidratos*@cantidad\n\tend", "def area_terreno\n\n\t\tif @area_terreno_m2 == 0\n\n\t\t\t@lista_alimentos.each do |alimento|\n\n\t\t\t\t@area_terreno_m2 += alimento.area_terreno\n\t\t\tend\n\n\t\t\t@area_terreno_m2 = @area_terreno_m2.round(2)\n\t\tend\n\n\t\t@area_terreno_m2\n\tend", "def calculo_de_sueldo(attr={})\r\n retencion = @salario * 0.1\r\n salud = @salario * 0.07\r\n pension = @salario * 0.12\r\n sueldo = @salario - retencion - salud - pension\r\n end", "def vrat_celkovy_soucet_vah\n soucet = 0\n @pole_vah.each do |prvek| \n soucet += prvek.to_i\n end\n return soucet\n end", "def valorenergeticoKJ\n\t\tveKJ=(cgrasas * 37) + (cgrasassa * 37) + (grasasmono * 37) + (grasaspoli * 37) + (hcarbono * 17) + (polialcoholes * 10) + (almidon * 17) + (fibra * 8) + (proteinas * 17) + (sal * 25)\n\t\tveKJ.round(2)\n\tend", "def ener_kj \n\t\t@ener_kj = @saturadas * 37 + @monoinsaturadas * 37 + @polinsaturadas * 37 + @azucares * 17 + @polialcoles * 10 + @almidon * 17 + @fibra * 8 + @proteinas * 17 + @sal * 25\n\t\treturn @ener_kj\n\tend", "def por_prote\n\t\t\t(@proteinas/suma_gramos)*100\n\t\tend", "def calcula_media\n array = []\n @hash.each do |curso, crs|\n crs.each do |cr|\n array << cr[0].values[1]\n end\n denominador = array.length\n numerador = array.sum\n puts \"#{curso.values[0]} --- #{numerador/denominador}\"\n array = []\n end\n end", "def huellaAmbiental\r\n if (menuValido == true)\r\n gei = 0.0\r\n terreno = 0.0\r\n @menu.each do |i|\r\n gei += i.gei\r\n terreno += i.terreno\r\n end\r\n return \"GEI: #{gei}, Uso de terreno: #{terreno}\"\r\n else\r\n return \"El sujeto no es valido pues no consume la cantidad diaria reomendada\"\r\n end\r\n end", "def to_s\n \"La eficiencia energetica del plato es: #{eficiencia_energetica()}\"\n end", "def disponibles\n total = []\n heros.each do |h|\n next unless h.tesoro\n next unless h.tesoro[item + 's']\n h.tesoro[item + 's'].each do |e|\n (total << h.id) if e == id\n end\n end\n total\n end", "def valor_calorico\n if eficiencia_energetica() < 670\n return 1\n end\n if eficiencia_energetica() > 830\n return 3\n else\n return 2\n end\n end", "def ir_proteina\n @ir_proteina = (@proteinas/50.to_f)*100\n @ir_proteina.round(1)\n end", "def to_extenso\n (@quantia/100.0).por_extenso_em_reais\n end", "def promedio(arreglo)\n\ttotal = 0.0\n\tfor i in 0...arreglo.size\n\t\ttotal = total + arreglo[i]\n\tend \n\n\treturn (total / arreglo.size).round(2)\nend", "def terreno\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n terrenototal = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n terrenototal += (auxNodo1.value.terreno * auxNodo2.value) / 100\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return terrenototal.round(1)\n end", "def renglon_a_grafica\n\t\tgenera_renglon_total\n\t\tdevuelto = Hash.new\n\t\t@renglones_reporte[0].id_columnas.each do |key|\n\t\t\tdevuelto[key] = @total[key][:promedio]\n\t\tend\n\t\tdevuelto\n\tend", "def calcular_Aptitud(alelos)\n return diff_vectors(alelos).round(2)\n #vector_R = producto_Mtz_Vcr(@matriz_problema, alelos)\n #return (sumatoriaCuadratico(vector_R, @vector_problema) * -1).round(2)\n end", "def irenergeticoKcal\n vag=(valorenergeticoKcal() * 100) / 2000\n vag.round(2)\n end", "def calculate_eficiencia_diaria\n\t\taux = @head\n\t\twhile (aux != nil) do\n\t\t\t$eficiencia_diaria += aux[\"value\"].get_eficiencia_energetica\n\t\t\taux = aux[\"next\"]\n\t\tend\n\t\t$eficiencia_diaria = $eficiencia_diaria.ceil(2)\n\n\tend", "def recalcular_tiempo(e_participacion, actividades)\n latest_start = self.proyecto.fecha_inicio\n self.participacion += (e_participacion / 100)\n\n latest_start = self.start_time if anteriores.split(/\\s*,\\s*/).count == 0\n anteriores.split(/\\s*,\\s*/).each do |ant|\n a = Actividad.find_by(nombre: ant)\n latest_start = a.end_time if a.end_time > latest_start\n end\n\n participacion_total = self.participacion == 0 ? 1.0 : self.participacion\n\n puts esfuerzo\n puts participacion_total\n self.start_time = latest_start\n self.end_time = (esfuerzo/participacion_total).to_i.business_hour.after(self.start_time)\n\n\n update(\n start_time: self.start_time,\n end_time: self.end_time,\n participacion: self.participacion\n )\n\n actividades.each do |a|\n if a.is_child_of(nombre)\n a.recalcular_tiempo(0, actividades)\n end\n end\n end", "def get_monoin\n @_100=((@monoin*100)/@peso)\n @ir_100=(@_100/25)*100\n @porcion=((@monoin*@gramos_porciones)/@peso)\n @ir_porcion=(@porcion/25)*100\n [ @monoin , @_100 , @ir_100.round(1) , @porcion , @ir_porcion.round(1) ]\n end", "def totalGramos\n\t\tgramos = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\tgramos += alimento.gramos\n\t\tend\n\t\treturn gramos.round(2)\n\tend", "def euclides_extendido(a,b)\n #condicion para comprobar si el numero b es mayor que a si es asi se hace un swap\n x,z=[],[]\n t_primo=false\n if(b.to_i>a.to_i)\n x[1],x[2]=b.to_i,a.to_i\n else\n x[1],x[2]=a.to_i,b.to_i\n end\n z[0],z[1]=0,1\n i=1\n r=x[1]%x[2]\n #puts \"resto al comienzo: #{r}\"\n if r==0\n t_primo=false\n else\n while(r>0)\n #puts \"#{\"=\"*30}\"\n #puts \"ITERACION #{i}\"\n #puts \"x[i-1]=#{x[i-1]}\"\n #puts \"x[i]=#{x[i]}\"\n #puts \"z[i-1]=#{z[i-1]}\"\n #puts \"z[i]=#{z[i]}\"\n if(i>=2)\n #puts \"entre...\"\n z[i]=(-1*((x[i-1]/x[i]).to_i))*z[i-1]+z[i-2]\n x[i+1]=x[i-1]%x[i]\n #puts \"z[i]=#{z[i]}\"\n #puts \"x[i+1]=#{x[i+1]}\"\n end\n r=x[i+1]\n mcd=x[i]\n if(mcd==1)\n t_primo=true\n #en caso de que el inverso de negativo, se suma al numero mayor que se paso a la función.\n if(z[i-1]<0)\n @inverso=z[i-1]+x[1]\n else\n @inverso=z[i-1]\n end\n end\n i+=1\n #puts \"#{\"=\"*30}\"\n end\n\n end\n puts \"MCD: #{mcd}\"\n puts \"INVERSO: #{@inverso}\"\n t_primo\n end", "def calculo_emisiones_diarias\n recorrido = lista_alimentos.head\n cantidad = lista_cantidades.head\n\n while (recorrido != nil && cantidad != nil)\n @emisiones_diarias = @emisiones_diarias + ((recorrido.value.gei * cantidad.value)/1000)\n\n recorrido = recorrido.next\n cantidad = cantidad.next\n end\n\n @emisiones_diarias\n end", "def hidratos \n\t\t@hidratos = @azucares + @polialcoles + @almidon\n\t\treturn @hidratos\n\tend", "def valorizacao\n \t\tif self.tipo_de_operacao.compra?\n ((self.atual - self.entrada) / self.entrada) * 100.0\n else\n ((self.entrada - self.atual) / self.atual ) * 100.0\n end\n \tend", "def calcula_imc(peso, altura)\n return peso / altura ** 2\nend" ]
[ "0.6618011", "0.66050166", "0.6540343", "0.6513198", "0.64192027", "0.64056027", "0.64035386", "0.63332355", "0.6322997", "0.6319128", "0.6309427", "0.6189992", "0.6164476", "0.6161472", "0.6161069", "0.6158572", "0.6151993", "0.6151541", "0.6120761", "0.6105959", "0.6104845", "0.60997355", "0.60878825", "0.6070855", "0.60693645", "0.6062414", "0.605853", "0.60576224", "0.60401124", "0.6038826", "0.6038049", "0.59817624", "0.59771097", "0.5971915", "0.5964209", "0.595955", "0.5942142", "0.59062546", "0.5902802", "0.5902377", "0.5888844", "0.5884904", "0.5882699", "0.5857086", "0.5855783", "0.58450955", "0.5832932", "0.5818224", "0.5805976", "0.5784643", "0.5777776", "0.5769283", "0.5766959", "0.5764266", "0.574543", "0.57438874", "0.57387316", "0.57320684", "0.5728487", "0.5714967", "0.571129", "0.5706162", "0.5702188", "0.5698226", "0.5698087", "0.56961364", "0.5691079", "0.56887394", "0.56827796", "0.56779003", "0.5677048", "0.56764585", "0.56732607", "0.5666957", "0.566667", "0.5666462", "0.5664065", "0.56620485", "0.56527907", "0.5643668", "0.564032", "0.56199765", "0.56194097", "0.5617512", "0.5615929", "0.5614474", "0.56131977", "0.56111205", "0.56104165", "0.5602843", "0.55994976", "0.5595891", "0.5592583", "0.55865294", "0.5586072", "0.5583696", "0.55827653", "0.5578083", "0.5571043", "0.556915" ]
0.6157524
16
If the numbers is even return true. If it's odd, return false. Oh yeah... the following symbols/commands have been disabled! use of % use of .even? in Ruby use of mod in Python
def is_even(n) return n % 2 === 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_odd?(num)\n # num.abs % 2 != 0 \n num % 2 == 1\n # ruby modulus operator always return non-negative result if num on right is positive\n # ie, % is a modulus operator and \"not a remainder operator as in some languages\"\n # my first line was correct, but more properly per the proposed problem\n # check if odd, do not check if not even\nend", "def is_odd2?(num)\n num.remainder(2) != 0\nend", "def even? num\n num.to_i % 2 == 0\n end", "def still_odd?(num)\n num.remainder(2).abs == 1\nend", "def is_odd?(number)\n number.remainder(2).abs > 0\nend", "def is_odd?(number)\n number.remainder(2) != 0\nend", "def is_odd?(num)\n num.remainder(2) != 0\nend", "def is_odd?(num)\n num.remainder(2) != 0\nend", "def is_odd?(num)\n num.remainder(2) != 0\nend", "def is_odd?(num)\n num.remainder(2).abs == 1\nend", "def is_odd?(n)\n n.abs % 2 != 0\nend", "def is_odd?(number)\n number.abs % 2 != 0\nend", "def is_odd?(number)\n number.abs % 2 != 0\nend", "def is_odd2?(num)\n num.abs % 2 == 1\nend", "def is_odd?(number)\n number % 2 != 0\nend", "def is_odd?(num)\n num.abs % 2 != 0\nend", "def is_odd?(num)\n num.remainder(2) == 1 || num.remainder(2) == -1\nend", "def is_even? (num_1)\n if num_1 %2 == 0\nreturn true\n else return false\n end \nend", "def is_it_odd?(int)\n int.abs % 2 != 0\nend", "def is_even?(n)\r\n\r\n remainder_when_divided_by_2 = n % 2\r\n \r\n if remainder_when_divided_by_2 == 0\r\n return true\r\n else\r\n return false\r\n end\r\n\r\nend", "def is_odd?(number)\n number.abs.remainder(2) == 1\nend", "def odd_number_check_two(number)\r\n number % 2 == 1 || number % 2 == -1 \r\nend", "def is_odd?(integer)\n integer % 2 != 0\nend", "def is_odd?(num)\n num % 2 != 0\nend", "def is_odd?(num)\n num % 2 != 0\nend", "def is_odd?(num)\n # return false if num.zero?\n # num *= -1 if num < 0\n !(num % 2).zero?\n # !(num.remainder(2).zero?)\nend", "def espar(num)\n (num % 2).zero?\nend", "def this_is_also_odd?(param_integer)\n param_integer.remainder(2) != 0\nend", "def odd_number?(number)\n number % 2 == 1\nend", "def is_odd(number)\n if number%2 > 0\n return true\n end\n return false\nend", "def is_also_odd?(param_integer)\n param_integer % 2 > 0\nend", "def is_odd?(number)\n\n\t#WHY WASN\"T MODULO WORKING?\n\t# if (number%2) != 0\n\t# \tputs \"true\"\n\t# \treturn true\n\tnumber = number.to_i\n\tif number.odd?\n\t\treturn true\n\telse\n\t\treturn false\n\tend\nend", "def is_odd?(int)\n (int % 2).abs != 0\nend", "def odd?(number)\n if number % 2 == 0\n false\n else \n true\n end\nend", "def is_odd?(num)\n num = num * -1 if num < 0 # get absolute value\n num.remainder(2) == 1 ? true: false\nend", "def is_odd_no_modulo?(number)\n float = number / 2.0\n if float == float.to_i.to_f\n puts \"#{number} is even.\"\n else\n puts \"#{number} is odd.\"\n end\nend", "def is_odd?(num)\n if num == 0 ||num.remainder(2) == 0\n false\n else\n true\n end\nend", "def is_odd?(number)\n number.remainder(2).abs == 1 # I originally wrote this w/o the .abs method call; -17 returned false as a result due to the remainder being\nend", "def is_odd?(num)\n return num.abs % 2 == 1 ? true : false\nend", "def is_even(number)\n if number % 2== 0\n return true\n else \n return false\n end \n \nend", "def is_odd(x)\n # Use the logical results provided to you by Ruby already..\n x % 2 != 0\nend", "def is_odd?(input)\n input % 2 != 0 # => true\nend", "def is_odd?(number)\n number.abs % 2 != 0 && number != 0\nend", "def is_odd?(num)\n num.abs.to_i % 2 != 0 && num.to_i == num\nend", "def is_even(number)\n output = false\n if number % 2 ==0\n output = true\n end\nreturn output\nend", "def even(num)\n if num % 2 == 0\n return true\n end\n return false\nend", "def is_odd? number\n number % 2 == 1\nend", "def is_even?(number)\n if number % 2 == 0\n return true\n end\n return false\nend", "def is_even(number)\n if number % 2 == 0\n return true\n else\n return false\n end\nend", "def is_even(num)\n if num%2 ==0\n puts true\n else\n puts false\n end\nend", "def is_odd?(n)\n n % 2 == 1\nend", "def is_odd?(integer)\r\n !(integer.abs.remainder(2) == 0)\r\nend", "def is_odd?(number)\n number % 2 == 1\nend", "def is_even(num)\n if num % 2 == 0\n return true\n else\n return false\n end\nend", "def is_even(num)\n return(num % 2) == 0\nend", "def is_odd(number)\n return true if number % 2 != 0\n return false if number % 2 == 0\nend", "def is_odd?(int)\n int.abs % 2 == 1\nend", "def is_even?(num)\n\nif num % 2 == 0\n true\nelse\n false\nend\nend", "def is_odd?(integer)\n integer % 2 == 1\nend", "def is_odd?(integer)\n integer % 2 == 1\nend", "def is_odd?(integer)\n integer % 2 == 1\nend", "def is_even?(n)\n\ttrue if n%2==0 else false\nend", "def is_odd?(int)\n int.abs.remainder(2) == 1\nend", "def is_odd?(integer)\n integer.abs.remainder\nend", "def is_even(num)\n return num % 2 == 0\nend", "def is_odd?(int)\n int % 2 == 1\nend", "def is_odd(num)\n return ((num % 2) != 0)\nend", "def is_odd?(integer)\n integer % 2 == 0 ? false : true\nend", "def is_odd(tal)\n if tal % 2 != 0\n return true\n else\n return false\n end\nend", "def is_odd(number)\n if number % 2 == 0\n return false\n end\n return true\nend", "def is_odd?(num)\r\n num % 2 == 1\r\nend", "def is_odd(num)\n output = false\n if num % 2 != 0\n output = true\n end\n return output\nend", "def is_odd(number)\n output = false\n if (number % 2) != 0\n output = true\n end\n return output\nend", "def is_even?(num)\n\tif ((num % 2) == 0)\n\t\tputs \"true\"\n\telse\n\t\tputs \"false\"\n\tend\nend", "def is_even(number)\n return true if number % 2 == 0\n return false\nend", "def is_odd1?(integer)\n integer.remainder(2) != 0\nend", "def is_odd?(integer)\n\tinteger.abs % 2 == 1\n\t\nend", "def is_other_odd?(n)\n n.abs.remainder(2) == 1\nend", "def is_odd_using_remainder(int)\n int.remainder(2).abs == 1\nend", "def is_even(num)\n if num % 2 == 1\n return false\n end\n return true\nend", "def is_even(n)\n !n.odd?\nend", "def odd_even(number)\n # Modulo Operator\n return number % 2\nend", "def is_odd?(num)\n num % 2 == 1\nend", "def is_odd?(num)\n num % 2 == 1\nend", "def is_odd?(num)\n num % 2 == 1\nend", "def is_odd?(num)\n num % 2 == 1\nend", "def is_odd?(num)\n num % 2 == 1\nend", "def is_odd(number)\n if number % 2== 1\n return true\n else \n return false\n end \nend", "def is_odd(num)\n return true if num % 2 != 0\n return false\nend", "def is_odd?(int)\n \n # int.abs.odd? # #abs, #remainder\n\n # int.abs.remainder(2) == 1 # #abs and #remainder \n \n # int.remainder(2) == 1 || int.remainder(2) == -1 # remainder only\n \n int % 2 == 1 # #modulo % always has the sign of the divisor (positive 2)\n\nend", "def is_odd_remainder?(num)\n num.abs.remainder(2) == 1\n # x.remainder(y) means x-y*(x/y).truncate.\nend", "def is_even(num)\n return true if num%2 == 0\n return false\nend", "def is_odd?(int) \n if int % 2 == 0\n return false\n else return true\n end\nend", "def is_odd?(num)\n # could use the built-in Integer#odd? method but building my own for practice\n num.abs % 2 == 1\nend", "def is_even(n)\n n % 2 == 0\nend", "def is_even(n)\n n % 2 == 0\nend", "def is_even(num)\n return true if num % 2 == 0\n return false\nend", "def is_odd(num)\n if num % 2 == 0\n return false\n else\n return true\n end\nend", "def even(numb)\n return true if numb % 2 == 0\n return false\nend", "def is_even(number)\n number.to_i\n if number%2 == 1\n return true\n else\n return false\n end\nend" ]
[ "0.8336703", "0.82884896", "0.8286844", "0.82431364", "0.82319057", "0.82111967", "0.8197993", "0.8197993", "0.8197993", "0.8171983", "0.8166805", "0.81619227", "0.81619227", "0.8155062", "0.81457776", "0.81422406", "0.8137257", "0.8131523", "0.8128214", "0.8124032", "0.81218654", "0.81147", "0.80976784", "0.8095749", "0.8095749", "0.8092688", "0.8083927", "0.8078018", "0.8066597", "0.80413884", "0.8038678", "0.80362743", "0.8032278", "0.803144", "0.8028986", "0.80285335", "0.80268806", "0.8012173", "0.8009995", "0.800655", "0.80055934", "0.8000396", "0.79979426", "0.79910296", "0.79907036", "0.7987133", "0.798574", "0.7974354", "0.7972859", "0.7966133", "0.7960947", "0.79607815", "0.7960106", "0.79555184", "0.79512066", "0.7950755", "0.7947161", "0.79460204", "0.79445183", "0.79445183", "0.79445183", "0.79431796", "0.79373443", "0.7936251", "0.7935257", "0.7934599", "0.7934259", "0.793184", "0.79298925", "0.79272485", "0.79249024", "0.79210806", "0.79205525", "0.7919271", "0.79099977", "0.79095113", "0.7908386", "0.7906024", "0.7901679", "0.78988856", "0.78902525", "0.7886313", "0.78832155", "0.78832155", "0.78832155", "0.78832155", "0.78832155", "0.7882308", "0.78756523", "0.78753936", "0.78681135", "0.7853523", "0.78514224", "0.7842598", "0.78372866", "0.78372866", "0.78367424", "0.78232145", "0.78207713", "0.7819921" ]
0.80281126
36